adicionado tela de acompanhamento dos robos

This commit is contained in:
Diego Freitas 2024-07-15 16:02:36 -03:00
parent 09150c93c4
commit 1f3484879b
47 changed files with 1725 additions and 215 deletions

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -29,11 +29,14 @@
private void InitializeComponent()
{
this.pnlEsquerda = new System.Windows.Forms.Panel();
this.picEsquerda = new System.Windows.Forms.PictureBox();
this.lblCameras = new System.Windows.Forms.Label();
this.lblEsquerda = new System.Windows.Forms.Label();
this.lblDireita = new System.Windows.Forms.Label();
this.pnlDireita = new System.Windows.Forms.Panel();
this.picDireita = new System.Windows.Forms.PictureBox();
this.pnlCentro = new System.Windows.Forms.Panel();
this.picCentro = new System.Windows.Forms.PictureBox();
this.lblCentro = new System.Windows.Forms.Label();
this.cmbS0 = new System.Windows.Forms.ComboBox();
this.cmbC = new System.Windows.Forms.ComboBox();
@ -60,20 +63,18 @@
this.picLer = new System.Windows.Forms.PictureBox();
this.picGravar = new System.Windows.Forms.PictureBox();
this.picAtualizar = new System.Windows.Forms.PictureBox();
this.picEsquerda = new System.Windows.Forms.PictureBox();
this.picCentro = new System.Windows.Forms.PictureBox();
this.picDireita = new System.Windows.Forms.PictureBox();
this.cmbComunicacao = new System.Windows.Forms.ComboBox();
this.pnlEsquerda.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picEsquerda)).BeginInit();
this.pnlDireita.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picDireita)).BeginInit();
this.pnlCentro.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picCentro)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picVoltar)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picSalvar)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picLer)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picGravar)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picAtualizar)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picEsquerda)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picCentro)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picDireita)).BeginInit();
this.SuspendLayout();
//
// pnlEsquerda
@ -84,6 +85,17 @@
this.pnlEsquerda.Size = new System.Drawing.Size(225, 172);
this.pnlEsquerda.TabIndex = 0;
//
// picEsquerda
//
this.picEsquerda.BackColor = System.Drawing.Color.Black;
this.picEsquerda.Dock = System.Windows.Forms.DockStyle.Fill;
this.picEsquerda.Location = new System.Drawing.Point(0, 0);
this.picEsquerda.Name = "picEsquerda";
this.picEsquerda.Size = new System.Drawing.Size(225, 172);
this.picEsquerda.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.picEsquerda.TabIndex = 0;
this.picEsquerda.TabStop = false;
//
// lblCameras
//
this.lblCameras.AutoSize = true;
@ -122,6 +134,17 @@
this.pnlDireita.Size = new System.Drawing.Size(225, 172);
this.pnlDireita.TabIndex = 4;
//
// picDireita
//
this.picDireita.BackColor = System.Drawing.Color.Black;
this.picDireita.Dock = System.Windows.Forms.DockStyle.Fill;
this.picDireita.Location = new System.Drawing.Point(0, 0);
this.picDireita.Name = "picDireita";
this.picDireita.Size = new System.Drawing.Size(225, 172);
this.picDireita.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.picDireita.TabIndex = 1;
this.picDireita.TabStop = false;
//
// pnlCentro
//
this.pnlCentro.Controls.Add(this.picCentro);
@ -130,6 +153,17 @@
this.pnlCentro.Size = new System.Drawing.Size(225, 172);
this.pnlCentro.TabIndex = 1;
//
// picCentro
//
this.picCentro.BackColor = System.Drawing.Color.Black;
this.picCentro.Dock = System.Windows.Forms.DockStyle.Fill;
this.picCentro.Location = new System.Drawing.Point(0, 0);
this.picCentro.Name = "picCentro";
this.picCentro.Size = new System.Drawing.Size(225, 172);
this.picCentro.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.picCentro.TabIndex = 1;
this.picCentro.TabStop = false;
//
// lblCentro
//
this.lblCentro.AutoSize = true;
@ -142,7 +176,6 @@
//
// cmbS0
//
this.cmbS0.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbS0.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F);
this.cmbS0.FormattingEnabled = true;
this.cmbS0.Location = new System.Drawing.Point(101, 249);
@ -152,7 +185,6 @@
//
// cmbC
//
this.cmbC.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbC.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F);
this.cmbC.FormattingEnabled = true;
this.cmbC.Location = new System.Drawing.Point(332, 249);
@ -162,7 +194,6 @@
//
// cmbS1
//
this.cmbS1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbS1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F);
this.cmbS1.FormattingEnabled = true;
this.cmbS1.Location = new System.Drawing.Point(563, 249);
@ -215,7 +246,7 @@
//
this.txtCanal.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F);
this.txtCanal.Location = new System.Drawing.Point(247, 431);
this.txtCanal.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.txtCanal.Margin = new System.Windows.Forms.Padding(2);
this.txtCanal.Name = "txtCanal";
this.txtCanal.Size = new System.Drawing.Size(155, 26);
this.txtCanal.TabIndex = 31;
@ -235,7 +266,7 @@
//
this.txtEndereco.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F);
this.txtEndereco.Location = new System.Drawing.Point(247, 401);
this.txtEndereco.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.txtEndereco.Margin = new System.Windows.Forms.Padding(2);
this.txtEndereco.Name = "txtEndereco";
this.txtEndereco.Size = new System.Drawing.Size(155, 26);
this.txtEndereco.TabIndex = 29;
@ -246,7 +277,7 @@
this.cmbPower.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F);
this.cmbPower.FormattingEnabled = true;
this.cmbPower.Location = new System.Drawing.Point(563, 433);
this.cmbPower.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.cmbPower.Margin = new System.Windows.Forms.Padding(2);
this.cmbPower.Name = "cmbPower";
this.cmbPower.Size = new System.Drawing.Size(155, 28);
this.cmbPower.TabIndex = 28;
@ -268,7 +299,7 @@
this.cmbWorCycle.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F);
this.cmbWorCycle.FormattingEnabled = true;
this.cmbWorCycle.Location = new System.Drawing.Point(563, 401);
this.cmbWorCycle.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.cmbWorCycle.Margin = new System.Windows.Forms.Padding(2);
this.cmbWorCycle.Name = "cmbWorCycle";
this.cmbWorCycle.Size = new System.Drawing.Size(155, 28);
this.cmbWorCycle.TabIndex = 26;
@ -290,7 +321,7 @@
this.cmbTransmissao.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F);
this.cmbTransmissao.FormattingEnabled = true;
this.cmbTransmissao.Location = new System.Drawing.Point(247, 369);
this.cmbTransmissao.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.cmbTransmissao.Margin = new System.Windows.Forms.Padding(2);
this.cmbTransmissao.Name = "cmbTransmissao";
this.cmbTransmissao.Size = new System.Drawing.Size(155, 28);
this.cmbTransmissao.TabIndex = 24;
@ -312,7 +343,7 @@
this.cmbPacketSize.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F);
this.cmbPacketSize.FormattingEnabled = true;
this.cmbPacketSize.Location = new System.Drawing.Point(563, 369);
this.cmbPacketSize.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.cmbPacketSize.Margin = new System.Windows.Forms.Padding(2);
this.cmbPacketSize.Name = "cmbPacketSize";
this.cmbPacketSize.Size = new System.Drawing.Size(155, 28);
this.cmbPacketSize.TabIndex = 22;
@ -334,7 +365,7 @@
this.cmbAirRate.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F);
this.cmbAirRate.FormattingEnabled = true;
this.cmbAirRate.Location = new System.Drawing.Point(563, 337);
this.cmbAirRate.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.cmbAirRate.Margin = new System.Windows.Forms.Padding(2);
this.cmbAirRate.Name = "cmbAirRate";
this.cmbAirRate.Size = new System.Drawing.Size(155, 28);
this.cmbAirRate.TabIndex = 20;
@ -356,7 +387,7 @@
this.cmbBaudRate.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F);
this.cmbBaudRate.FormattingEnabled = true;
this.cmbBaudRate.Location = new System.Drawing.Point(247, 337);
this.cmbBaudRate.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.cmbBaudRate.Margin = new System.Windows.Forms.Padding(2);
this.cmbBaudRate.Name = "cmbBaudRate";
this.cmbBaudRate.Size = new System.Drawing.Size(155, 28);
this.cmbBaudRate.TabIndex = 18;
@ -402,38 +433,17 @@
this.picAtualizar.TabIndex = 35;
this.picAtualizar.TabStop = false;
//
// picEsquerda
// cmbComunicacao
//
this.picEsquerda.BackColor = System.Drawing.Color.Black;
this.picEsquerda.Dock = System.Windows.Forms.DockStyle.Fill;
this.picEsquerda.Location = new System.Drawing.Point(0, 0);
this.picEsquerda.Name = "picEsquerda";
this.picEsquerda.Size = new System.Drawing.Size(225, 172);
this.picEsquerda.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.picEsquerda.TabIndex = 0;
this.picEsquerda.TabStop = false;
//
// picCentro
//
this.picCentro.BackColor = System.Drawing.Color.Black;
this.picCentro.Dock = System.Windows.Forms.DockStyle.Fill;
this.picCentro.Location = new System.Drawing.Point(0, 0);
this.picCentro.Name = "picCentro";
this.picCentro.Size = new System.Drawing.Size(225, 172);
this.picCentro.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.picCentro.TabIndex = 1;
this.picCentro.TabStop = false;
//
// picDireita
//
this.picDireita.BackColor = System.Drawing.Color.Black;
this.picDireita.Dock = System.Windows.Forms.DockStyle.Fill;
this.picDireita.Location = new System.Drawing.Point(0, 0);
this.picDireita.Name = "picDireita";
this.picDireita.Size = new System.Drawing.Size(225, 172);
this.picDireita.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.picDireita.TabIndex = 1;
this.picDireita.TabStop = false;
this.cmbComunicacao.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbComunicacao.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F);
this.cmbComunicacao.FormattingEnabled = true;
this.cmbComunicacao.Location = new System.Drawing.Point(247, 303);
this.cmbComunicacao.Margin = new System.Windows.Forms.Padding(2);
this.cmbComunicacao.Name = "cmbComunicacao";
this.cmbComunicacao.Size = new System.Drawing.Size(155, 28);
this.cmbComunicacao.TabIndex = 36;
this.cmbComunicacao.SelectedIndexChanged += new System.EventHandler(this.cmbComunicacao_SelectedIndexChanged);
//
// frmAjustes
//
@ -441,6 +451,7 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Ivory;
this.ClientSize = new System.Drawing.Size(800, 480);
this.Controls.Add(this.cmbComunicacao);
this.Controls.Add(this.picSalvar);
this.Controls.Add(this.picAtualizar);
this.Controls.Add(this.picGravar);
@ -479,16 +490,16 @@
this.Text = "frmAjustes";
this.Load += new System.EventHandler(this.frmAjustes_Load);
this.pnlEsquerda.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.picEsquerda)).EndInit();
this.pnlDireita.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.picDireita)).EndInit();
this.pnlCentro.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.picCentro)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picVoltar)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picSalvar)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picLer)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picGravar)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picAtualizar)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picEsquerda)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picCentro)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picDireita)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@ -531,5 +542,6 @@
private System.Windows.Forms.PictureBox picEsquerda;
private System.Windows.Forms.PictureBox picDireita;
private System.Windows.Forms.PictureBox picCentro;
private System.Windows.Forms.ComboBox cmbComunicacao;
}
}

View File

