finalizado controle remoto do equipamento pela base

This commit is contained in:
Diego Freitas 2024-07-19 15:04:31 -03:00
parent 765abed0ce
commit 04ca18acc2
28 changed files with 622 additions and 110 deletions

Binary file not shown.

View File

@ -128,11 +128,11 @@ namespace AgroBase.Forms.Operacoes
if (chbSonar.Checked && Sonar.DesvioNecessario && UltimoComandoDir.AddSeconds(1) < DateTime.Now)
{
Variaveis.OperacaoEmAndamento.Controle.Angulo = Sonar.AnguloDesvio;
Direcao direcaoDesvio = Direcao.Cima;
Direcao direcaoDesvio = Direcao.Direita;
if (Variaveis.OperacaoEmAndamento.Controle.Angulo < 0)
{
Variaveis.OperacaoEmAndamento.Controle.Angulo *= -1;
direcaoDesvio = Direcao.Baixo;
direcaoDesvio = Direcao.Esquerda;
}
Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos.ForEach(Modulo =>
{

View File

@ -24,10 +24,10 @@ namespace AgroBase
public static List<ComandosDispositivo> Comandos = new List<ComandosDispositivo>() { };
public static List<DeParaComandos> DeParaComandos = new List<DeParaComandos>()
{
new DeParaComandos() { key = Keys.A, Dispositivo = T_Code.Dir, botaoJoy = BotoesJoystick.SEsquerda, PararAoSoltar = true },
new DeParaComandos() { key = Keys.A, Dispositivo = T_Code.Dir, botaoJoy = BotoesJoystick.AEEsquerda, PararAoSoltar = true },
new DeParaComandos() { key = Keys.D, Dispositivo = T_Code.Dir, botaoJoy = BotoesJoystick.SDireita, PararAoSoltar = true },
new DeParaComandos() { key = Keys.D, Dispositivo = T_Code.Dir, botaoJoy = BotoesJoystick.AEDireita, PararAoSoltar = true },
new DeParaComandos() { key = Keys.Left, Dispositivo = T_Code.Dir, botaoJoy = BotoesJoystick.SEsquerda, PararAoSoltar = true },
new DeParaComandos() { key = Keys.Left, Dispositivo = T_Code.Dir, botaoJoy = BotoesJoystick.AEEsquerda, PararAoSoltar = true },
new DeParaComandos() { key = Keys.Right, Dispositivo = T_Code.Dir, botaoJoy = BotoesJoystick.SDireita, PararAoSoltar = true },
new DeParaComandos() { key = Keys.Right, Dispositivo = T_Code.Dir, botaoJoy = BotoesJoystick.AEDireita, PararAoSoltar = true },
new DeParaComandos() { key = Keys.Up, Dispositivo = T_Code.Mov, botaoJoy = BotoesJoystick.A, PararAoSoltar = true },
new DeParaComandos() { key = Keys.Down, Dispositivo = T_Code.Mov, botaoJoy = BotoesJoystick.X, PararAoSoltar = true },
new DeParaComandos() { key = Keys.Space, Dispositivo = T_Code.Mov, botaoJoy = BotoesJoystick.B, PararAoSoltar = true },
@ -456,9 +456,13 @@ namespace AgroBase
});
}
public static void EnviaComandoMotor(Keys Tecla, T_Code? Disp = null)
public static void EnviaComandoMotor(Keys Tecla, T_Code Disp = T_Code.Vzo, bool MensagemBase = false)
{
if ((Variaveis.OperacaoEmAndamento.Modo != ModoOperacao.Manual || !Variaveis.OperacaoEmAndamento.Iniciado))
if (
!Variaveis.OperacaoEmAndamento.OperacaoLiberada ||
!Variaveis.OperacaoEmAndamento.Iniciado ||
Variaveis.OperacaoEmAndamento.Modo != ModoOperacao.Manual
)
{
return;
}
@ -475,7 +479,7 @@ namespace AgroBase
// Cancelar Comando Anterior
if (Comando.Comando == Keys.Escape)
{
var ComandosDisp = Disp == null ? Comandos : Comandos.Where(x => x.Dispositivo == Disp).ToList();
var ComandosDisp = Disp == T_Code.Vzo ? Comandos : Comandos.Where(x => x.Dispositivo == Disp).ToList();
Comando.Dispositivo = ComandosDisp[ComandosDisp.Count - 1].Dispositivo;
Comando.IDcontrolar = ComandosDisp[ComandosDisp.Count - 1].IDcontrolar;
DirecaoAtual = Direcao.Parado;
@ -521,31 +525,19 @@ namespace AgroBase
DirecaoAtual = Direcao.EmFreio;
Pressionado = true;
}
// Controle de Rotação dos Motores de Passo (DIR)
else if (Comando.Comando == Keys.Left && UltimaDirecao != Direcao.Esquerda)
{
Comando.Dispositivo = T_Code.Mov;
Comando.Dispositivo = T_Code.Dir;
DirecaoAtual = Direcao.Esquerda;
Pressionado = true;
}
else if (Comando.Comando == Keys.Right && UltimaDirecao != Direcao.Direita)
{
Comando.Dispositivo = T_Code.Mov;
Comando.Dispositivo = T_Code.Dir;
DirecaoAtual = Direcao.Direita;
Pressionado = true;
}
// Controle de Rotação dos Motores de Passo (DIR)
else if (Comando.Comando == Keys.A && UltimaDirecao != Direcao.Cima)
{
Comando.Dispositivo = T_Code.Dir;
DirecaoAtual = Direcao.Cima;
Pressionado = true;
}
else if (Comando.Comando == Keys.D && UltimaDirecao != Direcao.Baixo)
{
Comando.Dispositivo = T_Code.Dir;
DirecaoAtual = Direcao.Baixo;
Pressionado = true;
}
// Controle dos Bicos Pulverizadores (ATU)
else if ((Comando.Comando == Keys.D1 || Comando.Comando == Keys.D2 || Comando.Comando == Keys.D3 || Comando.Comando == Keys.D4) && !Variaveis.OperacaoEmAndamento.DispAtu.Dados.BicosPulverizadores.FirstOrDefault(x => x.ID == Comando.IDcontrolar).Atuado)
{

View File

@ -209,6 +209,7 @@ namespace AgroBase.Models
MensagemTexto = 0x01,
DadosOperacao = 0x02,
PosicaoGPS = 0x03,
ComandoControle = 0x04,
}
}

View File

@ -398,8 +398,8 @@ namespace AgroBase.Models.Modules
if (Comandar && (Controlar))
{
Sentido_SP =
Direcao == Direcao.Cima ? ConfigSentidos.Direita :
Direcao == Direcao.Baixo ? ConfigSentidos.Esquerda :
Direcao == Direcao.Direita ? ConfigSentidos.Direita :
Direcao == Direcao.Esquerda ? ConfigSentidos.Esquerda :
!Livre && Sentido_SP == Sentido.Horario ? Sentido.Antihorario :
!Livre && Sentido_SP == Sentido.Antihorario ? Sentido.Horario :
Sentido.Parado;

View File

@ -719,6 +719,15 @@ namespace AgroBase.Models.Modules
{
if (Comandar && Controlar)
{
Angulo_SP = Livre ? -1 : (Direcao != Direcao.Esquerda && Direcao != Direcao.Direita) ? 0 : Variaveis.OperacaoEmAndamento.Controle.Angulo;
Sentido_SP =
Direcao == Direcao.Direita ? ConfigSentidos.Direita :
Direcao == Direcao.Esquerda ? ConfigSentidos.Esquerda :
!Livre && Sentido_SP == Sentido.Horario ? Sentido.Antihorario :
!Livre && Sentido_SP == Sentido.Antihorario ? Sentido.Horario :
Sentido.Parado;
if (MKS_Inicializado)
{
int mx = Sentido_SP == Sentido.Antihorario ? -1 : 1;
@ -739,15 +748,6 @@ namespace AgroBase.Models.Modules
}
if (Inicializado)
{
Sentido_SP =
Direcao == Direcao.Cima ? ConfigSentidos.Direita :
Direcao == Direcao.Baixo ? ConfigSentidos.Esquerda :
!Livre && Sentido_SP == Sentido.Horario ? Sentido.Antihorario :
!Livre && Sentido_SP == Sentido.Antihorario ? Sentido.Horario :
Sentido.Parado;
Angulo_SP = Livre ? -1 : (Direcao != Direcao.Cima && Direcao != Direcao.Baixo) ? 0 : Variaveis.OperacaoEmAndamento.Controle.Angulo;
string ProtocoloMotor =
((int)F_Code.Cmd).ToString() + SerialService.SplitMessage +
ID + SerialService.SplitParams +

View File

@ -758,7 +758,7 @@ namespace AgroBase.Models.Modules
}
if (Sensor != null && Sensor.Leituras != null)
if (Sensor != null && Sensor.Leituras != null && Sensor.Leituras.Count() > 0)
{
if (Sensor.Leituras[0] > Sensor.ValorMaximo)
{

View File

@ -112,6 +112,7 @@ namespace AgroBase.Models
public Form frmOperacao { get; set; }
private StatusOperacao _EtapaAtual;
private StatusOperacao _EtapaAnteriorParada = StatusOperacao.Parado;
public bool Emergencia { get; set; } = false;
public StatusOperacao StatusAtual
{
get
@ -217,6 +218,8 @@ namespace AgroBase.Models
if (frmInstancial.frmPrincipal.chbDebugMode.Checked) _operacaoLiberada = true;
if (Emergencia) _operacaoLiberada = false;
return _operacaoLiberada;
}
}
@ -991,7 +994,7 @@ namespace AgroBase.Models
}
else
{
Controle.Direcao = Direcao.Baixo;
Controle.Direcao = Direcao.Esquerda;
}
}
else
@ -1002,7 +1005,7 @@ namespace AgroBase.Models
}
else
{
Controle.Direcao = Direcao.Cima;
Controle.Direcao = Direcao.Direita;
}
}
}
@ -1362,6 +1365,53 @@ namespace AgroBase.Models
}
public void ExecutaComandoDaBase(OperacaoControleBaseModel controleBase)
{
Emergencia = controleBase.Emergencia;
if (Emergencia)
{
return;
}
// Salvar estado anterior
int oldRPM = Controle.RPM;
double oldAngulo = Controle.Angulo;
double oldVelocidadeMP = Controle.VelocidadeMP;
Dictionary<string, bool> oldControleMov = Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos.ToDictionary(x => x.Modulo_ID, x => x.MovMotor.Comandar);
Dictionary<string, bool> oldControleDir = Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos.ToDictionary(x => x.Modulo_ID, x => x.DirMotor.Comandar);
// Atualizar estado atual com os valores do controleBase
Controle.RPM = controleBase.RPM;
Controle.Angulo = controleBase.AnguloMP;
Controle.VelocidadeMP = controleBase.VelocidadeMP;
Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos.ForEach(x =>
{
bool controlarMov = controleBase.ControleMov != null && controleBase.ControleMov.Any(y => y.Key == x.Modulo_ID) ? controleBase.ControleMov[x.Modulo_ID] : oldControleMov[x.Modulo_ID];
bool controlarDir = controleBase.ControleDir != null && controleBase.ControleDir.Any(y => y.Key == x.Modulo_ID) ? controleBase.ControleDir[x.Modulo_ID] : oldControleDir[x.Modulo_ID];
x.MovMotor.Comandar = controlarMov;
x.DirMotor.Comandar = controlarDir;
x.DirMotor.Controlar = controlarDir;
});
// Enviar comando
GeneralJoystick.EnviaComandoMotor(controleBase.Tecla, controleBase.Dispositivo, true);
// Restaurar estado anterior
Controle.RPM = oldRPM;
Controle.Angulo = oldAngulo;
Controle.VelocidadeMP = oldVelocidadeMP;
Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos.ForEach(x =>
{
x.MovMotor.Comandar = oldControleMov[x.Modulo_ID];
x.DirMotor.Comandar = oldControleDir[x.Modulo_ID];
x.DirMotor.Controlar = oldControleDir[x.Modulo_ID];
});
}
#endregion
#region REGISTRO DE LOGS
@ -1822,6 +1872,18 @@ namespace AgroBase.Models
public bool Pronto { get; set; }
}
public class OperacaoControleBaseModel
{
public DateTime Momento { get; set; }
public Keys Tecla { get; set; }
public T_Code Dispositivo { get; set; }
public int RPM { get; set; }
public double AnguloMP { get; set; }
public double VelocidadeMP { get; set; }
public bool Emergencia { get; set; }
public Dictionary<string, bool> ControleMov { get; set; }
public Dictionary<string, bool> ControleDir { get; set; }
}
public class OperacaoDadosModel

