refinamento do fluxo

This commit is contained in:
Diego Freitas 2024-12-17 12:32:53 -03:00
parent 14744d35b9
commit b670c0a031
33 changed files with 228 additions and 271 deletions

Binary file not shown.

View File

@ -1,121 +1,12 @@
{ {
"Version": 1, "Version": 1,
"WorkspaceRootPath": "C:\\ZendionINC\\agrobot_base\\AgroBase\\", "WorkspaceRootPath": "C:\\ZendionINC\\agrobot_base\\AgroBase\\",
"Documents": [ "Documents": [],
{
"AbsoluteMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|C:\\ZendionINC\\agrobot_base\\AgroBase\\agrobase\\models\\operacoes\\operacaomodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|solutionrelative:agrobase\\models\\operacoes\\operacaomodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|c:\\zendioninc\\agrobot_base\\agrobase\\agrobase\\models\\modules\\movimentacaounificadomodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|solutionrelative:agrobase\\models\\modules\\movimentacaounificadomodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|c:\\zendioninc\\agrobot_base\\agrobase\\agrobase\\forms\\frminstancial.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|solutionrelative:agrobase\\forms\\frminstancial.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|c:\\zendioninc\\agrobot_base\\agrobase\\agrobase\\forms\\ihm\\frmihm.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|solutionrelative:agrobase\\forms\\ihm\\frmihm.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|c:\\zendioninc\\agrobot_base\\agrobase\\agrobase\\forms\\operacoes\\frmresultadosoperacao.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|solutionrelative:agrobase\\forms\\operacoes\\frmresultadosoperacao.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|C:\\ZendionINC\\agrobot_base\\AgroBase\\agrobase\\services\\gpsservice.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|solutionrelative:agrobase\\services\\gpsservice.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [ "DocumentGroupContainers": [
{ {
"Orientation": 0, "Orientation": 0,
"VerticalTabListWidth": 256, "VerticalTabListWidth": 256,
"DocumentGroups": [ "DocumentGroups": []
{
"DockedWidth": 200,
"SelectedChildIndex": 5,
"Children": [
{
"$type": "Document",
"DocumentIndex": 2,
"Title": "frmInstancial.cs",
"DocumentMoniker": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Forms\\frmInstancial.cs",
"RelativeDocumentMoniker": "AgroBase\\Forms\\frmInstancial.cs",
"ToolTip": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Forms\\frmInstancial.cs",
"RelativeToolTip": "AgroBase\\Forms\\frmInstancial.cs",
"ViewState": "AQIAAEEAAAAAAAAAAAAwwJQAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-12-17T13:19:03.476Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 3,
"Title": "frmIHM.cs",
"DocumentMoniker": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Forms\\IHM\\frmIHM.cs",
"RelativeDocumentMoniker": "AgroBase\\Forms\\IHM\\frmIHM.cs",
"ToolTip": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Forms\\IHM\\frmIHM.cs",
"RelativeToolTip": "AgroBase\\Forms\\IHM\\frmIHM.cs",
"ViewState": "AQIAAAIAAAAAAAAAAAAnwC4AAAAtAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-12-17T12:52:54.097Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "MovimentacaoUnificadoModel.cs",
"DocumentMoniker": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\Modules\\MovimentacaoUnificadoModel.cs",
"RelativeDocumentMoniker": "AgroBase\\Models\\Modules\\MovimentacaoUnificadoModel.cs",
"ToolTip": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\Modules\\MovimentacaoUnificadoModel.cs",
"RelativeToolTip": "AgroBase\\Models\\Modules\\MovimentacaoUnificadoModel.cs",
"ViewState": "AQIAAGQDAAAAAAAAAAAmwFEDAAAUAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-12-17T12:26:28.54Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 4,
"Title": "frmResultadosOperacao.cs",
"DocumentMoniker": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Forms\\Operacoes\\frmResultadosOperacao.cs",
"RelativeDocumentMoniker": "AgroBase\\Forms\\Operacoes\\frmResultadosOperacao.cs",
"ToolTip": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Forms\\Operacoes\\frmResultadosOperacao.cs",
"RelativeToolTip": "AgroBase\\Forms\\Operacoes\\frmResultadosOperacao.cs",
"ViewState": "AQIAAMEBAAAAAAAAAAAmwPoBAABAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-12-13T18:54:41.843Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 5,
"Title": "GPSService.cs",
"DocumentMoniker": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Services\\GPSService.cs",
"RelativeDocumentMoniker": "AgroBase\\Services\\GPSService.cs",
"ToolTip": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Services\\GPSService.cs",
"RelativeToolTip": "AgroBase\\Services\\GPSService.cs",
"ViewState": "AQIAAOIAAAAAAAAAAAAxwOsBAAAmAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-12-13T13:06:36.311Z"
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "OperacaoModel.cs",
"DocumentMoniker": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\Operacoes\\OperacaoModel.cs",
"RelativeDocumentMoniker": "AgroBase\\Models\\Operacoes\\OperacaoModel.cs",
"ToolTip": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\Operacoes\\OperacaoModel.cs",
"RelativeToolTip": "AgroBase\\Models\\Operacoes\\OperacaoModel.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAEAAAAAIAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-12-13T12:14:30.018Z",
"EditorCaption": ""
}
]
}
]
} }
] ]
} }

View File

@ -23,7 +23,7 @@ namespace AgroBase.Forms.IHM
InitializeComponent(); InitializeComponent();
} }
private void frmAjustes_Load(object sender, EventArgs e) private async void frmAjustes_Load(object sender, EventArgs e)
{ {
cmbComunicacao.Items.Clear(); cmbComunicacao.Items.Clear();
cmbComunicacao.Items.AddRange(new string[] { "Equipamento", "Base" }); cmbComunicacao.Items.AddRange(new string[] { "Equipamento", "Base" });
@ -90,7 +90,7 @@ namespace AgroBase.Forms.IHM
AtualizarCameras(); AtualizarCameras();
if (LoRaService.Iniciado) if (LoRaService.Iniciado)
{ {
AtualizarParametros().ConfigureAwait(false); await AtualizarParametros();
} }
chbKinect.Enabled = KinectService.Iniciado; chbKinect.Enabled = KinectService.Iniciado;
@ -349,9 +349,12 @@ namespace AgroBase.Forms.IHM
#endregion #endregion
private void cmbComunicacao_SelectedIndexChanged(object sender, EventArgs e) private async void cmbComunicacao_SelectedIndexChanged(object sender, EventArgs e)
{ {
AtualizarParametros().ConfigureAwait(false); if (LoRaService.Iniciado)
{
await AtualizarParametros();
}
} }
private void btnCalibrarKinect_Click(object sender, EventArgs e) private void btnCalibrarKinect_Click(object sender, EventArgs e)

View File

@ -84,7 +84,7 @@ namespace AgroBase.Forms.IHM
sucesso ? MessageBoxIcon.Asterisk : MessageBoxIcon.Error sucesso ? MessageBoxIcon.Asterisk : MessageBoxIcon.Error
); );
SyncDataService.SincronizarArquivosComServidor().ConfigureAwait(false); Task.Run(async () => await SyncDataService.SincronizarArquivosComServidor());
} }
else else
{ {

View File

@ -491,6 +491,24 @@ namespace AgroBase.Forms.Operacoes
Valores = LogsOperacao.Select(x => (double)(x?.GPU_temp ?? 0)).ToList(), Valores = LogsOperacao.Select(x => (double)(x?.GPU_temp ?? 0)).ToList(),
Visivel = true, Visivel = true,
}, },
new GraficoInterativoSerieModel()
{
Titulo = "Threads Ativas",
Valores = LogsOperacao.Select(x => (double)(x?.ActiveThreads ?? 0)).ToList(),
Visivel = true,
},
new GraficoInterativoSerieModel()
{
Titulo = "Threads de Trabalho %",
Valores = LogsOperacao.Select(x => (double)((x?.MaxWorkerThreads ?? 1) - (x?.WorkerThreads ?? 0)) / (x?.MaxWorkerThreads ?? 1) * 100.0).ToList(),
Visivel = true,
},
new GraficoInterativoSerieModel()
{
Titulo = "Threads de Portas %",
Valores = LogsOperacao.Select(x => (double)((x?.MaxCompletionPortThreads ?? 1) - (x?.CompletionPortThreads ?? 0)) / (x?.MaxCompletionPortThreads ?? 1) * 100.0).ToList(),
Visivel = true,
},
}); });