@ -17,18 +17,21 @@ namespace AgroBase.Forms.IHM
{
public partial class frmAjustes : Form
{
LoRaService loraService;
LoRaParametrosModel Parametros = null;
//LoRaParametrosModel loraParametrosBase;
Dictionary<string, string> Cameras = new Dictionary<string, string>();
public frmAjustes(LoRaService lora)
public frmAjustes()
{
InitializeComponent();
loraService = lora;
}
private void frmAjustes_Load(object sender, EventArgs e)
{
cmbComunicacao.Items.Clear();
cmbComunicacao.Items.AddRange(new string[] { "Equipamento", "Base" });
cmbComunicacao.SelectedIndex = 0;
FuncoesGlobais.DefinirEventosPicBtn(picVoltar, async () =>
{
this.Close();
@ -60,6 +63,8 @@ namespace AgroBase.Forms.IHM
{
if (LoRaService.Iniciado)
{
LoRaParametrosModel Parametros = new LoRaParametrosModel();
Parametros.baudRate = LoRaService.CodigosBaudRates.FirstOrDefault(x => x.Key.ToString() == cmbBaudRate.Text).Value;
Parametros.tranMode = LoRaService.CodigosTipoTransmissao.FirstOrDefault(x => x.Key.ToString() == cmbTransmissao.Text).Value;
Parametros.address = Convert.ToByte(txtEndereco.Text);
@ -69,7 +74,7 @@ namespace AgroBase.Forms.IHM
Parametros.worCycle = LoRaService.CodigosWorCycles.FirstOrDefault(x => x.Key.ToString() == cmbWorCycle.Text).Value;
Parametros.power = LoRaService.CodigosPowers.FirstOrDefault(x => x.Key.ToString() == cmbPower.Text).Value;
await ConfigurarModulo();
await ConfigurarModulo(Parametros);
MessageBox.Show("Configuração de comunicação salva com sucesso!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
@ -90,14 +95,23 @@ namespace AgroBase.Forms.IHM
private async Task AtualizarParametros()
{
var (sucesso, par) = await loraService.RequisitarParametrosModuloAsync();
LoRaParametrosModel Parametros = new LoRaParametrosModel();
if (!sucesso)
if (cmbComunicacao.SelectedIndex == 0)
{
MessageBox.Show("Erro ao requisitar parâmetros! Verifique o modo do módulo LoRa!");
}
var (sucesso, par) = await Variaveis.ConexaoLoRa.RequisitarParametrosModuloAsync();
Parametros = par;
if (!sucesso)
{
MessageBox.Show("Erro ao requisitar parâmetros! Verifique o modo do módulo LoRa!");
}
Parametros = par;
}
else
{
Parametros = Variaveis.OperacaoEmAndamento.DispSen.Dados.LoRaParametrosBase;
}
txtEndereco.Text = ((int)Parametros.address).ToString();
txtCanal.Text = ((int)Parametros.channel).ToString();
@ -122,16 +136,37 @@ namespace AgroBase.Forms.IHM
cmbPower.SelectedItem = LoRaService.CodigosPowers.FirstOrDefault(x => x.Value == Parametros.power).Key.ToString();
}
private async Task ConfigurarModulo()
private async Task ConfigurarModulo(LoRaParametrosModel Parametros)
{
var Sucesso = await loraService.ConfigurarModuloAsync(Parametros);
if (Sucesso != null)
if (cmbComunicacao.SelectedIndex == 0)
{
MessageBox.Show("Módulo configurado com sucesso!");
if (Parametros.address == Variaveis.OperacaoEmAndamento.DispSen.Dados.LoRaParametrosBase.address)
{
MessageBox.Show("O endereço informado já está sendo usado pelo módulo de comunicação LoRa da base!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
var Sucesso = await Variaveis.ConexaoLoRa.ConfigurarModuloAsync(Parametros);
if (Sucesso != null)
{
MessageBox.Show("Módulo de comunicação LoRa configurado com sucesso!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Erro ao configurar módulo de comunicação LoRa!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Erro ao configurar módulo!");
if (Parametros.address == Variaveis.ConexaoLoRa.parametros.address)
{
MessageBox.Show("O endereço informado já está sendo usado pelo módulo de comunicação LoRa do equipamento!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
Variaveis.OperacaoEmAndamento.DispSen.Dados.LoRaParametrosBase = Parametros;
Variaveis.OperacaoEmAndamento.DispSen.SalvarParametros(Variaveis.OperacaoEmAndamento.DispSen.Dados);
MessageBox.Show("Configuração do módulo de comunicação LoRa da base realizado com sucesso!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
await AtualizarParametros();
}
@ -314,11 +349,15 @@ namespace AgroBase.Forms.IHM
}
#endregion
private void cmbComunicacao_SelectedIndexChanged(object sender, EventArgs e)
{
AtualizarParametros().ConfigureAwait(false);
}
}
}

View File

@ -54,7 +54,7 @@ namespace AgroBase.Forms.IHM
});*/
FuncoesGlobais.DefinirEventosPicBtn(picAjustes, async () =>
{
frmAjustes frm = new frmAjustes(Variaveis.ConexaoLoRa);
frmAjustes frm = new frmAjustes();
frm.ShowDialog();
});
FuncoesGlobais.DefinirEventosPicBtn(picDesligar, async () =>

View File

@ -174,6 +174,7 @@ namespace AgroBase.Models
{
public double Latitude { get; set; }
public double Longitude { get; set; }
public double Orientacao { get; set; }
}
public class LoRaProtocoloTransmissaoSensoresModel
@ -182,11 +183,13 @@ namespace AgroBase.Models
public double PercentualReservatorio { get; set; }
public double PressaoLinha { get; set; }
public double DistanciaPercorrida { get; set; }
public double OrientacaoCarro { get; set; }
public double OrientacaoCaminho { get; set; }
public double Velocidade { get; set; }
public double ErvasIdentificadas { get; set; }
public double Temperatura { get; set; }
public double TemperaturaMotores { get; set; }
public double TemperaturaCampo { get; set; }
public double HerbicidaConsumido { get; set; }
public double HerbicidaPorErva { get; set; }
}
public class LoRaProtocoloTransmissaoOperacaoModel
@ -197,6 +200,7 @@ namespace AgroBase.Models
public double PercentualOperacao { get; set; }
public double PercentualRua { get; set; }
public int TempoOperacao { get; set; }
public string TempoEstimado { get; set; }
}
public enum LoRaTipoProtocolo

View File

@ -45,6 +45,17 @@ namespace AgroBase.Models.Modules
public string CameraID_Caminho { get; set; } = "";
public List<string> CameraID_Solo { get; set; } = new List<string>();
public double BateriaCargaConsumida { get; set; }
public LoRaParametrosModel LoRaParametrosBase { get; set; } = new LoRaParametrosModel()
{
address = 0x01,
channel = 0x17,
tranMode = LoRaService.CodigosTipoTransmissao["Fixed"],
baudRate = LoRaService.CodigosBaudRates[9600],
airRate = LoRaService.CodigosAirRates[2.4],
packetSize = LoRaService.CodigosPacketSizes[200],
worCycle = LoRaService.CodigosWorCycles[4000],
power = LoRaService.CodigosPowers[22],
};
public static SensoriamentoModel CarregarParametrosIniciais()

View File

@ -1565,45 +1565,9 @@ namespace AgroBase.Models
idxLog++;
if (LoRaService.Iniciado && idxLog % 2 == 0)
if (idxLog % 2 == 0)
{
LoRaProtocoloTransmissaoModel dados = new LoRaProtocoloTransmissaoModel()
{
Momento = Agora,
EnderecoCarro = Variaveis.ConexaoLoRa.parametros.address,
Operacao = new LoRaProtocoloTransmissaoOperacaoModel()
{
idxRuaAtual = Sensoriamento.IdxRuaAtual,
statusOperacao = Sensoriamento.StatusOperacao,
statusCarro = Sensoriamento.StatusCarro,
TempoOperacao = Convert.ToInt32(Tempo.TotalSeconds),
PercentualRua = OpMapaGPS.Sensoriamento.ProgressoRua,
PercentualOperacao = OpMapaGPS.Sensoriamento.ProgressoTrajeto,
},
Coordenadas = new LoRaProtocoloTransmissaoCoordenadasModel()
{
Latitude = GPSService.UltimaLeitura.Latitude,
Longitude = GPSService.UltimaLeitura.Longitude,
},
Sensores = new LoRaProtocoloTransmissaoSensoresModel()
{
DistanciaPercorrida = Math.Round(Sensoriamento.DistanciaPercorrida.Sum(), 2),
ErvasIdentificadas = OpMapaGPS.Sensoriamento.ErvasIdentificadas,
OrientacaoCaminho = Math.Round(Sensoriamento.AnguloRua, 2),
OrientacaoCarro = Math.Round(Sensoriamento.AnguloCarro, 2),
PercentualBateria = Math.Round(Sensoriamento.PorcentagemBateria, 2),
PercentualReservatorio = Math.Round(DispAtu.Dados.PercentualReservatorio, 2),
PressaoLinha = Math.Round(DispAtu.Dados.PressaoLinha, 2),
Temperatura = Math.Round(DispMvd.Dados.Modulos.Average(x => x.MovMotor.Temperatura), 2),
Velocidade = Math.Round(DispMvd.Dados.Modulos.Average(x => x.MovMotor.VelocidadeInstantanea), 2),
}
};
byte[] dadosEnvio = LoRaSerializer.SerializeLoRaProtocoloTransmissaoModel(dados);
var t = LoRaSerializer.DeserializeLoRaProtocoloTransmissaoModel(dadosEnvio);
LoRaService.MontarMensagemEnvio(dadosEnvio, VariaveisEquipamento.ComunicacaoLoRaBaseConfig.address, LoRaTipoProtocolo.DadosOperacao, true);
LoRaService.EnviarDadosParaBase();
}
}

View File

@ -133,18 +133,7 @@ namespace AgroBase.Models
public static double DiametroRoda { get; set; } = 0.3556;
public static double BateriaMax { get; set; } = 20;
public static double ReducaoDirecional { get; set; } = 20.0;
public static LoRaParametrosModel ComunicacaoLoRaBaseConfig { get; set; } = new LoRaParametrosModel()
{
address = 0x01,
channel = 0x17,
tranMode = LoRaService.CodigosTipoTransmissao["Fixed"],
baudRate = LoRaService.CodigosBaudRates[9600],
airRate = LoRaService.CodigosAirRates[2.4],
packetSize = LoRaService.CodigosPacketSizes[200],
worCycle = LoRaService.CodigosWorCycles[4000],
power = LoRaService.CodigosPowers[22],
};
public static int TempoEntrePingsConexao { get; set; } = 10000;
}
public static class VariaveisOperacao

View File

@ -538,7 +538,7 @@ namespace AgroBase.Services
public static void AtualizarCoordenadasGPS()
{
EnviarCoordenadasParaMapa(UltimaLeitura.Latitude, UltimaLeitura.Longitude, (Variaveis.OperacaoEmAndamento.Sensoriamento.AnguloCarro - 180));
EnviarCoordenadasParaMapa(UltimaLeitura.Latitude, UltimaLeitura.Longitude, ((Variaveis.OperacaoEmAndamento.Sensoriamento?.AnguloCarro ?? 0) - 180));
if (Variaveis.OperacaoEmAndamento.Iniciado)
{
@ -580,7 +580,8 @@ namespace AgroBase.Services
{
latitude = Latitude,
longitude = Longitude,
orientacao = Orientacao
orientacao = Orientacao,
id = Convert.ToInt32(Variaveis.IsAgroMonitor ? Variaveis.OperacaoEmAndamento.DispSen.Dados.LoRaParametrosBase.address : Variaveis.ConexaoLoRa.parametros.address)
};
Variaveis.MqttService.PublishAsync(
Variaveis.MqttService.Topicos.First(x => x.Topico == MapasVariaveisModel.TopicoCoordenadasGPS),

View File

@ -25,17 +25,20 @@ namespace AgroBase.Services
// Serializar Coordenadas (LoRaProtocoloTransmissaoCoordenadasModel)
bytes.AddRange(BitConverter.GetBytes(model.Coordenadas.Latitude));
bytes.AddRange(BitConverter.GetBytes(model.Coordenadas.Longitude));
bytes.AddRange(BitConverter.GetBytes(model.Coordenadas.Orientacao));
// Serializar Sensores (LoRaProtocoloTransmissaoSensoresModel)
bytes.AddRange(BitConverter.GetBytes(model.Sensores.PercentualBateria));
bytes.AddRange(BitConverter.GetBytes(model.Sensores.PercentualReservatorio));
bytes.AddRange(BitConverter.GetBytes(model.Sensores.PressaoLinha));
bytes.AddRange(BitConverter.GetBytes(model.Sensores.DistanciaPercorrida));
bytes.AddRange(BitConverter.GetBytes(model.Sensores.OrientacaoCarro));
bytes.AddRange(BitConverter.GetBytes(model.Sensores.OrientacaoCaminho));
bytes.AddRange(BitConverter.GetBytes(model.Sensores.Velocidade));
bytes.AddRange(BitConverter.GetBytes(model.Sensores.ErvasIdentificadas));
bytes.AddRange(BitConverter.GetBytes(model.Sensores.Temperatura));
bytes.AddRange(BitConverter.GetBytes(model.Sensores.TemperaturaMotores));
bytes.AddRange(BitConverter.GetBytes(model.Sensores.TemperaturaCampo));
bytes.AddRange(BitConverter.GetBytes(model.Sensores.HerbicidaConsumido));
bytes.AddRange(BitConverter.GetBytes(model.Sensores.HerbicidaPorErva));
// Serializar Operacao (LoRaProtocoloTransmissaoOperacaoModel)
bytes.Add((byte)model.Operacao.statusOperacao);
@ -45,6 +48,11 @@ namespace AgroBase.Services
bytes.AddRange(BitConverter.GetBytes(model.Operacao.PercentualRua));
bytes.AddRange(BitConverter.GetBytes(model.Operacao.TempoOperacao));
// Serializar TempoEstimado (string)
byte[] tempoEstimadoBytes = Encoding.UTF8.GetBytes(model.Operacao.TempoEstimado);
bytes.AddRange(BitConverter.GetBytes(tempoEstimadoBytes.Length)); // Adiciona o comprimento da string
bytes.AddRange(tempoEstimadoBytes); // Adiciona a string
return bytes.ToArray();
}
@ -65,9 +73,10 @@ namespace AgroBase.Services
model.Coordenadas = new LoRaProtocoloTransmissaoCoordenadasModel
{
Latitude = BitConverter.ToDouble(bytes, index),
Longitude = BitConverter.ToDouble(bytes, index + sizeof(double))
Longitude = BitConverter.ToDouble(bytes, index + sizeof(double)),
Orientacao = BitConverter.ToDouble(bytes, index + 2 * sizeof(double))
};
index += 2 * sizeof(double);
index += 3 * sizeof(double);
// Desserializar Sensores (LoRaProtocoloTransmissaoSensoresModel)
model.Sensores = new LoRaProtocoloTransmissaoSensoresModel
@ -76,13 +85,15 @@ namespace AgroBase.Services
PercentualReservatorio = BitConverter.ToDouble(bytes, index + sizeof(double)),
PressaoLinha = BitConverter.ToDouble(bytes, index + 2 * sizeof(double)),
DistanciaPercorrida = BitConverter.ToDouble(bytes, index + 3 * sizeof(double)),
OrientacaoCarro = BitConverter.ToDouble(bytes, index + 4 * sizeof(double)),
OrientacaoCaminho = BitConverter.ToDouble(bytes, index + 5 * sizeof(double)),
Velocidade = BitConverter.ToDouble(bytes, index + 6 * sizeof(double)),
ErvasIdentificadas = BitConverter.ToDouble(bytes, index + 7 * sizeof(double)),
Temperatura = BitConverter.ToDouble(bytes, index + 8 * sizeof(double))
OrientacaoCaminho = BitConverter.ToDouble(bytes, index + 4 * sizeof(double)),
Velocidade = BitConverter.ToDouble(bytes, index + 5 * sizeof(double)),
ErvasIdentificadas = BitConverter.ToDouble(bytes, index + 6 * sizeof(double)),
TemperaturaMotores = BitConverter.ToDouble(bytes, index + 7 * sizeof(double)),
TemperaturaCampo = BitConverter.ToDouble(bytes, index + 8 * sizeof(double)),
HerbicidaConsumido = BitConverter.ToDouble(bytes, index + 9 * sizeof(double)),
HerbicidaPorErva = BitConverter.ToDouble(bytes, index + 10 * sizeof(double))
};
index += 9 * sizeof(double);
index += 11 * sizeof(double);
// Desserializar Operacao (LoRaProtocoloTransmissaoOperacaoModel)
model.Operacao = new LoRaProtocoloTransmissaoOperacaoModel
@ -94,8 +105,15 @@ namespace AgroBase.Services
PercentualRua = BitConverter.ToDouble(bytes, index + 2 + sizeof(int) + sizeof(double)),
TempoOperacao = BitConverter.ToInt32(bytes, index + 2 + sizeof(int) + 2 * sizeof(double))
};
index += 2 + sizeof(int) + 2 * sizeof(double) + sizeof(int);
// Desserializar TempoEstimado (string)
int stringLength = BitConverter.ToInt32(bytes, index);
index += sizeof(int);
model.Operacao.TempoEstimado = Encoding.UTF8.GetString(bytes, index, stringLength);
return model;
}
}
}

View File

@ -1,5 +1,7 @@
using AgroBase.Models;
using Emgu.CV;
using Emgu.CV.Features2D;
using Emgu.CV.Structure;
using Microsoft.DirectX.DirectInput;
using Newtonsoft.Json;
using System;
@ -15,12 +17,12 @@ using System.Threading.Tasks;
using System.Windows.Forms;
using static AgroBase.Models.Enuns;
using static Emgu.CV.ML.KNearest;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
namespace AgroBase.Services
{
public class LoRaService
{
public static SerialPort PortaLoRa;
public static bool Iniciado
{
@ -131,6 +133,9 @@ namespace AgroBase.Services
public static List<LoRaProtocoloTransmissaoModel> LeituraDadosOperacao = new List<LoRaProtocoloTransmissaoModel>();
private static bool RotinaEnvioIniciada = false;
private static bool RotinaPingsIniciada = false;
public static async Task<bool> VerificaPortaLoRa(SerialPort porta)
{
@ -196,7 +201,14 @@ namespace AgroBase.Services
{
DefinirDispositivo();
LoopEnvioBuffer().ConfigureAwait(false);
if (!RotinaEnvioIniciada)
{
LoopEnvioBuffer().ConfigureAwait(false);
}
if (!RotinaPingsIniciada && !Variaveis.IsAgroMonitor)
{
EnviarPingComunicacao().ConfigureAwait(false);
}
}
}
@ -300,7 +312,7 @@ namespace AgroBase.Services
{
/*string leitura = PortaLoRa.ReadLine();
buffer = Encoding.UTF8.GetBytes(leitura);*/
buffer = SerialService.LerDadosDaPortaSerial(PortaLoRa, 100);
buffer = SerialService.LerDadosDaPortaSerial(PortaLoRa, 168);
}
// Cria um novo buffer com espaço para o caractere0 no início
@ -416,7 +428,8 @@ namespace AgroBase.Services
};
case LoRaTipoProtocolo.DadosOperacao:
{
byte[] bufferDados = new byte[resposta.Buffer.Length - 6];
byte[] bufferDados = new byte[resposta.Buffer.Length - 4];
Console.WriteLine("Recebendo log via LoRa... " + bufferDados.Length + " bytes");
Array.Copy(resposta.Buffer, 4, bufferDados, 0, bufferDados.Length);
LoRaProtocoloTransmissaoModel Dados = LoRaSerializer.DeserializeLoRaProtocoloTransmissaoModel(bufferDados);
LeituraDadosOperacao.Add(Dados);
@ -429,7 +442,7 @@ namespace AgroBase.Services
}
catch (Exception ex)
{
Console.WriteLine("Erro ao receber dados LoRa: " + ex.Message);
}
return null;
@ -601,6 +614,26 @@ namespace AgroBase.Services
Partes.Add(mensagem);
}
if (false)
{
string mensagemControle = " " + SerialService.EndLine + "\n";
byte[] beginLine = Encoding.UTF8.GetBytes(SerialService.BeginLine);
byte[] mensagemBytes = Encoding.UTF8.GetBytes(mensagemControle);
byte[] message = new byte[beginLine.Length + Cabecalho.Length + mensagemBytes.Length + 3];
message[0] = addressHigh;
message[1] = targetAddress;
message[2] = parametrosModel.channel;
Array.Copy(beginLine, 0, message, 3, beginLine.Length);
Array.Copy(Cabecalho, 0, message, 3 + beginLine.Length, Cabecalho.Length);
Array.Copy(mensagemBytes, 0, message, 3 + beginLine.Length + Cabecalho.Length, mensagemBytes.Length);
Partes.Add(message);
}
if (Enviar)
{
foreach (var parte in Partes)
@ -615,13 +648,14 @@ namespace AgroBase.Services
private static async Task LoopEnvioBuffer()
{
RotinaEnvioIniciada = true;
while (true)
{
var mensagens = bufferEnvio.ToList();
foreach (var buffer in mensagens)
{
EnviarComando(PortaLoRa, buffer);
await Task.Delay(800);
await Task.Delay(1500);
}
mensagens.ForEach(x => bufferEnvio.Remove(x));
@ -647,7 +681,7 @@ namespace AgroBase.Services
if (_Porta.IsOpen)
{
_Porta.Write(Comando, 0, Comando.Length);
Console.WriteLine($"Dados enviados: {Encoding.UTF8.GetString(Comando)}");
Console.WriteLine($"Dados enviados LoRa: {Comando.Length}");
}
}
}
@ -676,6 +710,70 @@ namespace AgroBase.Services
}
public static async Task EnviarPingComunicacao()
{
RotinaPingsIniciada = true;
while (true)
{
await Task.Delay(VariaveisEquipamento.TempoEntrePingsConexao);
if (!Variaveis.OperacaoEmAndamento.Iniciado)
{
Console.WriteLine("Enviando ping de comunicação para a base...");
EnviarDadosParaBase();
}
}
}
public static void EnviarDadosParaBase()
{
if (Iniciado && !Variaveis.IsAgroMonitor)
{
double velocidadeMax = MovimentacaoModel.CalculaVelocidadeRPM(Variaveis.OperacaoEmAndamento.Controle.RPM_Max);
double velocidadeMin = MovimentacaoModel.CalculaVelocidadeRPM(Variaveis.OperacaoEmAndamento.Controle.RPM_Min);
double TemperaturaCampo = WT901CService.Iniciado ? WT901CService.DadosLeitura.Temperatura : 0;
LoRaProtocoloTransmissaoModel dados = new LoRaProtocoloTransmissaoModel()
{
Momento = DateTime.Now,
EnderecoCarro = Variaveis.ConexaoLoRa.parametros.address,
Operacao = new LoRaProtocoloTransmissaoOperacaoModel()
{
idxRuaAtual = Variaveis.OperacaoEmAndamento.Sensoriamento.IdxRuaAtual,
statusOperacao = Variaveis.OperacaoEmAndamento.Sensoriamento.StatusOperacao,
statusCarro = Variaveis.OperacaoEmAndamento.Sensoriamento.StatusCarro,
TempoOperacao = Convert.ToInt32(Variaveis.OperacaoEmAndamento.Tempo.TotalSeconds),
PercentualRua = Variaveis.OperacaoEmAndamento.OpMapaGPS.Sensoriamento.ProgressoRua,
PercentualOperacao = Variaveis.OperacaoEmAndamento.OpMapaGPS.Sensoriamento.ProgressoTrajeto,
TempoEstimado = Variaveis.OperacaoEmAndamento.TempoEstimado(velocidadeMax, velocidadeMin),
},
Coordenadas = new LoRaProtocoloTransmissaoCoordenadasModel()
{
Latitude = GPSService.UltimaLeitura.Latitude,
Longitude = GPSService.UltimaLeitura.Longitude,
},
Sensores = new LoRaProtocoloTransmissaoSensoresModel()
{
DistanciaPercorrida = Math.Round(Variaveis.OperacaoEmAndamento.Sensoriamento.DistanciaPercorrida.Sum(), 2),
ErvasIdentificadas = Variaveis.OperacaoEmAndamento.OpMapaGPS.Sensoriamento.ErvasIdentificadas,
OrientacaoCaminho = Math.Round(Variaveis.OperacaoEmAndamento.Sensoriamento.AnguloRua, 2),
PercentualBateria = Math.Round(Variaveis.OperacaoEmAndamento.Sensoriamento.PorcentagemBateria, 2),
PercentualReservatorio = Math.Round(Variaveis.OperacaoEmAndamento.DispAtu.Dados.PercentualReservatorio, 2),
PressaoLinha = Math.Round(Variaveis.OperacaoEmAndamento.DispAtu.Dados.PressaoLinha, 2),
TemperaturaMotores = Math.Round(Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos.Average(x => x.MovMotor.Temperatura), 2),
TemperaturaCampo = Math.Round(TemperaturaCampo, 2),
Velocidade = Math.Round(Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos.Average(x => x.MovMotor.VelocidadeInstantanea), 2),
HerbicidaConsumido = Math.Round(Variaveis.OperacaoEmAndamento.Sensoriamento.HerbicidaConsumido, 2),
HerbicidaPorErva = Math.Round(Variaveis.OperacaoEmAndamento.Sensoriamento.HerbicidaPorErva, 2),
}
};
byte[] dadosEnvio = LoRaSerializer.SerializeLoRaProtocoloTransmissaoModel(dados);
MontarMensagemEnvio(dadosEnvio, Variaveis.OperacaoEmAndamento.DispSen.Dados.LoRaParametrosBase.address, LoRaTipoProtocolo.DadosOperacao, true);
}
}
}

View File

@ -7,6 +7,7 @@ using System.Drawing;
using System.IO.Ports;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
@ -111,11 +112,35 @@ namespace AgroBase.Services
Console.WriteLine("Procurando dispositivos conectados à porta " + PortaCom + "...");
SerialPort _Porta = new SerialPort() { PortName = PortaCom, BaudRate = 115200 };
if (Variaveis.IsAgroMonitor)
{
try
{
bool LoRa = await ProcuraDispositivoLoRa(_Porta);
if (!LoRa && !GPSService.Iniciado)
{
_Porta.Open();
await AguardaRespostaPorta(_Porta, 1100);
bool GPS = VerificaRespostaGPS(_Porta);
}
}
catch (Exception ex)
{
Console.WriteLine("Erro ao abrir a porta " + PortaCom + ": " + ex.Message);
}
finally
{
_Porta.Close();
}
continue;
}
bool PortaDispositivoProprio = false;
if (Variaveis.OperacaoEmAndamento.DispMvd == null)
{
//await TentarIdentificarDispositivo(_Porta);
continue;
}
@ -169,16 +194,18 @@ namespace AgroBase.Services
}
if (Variaveis.IsAgroMonitor)
{
return;
}
var DispositivosRemovidos = dispositivosMapeados.Where(x => !Portas.Contains(x.PortaCOM)).ToList();
foreach (var Dispositivo in DispositivosRemovidos)
{
DispositivosMapeados.Remove(Dispositivo);
}
if (!Variaveis.IsAgroMonitor)
{
AtualizarDispositivos();
}
AtualizarDispositivos();
// Se algum dispositivo no barramento RS485 para Modbus já foi identificado
if (ModbusService.Iniciado)
@ -223,9 +250,8 @@ namespace AgroBase.Services
if (Recebido.Length > 2)
{
if (Recebido.Contains("$GPTXT"))
if (VerificaRespostaGPS(Porta, Recebido))
{
GPSService.AtualizarPortaCOM(Porta);
return false;
}
@ -326,16 +352,12 @@ namespace AgroBase.Services
return true;
}
if (!LoRaService.Iniciado)
bool DispLoRa = await ProcuraDispositivoLoRa(porta);
if (DispLoRa)
{
bool Encontrado = await LoRaService.VerificaPortaLoRa(porta);
if (Encontrado)
{
return Encontrado;
}
return true;
}
if (TentativasPortas.TryGetValue(porta.PortName, out int tentativas))
{
@ -472,6 +494,37 @@ namespace AgroBase.Services
return MKS057DService.Iniciado;
}
private static async Task<bool> ProcuraDispositivoLoRa(SerialPort porta)
{
if (!LoRaService.Iniciado)
{
bool Encontrado = await LoRaService.VerificaPortaLoRa(porta);
return Encontrado;
}
else
{
return false;
}
}
private static bool VerificaRespostaGPS(SerialPort Porta, string Recebido = null)
{
if (string.IsNullOrEmpty(Recebido))
{
//Recebido = Porta.ReadLine();
byte[] buffer = LerDadosDaPortaSerial(Porta, 15);
Recebido = Encoding.ASCII.GetString(buffer);
}
if (Recebido.Contains("$GPTXT"))
{
GPSService.AtualizarPortaCOM(Porta);
return true;
}
return false;
}
public static byte[] VerificarRespostaPortasDesconhecidas(SerialPort Porta)
{
if (Porta != null && Porta.IsOpen)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,365 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script>
L_NO_TOUCH = false;
L_DISABLE_3D = false;
</script>
<style>html, body {width: 100%;height: 100%;margin: 0;padding: 0;}</style>
<style>#map {position:absolute;top:0;bottom:0;right:0;left:0;}</style>
<script src="folium/leaflet.js"></script>
<script src="folium/jquery-3.7.1.min.js"></script>
<script src="folium/bootstrap.bundle.min.js"></script>
<script src="folium/leaflet.awesome-markers.js"></script>
<link rel="stylesheet" href="folium/leaflet.css"/>
<link rel="stylesheet" href="folium/bootstrap.min.css"/>
<link rel="stylesheet" href="folium/bootstrap.min.css"/>
<link rel="stylesheet" href="folium/all.min.css"/>
<link rel="stylesheet" href="folium/leaflet.awesome-markers.css"/>
<link rel="stylesheet" href="folium/leaflet.awesome.rotate.min.css"/>
<meta name="viewport" content="width=device-width,
initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<style>
#map_9483db57aca52339fbb12d0797720dd8 {
position: relative;
width: 100.0%;
height: 100.0%;
left: 0.0%;
top: 0.0%;
}
.leaflet-container { font-size: 1rem; }
</style>
</head>
<body>
<div class="folium-map" id="map_9483db57aca52339fbb12d0797720dd8" ></div>
</body>
<script>
var map_9483db57aca52339fbb12d0797720dd8 = L.map(
"map_9483db57aca52339fbb12d0797720dd8",
{
center: [-22.07700866624257, -47.19598995141658],
crs: L.CRS.EPSG3857,
zoom: 12,
zoomControl: true,
preferCanvas: false,
}
);
var tile_layer_eaee1d1720b584ca7e1d5153ee999b8c = L.tileLayer(
"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}
);
tile_layer_eaee1d1720b584ca7e1d5153ee999b8c.addTo(map_9483db57aca52339fbb12d0797720dd8);
var trajetosSelecionados = {};
var RuasSelecionadas = [];
function enviarSelecaoParaServidor() {
client.publish("selecao_ruas_mapa", JSON.stringify(RuasSelecionadas), function (err) {
/*if (!err) {
console.log("Mensagem publicada com sucesso");
} else {
console.error("Falha ao publicar mensagem", err);
}*/
});
}
function geo_json_a4d4e644e3bfa4703ba740c32f8243fb_onEachFeature(feature, layer) {
layer.on({
click: function(e) {
// Verificar se o trajeto ja esta selecionado
if (trajetosSelecionados[feature.id]) {
// Se ja esta selecionado, reverta para a cor original e remova da selecao
e.target.setStyle({
color: '#3388ff' // Cor original
});
delete trajetosSelecionados[feature.id];
RuasSelecionadas.splice(RuasSelecionadas.indexOf(feature.id), 1);
} else {
// Se nao esta selecionado, mude a cor para indicar selecao e adicione ao objeto de selecao
e.target.setStyle({
color: 'blue' // Cor de selecao
});
trajetosSelecionados[feature.id] = true;
RuasSelecionadas.push(feature.id);
}
enviarSelecaoParaServidor();
}/*, mouseover: function(e) {
// Mostrar tooltip com o ID da geometria quando o mouse passar sobre a linha
var tooltip = L.tooltip({
direction: 'auto', // Leaflet determina a melhor posicao
sticky: true // Faz com que o tooltip siga o cursor do mouse
})
.setContent('Rua ' + feature.id); // Define o conteudo do tooltip
// Abre o tooltip na posicao atual do mouse
var latLng = e.latlng;
tooltip.setLatLng(latLng);
layer.bindTooltip(tooltip).openTooltip(latLng);
}*/
});
};
var geo_json_a4d4e644e3bfa4703ba740c32f8243fb = L.geoJson(null, {
onEachFeature: geo_json_a4d4e644e3bfa4703ba740c32f8243fb_onEachFeature,
});
function geo_json_a4d4e644e3bfa4703ba740c32f8243fb_add (data) {
geo_json_a4d4e644e3bfa4703ba740c32f8243fb
.addData(data);
}
geo_json_a4d4e644e3bfa4703ba740c32f8243fb_add({"features": [{"geometry": {"coordinates": [[-47.19774285726267, -22.07749281377239], [-47.19768293088881, -22.0774805271304], [-47.19759543090566, -22.077462587055873], [-47.197507930940425, -22.077444646932662], [-47.19742043099309, -22.0774267067607], [-47.19733293106367, -22.077408766540014], [-47.19724543115216, -22.0773908262706], [-47.19715793125859, -22.077372885952467], [-47.1970704313829, -22.077354945585615], [-47.19698293152512, -22.077337005170033], [-47.19689543168528, -22.07731906470573], [-47.19680793186334, -22.077301124192708], [-47.196720432059315, -22.077283183630975], [-47.196632932273204, -22.077265243020502], [-47.196545432505005, -22.07724730236131], [-47.19645793275472, -22.077229361653394], [-47.19637043302235, -22.077211420896752], [-47.19628293330789, -22.077193480091395], [-47.196195433611365, -22.077175539237324], [-47.19610793393272, -22.077157598334523], [-47.19602043427201, -22.077139657383004], [-47.19593293462923, -22.077121716382738], [-47.19584543500434, -22.077103775333782], [-47.19575793539737, -22.07708583423609], [-47.19567043580832, -22.077067893089676], [-47.19558293623719, -22.077049951894537], [-47.19549543668397, -22.077032010650683], [-47.19540793714869, -22.077014069358103], [-47.195320437631295, -22.07699612801682], [-47.195232938131824, -22.076978186626807], [-47.19514543865027, -22.07696024518807], [-47.19505793918664, -22.07694230370061], [-47.19497043974093, -22.076924362164426], [-47.19488294031313, -22.076906420579526], [-47.19479544090325, -22.076888478945907], [-47.19470794151129, -22.076870537263577], [-47.19462044213724, -22.076852595532525], [-47.19453294278113, -22.076834653752726], [-47.19444544344292, -22.076816711924245], [-47.19435794412263, -22.076798770047027], [-47.19429795311945, -22.076786468764478]], "id": "0", "type": "LineString"}, "id": 0, "properties": {"Dist1": 0.0, "Dist2": 0.0, "Id": "1517", "Length": 364.122430372, "Name": "Curvas"}, "type": "Feature"}, {"geometry": {"coordinates": [[-47.19554116539534, -22.078719292053304], [-47.19546767417662, -22.07870422337033], [-47.195442805154286, -22.078699124202906]], "id": "223", "type": "LineString"}, "id": 223, "properties": {"Dist1": 0.0, "Dist2": 0.0, "Id": "1517", "Length": 10.396452589, "Name": "Curvas"}, "type": "Feature"}, {"geometry": {"coordinates": [[-47.195512980813604, -22.07872738005577], [-47.19547733357063, -22.078720070922746]], "id": "224", "type": "LineString"}, "id": 224, "properties": {"Dist1": 0.0, "Dist2": 0.0, "Id": "1517", "Length": 3.767831676, "Name": "Curvas"}, "type": "Feature"}], "type": "FeatureCollection"});
geo_json_a4d4e644e3bfa4703ba740c32f8243fb.addTo(map_9483db57aca52339fbb12d0797720dd8);
</script>
<script>
function trajeto_json_onEachFeature(feature, layer) {
layer.on({
});
};
var trajeto_json = L.geoJson(null, {
onEachFeature: trajeto_json_onEachFeature,
style: function(feature) {
return {color: 'red'};
}
}
);
function trajeto_json_add (data) {
trajeto_json.addData(data);
}
trajeto_json_add({"features": []});
trajeto_json.addTo(map_9483db57aca52339fbb12d0797720dd8);
function adicionarGeometria(novaGeometria) {
trajeto_json.addData(novaGeometria);
}
function saoCoordenadasIguais(coord1, coord2, tolerancia) {
return Math.abs(coord1[0] - coord2[0]) < tolerancia && Math.abs(coord1[1] - coord2[1]) < tolerancia;
}
function adicionarCoordenada(idGeometria, novaCoordenada) {
var feature = trajeto_json.toGeoJSON().features.find(f => f.id === idGeometria);
if (feature) {
var ultima = [0.0,0.0];
if (feature.geometry.coordinates.length > 0) {
ultima = feature.geometry.coordinates[feature.geometry.coordinates.length - 1];
}
if (!saoCoordenadasIguais(ultima, novaCoordenada, 0.000001)) {
feature.geometry.coordinates.push(novaCoordenada);
var ft = feature;
trajeto_json.clearLayers();
trajeto_json.addData(ft);
}
} else {
console.log("Feature com ID " + idGeometria + " n<>o encontrada.");
}
}
adicionarGeometria({
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": []
},
"properties": {"Dist1": 0.0, "Dist2": 0.0, "Id": 1517, "Length": 21.724783283, "Name": "Projeto"},
"id": "Tj"
});
</script>
<script>
function trajeto_dinamico_json_onEachFeature(feature, layer) {
layer.on({
});
};
var trajeto_dinamico_json = L.geoJson(null, {
onEachFeature: trajeto_dinamico_json_onEachFeature,
style: function(feature) {
return {color: 'green'};
}
}
);
function trajeto_dinamico_json_add (data) {
trajeto_dinamico_json.addData(data);
}
trajeto_dinamico_json_add({"features": []});
trajeto_dinamico_json.addTo(map_9483db57aca52339fbb12d0797720dd8);
function adicionarGeometriaDinamica(novaGeometria) {
trajeto_dinamico_json.addData(novaGeometria);
}
function adicionarCoordenadaDinamica(idGeometria, coordenadas) {
var feature = trajeto_dinamico_json.toGeoJSON().features.find(f => f.id === idGeometria);
if (feature) {
feature.geometry.coordinates = [];
coordenadas.forEach(x => feature.geometry.coordinates.push([x.longitude, x.latitude]));
var ft = feature;
trajeto_dinamico_json.clearLayers();
trajeto_dinamico_json.addData(ft);
} else {
console.log("Feature com ID " + idGeometria + " nao encontrada.");
}
}
adicionarGeometriaDinamica({
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": []
},
"properties": {"Dist1": 0.0, "Dist2": 0.0, "Id": 1517, "Length": 21.724783283, "Name": "Projeto"},
"id": "TjD"
});
</script>
<script src="folium/mqtt.min.js"></script>
<script src="folium/leaflet.rotatedMarker.js"></script>
<script>
let posicaoAtual = {
lat: 0,
long: 0
};
var customIcon = L.icon({
iconUrl: 'folium/images/position_marker.png',
iconSize: [32, 32],
iconAnchor: [16, 16],
popupAnchor: [0, -16]
});
var marcadorDinamico = L.marker([0, 0], {
icon: customIcon
}).addTo(map_9483db57aca52339fbb12d0797720dd8);
// Conectar ao broker MQTT
const client = mqtt.connect('ws://localhost:9001'); // Use wss para conexao segura
// Quando conectado, inscreva-se no topico desejado
client.on('connect', function () {
console.log('Conectado ao broker MQTT');
// Inscrever-se no topico
client.subscribe('coordenadas_gps', function (err) {
if (!err) {
console.log("Inscricao bem-sucedida no topico");
} else {
console.error("Falha na inscricao do topico", err);
}
});
client.subscribe('trajetoria_dinamica', function (err) {
if (!err) {
console.log("Inscricao bem-sucedida no topico");
} else {
console.error("Falha na inscricao do topico", err);
}
});
client.subscribe('selecao_ruas_mapa', function (err) {
if (!err) {
console.log("Inscricao bem-sucedida no topico");
} else {
console.error("Falha na inscricao do topico", err);
}
});
});
// Lidar com mensagens recebidas para o topico inscrito
client.on('message', function (topic, message) {
var dados = JSON.parse(message);
if (topic === "trajetoria_dinamica") {
adicionarCoordenadaDinamica("TjD", dados); // "Tj" e o ID da feature no GeoJSON
}
else if (topic === "coordenadas_gps") {
// A mensagem e um Buffer, converta para string ou objeto conforme necessario
//console.log(`Mensagem recebida no topico '${topic}': ${message.toString()}`);
var novaLatitude = dados.latitude;
var novaLongitude = dados.longitude;
var novaPosicao = [novaLatitude, novaLongitude];
marcadorDinamico.setLatLng(novaPosicao);
// Calcular angulo de rotacao
var angulo = dados.orientacao;
posicaoAtual.lat = novaPosicao[0];
posicaoAtual.long = novaPosicao[1];
// Rotacionar o marcador para o angulo calculado
marcadorDinamico.setRotationAngle(angulo);
adicionarCoordenada("Tj", [novaLongitude, novaLatitude]);
map_9483db57aca52339fbb12d0797720dd8.setView(novaPosicao, map_9483db57aca52339fbb12d0797720dd8.getZoom());
}
else if (topic === 'selecao_ruas_mapa') {
var selecionadas = dados;
atualizarSelecaoRuas(selecionadas);
}
});
// Funcao para atualizar a selecao das ruas e mudar a cor no mapa
function atualizarSelecaoRuas(selecionadas) {
selecionadas = JSON.parse(selecionadas);
RuasSelecionadas = Array.isArray(selecionadas) ? [...selecionadas] : [];
geo_json_a4d4e644e3bfa4703ba740c32f8243fb.eachLayer(function (layer) {
if (RuasSelecionadas.includes(parseInt(layer.feature.id))) {
layer.setStyle({ color: 'blue' });
} else {
layer.setStyle({ color: '#3388ff' }); // Cor original
}
});
}
function calcularOrientacao(P1latitude, P1longitude, P2latitude, P2longitude) {
// Converter latitudes e longitudes de graus para radianos
const latA = P1latitude * (Math.PI / 180.0);
const lonA = P1longitude * (Math.PI / 180.0);
const latB = P2latitude * (Math.PI / 180.0);
const lonB = P2longitude * (Math.PI / 180.0);
// Calcular a diferenca de longitude
const deltaLon = lonB - lonA;
// Calcular a direcao
const y = Math.sin(deltaLon) * Math.cos(latB);
const x = Math.cos(latA) * Math.sin(latB) - Math.sin(latA) * Math.cos(latB) * Math.cos(deltaLon);
const direcaoRadianos = Math.atan2(y, x);
// Converter a direcao de radianos para graus
let direcaoGraus = direcaoRadianos * (180.0 / Math.PI);
// Normalizar a direcao para que esteja no intervalo de 0 a 360 graus
direcaoGraus = (direcaoGraus + 360) % 360;
return direcaoGraus;
}
</script>
</html>