View File

@ -6,6 +6,7 @@ using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static AgroBase.Models.Enuns;
namespace AgroBase.Services
@ -155,5 +156,117 @@ namespace AgroBase.Services
return (Endereco, model);
}
public static byte[] SerializeControleModel(OperacaoControleBaseModel model)
{
List<byte> bytes = new List<byte>();
// Serializar Momento (DateTime)
bytes.AddRange(BitConverter.GetBytes(model.Momento.ToBinary()));
// Serializar Tecla (int)
bytes.AddRange(BitConverter.GetBytes((int)model.Tecla));
// Serializar Dispositivo (int)
bytes.AddRange(BitConverter.GetBytes((int)model.Dispositivo));
// Serializar RPM
bytes.AddRange(BitConverter.GetBytes(model.RPM));
// Serializar AnguloMP
bytes.AddRange(BitConverter.GetBytes(model.AnguloMP));
// Serializar VelocidadeMP
bytes.AddRange(BitConverter.GetBytes(model.VelocidadeMP));
// Serializar Emergencia
bytes.AddRange(BitConverter.GetBytes(model.Emergencia));
// Serializar ControleMov
bytes.AddRange(BitConverter.GetBytes(model.ControleMov.Count));
foreach (var kvp in model.ControleMov)
{
bytes.AddRange(BitConverter.GetBytes(kvp.Key.Length));
bytes.AddRange(System.Text.Encoding.UTF8.GetBytes(kvp.Key));
bytes.Add(kvp.Value ? (byte)1 : (byte)0);
}
// Serializar ControleDir
bytes.AddRange(BitConverter.GetBytes(model.ControleDir.Count));
foreach (var kvp in model.ControleDir)
{
bytes.AddRange(BitConverter.GetBytes(kvp.Key.Length));
bytes.AddRange(System.Text.Encoding.UTF8.GetBytes(kvp.Key));
bytes.Add(kvp.Value ? (byte)1 : (byte)0);
}
return bytes.ToArray();
}
public static OperacaoControleBaseModel DeserializeControleModel(byte[] bytes)
{
OperacaoControleBaseModel model = new OperacaoControleBaseModel();
int index = 0;
// Desserializar Momento (DateTime)
model.Momento = DateTime.FromBinary(BitConverter.ToInt64(bytes, index));
index += sizeof(long);
// Desserializar Tecla (int)
model.Tecla = (Keys)BitConverter.ToInt32(bytes, index);
index += sizeof(int);
// Desserializar Dispositivo (int)
model.Dispositivo = (T_Code)BitConverter.ToInt32(bytes, index);
index += sizeof(int);
// Desserializar RPM
model.RPM = BitConverter.ToInt32(bytes, index);
index += sizeof(int);
// Desserializar AnguloMP
model.AnguloMP = BitConverter.ToDouble(bytes, index);
index += sizeof(double);
// Desserializar VelocidadeMP
model.VelocidadeMP = BitConverter.ToDouble(bytes, index);
index += sizeof(double);
// Desserializar Emergencia
model.Emergencia = BitConverter.ToBoolean(bytes, index);
index += sizeof(bool);
// Desserializar ControleMov
int controleMovCount = BitConverter.ToInt32(bytes, index);
index += sizeof(int);
model.ControleMov = new Dictionary<string, bool>();
for (int i = 0; i < controleMovCount; i++)
{
int keyLength = BitConverter.ToInt32(bytes, index);
index += sizeof(int);
string key = System.Text.Encoding.UTF8.GetString(bytes, index, keyLength);
index += keyLength;
bool value = bytes[index] == 1;
index += sizeof(byte);
model.ControleMov[key] = value;
}
// Desserializar ControleDir
int controleDirCount = BitConverter.ToInt32(bytes, index);
index += sizeof(int);
model.ControleDir = new Dictionary<string, bool>();
for (int i = 0; i < controleDirCount; i++)
{
int keyLength = BitConverter.ToInt32(bytes, index);
index += sizeof(int);
string key = System.Text.Encoding.UTF8.GetString(bytes, index, keyLength);
index += keyLength;
bool value = bytes[index] == 1;
index += sizeof(byte);
model.ControleDir[key] = value;
}
return model;
}
}
}