View File

@ -20,7 +20,7 @@ namespace AgroBase.Forms
InitializeComponent(); InitializeComponent();
} }
private void frmLoraConfig_Load(object sender, EventArgs e) private async void frmLoraConfig_Load(object sender, EventArgs e)
{ {
tmrLeitura = new AsyncTaskTimerModel("tmrLeitura", tmrLeitura_Tick, 1000, this); tmrLeitura = new AsyncTaskTimerModel("tmrLeitura", tmrLeitura_Tick, 1000, this);
tmrLeitura.Start(); tmrLeitura.Start();
@ -28,7 +28,7 @@ namespace AgroBase.Forms
//Parametros = loraService.CarregarParametros(); //Parametros = loraService.CarregarParametros();
if (LoRaService.Iniciado) if (LoRaService.Iniciado)
{ {
AtualizarParametros().ConfigureAwait(false); await AtualizarParametros();
} }
} }
@ -104,15 +104,15 @@ namespace AgroBase.Forms
btnSalvar.Enabled = false; btnSalvar.Enabled = false;
} }
private void btnLerParametros_Click(object sender, EventArgs e) private async void btnLerParametros_Click(object sender, EventArgs e)
{ {
if (LoRaService.Iniciado) if (LoRaService.Iniciado)
{ {
AtualizarParametros().ConfigureAwait(false); await AtualizarParametros();
} }
} }
private void btnGravarParametros_Click(object sender, EventArgs e) private async void btnGravarParametros_Click(object sender, EventArgs e)
{ {
if (LoRaService.Iniciado) if (LoRaService.Iniciado)
{ {
@ -125,7 +125,7 @@ namespace AgroBase.Forms
Parametros.worCycle = LoRaService.CodigosWorCycles.FirstOrDefault(x => x.Key.ToString() == cmbWorCycle.Text).Value; Parametros.worCycle = LoRaService.CodigosWorCycles.FirstOrDefault(x => x.Key.ToString() == cmbWorCycle.Text).Value;
Parametros.power = LoRaService.CodigosPowers.FirstOrDefault(x => x.Key.ToString() == cmbPower.Text).Value; Parametros.power = LoRaService.CodigosPowers.FirstOrDefault(x => x.Key.ToString() == cmbPower.Text).Value;
ConfigurarModulo().ConfigureAwait(false); await ConfigurarModulo();
} }
} }

View File

@ -52,14 +52,44 @@ namespace AgroBase
private void AtualizarListaRotinas() private void AtualizarListaRotinas()
{ {
string[] timers = new string[] { }; var selecionados = clbRotinas.CheckedItems.Cast<string>().ToHashSet();
string[] novosTimers;
// Bloqueia para coletar os dados mais recentes
lock (AsyncTaskTimerModel._timersLock) lock (AsyncTaskTimerModel._timersLock)
{ {
timers = AsyncTaskTimerModel.Timers.Select(x => $"{x.StackTrace} -> {x.Id} - Interval: {x.Interval} - Tick: {x.TimeTick.TotalSeconds} s - State: {x.State.ToString()}").ToArray(); novosTimers = AsyncTaskTimerModel.Timers
.Select(x => $"{x.StackTrace} -> {x.Id} - Interval: {x.Interval} - Tick: {x.TimeTick.TotalSeconds} s - State: {x.State.ToString()}")
.ToArray();
} }
clbRotinas.Items.Clear(); // Dicionário para facilitar comparação entre os itens atuais e os novos
clbRotinas.Items.AddRange(timers); var itensAtuais = clbRotinas.Items.Cast<string>().ToHashSet();
var novosItens = novosTimers.ToHashSet();
// 1. Remover itens que não existem mais
foreach (var item in itensAtuais.Except(novosItens))
{
clbRotinas.Items.Remove(item);
}
// 2. Adicionar novos itens que ainda não estão presentes
foreach (var item in novosItens.Except(itensAtuais))
{
clbRotinas.Items.Add(item);
}
// 3. (Opcional) Atualizar os itens existentes
// Neste caso, não precisa porque `string` é imutável e não há "atualização parcial".
// Restaura a seleção
foreach (var item in selecionados)
{
int index = clbRotinas.Items.IndexOf(item);
if (index >= 0)
clbRotinas.SetItemChecked(index, true);
}
} }
#region DISPOSITIVOS #region DISPOSITIVOS
@ -147,21 +177,48 @@ namespace AgroBase
} }
lstDisponiveis.Items.Clear(); var itensAtuais = lstDisponiveis.Items
lstDisponiveis.Items.AddRange( .Cast<ListViewItem>()
SerialService.DispositivosMapeados .ToDictionary(item => item.Text, item => item);
var novosItens = SerialService.DispositivosMapeados
.GroupBy(x => x.Dispositivo) .GroupBy(x => x.Dispositivo)
.Select(x => new ListViewItem() .Select(x => new ListViewItem()
{ {
Text = Text = x.FirstOrDefault().Endereco + " - " +
x.FirstOrDefault().Endereco + " - " + Enum.GetName(typeof(T_Code), x.Key) + " v" + x.FirstOrDefault().Versao + Enum.GetName(typeof(T_Code), x.Key) + " v" +
x.FirstOrDefault().Versao +
(SerialService.DispositivosMultiplos.Contains(x.FirstOrDefault().Dispositivo)
? (" (" + string.Join(", ", x.Where(y => y.Conectado).Select(y => y.Mod_ID)) + ")")
: "") +
" - " +
(x.Any(y => y.Conectado) ? "Conectado" : "Desconectado")
})
.ToDictionary(item => item.Text, item => item);
(SerialService.DispositivosMultiplos.Contains(x.FirstOrDefault().Dispositivo) ? (" (" + string.Join(", ", x.Where(y => y.Conectado).Select(y => y.Mod_ID)) + ")") : // **1. Remover itens que saíram**
foreach (var item in itensAtuais.Keys.Except(novosItens.Keys))
{
lstDisponiveis.Items.Remove(itensAtuais[item]);
}
// **2. Adicionar novos itens**
foreach (var item in novosItens.Keys.Except(itensAtuais.Keys))
{
lstDisponiveis.Items.Add(novosItens[item]);
}
// **3. Atualizar itens que mudaram**
foreach (var item in novosItens.Keys.Intersect(itensAtuais.Keys))
{
var itemAtual = itensAtuais[item];
var novoItem = novosItens[item];
if (itemAtual.Text != novoItem.Text) // Só atualiza se mudou
{
itemAtual.Text = novoItem.Text;
}
}
"") + " - " +
(x.Any(y => y.Conectado) ? "Conectado" : "Desconectado")
}).ToArray()
);
tkbVelocidade.Minimum = 0; tkbVelocidade.Minimum = 0;
tkbVelocidade.Maximum = 100; tkbVelocidade.Maximum = 100;
@ -186,10 +243,10 @@ namespace AgroBase
#region VERSIONAMENTO DE ARQUIVOS #region VERSIONAMENTO DE ARQUIVOS
private void btnForcarAtualizacao_Click(object sender, EventArgs e) private async void btnForcarAtualizacao_Click(object sender, EventArgs e)
{ {
VersionamentoService.ForcarDownloadArquivos = true; VersionamentoService.ForcarDownloadArquivos = true;
VersionamentoService.AtualizarArquivoVersionamento(true).ConfigureAwait(false); await VersionamentoService.AtualizarArquivoVersionamento(true);
} }