View File

@ -56,6 +56,12 @@
<Compile Include="Forms\frmAjustesOperacao.Designer.cs">
<DependentUpon>frmAjustesOperacao.cs</DependentUpon>
</Compile>
<Compile Include="Forms\frmMonitoramento.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\frmMonitoramento.Designer.cs">
<DependentUpon>frmMonitoramento.cs</DependentUpon>
</Compile>
<Compile Include="frmInicial.cs">
<SubType>Form</SubType>
</Compile>
@ -68,6 +74,9 @@
<EmbeddedResource Include="Forms\frmAjustesOperacao.resx">
<DependentUpon>frmAjustesOperacao.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\frmMonitoramento.resx">
<DependentUpon>frmMonitoramento.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmInicial.resx">
<DependentUpon>frmInicial.cs</DependentUpon>
</EmbeddedResource>

View File

@ -60,18 +60,18 @@ namespace AgroMonitor.Forms
chb.Checked = Variaveis.OperacaoEmAndamento.ModulosMandatorios.Any(x => x.Dispositivo == Dispositivo);
}
double velocidadeMax = MovimentacaoModel.CalculaVelocidadeRPM(Variaveis.OperacaoEmAndamento.OpMapaGPS.Controle.RPM_Max);
double velocidadeMin = MovimentacaoModel.CalculaVelocidadeRPM(Variaveis.OperacaoEmAndamento.OpMapaGPS.Controle.RPM_Min);
double velocidadeMax = MovimentacaoModel.CalculaVelocidadeRPM(Variaveis.OperacaoEmAndamento.Controle.RPM_Max);
double velocidadeMin = MovimentacaoModel.CalculaVelocidadeRPM(Variaveis.OperacaoEmAndamento.Controle.RPM_Min);
txtDescricao.Text = Variaveis.OperacaoEmAndamento.Descricao;
txtVelocidadeSemErvas.Text = velocidadeMax.ToString("0.00");
txtVelocidadeComErvas.Text = velocidadeMin.ToString("0.00");
txtAnguloMaximo.Text = Variaveis.OperacaoEmAndamento.OpMapaGPS.Controle.Angulo_Max.ToString("0");
txtVelocidadeDirecional.Text = Variaveis.OperacaoEmAndamento.OpMapaGPS.Controle.VelocidadeMP.ToString("0");
txtPercentualAtuacao.Text = (Variaveis.OperacaoEmAndamento.OpMapaGPS.Controle.PercentualInicioPulverizacao * 100).ToString("0");
txtAnguloMaximo.Text = Variaveis.OperacaoEmAndamento.Controle.Angulo_Max.ToString("0");
txtVelocidadeDirecional.Text = Variaveis.OperacaoEmAndamento.Controle.VelocidadeMP.ToString("0");
txtPercentualAtuacao.Text = (Variaveis.OperacaoEmAndamento.Controle.PercentualInicioPulverizacao * 100).ToString("0");
txtCapacidadeReservatorio.Text = Variaveis.OperacaoEmAndamento.CapacidadeReservatorio.ToString("0");
txtPressaoLinha.Text = Variaveis.OperacaoEmAndamento.OpMapaGPS.Controle.PressaoLinha.ToString("0");
txtDuracaoAtuacao.Text = Variaveis.OperacaoEmAndamento.OpMapaGPS.Controle.TempoAtuacao.ToString("0");
txtPressaoLinha.Text = Variaveis.OperacaoEmAndamento.Controle.PressaoLinha.ToString("0");
txtDuracaoAtuacao.Text = Variaveis.OperacaoEmAndamento.Controle.TempoAtuacao.ToString("0");
}
private void btnProximo_Click(object sender, EventArgs e)
@ -116,7 +116,7 @@ namespace AgroMonitor.Forms
double.TryParse(txtVelocidadeSemErvas.Text, out double velocidadeSemErvas);
double.TryParse(txtVelocidadeComErvas.Text, out double velocidadeComErvas);
string tempo = OperacaoModel.TempoEstimado(velocidadeSemErvas, velocidadeComErvas);
string tempo = Variaveis.OperacaoEmAndamento.TempoEstimado(velocidadeSemErvas, velocidadeComErvas);
lblTempoEstimado.Text = $"Tempo estimado: {tempo}";
}