View File

@ -448,6 +448,15 @@ namespace AgroBase.Services
}
break;
}
case LoRaTipoProtocolo.ComandoControle:
{
byte[] bufferDados = new byte[resposta.Buffer.Length - 4];
Array.Copy(resposta.Buffer, 4, bufferDados, 0, bufferDados.Length);
OperacaoControleBaseModel Controle = LoRaSerializer.DeserializeControleModel(bufferDados);
Variaveis.OperacaoEmAndamento.ExecutaComandoDaBase(Controle);
break;
}
}
}
@ -807,6 +816,16 @@ namespace AgroBase.Services
}
}
public static void EnviarDadosComandoControle(OperacaoControleBaseModel Controle, byte EnderecoDestinatario)
{
if (Iniciado && Variaveis.IsAgroMonitor)
{
byte[] dadosEnvio = LoRaSerializer.SerializeControleModel(Controle);
MontarMensagemEnvio(dadosEnvio, EnderecoDestinatario, LoRaTipoProtocolo.ComandoControle, true);
}
}
}

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -34,7 +34,8 @@
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.pnlDados = new System.Windows.Forms.Panel();
this.chbFoco = new System.Windows.Forms.CheckBox();
this.txtTempoEstimado = new System.Windows.Forms.TextBox();
this.lblTempoEstimado = new System.Windows.Forms.Label();
this.lblTempoDecorrido = new System.Windows.Forms.Label();
@ -73,11 +74,32 @@
this.lblOrientacao = new System.Windows.Forms.Label();
this.lblLeitura = new System.Windows.Forms.Label();
this.txtLeitura = new System.Windows.Forms.TextBox();
this.chbFoco = new System.Windows.Forms.CheckBox();
this.pnlMapa = new System.Windows.Forms.Panel();
this.lblMapa = new System.Windows.Forms.Label();
this.btnCarregar = new System.Windows.Forms.Button();
this.panel1.SuspendLayout();
this.lblControle = new System.Windows.Forms.Label();
this.pnlControle = new System.Windows.Forms.Panel();
this.chb_EF_Dir = new System.Windows.Forms.CheckBox();
this.chb_EF_Mov = new System.Windows.Forms.CheckBox();
this.chb_ET_Mov = new System.Windows.Forms.CheckBox();
this.chb_ET_Dir = new System.Windows.Forms.CheckBox();
this.chb_DT_Mov = new System.Windows.Forms.CheckBox();
this.chb_DT_Dir = new System.Windows.Forms.CheckBox();
this.chb_DF_Mov = new System.Windows.Forms.CheckBox();
this.chb_DF_Dir = new System.Windows.Forms.CheckBox();
this.btnControle = new System.Windows.Forms.Button();
this.nudRPM = new System.Windows.Forms.NumericUpDown();
this.nudAngulo = new System.Windows.Forms.NumericUpDown();
this.nudVelocidadeMP = new System.Windows.Forms.NumericUpDown();
this.lblRPM = new System.Windows.Forms.Label();
this.lblAngulo = new System.Windows.Forms.Label();
this.lblVelocidadeMP = new System.Windows.Forms.Label();
this.btnParar = new System.Windows.Forms.Button();
this.pnlDados.SuspendLayout();
this.pnlControle.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nudRPM)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nudAngulo)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nudVelocidadeMP)).BeginInit();
this.SuspendLayout();
//
// lblEquipamento
@ -139,59 +161,71 @@
this.txtLongitude.TabIndex = 5;
this.txtLongitude.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// panel1
// pnlDados
//
this.panel1.AutoScroll = true;
this.panel1.Controls.Add(this.chbFoco);
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, 594);
this.panel1.TabIndex = 6;
this.pnlDados.AutoScroll = true;
this.pnlDados.Controls.Add(this.pnlControle);
this.pnlDados.Controls.Add(this.lblControle);
this.pnlDados.Controls.Add(this.chbFoco);
this.pnlDados.Controls.Add(this.txtTempoEstimado);
this.pnlDados.Controls.Add(this.lblTempoEstimado);
this.pnlDados.Controls.Add(this.lblTempoDecorrido);
this.pnlDados.Controls.Add(this.txtTempoDecorrido);
this.pnlDados.Controls.Add(this.lblProgressoRua);
this.pnlDados.Controls.Add(this.pgbProgressoRua);
this.pnlDados.Controls.Add(this.lblProgressoOperacao);
this.pnlDados.Controls.Add(this.pgbProgressoOperacao);
this.pnlDados.Controls.Add(this.txtStatusCarro);
this.pnlDados.Controls.Add(this.lblStatusCarro);
this.pnlDados.Controls.Add(this.lblStatusOperacao);
this.pnlDados.Controls.Add(this.txtStatusOperacao);
this.pnlDados.Controls.Add(this.lblErvasIdentificadas);
this.pnlDados.Controls.Add(this.lblVelocidadeDados);
this.pnlDados.Controls.Add(this.lblVelocidade);
this.pnlDados.Controls.Add(this.pgbVelocidade);
this.pnlDados.Controls.Add(this.lblHerbicidaDados);
this.pnlDados.Controls.Add(this.lblHerbicida);
this.pnlDados.Controls.Add(this.pgbHerbicidaAplicado);
this.pnlDados.Controls.Add(this.lblPressaoDados);
this.pnlDados.Controls.Add(this.lblPressao);
this.pnlDados.Controls.Add(this.pgbPressao);
this.pnlDados.Controls.Add(this.lblTemperaturaCampoDados);
this.pnlDados.Controls.Add(this.lblTemperaturaCampo);
this.pnlDados.Controls.Add(this.pgbTemperaturaCampo);
this.pnlDados.Controls.Add(this.lblTemperaturaMotoresDados);
this.pnlDados.Controls.Add(this.lblTemperaturaMotores);
this.pnlDados.Controls.Add(this.pgbTemperaturaMotores);
this.pnlDados.Controls.Add(this.lblReservatorioDados);
this.pnlDados.Controls.Add(this.lblBateriaDados);
this.pnlDados.Controls.Add(this.lblReservatorio);
this.pnlDados.Controls.Add(this.pgbReservatorio);
this.pnlDados.Controls.Add(this.lblBateria);
this.pnlDados.Controls.Add(this.pgbBateria);
this.pnlDados.Controls.Add(this.txtOrientacao);
this.pnlDados.Controls.Add(this.lblOrientacao);
this.pnlDados.Controls.Add(this.lblLeitura);
this.pnlDados.Controls.Add(this.txtLeitura);
this.pnlDados.Controls.Add(this.cmbEquipamento);
this.pnlDados.Controls.Add(this.lblEquipamento);
this.pnlDados.Controls.Add(this.txtLatitude);
this.pnlDados.Controls.Add(this.lblLongitude);
this.pnlDados.Controls.Add(this.lblLatitude);
this.pnlDados.Controls.Add(this.txtLongitude);
this.pnlDados.Dock = System.Windows.Forms.DockStyle.Right;
this.pnlDados.Location = new System.Drawing.Point(787, 0);
this.pnlDados.Name = "pnlDados";
this.pnlDados.Size = new System.Drawing.Size(239, 594);
this.pnlDados.TabIndex = 6;
//
// chbFoco
//
this.chbFoco.AutoSize = true;
this.chbFoco.Location = new System.Drawing.Point(9, 41);
this.chbFoco.Name = "chbFoco";
this.chbFoco.Size = new System.Drawing.Size(86, 17);
this.chbFoco.TabIndex = 7;
this.chbFoco.Text = "Acompanhar";
this.chbFoco.UseVisualStyleBackColor = true;
//
// txtTempoEstimado
//
@ -545,16 +579,6 @@
this.txtLeitura.TabIndex = 6;
this.txtLeitura.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// chbFoco
//
this.chbFoco.AutoSize = true;
this.chbFoco.Location = new System.Drawing.Point(9, 41);
this.chbFoco.Name = "chbFoco";
this.chbFoco.Size = new System.Drawing.Size(86, 17);
this.chbFoco.TabIndex = 7;
this.chbFoco.Text = "Acompanhar";
this.chbFoco.UseVisualStyleBackColor = true;
//
// pnlMapa
//
this.pnlMapa.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -589,6 +613,205 @@
this.btnCarregar.UseVisualStyleBackColor = true;
this.btnCarregar.Click += new System.EventHandler(this.btnCarregar_Click);
//
// lblControle
//
this.lblControle.AutoSize = true;
this.lblControle.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.25F);
this.lblControle.Location = new System.Drawing.Point(6, 603);
this.lblControle.Name = "lblControle";
this.lblControle.Size = new System.Drawing.Size(61, 17);
this.lblControle.TabIndex = 48;
this.lblControle.Text = "Controle";
//
// pnlControle
//
this.pnlControle.Controls.Add(this.btnParar);
this.pnlControle.Controls.Add(this.lblVelocidadeMP);
this.pnlControle.Controls.Add(this.lblAngulo);
this.pnlControle.Controls.Add(this.lblRPM);
this.pnlControle.Controls.Add(this.nudVelocidadeMP);
this.pnlControle.Controls.Add(this.nudAngulo);
this.pnlControle.Controls.Add(this.nudRPM);
this.pnlControle.Controls.Add(this.btnControle);
this.pnlControle.Controls.Add(this.chb_DT_Mov);
this.pnlControle.Controls.Add(this.chb_DT_Dir);
this.pnlControle.Controls.Add(this.chb_DF_Mov);
this.pnlControle.Controls.Add(this.chb_DF_Dir);
this.pnlControle.Controls.Add(this.chb_ET_Mov);
this.pnlControle.Controls.Add(this.chb_ET_Dir);
this.pnlControle.Controls.Add(this.chb_EF_Mov);
this.pnlControle.Controls.Add(this.chb_EF_Dir);
this.pnlControle.Location = new System.Drawing.Point(5, 623);
this.pnlControle.Name = "pnlControle";
this.pnlControle.Size = new System.Drawing.Size(208, 232);
this.pnlControle.TabIndex = 49;
//
// chb_EF_Dir
//
this.chb_EF_Dir.AutoSize = true;
this.chb_EF_Dir.Location = new System.Drawing.Point(4, 3);
this.chb_EF_Dir.Name = "chb_EF_Dir";
this.chb_EF_Dir.Size = new System.Drawing.Size(55, 17);
this.chb_EF_Dir.TabIndex = 0;
this.chb_EF_Dir.Text = "EF Dir";
this.chb_EF_Dir.UseVisualStyleBackColor = true;
//
// chb_EF_Mov
//
this.chb_EF_Mov.AutoSize = true;
this.chb_EF_Mov.Location = new System.Drawing.Point(4, 26);
this.chb_EF_Mov.Name = "chb_EF_Mov";
this.chb_EF_Mov.Size = new System.Drawing.Size(63, 17);
this.chb_EF_Mov.TabIndex = 1;
this.chb_EF_Mov.Text = "EF Mov";
this.chb_EF_Mov.UseVisualStyleBackColor = true;
//
// chb_ET_Mov
//
this.chb_ET_Mov.AutoSize = true;
this.chb_ET_Mov.Location = new System.Drawing.Point(4, 110);
this.chb_ET_Mov.Name = "chb_ET_Mov";
this.chb_ET_Mov.Size = new System.Drawing.Size(64, 17);
this.chb_ET_Mov.TabIndex = 3;
this.chb_ET_Mov.Text = "ET Mov";
this.chb_ET_Mov.UseVisualStyleBackColor = true;
//
// chb_ET_Dir
//
this.chb_ET_Dir.AutoSize = true;
this.chb_ET_Dir.Location = new System.Drawing.Point(4, 87);
this.chb_ET_Dir.Name = "chb_ET_Dir";
this.chb_ET_Dir.Size = new System.Drawing.Size(56, 17);
this.chb_ET_Dir.TabIndex = 2;
this.chb_ET_Dir.Text = "ET Dir";
this.chb_ET_Dir.UseVisualStyleBackColor = true;
//
// chb_DT_Mov
//
this.chb_DT_Mov.AutoSize = true;
this.chb_DT_Mov.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
this.chb_DT_Mov.Location = new System.Drawing.Point(139, 110);
this.chb_DT_Mov.Name = "chb_DT_Mov";
this.chb_DT_Mov.Size = new System.Drawing.Size(65, 17);
this.chb_DT_Mov.TabIndex = 7;
this.chb_DT_Mov.Text = "DT Mov";
this.chb_DT_Mov.UseVisualStyleBackColor = true;
//
// chb_DT_Dir
//
this.chb_DT_Dir.AutoSize = true;
this.chb_DT_Dir.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
this.chb_DT_Dir.Location = new System.Drawing.Point(147, 87);
this.chb_DT_Dir.Name = "chb_DT_Dir";
this.chb_DT_Dir.Size = new System.Drawing.Size(57, 17);
this.chb_DT_Dir.TabIndex = 6;
this.chb_DT_Dir.Text = "DT Dir";
this.chb_DT_Dir.UseVisualStyleBackColor = true;
//
// chb_DF_Mov
//
this.chb_DF_Mov.AutoSize = true;
this.chb_DF_Mov.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
this.chb_DF_Mov.Location = new System.Drawing.Point(140, 26);
this.chb_DF_Mov.Name = "chb_DF_Mov";
this.chb_DF_Mov.Size = new System.Drawing.Size(64, 17);
this.chb_DF_Mov.TabIndex = 5;
this.chb_DF_Mov.Text = "DF Mov";
this.chb_DF_Mov.UseVisualStyleBackColor = true;
//
// chb_DF_Dir
//
this.chb_DF_Dir.AutoSize = true;
this.chb_DF_Dir.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
this.chb_DF_Dir.Location = new System.Drawing.Point(148, 3);
this.chb_DF_Dir.Name = "chb_DF_Dir";
this.chb_DF_Dir.Size = new System.Drawing.Size(56, 17);
this.chb_DF_Dir.TabIndex = 4;
this.chb_DF_Dir.Text = "DF Dir";
this.chb_DF_Dir.UseVisualStyleBackColor = true;
//
// btnControle
//
this.btnControle.Location = new System.Drawing.Point(52, 44);
this.btnControle.Name = "btnControle";
this.btnControle.Size = new System.Drawing.Size(94, 43);
this.btnControle.TabIndex = 8;
this.btnControle.UseVisualStyleBackColor = true;
this.btnControle.KeyDown += new System.Windows.Forms.KeyEventHandler(this.btnControle_KeyDown);
this.btnControle.KeyUp += new System.Windows.Forms.KeyEventHandler(this.btnControle_KeyUp);
//
// nudRPM
//
this.nudRPM.Location = new System.Drawing.Point(4, 156);
this.nudRPM.Maximum = new decimal(new int[] {
600,
0,
0,
0});
this.nudRPM.Name = "nudRPM";
this.nudRPM.Size = new System.Drawing.Size(62, 20);
this.nudRPM.TabIndex = 9;
this.nudRPM.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// nudAngulo
//
this.nudAngulo.Location = new System.Drawing.Point(72, 156);
this.nudAngulo.Maximum = new decimal(new int[] {
90,
0,
0,
0});
this.nudAngulo.Name = "nudAngulo";
this.nudAngulo.Size = new System.Drawing.Size(62, 20);
this.nudAngulo.TabIndex = 10;
this.nudAngulo.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// nudVelocidadeMP
//
this.nudVelocidadeMP.Location = new System.Drawing.Point(140, 156);
this.nudVelocidadeMP.Name = "nudVelocidadeMP";
this.nudVelocidadeMP.Size = new System.Drawing.Size(62, 20);
this.nudVelocidadeMP.TabIndex = 11;
this.nudVelocidadeMP.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// lblRPM
//
this.lblRPM.AutoSize = true;
this.lblRPM.Location = new System.Drawing.Point(3, 140);
this.lblRPM.Name = "lblRPM";
this.lblRPM.Size = new System.Drawing.Size(31, 13);
this.lblRPM.TabIndex = 12;
this.lblRPM.Text = "RPM";
//
// lblAngulo
//
this.lblAngulo.AutoSize = true;
this.lblAngulo.Location = new System.Drawing.Point(69, 140);
this.lblAngulo.Name = "lblAngulo";
this.lblAngulo.Size = new System.Drawing.Size(40, 13);
this.lblAngulo.TabIndex = 13;
this.lblAngulo.Text = "Angulo";
//
// lblVelocidadeMP
//
this.lblVelocidadeMP.AutoSize = true;
this.lblVelocidadeMP.Location = new System.Drawing.Point(137, 140);
this.lblVelocidadeMP.Name = "lblVelocidadeMP";
this.lblVelocidadeMP.Size = new System.Drawing.Size(31, 13);
this.lblVelocidadeMP.TabIndex = 14;
this.lblVelocidadeMP.Text = "% Dir";
//
// btnParar
//
this.btnParar.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F);
this.btnParar.Location = new System.Drawing.Point(6, 191);
this.btnParar.Name = "btnParar";
this.btnParar.Size = new System.Drawing.Size(195, 38);
this.btnParar.TabIndex = 15;
this.btnParar.Text = "Parar";
this.btnParar.UseVisualStyleBackColor = true;
this.btnParar.Click += new System.EventHandler(this.btnParar_Click);
//
// frmMonitoramento
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -597,13 +820,18 @@
this.Controls.Add(this.btnCarregar);
this.Controls.Add(this.lblMapa);
this.Controls.Add(this.pnlMapa);
this.Controls.Add(this.panel1);
this.Controls.Add(this.pnlDados);
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.pnlDados.ResumeLayout(false);
this.pnlDados.PerformLayout();
this.pnlControle.ResumeLayout(false);
this.pnlControle.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nudRPM)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nudAngulo)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nudVelocidadeMP)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@ -616,7 +844,7 @@
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.Panel pnlDados;
private System.Windows.Forms.Label lblLeitura;
private System.Windows.Forms.TextBox txtLeitura;
private System.Windows.Forms.TextBox txtOrientacao;
@ -659,5 +887,23 @@
private System.Windows.Forms.Panel pnlMapa;
private System.Windows.Forms.Label lblMapa;
private System.Windows.Forms.Button btnCarregar;
private System.Windows.Forms.Panel pnlControle;
private System.Windows.Forms.CheckBox chb_DT_Mov;
private System.Windows.Forms.CheckBox chb_DT_Dir;
private System.Windows.Forms.CheckBox chb_DF_Mov;
private System.Windows.Forms.CheckBox chb_DF_Dir;
private System.Windows.Forms.CheckBox chb_ET_Mov;
private System.Windows.Forms.CheckBox chb_ET_Dir;
private System.Windows.Forms.CheckBox chb_EF_Mov;
private System.Windows.Forms.CheckBox chb_EF_Dir;
private System.Windows.Forms.Label lblControle;
private System.Windows.Forms.Button btnControle;
private System.Windows.Forms.Label lblVelocidadeMP;
private System.Windows.Forms.Label lblAngulo;
private System.Windows.Forms.Label lblRPM;
private System.Windows.Forms.NumericUpDown nudVelocidadeMP;
private System.Windows.Forms.NumericUpDown nudAngulo;
private System.Windows.Forms.NumericUpDown nudRPM;
private System.Windows.Forms.Button btnParar;
}
}