View File

@ -76,7 +76,7 @@ namespace AgroBase.Models
panel.Controls.Remove(browser); panel.Controls.Remove(browser);
} }
browser = null; browser = null;
Variaveis.MqttService.UnsubscribeAsync(camera._mqttTopico).ConfigureAwait(false); Task.Run(async () => await Variaveis.MqttService.UnsubscribeAsync(camera._mqttTopico));
if (camera.pythonProcess != null) if (camera.pythonProcess != null)
{ {
camera.pythonProcess.Kill(); camera.pythonProcess.Kill();

View File

@ -1,6 +1,7 @@
using AgroBase.Services; using AgroBase.Services;
using CefSharp.WinForms; using CefSharp.WinForms;
using System; using System;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace AgroBase.Models namespace AgroBase.Models
@ -23,7 +24,7 @@ namespace AgroBase.Models
panel.Controls.Remove(browser); panel.Controls.Remove(browser);
} }
browser = null; browser = null;
Variaveis.MqttService.UnsubscribeAsync(camera._mqttTopico).ConfigureAwait(false); Task.Run(async () => Variaveis.MqttService.UnsubscribeAsync(camera._mqttTopico));
if (camera.pythonProcess != null && !camera.pythonProcess.HasExited) if (camera.pythonProcess != null && !camera.pythonProcess.HasExited)
{ {
camera.pythonProcess.Kill(); camera.pythonProcess.Kill();

View File

@ -195,7 +195,9 @@ namespace AgroBase.Models.Operacoes
private void DefinirTipoMovimento(StatusCarroMapa statusCarro) private void DefinirTipoMovimento(StatusCarroMapa statusCarro)
{ {
Variaveis.OperacaoEmAndamento.Controle.TipoMovimento = statusCarro == StatusCarroMapa.Manobrando ? TipoMovimentoDirecional.MovimentoArco : TipoMovimentoDirecional.RodasDianteiras; Variaveis.OperacaoEmAndamento.Controle.TipoMovimento =
Variaveis.OperacaoEmAndamento.OpMapaGPS.ReferencialRuaGPS.ManobrandoEntreRuas ? TipoMovimentoDirecional.MovimentoArco :
TipoMovimentoDirecional.RodasDianteiras;
} }
public void CalculaDadosMovimentacaoAutonoma() public void CalculaDadosMovimentacaoAutonoma()
@ -459,6 +461,16 @@ namespace AgroBase.Models.Operacoes
return Variaveis.OperacaoEmAndamento.Mapa.IdxUltimoPontoTrajetoria == 0 && StatusAtual == StatusCarroMapa.Direcionando; return Variaveis.OperacaoEmAndamento.Mapa.IdxUltimoPontoTrajetoria == 0 && StatusAtual == StatusCarroMapa.Direcionando;
} }
} }
public bool ManobrandoEntreRuas
{
get
{
bool proximoEntradaRua = Variaveis.OperacaoEmAndamento.Mapa.DistanciaAteProximoPonto <= Variaveis.OperacaoEmAndamento.Mapa.DistanciaProjecaoRua;
bool Manobrando = proximoEntradaRua && EmManobra;
return Manobrando;
}
}
public void VerificaFimRuaAtual() public void VerificaFimRuaAtual()
{ {

View File

@ -365,6 +365,7 @@ namespace AgroBase.Models
saveFileDialog.DefaultExt = "opr"; saveFileDialog.DefaultExt = "opr";
saveFileDialog.AddExtension = true; saveFileDialog.AddExtension = true;
saveFileDialog.InitialDirectory = Variaveis.CaminhoSistema + Variaveis.CaminhoOperacoes; saveFileDialog.InitialDirectory = Variaveis.CaminhoSistema + Variaveis.CaminhoOperacoes;
saveFileDialog.FileName = descricao;
if (saveFileDialog.ShowDialog() == DialogResult.OK) if (saveFileDialog.ShowDialog() == DialogResult.OK)
{ {
string filePath = saveFileDialog.FileName; string filePath = saveFileDialog.FileName;
@ -1890,7 +1891,6 @@ namespace AgroBase.Models
} }
int activeThreads = Process.GetCurrentProcess().Threads.Count; int activeThreads = Process.GetCurrentProcess().Threads.Count;
// Status do Thread Pool
ThreadPool.GetAvailableThreads(out int workerThreads, out int completionPortThreads); ThreadPool.GetAvailableThreads(out int workerThreads, out int completionPortThreads);
ThreadPool.GetMaxThreads(out int maxWorkerThreads, out int maxCompletionPortThreads); ThreadPool.GetMaxThreads(out int maxWorkerThreads, out int maxCompletionPortThreads);
@ -2145,7 +2145,7 @@ namespace AgroBase.Models
SalvarLogKinect(Agora); SalvarLogKinect(Agora);
SalvarLogCameras(Agora).ConfigureAwait(false); Task.Run(async () => await SalvarLogCameras(Agora));
string ArquivoOp = Variaveis.CaminhoOperacoes + Variaveis.OperacaoEmAndamento.ID + "/data.lgop"; string ArquivoOp = Variaveis.CaminhoOperacoes + Variaveis.OperacaoEmAndamento.ID + "/data.lgop";
if (!File.Exists(ArquivoOp)) if (!File.Exists(ArquivoOp))

View File

@ -570,12 +570,12 @@ namespace AgroBase.Models
} }
public static void picBtn_MouseEnter(object sender, EventArgs e) public static void picBtn_MouseEnter(object sender, EventArgs e)
{ {
TransicaoTamanho((Control)sender, true, 5).ConfigureAwait(false); Task.Run(async () => await TransicaoTamanho((Control)sender, true, 5));
} }
public static void picBtn_MouseLeave(object sender, EventArgs e) public static void picBtn_MouseLeave(object sender, EventArgs e)
{ {
TransicaoTamanho((Control)sender, false, 5).ConfigureAwait(false); Task.Run(async () => await TransicaoTamanho((Control)sender, false, 5));
} }
private static void AlteraTamanhoObjeto(Control ctrl, bool Cresce) private static void AlteraTamanhoObjeto(Control ctrl, bool Cresce)