View File

@ -0,0 +1,606 @@
namespace AgroMonitor.Forms
{
partial class frmMonitoramento
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lblEquipamento = new System.Windows.Forms.Label();
this.cmbEquipamento = new System.Windows.Forms.ComboBox();
this.lblLatitude = new System.Windows.Forms.Label();
this.lblLongitude = new System.Windows.Forms.Label();
this.txtLatitude = new System.Windows.Forms.TextBox();
this.txtLongitude = new System.Windows.Forms.TextBox();
this.panel1 = new System.Windows.Forms.Panel();
this.txtLeitura = new System.Windows.Forms.TextBox();
this.lblLeitura = new System.Windows.Forms.Label();
this.txtOrientacao = new System.Windows.Forms.TextBox();
this.lblOrientacao = new System.Windows.Forms.Label();
this.pgbBateria = new System.Windows.Forms.ProgressBar();
this.lblBateria = new System.Windows.Forms.Label();
this.lblReservatorio = new System.Windows.Forms.Label();
this.pgbReservatorio = new System.Windows.Forms.ProgressBar();
this.lblBateriaDados = new System.Windows.Forms.Label();
this.lblReservatorioDados = new System.Windows.Forms.Label();
this.lblTemperaturaMotoresDados = new System.Windows.Forms.Label();
this.lblTemperaturaMotores = new System.Windows.Forms.Label();
this.pgbTemperaturaMotores = new System.Windows.Forms.ProgressBar();
this.lblTemperaturaCampoDados = new System.Windows.Forms.Label();
this.lblTemperaturaCampo = new System.Windows.Forms.Label();
this.pgbTemperaturaCampo = new System.Windows.Forms.ProgressBar();
this.lblPressaoDados = new System.Windows.Forms.Label();
this.lblPressao = new System.Windows.Forms.Label();
this.pgbPressao = new System.Windows.Forms.ProgressBar();
this.lblHerbicidaDados = new System.Windows.Forms.Label();
this.lblHerbicida = new System.Windows.Forms.Label();
this.pgbHerbicidaAplicado = new System.Windows.Forms.ProgressBar();
this.lblVelocidadeDados = new System.Windows.Forms.Label();
this.lblVelocidade = new System.Windows.Forms.Label();
this.pgbVelocidade = new System.Windows.Forms.ProgressBar();
this.lblErvasIdentificadas = new System.Windows.Forms.Label();
this.txtStatusCarro = new System.Windows.Forms.TextBox();
this.lblStatusCarro = new System.Windows.Forms.Label();
this.lblStatusOperacao = new System.Windows.Forms.Label();
this.txtStatusOperacao = new System.Windows.Forms.TextBox();
this.lblProgressoOperacao = new System.Windows.Forms.Label();
this.pgbProgressoOperacao = new System.Windows.Forms.ProgressBar();
this.lblProgressoRua = new System.Windows.Forms.Label();
this.pgbProgressoRua = new System.Windows.Forms.ProgressBar();
this.txtTempoEstimado = new System.Windows.Forms.TextBox();
this.lblTempoEstimado = new System.Windows.Forms.Label();
this.lblTempoDecorrido = new System.Windows.Forms.Label();
this.txtTempoDecorrido = new System.Windows.Forms.TextBox();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// lblEquipamento
//
this.lblEquipamento.AutoSize = true;
this.lblEquipamento.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.25F);
this.lblEquipamento.Location = new System.Drawing.Point(6, 11);
this.lblEquipamento.Name = "lblEquipamento";
this.lblEquipamento.Size = new System.Drawing.Size(91, 17);
this.lblEquipamento.TabIndex = 0;
this.lblEquipamento.Text = "Equipamento";
//
// cmbEquipamento
//
this.cmbEquipamento.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbEquipamento.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.25F);
this.cmbEquipamento.FormattingEnabled = true;
this.cmbEquipamento.Location = new System.Drawing.Point(113, 8);
this.cmbEquipamento.Name = "cmbEquipamento";
this.cmbEquipamento.Size = new System.Drawing.Size(100, 25);
this.cmbEquipamento.TabIndex = 1;
this.cmbEquipamento.SelectedIndexChanged += new System.EventHandler(this.cmbEquipamento_SelectedIndexChanged);
//
// lblLatitude
//
this.lblLatitude.AutoSize = true;
this.lblLatitude.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.25F);
this.lblLatitude.Location = new System.Drawing.Point(6, 88);
this.lblLatitude.Name = "lblLatitude";
this.lblLatitude.Size = new System.Drawing.Size(59, 17);
this.lblLatitude.TabIndex = 2;
this.lblLatitude.Text = "Latitude";
//
// lblLongitude
//
this.lblLongitude.AutoSize = true;
this.lblLongitude.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.25F);
this.lblLongitude.Location = new System.Drawing.Point(111, 88);
this.lblLongitude.Name = "lblLongitude";
this.lblLongitude.Size = new System.Drawing.Size(71, 17);
this.lblLongitude.TabIndex = 3;
this.lblLongitude.Text = "Longitude";
//
// txtLatitude
//
this.txtLatitude.Location = new System.Drawing.Point(5, 108);
this.txtLatitude.Name = "txtLatitude";
this.txtLatitude.ReadOnly = true;
this.txtLatitude.Size = new System.Drawing.Size(100, 20);
this.txtLatitude.TabIndex = 4;
this.txtLatitude.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// txtLongitude
//
this.txtLongitude.Location = new System.Drawing.Point(113, 108);
this.txtLongitude.Name = "txtLongitude";
this.txtLongitude.ReadOnly = true;
this.txtLongitude.Size = new System.Drawing.Size(100, 20);
this.txtLongitude.TabIndex = 5;
this.txtLongitude.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// panel1
//
this.panel1.AutoScroll = true;
this.panel1.Controls.Add(this.txtTempoEstimado);
this.panel1.Controls.Add(this.lblTempoEstimado);
this.panel1.Controls.Add(this.lblTempoDecorrido);
this.panel1.Controls.Add(this.txtTempoDecorrido);
this.panel1.Controls.Add(this.lblProgressoRua);
this.panel1.Controls.Add(this.pgbProgressoRua);
this.panel1.Controls.Add(this.lblProgressoOperacao);
this.panel1.Controls.Add(this.pgbProgressoOperacao);
this.panel1.Controls.Add(this.txtStatusCarro);
this.panel1.Controls.Add(this.lblStatusCarro);
this.panel1.Controls.Add(this.lblStatusOperacao);
this.panel1.Controls.Add(this.txtStatusOperacao);
this.panel1.Controls.Add(this.lblErvasIdentificadas);
this.panel1.Controls.Add(this.lblVelocidadeDados);
this.panel1.Controls.Add(this.lblVelocidade);
this.panel1.Controls.Add(this.pgbVelocidade);
this.panel1.Controls.Add(this.lblHerbicidaDados);
this.panel1.Controls.Add(this.lblHerbicida);
this.panel1.Controls.Add(this.pgbHerbicidaAplicado);
this.panel1.Controls.Add(this.lblPressaoDados);
this.panel1.Controls.Add(this.lblPressao);
this.panel1.Controls.Add(this.pgbPressao);
this.panel1.Controls.Add(this.lblTemperaturaCampoDados);
this.panel1.Controls.Add(this.lblTemperaturaCampo);
this.panel1.Controls.Add(this.pgbTemperaturaCampo);
this.panel1.Controls.Add(this.lblTemperaturaMotoresDados);
this.panel1.Controls.Add(this.lblTemperaturaMotores);
this.panel1.Controls.Add(this.pgbTemperaturaMotores);
this.panel1.Controls.Add(this.lblReservatorioDados);
this.panel1.Controls.Add(this.lblBateriaDados);
this.panel1.Controls.Add(this.lblReservatorio);
this.panel1.Controls.Add(this.pgbReservatorio);
this.panel1.Controls.Add(this.lblBateria);
this.panel1.Controls.Add(this.pgbBateria);
this.panel1.Controls.Add(this.txtOrientacao);
this.panel1.Controls.Add(this.lblOrientacao);
this.panel1.Controls.Add(this.lblLeitura);
this.panel1.Controls.Add(this.txtLeitura);
this.panel1.Controls.Add(this.cmbEquipamento);
this.panel1.Controls.Add(this.lblEquipamento);
this.panel1.Controls.Add(this.txtLatitude);
this.panel1.Controls.Add(this.lblLongitude);
this.panel1.Controls.Add(this.lblLatitude);
this.panel1.Controls.Add(this.txtLongitude);
this.panel1.Dock = System.Windows.Forms.DockStyle.Right;
this.panel1.Location = new System.Drawing.Point(787, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(239, 566);
this.panel1.TabIndex = 6;
//
// txtLeitura
//
this.txtLeitura.Location = new System.Drawing.Point(5, 65);
this.txtLeitura.Name = "txtLeitura";
this.txtLeitura.ReadOnly = true;
this.txtLeitura.Size = new System.Drawing.Size(100, 20);
this.txtLeitura.TabIndex = 6;
this.txtLeitura.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// lblLeitura
//
this.lblLeitura.AutoSize = true;
this.lblLeitura.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.25F);
this.lblLeitura.Location = new System.Drawing.Point(6, 45);
this.lblLeitura.Name = "lblLeitura";
this.lblLeitura.Size = new System.Drawing.Size(52, 17);
this.lblLeitura.TabIndex = 7;
this.lblLeitura.Text = "Leitura";
//
// txtOrientacao
//
this.txtOrientacao.Location = new System.Drawing.Point(113, 65);
this.txtOrientacao.Name = "txtOrientacao";
this.txtOrientacao.ReadOnly = true;
this.txtOrientacao.Size = new System.Drawing.Size(100, 20);
this.txtOrientacao.TabIndex = 9;
this.txtOrientacao.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// lblOrientacao
//
this.lblOrientacao.AutoSize = true;
this.lblOrientacao.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.25F);
this.lblOrientacao.Location = new System.Drawing.Point(111, 45);
this.lblOrientacao.Name = "lblOrientacao";
this.lblOrientacao.Size = new System.Drawing.Size(78, 17);
this.lblOrientacao.TabIndex = 8;
this.lblOrientacao.Text = "Orientação";
//
// pgbBateria
//
this.pgbBateria.Location = new System.Drawing.Point(5, 280);
this.pgbBateria.Name = "pgbBateria";
this.pgbBateria.Size = new System.Drawing.Size(100, 20);
this.pgbBateria.TabIndex = 10;
//
// lblBateria
//
this.lblBateria.AutoSize = true;
this.lblBateria.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.25F);
this.lblBateria.Location = new System.Drawing.Point(6, 260);
this.lblBateria.Name = "lblBateria";
this.lblBateria.Size = new System.Drawing.Size(53, 17);
this.lblBateria.TabIndex = 11;
this.lblBateria.Text = "Bateria";
//
// lblReservatorio
//
this.lblReservatorio.AutoSize = true;
this.lblReservatorio.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.25F);
this.lblReservatorio.Location = new System.Drawing.Point(6, 303);
this.lblReservatorio.Name = "lblReservatorio";
this.lblReservatorio.Size = new System.Drawing.Size(153, 17);
this.lblReservatorio.TabIndex = 13;
this.lblReservatorio.Text = "Reservatório Herbicida";
//
// pgbReservatorio
//
this.pgbReservatorio.Location = new System.Drawing.Point(5, 323);
this.pgbReservatorio.Maximum = 35;
this.pgbReservatorio.Name = "pgbReservatorio";
this.pgbReservatorio.Size = new System.Drawing.Size(100, 20);
this.pgbReservatorio.TabIndex = 12;
//
// lblBateriaDados
//
this.lblBateriaDados.AutoSize = true;
this.lblBateriaDados.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
this.lblBateriaDados.Location = new System.Drawing.Point(111, 283);
this.lblBateriaDados.Name = "lblBateriaDados";
this.lblBateriaDados.Size = new System.Drawing.Size(98, 13);
this.lblBateriaDados.TabIndex = 14;
this.lblBateriaDados.Text = "42,3V 5,2A 100,0%";
//
// lblReservatorioDados
//
this.lblReservatorioDados.AutoSize = true;
this.lblReservatorioDados.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
this.lblReservatorioDados.Location = new System.Drawing.Point(111, 326);
this.lblReservatorioDados.Name = "lblReservatorioDados";
this.lblReservatorioDados.Size = new System.Drawing.Size(75, 13);
this.lblReservatorioDados.TabIndex = 15;
this.lblReservatorioDados.Text = "28,5 L 100,0%";
//
// lblTemperaturaMotoresDados
//
this.lblTemperaturaMotoresDados.AutoSize = true;
this.lblTemperaturaMotoresDados.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
this.lblTemperaturaMotoresDados.Location = new System.Drawing.Point(111, 455);
this.lblTemperaturaMotoresDados.Name = "lblTemperaturaMotoresDados";
this.lblTemperaturaMotoresDados.Size = new System.Drawing.Size(42, 13);
this.lblTemperaturaMotoresDados.TabIndex = 21;
this.lblTemperaturaMotoresDados.Text = "57,5 ºC";
//
// lblTemperaturaMotores
//
this.lblTemperaturaMotores.AutoSize = true;
this.lblTemperaturaMotores.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.25F);
this.lblTemperaturaMotores.Location = new System.Drawing.Point(6, 432);
this.lblTemperaturaMotores.Name = "lblTemperaturaMotores";
this.lblTemperaturaMotores.Size = new System.Drawing.Size(145, 17);
this.lblTemperaturaMotores.TabIndex = 20;
this.lblTemperaturaMotores.Text = "Temperatura Motores";
//
// pgbTemperaturaMotores
//
this.pgbTemperaturaMotores.Location = new System.Drawing.Point(5, 452);
this.pgbTemperaturaMotores.Maximum = 200;
this.pgbTemperaturaMotores.Name = "pgbTemperaturaMotores";
this.pgbTemperaturaMotores.Size = new System.Drawing.Size(100, 20);
this.pgbTemperaturaMotores.TabIndex = 19;
//
// lblTemperaturaCampoDados
//
this.lblTemperaturaCampoDados.AutoSize = true;
this.lblTemperaturaCampoDados.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
this.lblTemperaturaCampoDados.Location = new System.Drawing.Point(111, 498);
this.lblTemperaturaCampoDados.Name = "lblTemperaturaCampoDados";
this.lblTemperaturaCampoDados.Size = new System.Drawing.Size(42, 13);
this.lblTemperaturaCampoDados.TabIndex = 24;
this.lblTemperaturaCampoDados.Text = "38,7 ºC";
//
// lblTemperaturaCampo
//
this.lblTemperaturaCampo.AutoSize = true;
this.lblTemperaturaCampo.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.25F);
this.lblTemperaturaCampo.Location = new System.Drawing.Point(6, 475);
this.lblTemperaturaCampo.Name = "lblTemperaturaCampo";
this.lblTemperaturaCampo.Size = new System.Drawing.Size(138, 17);
this.lblTemperaturaCampo.TabIndex = 23;
this.lblTemperaturaCampo.Text = "Temperatura Campo";
//
// pgbTemperaturaCampo
//
this.pgbTemperaturaCampo.Location = new System.Drawing.Point(5, 495);
this.pgbTemperaturaCampo.Name = "pgbTemperaturaCampo";
this.pgbTemperaturaCampo.Size = new System.Drawing.Size(100, 20);
this.pgbTemperaturaCampo.TabIndex = 22;
//
// lblPressaoDados
//
this.lblPressaoDados.AutoSize = true;
this.lblPressaoDados.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
this.lblPressaoDados.Location = new System.Drawing.Point(111, 412);
this.lblPressaoDados.Name = "lblPressaoDados";
this.lblPressaoDados.Size = new System.Drawing.Size(44, 13);
this.lblPressaoDados.TabIndex = 27;
this.lblPressaoDados.Text = "86,3 psi";
//
// lblPressao
//
this.lblPressao.AutoSize = true;
this.lblPressao.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.25F);
this.lblPressao.Location = new System.Drawing.Point(6, 389);
this.lblPressao.Name = "lblPressao";
this.lblPressao.Size = new System.Drawing.Size(119, 17);
this.lblPressao.TabIndex = 26;
this.lblPressao.Text = "Pressão da Linha";
//
// pgbPressao
//
this.pgbPressao.Location = new System.Drawing.Point(5, 409);
this.pgbPressao.Maximum = 150;
this.pgbPressao.Name = "pgbPressao";
this.pgbPressao.Size = new System.Drawing.Size(100, 20);
this.pgbPressao.TabIndex = 25;
//
// lblHerbicidaDados
//
this.lblHerbicidaDados.AutoSize = true;
this.lblHerbicidaDados.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
this.lblHerbicidaDados.Location = new System.Drawing.Point(111, 369);
this.lblHerbicidaDados.Name = "lblHerbicidaDados";
this.lblHerbicidaDados.Size = new System.Drawing.Size(100, 13);
this.lblHerbicidaDados.TabIndex = 30;
this.lblHerbicidaDados.Text = "2,3 L (35,9 ml/erva)";
//
// lblHerbicida
//
this.lblHerbicida.AutoSize = true;
this.lblHerbicida.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.25F);
this.lblHerbicida.Location = new System.Drawing.Point(6, 346);
this.lblHerbicida.Name = "lblHerbicida";
this.lblHerbicida.Size = new System.Drawing.Size(126, 17);
this.lblHerbicida.TabIndex = 29;
this.lblHerbicida.Text = "Herbicida Aplicado";
//
// pgbHerbicidaAplicado
//
this.pgbHerbicidaAplicado.Location = new System.Drawing.Point(5, 366);
this.pgbHerbicidaAplicado.Maximum = 35;
this.pgbHerbicidaAplicado.Name = "pgbHerbicidaAplicado";
this.pgbHerbicidaAplicado.Size = new System.Drawing.Size(100, 20);
this.pgbHerbicidaAplicado.TabIndex = 28;
//
// lblVelocidadeDados
//
this.lblVelocidadeDados.AutoSize = true;
this.lblVelocidadeDados.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
this.lblVelocidadeDados.Location = new System.Drawing.Point(111, 541);
this.lblVelocidadeDados.Name = "lblVelocidadeDados";
this.lblVelocidadeDados.Size = new System.Drawing.Size(82, 13);
this.lblVelocidadeDados.TabIndex = 33;
this.lblVelocidadeDados.Text = "5,3 km/h 85,3%";
//
// lblVelocidade
//
this.lblVelocidade.AutoSize = true;
this.lblVelocidade.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.25F);
this.lblVelocidade.Location = new System.Drawing.Point(6, 518);
this.lblVelocidade.Name = "lblVelocidade";
this.lblVelocidade.Size = new System.Drawing.Size(78, 17);
this.lblVelocidade.TabIndex = 32;
this.lblVelocidade.Text = "Velocidade";
//
// pgbVelocidade
//
this.pgbVelocidade.Location = new System.Drawing.Point(5, 538);
this.pgbVelocidade.Maximum = 20;
this.pgbVelocidade.Name = "pgbVelocidade";
this.pgbVelocidade.Size = new System.Drawing.Size(100, 20);
this.pgbVelocidade.TabIndex = 31;
//
// lblErvasIdentificadas
//
this.lblErvasIdentificadas.AutoSize = true;
this.lblErvasIdentificadas.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
this.lblErvasIdentificadas.Location = new System.Drawing.Point(152, 356);
this.lblErvasIdentificadas.Name = "lblErvasIdentificadas";
this.lblErvasIdentificadas.Size = new System.Drawing.Size(54, 13);
this.lblErvasIdentificadas.TabIndex = 34;
this.lblErvasIdentificadas.Text = "154 ervas";
//
// txtStatusCarro
//
this.txtStatusCarro.Location = new System.Drawing.Point(113, 151);
this.txtStatusCarro.Name = "txtStatusCarro";
this.txtStatusCarro.ReadOnly = true;
this.txtStatusCarro.Size = new System.Drawing.Size(100, 20);
this.txtStatusCarro.TabIndex = 38;
this.txtStatusCarro.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// lblStatusCarro
//
this.lblStatusCarro.AutoSize = true;
this.lblStatusCarro.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.25F);
this.lblStatusCarro.Location = new System.Drawing.Point(111, 131);
this.lblStatusCarro.Name = "lblStatusCarro";
this.lblStatusCarro.Size = new System.Drawing.Size(43, 17);
this.lblStatusCarro.TabIndex = 37;
this.lblStatusCarro.Text = "Carro";
//
// lblStatusOperacao
//
this.lblStatusOperacao.AutoSize = true;
this.lblStatusOperacao.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.25F);
this.lblStatusOperacao.Location = new System.Drawing.Point(6, 131);
this.lblStatusOperacao.Name = "lblStatusOperacao";
this.lblStatusOperacao.Size = new System.Drawing.Size(71, 17);
this.lblStatusOperacao.TabIndex = 36;
this.lblStatusOperacao.Text = "Operação";
//
// txtStatusOperacao
//
this.txtStatusOperacao.Location = new System.Drawing.Point(5, 151);
this.txtStatusOperacao.Name = "txtStatusOperacao";
this.txtStatusOperacao.ReadOnly = true;
this.txtStatusOperacao.Size = new System.Drawing.Size(100, 20);
this.txtStatusOperacao.TabIndex = 35;
this.txtStatusOperacao.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// lblProgressoOperacao
//
this.lblProgressoOperacao.AutoSize = true;
this.lblProgressoOperacao.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.25F);
this.lblProgressoOperacao.Location = new System.Drawing.Point(6, 217);
this.lblProgressoOperacao.Name = "lblProgressoOperacao";
this.lblProgressoOperacao.Size = new System.Drawing.Size(87, 17);
this.lblProgressoOperacao.TabIndex = 40;
this.lblProgressoOperacao.Text = "% Operação";
//
// pgbProgressoOperacao
//
this.pgbProgressoOperacao.Location = new System.Drawing.Point(5, 237);
this.pgbProgressoOperacao.Name = "pgbProgressoOperacao";
this.pgbProgressoOperacao.Size = new System.Drawing.Size(100, 20);
this.pgbProgressoOperacao.TabIndex = 39;
//
// lblProgressoRua
//
this.lblProgressoRua.AutoSize = true;
this.lblProgressoRua.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.25F);
this.lblProgressoRua.Location = new System.Drawing.Point(112, 217);
this.lblProgressoRua.Name = "lblProgressoRua";
this.lblProgressoRua.Size = new System.Drawing.Size(50, 17);
this.lblProgressoRua.TabIndex = 42;
this.lblProgressoRua.Text = "% Rua";
//
// pgbProgressoRua
//
this.pgbProgressoRua.Location = new System.Drawing.Point(111, 237);
this.pgbProgressoRua.Name = "pgbProgressoRua";
this.pgbProgressoRua.Size = new System.Drawing.Size(100, 20);
this.pgbProgressoRua.TabIndex = 41;
//
// txtTempoEstimado
//
this.txtTempoEstimado.Location = new System.Drawing.Point(113, 194);
this.txtTempoEstimado.Name = "txtTempoEstimado";
this.txtTempoEstimado.ReadOnly = true;
this.txtTempoEstimado.Size = new System.Drawing.Size(100, 20);
this.txtTempoEstimado.TabIndex = 46;
this.txtTempoEstimado.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// lblTempoEstimado
//
this.lblTempoEstimado.AutoSize = true;
this.lblTempoEstimado.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.25F);
this.lblTempoEstimado.Location = new System.Drawing.Point(111, 174);
this.lblTempoEstimado.Name = "lblTempoEstimado";
this.lblTempoEstimado.Size = new System.Drawing.Size(66, 17);
this.lblTempoEstimado.TabIndex = 45;
this.lblTempoEstimado.Text = "Estimado";
//
// lblTempoDecorrido
//
this.lblTempoDecorrido.AutoSize = true;
this.lblTempoDecorrido.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.25F);
this.lblTempoDecorrido.Location = new System.Drawing.Point(6, 174);
this.lblTempoDecorrido.Name = "lblTempoDecorrido";
this.lblTempoDecorrido.Size = new System.Drawing.Size(70, 17);
this.lblTempoDecorrido.TabIndex = 44;
this.lblTempoDecorrido.Text = "Decorrido";
//
// txtTempoDecorrido
//
this.txtTempoDecorrido.Location = new System.Drawing.Point(5, 194);
this.txtTempoDecorrido.Name = "txtTempoDecorrido";
this.txtTempoDecorrido.ReadOnly = true;
this.txtTempoDecorrido.Size = new System.Drawing.Size(100, 20);
this.txtTempoDecorrido.TabIndex = 43;
this.txtTempoDecorrido.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// frmMonitoramento
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1026, 566);
this.Controls.Add(this.panel1);
this.Name = "frmMonitoramento";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Monitoramento";
this.Load += new System.EventHandler(this.frmMonitoramento_Load);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Label lblEquipamento;
private System.Windows.Forms.ComboBox cmbEquipamento;
private System.Windows.Forms.Label lblLatitude;
private System.Windows.Forms.Label lblLongitude;
private System.Windows.Forms.TextBox txtLatitude;
private System.Windows.Forms.TextBox txtLongitude;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label lblLeitura;
private System.Windows.Forms.TextBox txtLeitura;
private System.Windows.Forms.TextBox txtOrientacao;
private System.Windows.Forms.Label lblOrientacao;
private System.Windows.Forms.Label lblReservatorio;
private System.Windows.Forms.ProgressBar pgbReservatorio;
private System.Windows.Forms.Label lblBateria;
private System.Windows.Forms.ProgressBar pgbBateria;
private System.Windows.Forms.Label lblBateriaDados;
private System.Windows.Forms.Label lblReservatorioDados;
private System.Windows.Forms.Label lblTemperaturaCampoDados;
private System.Windows.Forms.Label lblTemperaturaCampo;
private System.Windows.Forms.ProgressBar pgbTemperaturaCampo;
private System.Windows.Forms.Label lblTemperaturaMotoresDados;
private System.Windows.Forms.Label lblTemperaturaMotores;
private System.Windows.Forms.ProgressBar pgbTemperaturaMotores;
private System.Windows.Forms.Label lblPressaoDados;
private System.Windows.Forms.Label lblPressao;
private System.Windows.Forms.ProgressBar pgbPressao;
private System.Windows.Forms.Label lblHerbicidaDados;
private System.Windows.Forms.Label lblHerbicida;
private System.Windows.Forms.ProgressBar pgbHerbicidaAplicado;
private System.Windows.Forms.Label lblVelocidadeDados;
private System.Windows.Forms.Label lblVelocidade;
private System.Windows.Forms.ProgressBar pgbVelocidade;
private System.Windows.Forms.Label lblErvasIdentificadas;
private System.Windows.Forms.Label lblProgressoOperacao;
private System.Windows.Forms.ProgressBar pgbProgressoOperacao;
private System.Windows.Forms.TextBox txtStatusCarro;
private System.Windows.Forms.Label lblStatusCarro;
private System.Windows.Forms.Label lblStatusOperacao;
private System.Windows.Forms.TextBox txtStatusOperacao;
private System.Windows.Forms.Label lblProgressoRua;
private System.Windows.Forms.ProgressBar pgbProgressoRua;
private System.Windows.Forms.TextBox txtTempoEstimado;
private System.Windows.Forms.Label lblTempoEstimado;
private System.Windows.Forms.Label lblTempoDecorrido;
private System.Windows.Forms.TextBox txtTempoDecorrido;
}
}