View File

@ -9,6 +9,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static AgroBase.Models.Enuns;
namespace AgroMonitor.Forms
{
@ -191,7 +192,82 @@ namespace AgroMonitor.Forms
Mapa.btnCarregar_Click(sender, e, "", true);
}
private void btnControle_KeyDown(object sender, KeyEventArgs e)
{
EnviarComandoControleEquipamento(e.KeyCode);
}
private void btnControle_KeyUp(object sender, KeyEventArgs e)
{
EnviarComandoControleEquipamento(Keys.Escape);
}
private void EnviarComandoControleEquipamento(Keys Tecla, T_Code Disp = T_Code.Vzo)
{
byte Endereco = Convert.ToByte(cmbEquipamento.Text);
Dictionary<Keys, Keys> DeParaTeclas = new Dictionary<Keys, Keys>()
{
{ Keys.W, Keys.Up },
{ Keys.S, Keys.Down },
{ Keys.A, Keys.Left },
{ Keys.D, Keys.Right },
{ Keys.Escape, Keys.Escape },
};
if (!DeParaTeclas.ContainsKey(Tecla))
{
return;
}
Keys[] TeclasDir = { Keys.A, Keys.D };
Keys[] TeclasMov = { Keys.W, Keys.S };
OperacaoControleBaseModel Controle = new OperacaoControleBaseModel()
{
Momento = DateTime.Now,
Tecla = DeParaTeclas[Tecla],
ControleMov = pnlControle.Controls.OfType<CheckBox>().Where(x => x.Name.Contains("Mov")).ToDictionary(x => x.Name.Split('_')[1], x => x.Checked),
ControleDir = pnlControle.Controls.OfType<CheckBox>().Where(x => x.Name.Contains("Dir")).ToDictionary(x => x.Name.Split('_')[1], x => x.Checked),
RPM = Convert.ToInt32(nudRPM.Value),
AnguloMP = Convert.ToInt32(nudAngulo.Value),
VelocidadeMP = Convert.ToInt32(nudVelocidadeMP.Value),
Dispositivo = Disp,
Emergencia = btnParar.Text == "Retomar"
};
if (Disp == T_Code.Vzo)
{
if (Tecla == Keys.Escape || (!TeclasDir.Contains(Tecla) && !TeclasMov.Contains(Tecla)))
{
Controle.Dispositivo = T_Code.Vzo;
}
else if (TeclasDir.Contains(Tecla))
{
Controle.Dispositivo = T_Code.Dir;
}
else if (TeclasMov.Contains(Tecla))
{
Controle.Dispositivo = T_Code.Mov;
}
}
LoRaService.EnviarDadosComandoControle(Controle, Endereco);
}
private void btnParar_Click(object sender, EventArgs e)
{
if (btnParar.Text == "Parar")
{
btnParar.Text = "Retomar";
EnviarComandoControleEquipamento(Keys.Escape);
}
else
{
btnParar.Text = "Parar";
EnviarComandoControleEquipamento(Keys.Escape);
}
}
}
}

View File

@ -216,4 +216,4 @@ C:\ZendionInc\agrobot_base\AgroBase\AgroMonitor\bin\Debug\System.Runtime.Compile
C:\ZendionInc\agrobot_base\AgroBase\AgroMonitor\obj\Debug\AgroMonitor.Forms.frmAjustesOperacao.resources
C:\ZendionInc\agrobot_base\AgroBase\AgroMonitor\obj\Debug\AgroMonitor.Forms.frmMonitoramento.resources
C:\ZendionINC\agrobot_base\AgroBase\AgroMonitor\bin\Debug\Python\Scripts\map-follow.py
C:\ZendionINC\agrobot_base\AgroBase\AgroMonitor\obj\Debug\AgroMoni.D419EBC3.Up2Date
C:\ZendionInc\agrobot_base\AgroBase\AgroMonitor\obj\Debug\AgroMonitor.csproj.CopyComplete