View File

@ -1,11 +1,11 @@
using AgroBase.Forms; using AgroBase.Models;
using AgroBase.Models;
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO.Ports; using System.IO.Ports;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
using static AgroBase.Models.Enums; using static AgroBase.Models.Enums;
namespace AgroBase.Services namespace AgroBase.Services
@ -650,10 +650,13 @@ namespace AgroBase.Services
id = ID, id = ID,
foco = EmFoco foco = EmFoco
}; };
Variaveis.MqttService.PublishAsync( Task.Run(async () =>
Variaveis.MqttService.Topicos.First(x => x.Topico == MapasVariaveisModel.TopicoCoordenadasGPS), {
JsonConvert.SerializeObject(Coordenadas) await Variaveis.MqttService.PublishAsync(
).ConfigureAwait(false); Variaveis.MqttService.Topicos.First(x => x.Topico == MapasVariaveisModel.TopicoCoordenadasGPS),
JsonConvert.SerializeObject(Coordenadas)
);
});
} }
public static void AtualizarTrajetoriaDinamica() public static void AtualizarTrajetoriaDinamica()
@ -666,20 +669,26 @@ namespace AgroBase.Services
latitude = x.Latitude, latitude = x.Latitude,
longitude = x.Longitude longitude = x.Longitude
}).ToArray(); }).ToArray();
Variaveis.MqttService.PublishAsync( Task.Run(async () =>
Variaveis.MqttService.Topicos.First(x => x.Topico == MapasVariaveisModel.TopicoTrajetoriaDinamica), {
JsonConvert.SerializeObject(Trajetoria) await Variaveis.MqttService.PublishAsync(
).ConfigureAwait(false); Variaveis.MqttService.Topicos.First(x => x.Topico == MapasVariaveisModel.TopicoTrajetoriaDinamica),
JsonConvert.SerializeObject(Trajetoria)
);
});
} }
} }
public static void AtualizarRuasSelecionadas(List<string> RuasSelecionadas) public static void AtualizarRuasSelecionadas(List<string> RuasSelecionadas)
{ {
Variaveis.MqttService.PublishAsync( Task.Run(async () =>
Variaveis.MqttService.Topicos.First(x => x.Topico == MapasVariaveisModel.TopicoSelecaoRuasMapa), {
JsonConvert.SerializeObject("[" + string.Join(",", RuasSelecionadas.ToArray()) + "]"), await Variaveis.MqttService.PublishAsync(
true Variaveis.MqttService.Topicos.First(x => x.Topico == MapasVariaveisModel.TopicoSelecaoRuasMapa),
).ConfigureAwait(false); JsonConvert.SerializeObject("[" + string.Join(",", RuasSelecionadas.ToArray()) + "]"),
true
);
});
} }
public static List<GPSModel> InterpolarPontos(GPSModel inicio, GPSModel destino, double distanciaPasso) public static List<GPSModel> InterpolarPontos(GPSModel inicio, GPSModel destino, double distanciaPasso)

View File

@ -322,29 +322,35 @@ namespace AgroBase.Services
private static void RealizarVerificacaoDeRotina() private static void RealizarVerificacaoDeRotina()
{ {
FuncoesGlobais.SafeExecuteAsync(async () => Task.Run(async () =>
{ {
try await FuncoesGlobais.SafeExecuteAsync(async () =>
{ {
await VersionamentoService.AtualizarArquivoVersionamento(false); try
} {
catch (Exception ex) await VersionamentoService.AtualizarArquivoVersionamento(false);
{ }
Console.WriteLine($"Erro ao atualizar arquivo de versionamento: {ex.Message}"); catch (Exception ex)
} {
}).ConfigureAwait(false); Console.WriteLine($"Erro ao atualizar arquivo de versionamento: {ex.Message}");
}
});
});
FuncoesGlobais.SafeExecuteAsync(async () => Task.Run(async () =>
{ {
try await FuncoesGlobais.SafeExecuteAsync(async () =>
{ {
await SyncDataService.SincronizarArquivosComServidor(); try
} {
catch (Exception ex) await SyncDataService.SincronizarArquivosComServidor();
{ }
Console.WriteLine($"Erro ao sincronizar arquivos com o servidor: {ex.Message}"); catch (Exception ex)
} {
}).ConfigureAwait(false); Console.WriteLine($"Erro ao sincronizar arquivos com o servidor: {ex.Message}");
}
});
});
} }
private static bool ProcessarRespostaDispositivo(SerialPort Porta) private static bool ProcessarRespostaDispositivo(SerialPort Porta)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"Id":"1","Name":"17_12_2024_08_33_02","Length":33.462942499632895,"Dist1":0.0,"Dist2":0.0},"geometry":{"id":null,"type":"LineString","coordinates":[[-47.3815305,-22.213009],[-47.381530166666664,-22.213009],[-47.381528166666669,-22.213008833333333],[-47.381527666666663,-22.213008833333333],[-47.3815275,-22.213008833333333],[-47.381527166666665,-22.213008833333333],[-47.381528333333335,-22.213007833333332],[-47.3815315,-22.213003833333332],[-47.381532666666665,-22.213001666666667],[-47.38153366666667,-22.212998833333334],[-47.381534,-22.212990666666666],[-47.3815325,-22.212985333333332],[-47.381526666666666,-22.2129765],[-47.381525333333336,-22.212974166666665],[-47.381525666666668,-22.212974833333334],[-47.381529833333332,-22.212982666666665],[-47.3815305,-22.212983833333332],[-47.381525666666668,-22.212981333333332],[-47.381523166666668,-22.212980166666668],[-47.381521,-22.212979166666667],[-47.381515833333332,-22.2129785],[-47.381515333333333,-22.212979333333333],[-47.381516,-22.212979833333332],[-47.381516166666664,-22.21298],[-47.3815185,-22.212979666666666],[-47.381518,-22.2129795],[-47.381517833333334,-22.2129795],[-47.381522666666669,-22.212981833333334],[-47.3815235,-22.212982166666666],[-47.3815295,-22.212984666666667],[-47.381532833333331,-22.212985666666668],[-47.38153333333333,-22.212985833333335],[-47.381529,-22.212989166666667],[-47.381527333333331,-22.212990833333333],[-47.38152516666667,-22.212994333333334],[-47.381523666666666,-22.212996],[-47.381522666666669,-22.212997],[-47.381519,-22.213001],[-47.3815185,-22.213001666666667],[-47.381512666666666,-22.213006833333335],[-47.381508,-22.213010166666667],[-47.381505,-22.213013833333335],[-47.3815015,-22.213023166666666],[-47.381501,-22.213028],[-47.381502166666664,-22.213038166666667],[-47.381502,-22.213043333333335],[-47.381502,-22.213052833333332],[-47.381504166666666,-22.213057666666668],[-47.381506666666667,-22.213062833333332],[-47.38151116666667,-22.213072833333332],[-47.381512166666667,-22.213077333333334],[-47.381513666666663,-22.213084],[-47.3815145,-22.213088666666668],[-47.381517,-22.213092166666666],[-47.3815215,-22.213095333333332],[-47.381522666666669,-22.213096],[-47.3815255,-22.213096333333333],[-47.3815285,-22.2130975],[-47.3815315,-22.213099166666666],[-47.3815385,-22.213101166666668],[-47.381541666666664,-22.213102833333334],[-47.381549666666665,-22.21311],[-47.381554666666666,-22.213113333333332],[-47.381561,-22.213115],[-47.381571,-22.2131175],[-47.381574833333332,-22.213119],[-47.381578,-22.213125833333333],[-47.381581,-22.213127833333335],[-47.381585,-22.213130666666668],[-47.381586333333331,-22.213132166666668],[-47.381587333333336,-22.213133],[-47.381587333333336,-22.213133833333334],[-47.381588,-22.213134],[-47.381588833333332,-22.213135166666667],[-47.38159,-22.213137],[-47.381590333333335,-22.213137833333334],[-47.38159233333333,-22.213139666666667],[-47.381593166666669,-22.213140833333334],[-47.381593,-22.213140666666668],[-47.381592833333336,-22.2131405],[-47.381593,-22.213140833333334],[-47.381593833333334,-22.213142333333334],[-47.381594,-22.213142666666666],[-47.381594,-22.213142666666666]]}}]} {"type":"FeatureCollection","features":[{"type":"Feature","properties":{"Id":"1","Name":"Projeto","Length":21.332976190943135,"Dist1":0.0,"Dist2":0.0},"geometry":{"id":"0","type":"LineString","coordinates":[[-47.381495333333334,-22.213068166666666],[-47.381469166666669,-22.213091333333335],[-47.38141825,-22.213137833333334],[-47.3813925,-22.213161666666668],[-47.381369666666664,-22.2131845]]}},{"type":"Feature","properties":{"Id":"2","Name":"Projeto","Length":24.045328359726675,"Dist1":0.0,"Dist2":0.0},"geometry":{"id":"1","type":"LineString","coordinates":[[-47.381340166666668,-22.213175666666668],[-47.381375333333331,-22.213137166666666],[-47.38140933333333,-22.213102666666668],[-47.381453666666665,-22.213058166666666],[-47.381496666666663,-22.213015666666667]]}}]}