View File

@ -0,0 +1,131 @@
using AgroBase.Models;
using AgroBase.Services;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AgroMonitor.Forms
{
public partial class frmMonitoramento : Form
{
Timer tmrLeituras = new Timer();
DateTime MomentoLog = DateTime.Now;
public frmMonitoramento()
{
InitializeComponent();
}
private void frmMonitoramento_Load(object sender, EventArgs e)
{
tmrLeituras.Interval = 1000;
tmrLeituras.Tick += tmrLeituras_Tick;
tmrLeituras.Start();
}
private void tmrLeituras_Tick(object sender, EventArgs e)
{
string EquipamentoSelecionado = cmbEquipamento.Text;
if (cmbEquipamento.Items.Count != VariaveisMonitoramento.EquipamentosConectados.Count())
{
cmbEquipamento.Items.Clear();
cmbEquipamento.Items.AddRange(VariaveisMonitoramento.EquipamentosConectados.Keys.Select(x => x.ToString()).ToArray());
if (cmbEquipamento.Items.Contains(EquipamentoSelecionado))
{
cmbEquipamento.SelectedIndex = cmbEquipamento.Items.IndexOf(EquipamentoSelecionado);
}
}
if (cmbEquipamento.SelectedIndex > -1)
{
AtualizarDadosTela();
}
}
private void cmbEquipamento_SelectedIndexChanged(object sender, EventArgs e)
{
MomentoLog = MomentoLog.AddSeconds(-15);
AtualizarDadosTela();
}
private void AtualizarDadosTela()
{
byte Endereco = Convert.ToByte(cmbEquipamento.Text);
if (Endereco == VariaveisMonitoramento.ComunicacaoLoRa.parametros.address)
{
MomentoLog = DateTime.Now;
txtLeitura.Text = MomentoLog.ToString("ddd HH:mm:ss");
txtOrientacao.Text = GPSService.UltimaLeitura.Orientacao.ToString("0.00");
txtLatitude.Text = GPSService.UltimaLeitura.Latitude.ToString();
txtLongitude.Text = GPSService.UltimaLeitura.Longitude.ToString();
txtStatusOperacao.Text = "";
txtStatusCarro.Text = "";
txtTempoDecorrido.Text = "";
txtTempoEstimado.Text = "";
FuncoesGlobais.PreencheValorProgressBar(pgbProgressoOperacao, 0);
FuncoesGlobais.PreencheValorProgressBar(pgbProgressoRua, 0);
FuncoesGlobais.PreencheValorProgressBar(pgbBateria, 0);
lblBateriaDados.Text = "0,00%";
FuncoesGlobais.PreencheValorProgressBar(pgbReservatorio, 0);
lblReservatorioDados.Text = "0,00%";
FuncoesGlobais.PreencheValorProgressBar(pgbHerbicidaAplicado, 0);
lblHerbicidaDados.Text = "0,00 L (0,00 ml/erva)";
lblErvasIdentificadas.Text = "0 ervas";
FuncoesGlobais.PreencheValorProgressBar(pgbPressao, 0);
lblPressaoDados.Text = "0,00 psi";
FuncoesGlobais.PreencheValorProgressBar(pgbTemperaturaMotores, 0);
lblTemperaturaMotoresDados.Text = "0,00 ºC";
FuncoesGlobais.PreencheValorProgressBar(pgbTemperaturaCampo, 0);
lblTemperaturaCampoDados.Text = "0,00 ºC";
FuncoesGlobais.PreencheValorProgressBar(pgbVelocidade, 0);
lblVelocidadeDados.Text = "0,00 km/h";
}
else if (Endereco > 0x00 && VariaveisMonitoramento.EquipamentosConectados.Any(x => x.Key == Endereco))
{
var Equipamento = VariaveisMonitoramento.EquipamentosConectados[Endereco];
if (Equipamento.Momento > MomentoLog)
{
MomentoLog = Equipamento.Momento;
txtLeitura.Text = Equipamento.Momento.ToString("ddd HH:mm:ss");
txtOrientacao.Text = Equipamento.Coordenadas.Orientacao.ToString("0.00");
txtLatitude.Text = Equipamento.Coordenadas.Latitude.ToString();
txtLongitude.Text = Equipamento.Coordenadas.Longitude.ToString();
txtStatusOperacao.Text = Equipamento.Operacao.statusOperacao.ToString();
txtStatusCarro.Text = Equipamento.Operacao.statusCarro.ToString();
txtTempoDecorrido.Text = TimeSpan.FromSeconds(Equipamento.Operacao.TempoOperacao).ToString(@"hh\:mm\:ss");
txtTempoEstimado.Text = Equipamento.Operacao.TempoEstimado;
FuncoesGlobais.PreencheValorProgressBar(pgbProgressoOperacao, Equipamento.Operacao.PercentualOperacao);
FuncoesGlobais.PreencheValorProgressBar(pgbProgressoRua, Equipamento.Operacao.PercentualRua);
FuncoesGlobais.PreencheValorProgressBar(pgbBateria, Equipamento.Sensores.PercentualBateria);
lblBateriaDados.Text = $"{Equipamento.Sensores.PercentualBateria.ToString("0.00")}%";
FuncoesGlobais.PreencheValorProgressBar(pgbReservatorio, Equipamento.Sensores.PercentualReservatorio);
lblReservatorioDados.Text = $"{Equipamento.Sensores.PercentualReservatorio.ToString("0.00")}%";
FuncoesGlobais.PreencheValorProgressBar(pgbHerbicidaAplicado, Equipamento.Sensores.HerbicidaConsumido);
lblHerbicidaDados.Text = $"{Equipamento.Sensores.HerbicidaConsumido.ToString("0.00")} L ({Equipamento.Sensores.HerbicidaPorErva.ToString("0.00")} ml/erva)";
lblErvasIdentificadas.Text = $"{Equipamento.Sensores.ErvasIdentificadas} ervas";
FuncoesGlobais.PreencheValorProgressBar(pgbPressao, Equipamento.Sensores.PressaoLinha);
lblPressaoDados.Text = $"{Equipamento.Sensores.PressaoLinha.ToString("0.00")} psi";
FuncoesGlobais.PreencheValorProgressBar(pgbTemperaturaMotores, Equipamento.Sensores.TemperaturaMotores);
lblTemperaturaMotoresDados.Text = $"{Equipamento.Sensores.TemperaturaMotores.ToString("0.00")} ºC";
FuncoesGlobais.PreencheValorProgressBar(pgbTemperaturaCampo, Equipamento.Sensores.TemperaturaCampo);
lblTemperaturaCampoDados.Text = $"{Equipamento.Sensores.TemperaturaCampo.ToString("0.00")} ºC";
FuncoesGlobais.PreencheValorProgressBar(pgbVelocidade, Equipamento.Sensores.Velocidade);
lblVelocidadeDados.Text = $"{Equipamento.Sensores.Velocidade.ToString("0.00")} km/h";
}
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,4 +1,5 @@
using AgroBase.Services;
using AgroBase.Models;
using AgroBase.Services;
using System;
using System.Collections.Generic;
using System.Linq;
@ -10,5 +11,57 @@ namespace AgroMonitor
public class VariaveisMonitoramento
{
public static LoRaService ComunicacaoLoRa = new LoRaService();
public static Dictionary<byte, LoRaProtocoloTransmissaoModel> EquipamentosConectados
{
get
{
var Equipamentos = new Dictionary<byte, LoRaProtocoloTransmissaoModel>()
{
{ ComunicacaoLoRa.parametros.address, new LoRaProtocoloTransmissaoModel() }
};
if (LoRaService.Iniciado)
{
// Mensagens dos equipamentos conectados dentro dos ultimos 10 segundos
var Mensagens = LoRaService.LeituraDadosOperacao.Where(x => x.Momento.AddMilliseconds(VariaveisEquipamento.TempoEntrePingsConexao) < DateTime.Now).ToList();
var _equipamentos = Mensagens
.GroupBy(x => x.EnderecoCarro)
.OrderBy(x => x.Key)
.ToDictionary(x => x.Key, x => x.OrderByDescending(y => y.Momento).FirstOrDefault());
foreach (var item in _equipamentos)
{
Equipamentos.Add(item.Key, item.Value);
}
}
return Equipamentos;
}
}
public static Dictionary<byte, List<LoRaProtocoloTransmissaoModel>> EquipamentosConectadosLogs
{
get
{
var Equipamentos = new Dictionary<byte, List<LoRaProtocoloTransmissaoModel>>()
{
{ ComunicacaoLoRa.parametros.address, new List<LoRaProtocoloTransmissaoModel>() }
};
if (LoRaService.Iniciado)
{
// Mensagens dos equipamentos conectados dentro dos ultimos 10 segundos
var Mensagens = LoRaService.LeituraDadosOperacao.Where(x => x.Momento.AddMilliseconds(VariaveisEquipamento.TempoEntrePingsConexao) < DateTime.Now).ToList();
var _equipamentos = Mensagens
.GroupBy(x => x.EnderecoCarro)
.ToDictionary(x => x.Key, x => x.OrderBy(y => y.Momento).ToList());
foreach (var item in _equipamentos)
{
Equipamentos.Add(item.Key, item.Value);
}
}
return Equipamentos;
}
}
}
}

View File

@ -31,9 +31,14 @@
this.picRastreamento = new System.Windows.Forms.PictureBox();
this.picRede = new System.Windows.Forms.PictureBox();
this.picAjustes = new System.Windows.Forms.PictureBox();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.lblMqtt = new System.Windows.Forms.ToolStripStatusLabel();
this.lblLoRa = new System.Windows.Forms.ToolStripStatusLabel();
this.lblGps = new System.Windows.Forms.ToolStripStatusLabel();
((System.ComponentModel.ISupportInitialize)(this.picRastreamento)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picRede)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picAjustes)).BeginInit();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
// picRastreamento
@ -46,7 +51,6 @@
this.picRastreamento.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.picRastreamento.TabIndex = 4;
this.picRastreamento.TabStop = false;
this.picRastreamento.Click += new System.EventHandler(this.picRastreamento_Click);
//
// picRede
//
@ -58,7 +62,6 @@
this.picRede.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.picRede.TabIndex = 3;
this.picRede.TabStop = false;
this.picRede.Click += new System.EventHandler(this.picRede_Click);
//
// picAjustes
//
@ -70,13 +73,43 @@
this.picAjustes.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.picAjustes.TabIndex = 2;
this.picAjustes.TabStop = false;
this.picAjustes.Click += new System.EventHandler(this.picAjustes_Click);
//
// statusStrip1
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.lblMqtt,
this.lblLoRa,
this.lblGps});
this.statusStrip1.Location = new System.Drawing.Point(0, 230);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(701, 22);
this.statusStrip1.TabIndex = 5;
this.statusStrip1.Text = "statusStrip1";
//
// lblMqtt
//
this.lblMqtt.Name = "lblMqtt";
this.lblMqtt.Size = new System.Drawing.Size(119, 17);
this.lblMqtt.Text = "MQTT: Desconectado";
//
// lblLoRa
//
this.lblLoRa.Name = "lblLoRa";
this.lblLoRa.Size = new System.Drawing.Size(114, 17);
this.lblLoRa.Text = "LoRa: Desconectado";
//
// lblGps
//
this.lblGps.Name = "lblGps";
this.lblGps.Size = new System.Drawing.Size(109, 17);
this.lblGps.Text = "GPS: Desconectado";
//
// frmInicial
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(701, 224);
this.ClientSize = new System.Drawing.Size(701, 252);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.picRastreamento);
this.Controls.Add(this.picRede);
this.Controls.Add(this.picAjustes);
@ -88,7 +121,10 @@
((System.ComponentModel.ISupportInitialize)(this.picRastreamento)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picRede)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picAjustes)).EndInit();
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
@ -96,6 +132,10 @@
private System.Windows.Forms.PictureBox picAjustes;
private System.Windows.Forms.PictureBox picRede;
private System.Windows.Forms.PictureBox picRastreamento;
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel lblMqtt;
private System.Windows.Forms.ToolStripStatusLabel lblLoRa;
private System.Windows.Forms.ToolStripStatusLabel lblGps;
}
}

View File

@ -1,5 +1,6 @@
using AgroBase.Forms;
using AgroBase.Forms.Operacoes;
using AgroBase.Models;
using AgroBase.Services;
using AgroMonitor.Forms;
using System;
@ -22,6 +23,31 @@ namespace AgroMonitor
InitializeComponent();
IniciarDependencias();
FuncoesGlobais.DefinirEventosPicBtn(picAjustes, async () =>
{
frmAjustesOperacao frm = new frmAjustesOperacao();
frm.ShowDialog();
});
FuncoesGlobais.DefinirEventosPicBtn(picRede, async () =>
{
if (LoRaService.Iniciado)
{
frmLoraConfig frm = new frmLoraConfig(VariaveisMonitoramento.ComunicacaoLoRa);
frm.ShowDialog();
}
else
{
MessageBox.Show("Módulo LoRa de comunicação não está conectado ou não está no modo de parametrização!", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
});
FuncoesGlobais.DefinirEventosPicBtn(picRastreamento, async () =>
{
frmMonitoramento frm = new frmMonitoramento();
frm.ShowDialog();
});
}
private void IniciarDependencias()
@ -33,50 +59,17 @@ namespace AgroMonitor
private void tmrDispositivos_Tick(object sender, EventArgs e)
{
SerialService.RealizarVarreduraPortasUSB().ConfigureAwait(false);
lblMqtt.Text = "MQTT: " + (Variaveis.MqttService.StatusConexao() ? "Conectado" : "Desconectado");
lblMqtt.ForeColor = Variaveis.MqttService.StatusConexao() ? Color.Green : Color.Red;
lblLoRa.Text = "LoRa: " + (LoRaService.Iniciado ? "Conectado" : "Desconectado");
lblLoRa.ForeColor = LoRaService.Iniciado ? Color.Green : Color.Red;
lblGps.Text = "GPS: " + (GPSService.Iniciado ? "Conectado" : "Desconectado");
lblGps.ForeColor = GPSService.Iniciado ? Color.Green : Color.Red;
}
private void btnAbrir_Click(object sender, EventArgs e)
{
frmResultadosOperacao frm = new frmResultadosOperacao();
frm.ShowDialog();
}
private void btnComunicacao_Click(object sender, EventArgs e)
{
if (LoRaService.Iniciado)
{
frmLoraConfig frm = new frmLoraConfig(VariaveisMonitoramento.ComunicacaoLoRa);
frm.ShowDialog();
}
else
{
MessageBox.Show("Módulo LoRa de comunicação não está conectado ou não está no modo de parametrização!");
}
}
private void picAjustes_Click(object sender, EventArgs e)
{
frmAjustesOperacao frm = new frmAjustesOperacao();
frm.ShowDialog();
}
private void picRede_Click(object sender, EventArgs e)
{
if (LoRaService.Iniciado)
{
frmLoraConfig frm = new frmLoraConfig(VariaveisMonitoramento.ComunicacaoLoRa);
frm.ShowDialog();
}
else
{
MessageBox.Show("Módulo LoRa de comunicação não está conectado ou não está no modo de parametrização!");
}
}
private void picRastreamento_Click(object sender, EventArgs e)
{
frmResultadosOperacao frm = new frmResultadosOperacao();
frm.ShowDialog();
}
}
}

View File

@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -1 +1 @@
1e20944e4ca6b40a68d24f14051c9196c59d0fbef03a90ffaee2db8dc4ac98c6
4ba9d763c6380206abf9055da0c8733ea87c9c5c172d8e17e1776628c9d38991

View File

@ -215,3 +215,4 @@ C:\ZendionInc\agrobot_base\AgroBase\AgroMonitor\bin\Debug\Microsoft.Bcl.AsyncInt
C:\ZendionInc\agrobot_base\AgroBase\AgroMonitor\bin\Debug\System.Runtime.CompilerServices.Unsafe.xml
C:\ZendionInc\agrobot_base\AgroBase\AgroMonitor\obj\Debug\AgroMonitor.csproj.CopyComplete
C:\ZendionInc\agrobot_base\AgroBase\AgroMonitor\obj\Debug\AgroMonitor.Forms.frmAjustesOperacao.resources
C:\ZendionInc\agrobot_base\AgroBase\AgroMonitor\obj\Debug\AgroMonitor.Forms.frmMonitoramento.resources