View File

@ -25,7 +25,7 @@
<meta name="viewport" content="width=device-width, <meta name="viewport" content="width=device-width,
initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<style> <style>
#map_5ccd27c8efed2f1d5f821cab9236ab21 { #map_f0b88e3c9fbbb871f17a4dbd225c6fff {
position: relative; position: relative;
width: 100.0%; width: 100.0%;
height: 100.0%; height: 100.0%;
@ -39,16 +39,16 @@
<body> <body>
<div class="folium-map" id="map_5ccd27c8efed2f1d5f821cab9236ab21" ></div> <div class="folium-map" id="map_f0b88e3c9fbbb871f17a4dbd225c6fff" ></div>
</body> </body>
<script> <script>
var map_5ccd27c8efed2f1d5f821cab9236ab21 = L.map( var map_f0b88e3c9fbbb871f17a4dbd225c6fff = L.map(
"map_5ccd27c8efed2f1d5f821cab9236ab21", "map_f0b88e3c9fbbb871f17a4dbd225c6fff",
{ {
center: [-22.213058416666666, -47.381547499999996], center: [-22.213100083333334, -47.38141841666666],
crs: L.CRS.EPSG3857, crs: L.CRS.EPSG3857,
zoom: 12, zoom: 12,
zoomControl: true, zoomControl: true,
@ -60,13 +60,13 @@
var tile_layer_9147458df3f36d24646c83b8de0dce25 = L.tileLayer( var tile_layer_fb166f510d9dc07cae4560a0da44b242 = L.tileLayer(
"https://tile.openstreetmap.org/{z}/{x}/{y}.png", "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
{"attribution": "\u0026copy; \u003ca href=\"https://www.openstreetmap.org/copyright\"\u003eOpenStreetMap\u003c/a\u003e contributors", "detectRetina": false, "maxNativeZoom": 19, "maxZoom": 19, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false} {"attribution": "\u0026copy; \u003ca href=\"https://www.openstreetmap.org/copyright\"\u003eOpenStreetMap\u003c/a\u003e contributors", "detectRetina": false, "maxNativeZoom": 19, "maxZoom": 19, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}
); );
tile_layer_9147458df3f36d24646c83b8de0dce25.addTo(map_5ccd27c8efed2f1d5f821cab9236ab21); tile_layer_fb166f510d9dc07cae4560a0da44b242.addTo(map_f0b88e3c9fbbb871f17a4dbd225c6fff);
@ -82,7 +82,7 @@
}*/ }*/
}); });
} }
function geo_json_04db30abe29c98f8b704fb7bbb35c27c_onEachFeature(feature, layer) { function geo_json_afbdf9289c407bb446a01d22a6f4e29b_onEachFeature(feature, layer) {
layer.on({ layer.on({
click: function(e) { click: function(e) {
@ -118,20 +118,20 @@
}*/ }*/
}); });
}; };
var geo_json_04db30abe29c98f8b704fb7bbb35c27c = L.geoJson(null, { var geo_json_afbdf9289c407bb446a01d22a6f4e29b = L.geoJson(null, {
onEachFeature: geo_json_04db30abe29c98f8b704fb7bbb35c27c_onEachFeature, onEachFeature: geo_json_afbdf9289c407bb446a01d22a6f4e29b_onEachFeature,
}); });
function geo_json_04db30abe29c98f8b704fb7bbb35c27c_add (data) { function geo_json_afbdf9289c407bb446a01d22a6f4e29b_add (data) {
geo_json_04db30abe29c98f8b704fb7bbb35c27c geo_json_afbdf9289c407bb446a01d22a6f4e29b
.addData(data); .addData(data);
} }
geo_json_04db30abe29c98f8b704fb7bbb35c27c_add({"features": [{"geometry": {"coordinates": [[-47.3815305, -22.213009], [-47.381530166666664, -22.213009], [-47.38152816666667, -22.213008833333333], [-47.38152766666666, -22.213008833333333], [-47.3815275, -22.213008833333333], [-47.381527166666665, -22.213008833333333], [-47.381528333333335, -22.213007833333332], [-47.3815315, -22.21300383333333], [-47.381532666666665, -22.213001666666667], [-47.38153366666667, -22.212998833333334], [-47.381534, -22.212990666666666], [-47.3815325, -22.212985333333332], [-47.381526666666666, -22.2129765], [-47.381525333333336, -22.212974166666665], [-47.38152566666667, -22.212974833333334], [-47.38152983333333, -22.212982666666665], [-47.3815305, -22.212983833333332], [-47.38152566666667, -22.21298133333333], [-47.38152316666667, -22.212980166666668], [-47.381521, -22.212979166666667], [-47.38151583333333, -22.2129785], [-47.38151533333333, -22.212979333333333], [-47.381516, -22.212979833333332], [-47.381516166666664, -22.21298], [-47.3815185, -22.212979666666666], [-47.381518, -22.2129795], [-47.381517833333334, -22.2129795], [-47.38152266666667, -22.212981833333334], [-47.3815235, -22.212982166666666], [-47.3815295, -22.212984666666667], [-47.38153283333333, -22.21298566666667], [-47.38153333333333, -22.212985833333335], [-47.381529, -22.212989166666667], [-47.38152733333333, -22.212990833333333], [-47.38152516666667, -22.212994333333334], [-47.381523666666666, -22.212996], [-47.38152266666667, -22.212997], [-47.381519, -22.213001], [-47.3815185, -22.213001666666667], [-47.381512666666666, -22.213006833333335], [-47.381508, -22.213010166666667], [-47.381505, -22.213013833333335], [-47.3815015, -22.213023166666666], [-47.381501, -22.213028], [-47.381502166666664, -22.213038166666667], [-47.381502, -22.213043333333335], [-47.381502, -22.213052833333332], [-47.381504166666666, -22.213057666666668], [-47.38150666666667, -22.213062833333332], [-47.38151116666667, -22.21307283333333], [-47.38151216666667, -22.213077333333334], [-47.38151366666666, -22.213084], [-47.3815145, -22.213088666666668], [-47.381517, -22.213092166666666], [-47.3815215, -22.21309533333333], [-47.38152266666667, -22.213096], [-47.3815255, -22.213096333333333], [-47.3815285, -22.2130975], [-47.3815315, -22.213099166666666], [-47.3815385, -22.213101166666668], [-47.381541666666664, -22.213102833333334], [-47.381549666666665, -22.21311], [-47.381554666666666, -22.213113333333332], [-47.381561, -22.213115], [-47.381571, -22.2131175], [-47.38157483333333, -22.213119], [-47.381578, -22.213125833333333], [-47.381581, -22.213127833333335], [-47.381585, -22.213130666666668], [-47.38158633333333, -22.213132166666668], [-47.381587333333336, -22.213133], [-47.381587333333336, -22.213133833333334], [-47.381588, -22.213134], [-47.38158883333333, -22.213135166666667], [-47.38159, -22.213137], [-47.381590333333335, -22.213137833333334], [-47.38159233333333, -22.213139666666667], [-47.38159316666667, -22.213140833333334], [-47.381593, -22.213140666666668], [-47.381592833333336, -22.2131405], [-47.381593, -22.213140833333334], [-47.38159383333333, -22.213142333333334], [-47.381594, -22.213142666666666], [-47.381594, -22.213142666666666]], "id": null, "type": "LineString"}, "id": 0, "properties": {"Dist1": 0.0, "Dist2": 0.0, "Id": "1", "Length": 33.462942499632895, "Name": "17_12_2024_08_33_02"}, "type": "Feature"}], "type": "FeatureCollection"}); geo_json_afbdf9289c407bb446a01d22a6f4e29b_add({"features": [{"geometry": {"coordinates": [[-47.38149533333333, -22.213068166666666], [-47.38146916666667, -22.213091333333335], [-47.38141825, -22.213137833333334], [-47.3813925, -22.213161666666668], [-47.381369666666664, -22.2131845]], "id": "0", "type": "LineString"}, "id": 0, "properties": {"Dist1": 0.0, "Dist2": 0.0, "Id": "1", "Length": 21.332976190943135, "Name": "Projeto"}, "type": "Feature"}, {"geometry": {"coordinates": [[-47.38134016666667, -22.213175666666668], [-47.38137533333333, -22.213137166666666], [-47.38140933333333, -22.213102666666668], [-47.381453666666665, -22.213058166666666], [-47.38149666666666, -22.213015666666667]], "id": "1", "type": "LineString"}, "id": 1, "properties": {"Dist1": 0.0, "Dist2": 0.0, "Id": "2", "Length": 24.045328359726675, "Name": "Projeto"}, "type": "Feature"}], "type": "FeatureCollection"});
geo_json_04db30abe29c98f8b704fb7bbb35c27c.addTo(map_5ccd27c8efed2f1d5f821cab9236ab21); geo_json_afbdf9289c407bb446a01d22a6f4e29b.addTo(map_f0b88e3c9fbbb871f17a4dbd225c6fff);
</script> </script>
@ -152,7 +152,7 @@
} }
trajeto_json_add({"features": []}); trajeto_json_add({"features": []});
trajeto_json.addTo(map_5ccd27c8efed2f1d5f821cab9236ab21); trajeto_json.addTo(map_f0b88e3c9fbbb871f17a4dbd225c6fff);
function adicionarGeometria(novaGeometria) { function adicionarGeometria(novaGeometria) {
trajeto_json.addData(novaGeometria); trajeto_json.addData(novaGeometria);
@ -210,7 +210,7 @@
} }
trajeto_dinamico_json_add({"features": []}); trajeto_dinamico_json_add({"features": []});
trajeto_dinamico_json.addTo(map_5ccd27c8efed2f1d5f821cab9236ab21); trajeto_dinamico_json.addTo(map_f0b88e3c9fbbb871f17a4dbd225c6fff);
function adicionarGeometriaDinamica(novaGeometria) { function adicionarGeometriaDinamica(novaGeometria) {
trajeto_dinamico_json.addData(novaGeometria); trajeto_dinamico_json.addData(novaGeometria);
@ -263,9 +263,9 @@
var marcadorEquipamento = L.marker([0, 0], { var marcadorEquipamento = L.marker([0, 0], {
icon: customIcon icon: customIcon
}).addTo(map_5ccd27c8efed2f1d5f821cab9236ab21); }).addTo(map_f0b88e3c9fbbb871f17a4dbd225c6fff);
var marcadorBase = L.marker([0, 0], {}).addTo(map_5ccd27c8efed2f1d5f821cab9236ab21); var marcadorBase = L.marker([0, 0], {}).addTo(map_f0b88e3c9fbbb871f17a4dbd225c6fff);
var icon = L.AwesomeMarkers.icon( var icon = L.AwesomeMarkers.icon(
{"extraClasses": "fa-rotate-0", "icon": "info-sign", "iconColor": "white", "markerColor": "red", "prefix": "glyphicon"} {"extraClasses": "fa-rotate-0", "icon": "info-sign", "iconColor": "white", "markerColor": "red", "prefix": "glyphicon"}
); );
@ -347,7 +347,7 @@
} }
if (foco) { if (foco) {
map_5ccd27c8efed2f1d5f821cab9236ab21.setView(novaPosicao, map_5ccd27c8efed2f1d5f821cab9236ab21.getZoom()); map_f0b88e3c9fbbb871f17a4dbd225c6fff.setView(novaPosicao, map_f0b88e3c9fbbb871f17a4dbd225c6fff.getZoom());
} }
} }
@ -364,7 +364,7 @@
function atualizarSelecaoRuas(selecionadas) { function atualizarSelecaoRuas(selecionadas) {
selecionadas = JSON.parse(selecionadas); selecionadas = JSON.parse(selecionadas);
RuasSelecionadas = Array.isArray(selecionadas) ? [...selecionadas] : []; RuasSelecionadas = Array.isArray(selecionadas) ? [...selecionadas] : [];
geo_json_04db30abe29c98f8b704fb7bbb35c27c.eachLayer(function (layer) { geo_json_afbdf9289c407bb446a01d22a6f4e29b.eachLayer(function (layer) {
if (RuasSelecionadas.includes(parseInt(layer.feature.id))) { if (RuasSelecionadas.includes(parseInt(layer.feature.id))) {
layer.setStyle({ color: 'blue' }); layer.setStyle({ color: 'blue' });
} else { } else {

View File

@ -16,6 +16,7 @@ namespace AgroMonitor.Forms
AsyncTaskTimerModel tmrDadosMapa; AsyncTaskTimerModel tmrDadosMapa;
string path = Variaveis.CaminhoSistema + Variaveis.CaminhoOperacoes + "\\" + MapasVariaveisModel.NomeArquivoMapaInterativoSaida; string path = Variaveis.CaminhoSistema + Variaveis.CaminhoOperacoes + "\\" + MapasVariaveisModel.NomeArquivoMapaInterativoSaida;
UltrasonicA05Configuracoes ConfigUltrassom = UltrasonicA05Helper.CarregarConfiguracaoPadrao(ConfiguracaoSensorUltrassonico.NaoUtilizado); UltrasonicA05Configuracoes ConfigUltrassom = UltrasonicA05Helper.CarregarConfiguracaoPadrao(ConfiguracaoSensorUltrassonico.NaoUtilizado);
bool carregarOpPadrao = true;
public frmAjustesOperacao() public frmAjustesOperacao()
{ {
@ -42,12 +43,12 @@ namespace AgroMonitor.Forms
private void cmbModosOperacao_SelectedIndexChanged(object sender, EventArgs e) private void cmbModosOperacao_SelectedIndexChanged(object sender, EventArgs e)
{ {
AtualizarDadosOperacao(true); AtualizarDadosOperacao();
} }
private void AtualizarDadosOperacao(bool CarregarOperacao) private void AtualizarDadosOperacao()
{ {
if (CarregarOperacao) if (carregarOpPadrao)
{ {
OperacaoModel.CarregarParametrosOperacaoPadrao((ModoOperacao)cmbModosOperacao.SelectedIndex); OperacaoModel.CarregarParametrosOperacaoPadrao((ModoOperacao)cmbModosOperacao.SelectedIndex);
} }
@ -162,14 +163,15 @@ namespace AgroMonitor.Forms
{ {
tabControl1.SelectedIndex = 1; tabControl1.SelectedIndex = 1;
AtualizarDadosOperacao(false); carregarOpPadrao = false;
cmbModosOperacao.SelectedIndex = (int)Variaveis.OperacaoEmAndamento.Modo;
MessageBox.Show("Operação carregada com sucesso!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Operação carregada com sucesso!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
tmrDadosMapa = new AsyncTaskTimerModel("tmrDadosMapa", tmrDadosMapa_Tick, 500, this); tmrDadosMapa = new AsyncTaskTimerModel("tmrDadosMapa", tmrDadosMapa_Tick, 500, this);
tmrDadosMapa.Start(); tmrDadosMapa.Start();
await Task.Delay(1000); await Task.Delay(2000);
if (ruasSelecionadas.Any()) if (ruasSelecionadas.Any())
{ {
@ -177,6 +179,8 @@ namespace AgroMonitor.Forms
GPSService.AtualizarRuasSelecionadas(ruasSelecionadas); GPSService.AtualizarRuasSelecionadas(ruasSelecionadas);
File.Delete(path); File.Delete(path);
} }
carregarOpPadrao = true;
} }
} }

File diff suppressed because one or more lines are too long

View File

@ -1,47 +1 @@
{ {"type":"FeatureCollection","features":[{"type":"Feature","properties":{"Id":"1","Name":"Projeto","Length":21.332976190943135,"Dist1":0.0,"Dist2":0.0},"geometry":{"id":"0","type":"LineString","coordinates":[[-47.381495333333334,-22.213068166666666],[-47.381469166666669,-22.213091333333335],[-47.38141825,-22.213137833333334],[-47.3813925,-22.213161666666668],[-47.381369666666664,-22.2131845]]}},{"type":"Feature","properties":{"Id":"2","Name":"Projeto","Length":24.045328359726675,"Dist1":0.0,"Dist2":0.0},"geometry":{"id":"1","type":"LineString","coordinates":[[-47.381340166666668,-22.213175666666668],[-47.381375333333331,-22.213137166666666],[-47.38140933333333,-22.213102666666668],[-47.381453666666665,-22.213058166666666],[-47.381496666666663,-22.213015666666667]]}}]}
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"Id": "1",
"Name": "Projeto",
"Length": 21.332976190943135,
"Dist1": 0.0,
"Dist2": 0.0
},
"geometry": {
"id": null,
"type": "LineString",
"coordinates": [
[-47.381495333333334, -22.213068166666666],
[-47.38146916666667, -22.213091333333335],
[-47.38141825, -22.213137833333333],
[-47.3813925, -22.213161666666668],
[-47.381369666666664, -22.2131845]
]
}
},
{
"type": "Feature",
"properties": {
"Id": "2",
"Name": "Projeto",
"Length": 24.045328359726675,
"Dist1": 0.0,
"Dist2": 0.0
},
"geometry": {
"id": null,
"type": "LineString",
"coordinates": [
[-47.381340166666668, -22.213175666666668],
[-47.381375333333331, -22.213137166666666],
[-47.38140933333333, -22.213102666666668],
[-47.381453666666665, -22.213058166666666],
[-47.381496666666663, -22.213015666666667]
]
}
}
]
}

View File

@ -25,7 +25,7 @@
<meta name="viewport" content="width=device-width, <meta name="viewport" content="width=device-width,
initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<style> <style>
#map_978f1cf22df0182e13bba9beda806341 { #map_db1225b1e62d9bab1ce65e5a1b0337da {
position: relative; position: relative;
width: 100.0%; width: 100.0%;
height: 100.0%; height: 100.0%;
@ -39,14 +39,14 @@
<body> <body>
<div class="folium-map" id="map_978f1cf22df0182e13bba9beda806341" ></div> <div class="folium-map" id="map_db1225b1e62d9bab1ce65e5a1b0337da" ></div>
</body> </body>
<script> <script>
var map_978f1cf22df0182e13bba9beda806341 = L.map( var map_db1225b1e62d9bab1ce65e5a1b0337da = L.map(
"map_978f1cf22df0182e13bba9beda806341", "map_db1225b1e62d9bab1ce65e5a1b0337da",
{ {
center: [-22.213100083333334, -47.38141841666666], center: [-22.213100083333334, -47.38141841666666],
crs: L.CRS.EPSG3857, crs: L.CRS.EPSG3857,
@ -60,13 +60,13 @@
var tile_layer_c69220a59438ecb349e64b03d41a2724 = L.tileLayer( var tile_layer_780db0f51e5cd4e2609b0632b0bfa588 = L.tileLayer(
"https://tile.openstreetmap.org/{z}/{x}/{y}.png", "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
{"attribution": "\u0026copy; \u003ca href=\"https://www.openstreetmap.org/copyright\"\u003eOpenStreetMap\u003c/a\u003e contributors", "detectRetina": false, "maxNativeZoom": 19, "maxZoom": 19, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false} {"attribution": "\u0026copy; \u003ca href=\"https://www.openstreetmap.org/copyright\"\u003eOpenStreetMap\u003c/a\u003e contributors", "detectRetina": false, "maxNativeZoom": 19, "maxZoom": 19, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}
); );
tile_layer_c69220a59438ecb349e64b03d41a2724.addTo(map_978f1cf22df0182e13bba9beda806341); tile_layer_780db0f51e5cd4e2609b0632b0bfa588.addTo(map_db1225b1e62d9bab1ce65e5a1b0337da);
@ -82,7 +82,7 @@
}*/ }*/
}); });
} }
function geo_json_8f995dd45ce0247620e88f5983daaaeb_onEachFeature(feature, layer) { function geo_json_c919ee5e792846159b7b6a14116f9dcb_onEachFeature(feature, layer) {
layer.on({ layer.on({
click: function(e) { click: function(e) {
@ -118,20 +118,20 @@
}*/ }*/
}); });
}; };
var geo_json_8f995dd45ce0247620e88f5983daaaeb = L.geoJson(null, { var geo_json_c919ee5e792846159b7b6a14116f9dcb = L.geoJson(null, {
onEachFeature: geo_json_8f995dd45ce0247620e88f5983daaaeb_onEachFeature, onEachFeature: geo_json_c919ee5e792846159b7b6a14116f9dcb_onEachFeature,
}); });
function geo_json_8f995dd45ce0247620e88f5983daaaeb_add (data) { function geo_json_c919ee5e792846159b7b6a14116f9dcb_add (data) {
geo_json_8f995dd45ce0247620e88f5983daaaeb geo_json_c919ee5e792846159b7b6a14116f9dcb
.addData(data); .addData(data);
} }
geo_json_8f995dd45ce0247620e88f5983daaaeb_add({"features": [{"geometry": {"coordinates": [[-47.38149533333333, -22.213068166666666], [-47.38146916666667, -22.213091333333335], [-47.38141825, -22.213137833333334], [-47.3813925, -22.213161666666668], [-47.381369666666664, -22.2131845]], "id": null, "type": "LineString"}, "id": 0, "properties": {"Dist1": 0.0, "Dist2": 0.0, "Id": "1", "Length": 21.332976190943135, "Name": "Projeto"}, "type": "Feature"}, {"geometry": {"coordinates": [[-47.38134016666667, -22.213175666666668], [-47.38137533333333, -22.213137166666666], [-47.38140933333333, -22.213102666666668], [-47.381453666666665, -22.213058166666666], [-47.38149666666666, -22.213015666666667]], "id": null, "type": "LineString"}, "id": 1, "properties": {"Dist1": 0.0, "Dist2": 0.0, "Id": "2", "Length": 24.045328359726675, "Name": "Projeto"}, "type": "Feature"}], "type": "FeatureCollection"}); geo_json_c919ee5e792846159b7b6a14116f9dcb_add({"features": [{"geometry": {"coordinates": [[-47.38149533333333, -22.213068166666666], [-47.38146916666667, -22.213091333333335], [-47.38141825, -22.213137833333334], [-47.3813925, -22.213161666666668], [-47.381369666666664, -22.2131845]], "id": "0", "type": "LineString"}, "id": 0, "properties": {"Dist1": 0.0, "Dist2": 0.0, "Id": "1", "Length": 21.332976190943135, "Name": "Projeto"}, "type": "Feature"}, {"geometry": {"coordinates": [[-47.38134016666667, -22.213175666666668], [-47.38137533333333, -22.213137166666666], [-47.38140933333333, -22.213102666666668], [-47.381453666666665, -22.213058166666666], [-47.38149666666666, -22.213015666666667]], "id": "1", "type": "LineString"}, "id": 1, "properties": {"Dist1": 0.0, "Dist2": 0.0, "Id": "2", "Length": 24.045328359726675, "Name": "Projeto"}, "type": "Feature"}], "type": "FeatureCollection"});
geo_json_8f995dd45ce0247620e88f5983daaaeb.addTo(map_978f1cf22df0182e13bba9beda806341); geo_json_c919ee5e792846159b7b6a14116f9dcb.addTo(map_db1225b1e62d9bab1ce65e5a1b0337da);
</script> </script>
@ -152,7 +152,7 @@
} }
trajeto_json_add({"features": []}); trajeto_json_add({"features": []});
trajeto_json.addTo(map_978f1cf22df0182e13bba9beda806341); trajeto_json.addTo(map_db1225b1e62d9bab1ce65e5a1b0337da);
function adicionarGeometria(novaGeometria) { function adicionarGeometria(novaGeometria) {
trajeto_json.addData(novaGeometria); trajeto_json.addData(novaGeometria);
@ -210,7 +210,7 @@
} }
trajeto_dinamico_json_add({"features": []}); trajeto_dinamico_json_add({"features": []});
trajeto_dinamico_json.addTo(map_978f1cf22df0182e13bba9beda806341); trajeto_dinamico_json.addTo(map_db1225b1e62d9bab1ce65e5a1b0337da);
function adicionarGeometriaDinamica(novaGeometria) { function adicionarGeometriaDinamica(novaGeometria) {
trajeto_dinamico_json.addData(novaGeometria); trajeto_dinamico_json.addData(novaGeometria);
@ -263,9 +263,9 @@
var marcadorEquipamento = L.marker([0, 0], { var marcadorEquipamento = L.marker([0, 0], {
icon: customIcon icon: customIcon
}).addTo(map_978f1cf22df0182e13bba9beda806341); }).addTo(map_db1225b1e62d9bab1ce65e5a1b0337da);
var marcadorBase = L.marker([0, 0], {}).addTo(map_978f1cf22df0182e13bba9beda806341); var marcadorBase = L.marker([0, 0], {}).addTo(map_db1225b1e62d9bab1ce65e5a1b0337da);
var icon = L.AwesomeMarkers.icon( var icon = L.AwesomeMarkers.icon(
{"extraClasses": "fa-rotate-0", "icon": "info-sign", "iconColor": "white", "markerColor": "red", "prefix": "glyphicon"} {"extraClasses": "fa-rotate-0", "icon": "info-sign", "iconColor": "white", "markerColor": "red", "prefix": "glyphicon"}
); );
@ -347,7 +347,7 @@
} }
if (foco) { if (foco) {
map_978f1cf22df0182e13bba9beda806341.setView(novaPosicao, map_978f1cf22df0182e13bba9beda806341.getZoom()); map_db1225b1e62d9bab1ce65e5a1b0337da.setView(novaPosicao, map_db1225b1e62d9bab1ce65e5a1b0337da.getZoom());
} }
} }
@ -364,7 +364,7 @@
function atualizarSelecaoRuas(selecionadas) { function atualizarSelecaoRuas(selecionadas) {
selecionadas = JSON.parse(selecionadas); selecionadas = JSON.parse(selecionadas);
RuasSelecionadas = Array.isArray(selecionadas) ? [...selecionadas] : []; RuasSelecionadas = Array.isArray(selecionadas) ? [...selecionadas] : [];
geo_json_8f995dd45ce0247620e88f5983daaaeb.eachLayer(function (layer) { geo_json_c919ee5e792846159b7b6a14116f9dcb.eachLayer(function (layer) {
if (RuasSelecionadas.includes(parseInt(layer.feature.id))) { if (RuasSelecionadas.includes(parseInt(layer.feature.id))) {
layer.setStyle({ color: 'blue' }); layer.setStyle({ color: 'blue' });
} else { } else {