ajustes nas firmwares Atu e Sen e criacao do botao para reiniciar o modulo

This commit is contained in:
Diego Freitas 2026-04-08 15:35:31 -03:00
parent e7433eab9d
commit 0499f998d1
10 changed files with 114 additions and 74 deletions

View File

@ -56,6 +56,8 @@
this.tabDeteccoes = new System.Windows.Forms.TabPage();
this.pnlDeteccoesRua = new System.Windows.Forms.Panel();
this.tabPulverizador = new System.Windows.Forms.TabPage();
this.lblPotenciaSP = new System.Windows.Forms.Label();
this.nudPotenciaSP = new System.Windows.Forms.NumericUpDown();
this.btnDeslsigarAgitador = new System.Windows.Forms.Button();
this.btnLigarAgitador = new System.Windows.Forms.Button();
this.lblPressaoSP = new System.Windows.Forms.Label();
@ -83,8 +85,7 @@
this.chbPulverizador = new System.Windows.Forms.CheckBox();
this.flwCamerasSolo = new System.Windows.Forms.FlowLayoutPanel();
this.chbSonarAtivado = new System.Windows.Forms.CheckBox();
this.lblPotenciaSP = new System.Windows.Forms.Label();
this.nudPotenciaSP = new System.Windows.Forms.NumericUpDown();
this.lblPressao = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.chartGraficos)).BeginInit();
this.tabControl1.SuspendLayout();
this.tabMapa.SuspendLayout();
@ -92,12 +93,12 @@
((System.ComponentModel.ISupportInitialize)(this.gridDados)).BeginInit();
this.tabDeteccoes.SuspendLayout();
this.tabPulverizador.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nudPotenciaSP)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nudPressaoSP)).BeginInit();
this.pnlDir_EF.SuspendLayout();
this.pnlDir_ET.SuspendLayout();
this.pnlDir_DT.SuspendLayout();
this.pnlDir_DF.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nudPotenciaSP)).BeginInit();
this.SuspendLayout();
//
// pnlAtuadores
@ -272,6 +273,9 @@
//
// pnlMapa
//
this.pnlMapa.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.pnlMapa.Location = new System.Drawing.Point(104, 2);
this.pnlMapa.Margin = new System.Windows.Forms.Padding(2);
this.pnlMapa.Name = "pnlMapa";
@ -386,6 +390,28 @@
this.tabPulverizador.Text = "Pulverizador";
this.tabPulverizador.UseVisualStyleBackColor = true;
//
// lblPotenciaSP
//
this.lblPotenciaSP.AutoSize = true;
this.lblPotenciaSP.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblPotenciaSP.Location = new System.Drawing.Point(21, 57);
this.lblPotenciaSP.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblPotenciaSP.Name = "lblPotenciaSP";
this.lblPotenciaSP.Size = new System.Drawing.Size(77, 13);
this.lblPotenciaSP.TabIndex = 33;
this.lblPotenciaSP.Text = "Potencia SP";
//
// nudPotenciaSP
//
this.nudPotenciaSP.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.nudPotenciaSP.Location = new System.Drawing.Point(21, 73);
this.nudPotenciaSP.Margin = new System.Windows.Forms.Padding(2);
this.nudPotenciaSP.Name = "nudPotenciaSP";
this.nudPotenciaSP.Size = new System.Drawing.Size(79, 19);
this.nudPotenciaSP.TabIndex = 32;
this.nudPotenciaSP.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.nudPotenciaSP.ValueChanged += new System.EventHandler(this.nudPotenciaSP_ValueChanged);
//
// btnDeslsigarAgitador
//
this.btnDeslsigarAgitador.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
@ -683,27 +709,17 @@
this.chbSonarAtivado.UseVisualStyleBackColor = true;
this.chbSonarAtivado.CheckedChanged += new System.EventHandler(this.chbSonarAtivado_CheckedChanged);
//
// lblPotenciaSP
// lblPressao
//
this.lblPotenciaSP.AutoSize = true;
this.lblPotenciaSP.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblPotenciaSP.Location = new System.Drawing.Point(21, 57);
this.lblPotenciaSP.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblPotenciaSP.Name = "lblPotenciaSP";
this.lblPotenciaSP.Size = new System.Drawing.Size(77, 13);
this.lblPotenciaSP.TabIndex = 33;
this.lblPotenciaSP.Text = "Potencia SP";
//
// nudPotenciaSP
//
this.nudPotenciaSP.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.nudPotenciaSP.Location = new System.Drawing.Point(21, 73);
this.nudPotenciaSP.Margin = new System.Windows.Forms.Padding(2);
this.nudPotenciaSP.Name = "nudPotenciaSP";
this.nudPotenciaSP.Size = new System.Drawing.Size(79, 19);
this.nudPotenciaSP.TabIndex = 32;
this.nudPotenciaSP.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.nudPotenciaSP.ValueChanged += new System.EventHandler(this.nudPotenciaSP_ValueChanged);
this.lblPressao.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.lblPressao.AutoSize = true;
this.lblPressao.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblPressao.Location = new System.Drawing.Point(1111, 500);
this.lblPressao.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblPressao.Name = "lblPressao";
this.lblPressao.Size = new System.Drawing.Size(109, 37);
this.lblPressao.TabIndex = 38;
this.lblPressao.Text = "80 psi";
//
// frmOperacaoManual
//
@ -711,6 +727,7 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(1243, 649);
this.Controls.Add(this.lblPressao);
this.Controls.Add(this.chbSonarAtivado);
this.Controls.Add(this.flwCamerasSolo);
this.Controls.Add(this.chbPulverizador);
@ -748,6 +765,7 @@
this.tabDeteccoes.ResumeLayout(false);
this.tabPulverizador.ResumeLayout(false);
this.tabPulverizador.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nudPotenciaSP)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nudPressaoSP)).EndInit();
this.pnlDir_EF.ResumeLayout(false);
this.pnlDir_EF.PerformLayout();
@ -757,7 +775,6 @@
this.pnlDir_DT.PerformLayout();
this.pnlDir_DF.ResumeLayout(false);
this.pnlDir_DF.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nudPotenciaSP)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@ -817,5 +834,6 @@
private System.Windows.Forms.Button btnLigarAgitador;
private System.Windows.Forms.Label lblPotenciaSP;
private System.Windows.Forms.NumericUpDown nudPotenciaSP;
private System.Windows.Forms.Label lblPressao;
}
}

View File

@ -7,7 +7,6 @@ using static AgroBase.Models.Enums;
using AgroBase.Services;
using AgroBase.Models.Modules;
using System.Threading.Tasks;
using AgroBase.Models.Operadores;
using AgroBase.Services.Operadores;
namespace AgroBase.Forms.Operacoes
@ -166,6 +165,7 @@ namespace AgroBase.Forms.Operacoes
lblCorrente.Text = _Sensoriamento.Bateria.CorrenteInstantanea.ToString("0.00") + " A";
lblRPM.Text = _Sensoriamento.Movimentacao.RPMMedio.ToString("0") + " rpm";
lblVelocidade.Text = (_Sensoriamento.Movimentacao.VelocidadeMedia * 3.6).ToString("0.00");
lblPressao.Text = $"{(_Sensoriamento.Atuador.PressaoLinha):F0} psi";
bool atuadorAtivado = Variaveis.OperacaoEmAndamento.DispAtu.Dados.Conectado;
chbPulverizador.Enabled = atuadorAtivado;
@ -481,6 +481,7 @@ namespace AgroBase.Forms.Operacoes
gridDados.Rows.Add("Barramento 19V", "", "mA");
gridDados.Rows.Add("Barramento 24V", "", "V");
gridDados.Rows.Add("Barramento 24V", "", "mA");
gridDados.Rows.Add("", "", "");
gridDados.Rows.Add("Nível do Reservatório", "", "%");
gridDados.Rows.Add("Massa do Reservatório", "", "Kg");
gridDados.Rows.Add("Volume do Reservatório", "", "L");
@ -490,6 +491,7 @@ namespace AgroBase.Forms.Operacoes
gridDados.Rows.Add("Distancia Estimada Restante", "", "m");
gridDados.Rows.Add("Pressão da Linha", "", "psi");
gridDados.Rows.Add("Potência na Bomba", "", "%");
gridDados.Rows.Add("Bomba Cavitada", "", "");
gridDados.Rows.Add("Vazão Instantanea", "", "mL/s");
gridDados.Rows.Add("Vazão Media", "", "mL/s");
gridDados.Rows.Add("Volume Vazado", "", "mL");
@ -541,25 +543,27 @@ namespace AgroBase.Forms.Operacoes
gridDados.Rows[18].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB19V")?.Corrente ?? 0).ToString("0.00");
gridDados.Rows[19].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB24V")?.Tensao ?? 0).ToString("0.00");
gridDados.Rows[20].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB24V")?.Corrente ?? 0).ToString("0.00");
gridDados.Rows[21].Cells[1].Value = (_Atuador?.PercentualReservatorio ?? 0).ToString("0.00");
gridDados.Rows[22].Cells[1].Value = $"{_Atuador?.MassaReservatorio ?? 0:0.000} ({Variaveis.OperacaoEmAndamento.DispAtu?.Dados?.ContadorCarga?.MassaAtual_Kg_Calc ?? 0:0.000})";
gridDados.Rows[23].Cells[1].Value = $"{_Atuador?.VolumeReservatorio ?? 0:0.000}";
gridDados.Rows[24].Cells[1].Value = (_Atuador?.LPorMetro ?? 0).ToString("0.000");
gridDados.Rows[25].Cells[1].Value = (_Atuador?.LPorMinuto ?? 0).ToString("0.000");
gridDados.Rows[26].Cells[1].Value = TimeSpan.FromMinutes(_Atuador?.TempoEstimadoRestanteMinutos ?? 0).ToString(@"hh\:mm\:ss");
gridDados.Rows[27].Cells[1].Value = (_Atuador?.DistanciaEstimadaRestanteMetros ?? 0).ToString("0.00");
gridDados.Rows[28].Cells[1].Value = (_Atuador?.PressaoLinha ?? 0).ToString("0.00");
gridDados.Rows[29].Cells[1].Value = (_Atuador?.LeituraPotenciaBomba ?? 0).ToString("0.00");
gridDados.Rows[30].Cells[1].Value = $"{_Atuador?.VazaoInstantanea ?? 0:0.000} ({Variaveis.OperacaoEmAndamento.DispAtu?.Dados?.VazaoFluxoMLpSInstantaneaCalc:0.000})";
gridDados.Rows[31].Cells[1].Value = $"{_Atuador?.VazaoMedia ?? 0:0.000}";
gridDados.Rows[32].Cells[1].Value = (_Atuador?.VolumeVazaoMl ?? 0).ToString("0.00");
gridDados.Rows[33].Cells[1].Value = (_Atuador?.AnguloBarraEsquerda ?? 0).ToString("0.00");
gridDados.Rows[34].Cells[1].Value = (_Atuador?.AnguloBarraDireita ?? 0).ToString("0.00");
gridDados.Rows[35].Cells[1].Value = (Variaveis.OperacaoEmAndamento.DispAtu?.Dados?.ContadorCarga?.AgitadorCalda?._Potencia ?? 0).ToString("0.00");
gridDados.Rows[36].Cells[1].Value = "";
gridDados.Rows[37].Cells[1].Value = (_IMU?.InclinacaoLateral ?? 0).ToString("0.00");
gridDados.Rows[38].Cells[1].Value = (_IMU?.InclinacaoFrontal ?? 0).ToString("0.00");
gridDados.Rows[39].Cells[1].Value = (_IMU?.Rotacao ?? 0).ToString("0.00");
gridDados.Rows[21].Cells[1].Value = "";
gridDados.Rows[22].Cells[1].Value = (_Atuador?.PercentualReservatorio ?? 0).ToString("0.00");
gridDados.Rows[23].Cells[1].Value = $"{_Atuador?.MassaReservatorio ?? 0:0.000} ({Variaveis.OperacaoEmAndamento.DispAtu?.Dados?.ContadorCarga?.MassaAtual_Kg_Calc ?? 0:0.000})";
gridDados.Rows[24].Cells[1].Value = $"{_Atuador?.VolumeReservatorio ?? 0:0.000}";
gridDados.Rows[25].Cells[1].Value = (_Atuador?.LPorMetro ?? 0).ToString("0.000");
gridDados.Rows[26].Cells[1].Value = (_Atuador?.LPorMinuto ?? 0).ToString("0.000");
gridDados.Rows[27].Cells[1].Value = TimeSpan.FromMinutes(_Atuador?.TempoEstimadoRestanteMinutos ?? 0).ToString(@"hh\:mm\:ss");
gridDados.Rows[28].Cells[1].Value = (_Atuador?.DistanciaEstimadaRestanteMetros ?? 0).ToString("0.00");
gridDados.Rows[29].Cells[1].Value = (_Atuador?.PressaoLinha ?? 0).ToString("0.00");
gridDados.Rows[30].Cells[1].Value = (_Atuador?.LeituraPotenciaBomba ?? 0).ToString("0.00");
gridDados.Rows[31].Cells[1].Value = (_Atuador?.BombaCavitada ?? false) ? "Sim" : "Não";
gridDados.Rows[32].Cells[1].Value = $"{_Atuador?.VazaoInstantanea ?? 0:0.000} ({Variaveis.OperacaoEmAndamento.DispAtu?.Dados?.VazaoFluxoMLpSInstantaneaCalc:0.000})";
gridDados.Rows[33].Cells[1].Value = $"{_Atuador?.VazaoMedia ?? 0:0.000}";
gridDados.Rows[34].Cells[1].Value = (_Atuador?.VolumeVazaoMl ?? 0).ToString("0.00");
gridDados.Rows[35].Cells[1].Value = (_Atuador?.AnguloBarraEsquerda ?? 0).ToString("0.00");
gridDados.Rows[36].Cells[1].Value = (_Atuador?.AnguloBarraDireita ?? 0).ToString("0.00");
gridDados.Rows[37].Cells[1].Value = (Variaveis.OperacaoEmAndamento.DispAtu?.Dados?.ContadorCarga?.AgitadorCalda?._Potencia ?? 0).ToString("0.00");
gridDados.Rows[38].Cells[1].Value = "";
gridDados.Rows[39].Cells[1].Value = (_IMU?.InclinacaoLateral ?? 0).ToString("0.00");
gridDados.Rows[40].Cells[1].Value = (_IMU?.InclinacaoFrontal ?? 0).ToString("0.00");
gridDados.Rows[41].Cells[1].Value = (_IMU?.Rotacao ?? 0).ToString("0.00");
}
#endregion
@ -583,7 +587,7 @@ namespace AgroBase.Forms.Operacoes
{
var Atuador = Variaveis.OperacaoEmAndamento.DispAtu;
nudPressaoSP.Value = Convert.ToInt32(Variaveis.OperacaoEmAndamento.Parametros.Controle.AtuPressaoLinha);
nudPotenciaSP.Value = (decimal)(Atuador.Dados?.ContadorCarga?.AgitadorCalda?.PotenciaSP ?? 0);
nudPotenciaSP.Value = 100;
int panelWidth = pnlAtuadores.Width;
int circleDiameter = 40; // Diâmetro dos círculos grandes

View File

@ -828,16 +828,16 @@ namespace AgroBase.Models.Modules
bool configurarTodos = !DadosLeitura.Conectado && Conectar;
// Adicionar configurações dos Sensores que devem ser aferidos
var sensoresConfig = SensoresConfig(Conectar, configurarTodos);
config.AddRange(sensoresConfig);
//var sensoresConfig = SensoresConfig(Conectar, configurarTodos);
//config.AddRange(sensoresConfig);
// Adicionar configurações dos Bicos
var bicosConfig = BicosConfig(Conectar, configurarTodos);
config.AddRange(bicosConfig);
//var bicosConfig = BicosConfig(Conectar, configurarTodos);
//config.AddRange(bicosConfig);
// Adicionar configurações das Bombas
var bombasConfig = BombasConfig(Conectar, configurarTodos);
config.AddRange(bombasConfig);
//var bombasConfig = BombasConfig(Conectar, configurarTodos);
//config.AddRange(bombasConfig);
return config;
}

View File

@ -2168,20 +2168,20 @@ namespace AgroBase.Models.Modules
bool configurarTodos = !DadosLeitura.Conectado && Conectar;
// Adicionar configurações dos Sinaleiros
var sinaleirosConfig = SinaleirosConfig(Conectar, configurarTodos);
config.AddRange(sinaleirosConfig);
//var sinaleirosConfig = SinaleirosConfig(Conectar, configurarTodos);
//config.AddRange(sinaleirosConfig);
// Adicionar configurações dos Servos
var servosConfig = ServosConfig(Conectar, configurarTodos);
config.AddRange(servosConfig);
//var servosConfig = ServosConfig(Conectar, configurarTodos);
//config.AddRange(servosConfig);
// Adicionar configurações dos Reles
var relesConfig = RelesConfig(Conectar, configurarTodos);
config.AddRange(relesConfig);
//var relesConfig = RelesConfig(Conectar, configurarTodos);
//config.AddRange(relesConfig);
// Adicionar configurações dos Sensores que devem ser aferidos
var sensoresConfig = SensoresConfig(Conectar, configurarTodos);
config.AddRange(sensoresConfig);
//var sensoresConfig = SensoresConfig(Conectar, configurarTodos);
//config.AddRange(sensoresConfig);
// Adicionar configurações do LoRa
if (Variaveis.OperacaoEmAndamento.Parametros.ModulosMandatorios.Any(x => x.Dispositivo == T_Code.Lra && x.Mandatorio && x.Utilizar) && (!loRaService.Conectado || !loRaService.Configurado || configurarTodos))

View File

@ -96,6 +96,15 @@ namespace AgroBase.Comum
Location = new System.Drawing.Point() { X = 28, Y = 27 },
Size = new System.Drawing.Size() { Height = 17, Width = 42 }
};
Button btnReiniciar = new Button()
{
Name = $"btn{_Nome}Reiniciar",
Text = "Reiniciar",
Location = new System.Drawing.Point() { X = 28, Y = 27 },
Size = new System.Drawing.Size() { Height = 24, Width = 89 }
};
btnReiniciar.Click -= btnReiniciar_Click;
btnReiniciar.Click += btnReiniciar_Click;
Label lblBaudRate = new Label()
{
Name = "lbl" + _Nome + "Bau",
@ -266,8 +275,9 @@ namespace AgroBase.Comum
//tmrLogsDispositivo = new AsyncTaskTimerModel("tmrLogsDispositivo_" + Dispositivo.ToString(), tmrLogsDispositivo_Tick, 1000);
//tmrLogsDispositivo.Start();
gpbItem.Controls.Add(lblPorta);
gpbItem.Controls.Add(lblBaudRate);
//gpbItem.Controls.Add(lblPorta);
//gpbItem.Controls.Add(lblBaudRate);
gpbItem.Controls.Add(btnReiniciar);
gpbItem.Controls.Add(lblAmostragem);
gpbItem.Controls.Add(nudAmostragem);
gpbItem.Controls.Add(lblDispositivos);
@ -283,6 +293,14 @@ namespace AgroBase.Comum
return gpbItem;
}
private void btnReiniciar_Click(object sender, EventArgs e)
{
if (Dispositivo == T_Code.Sen)
GeneralJoystick.EnviarComandoSensoriamento(S_Code.sMOD, "", Status: true);
else if (Dispositivo == T_Code.Atu)
GeneralJoystick.EnviarComandoAtuador(S_Code.sMOD, "", Status: true);
}
private void btnPinout_Click(object sender, EventArgs e)
{
if (frmPin != null)

View File

@ -289,11 +289,11 @@ void ProcessarCfg(std::vector<uint8_t> data) {
_TaxaAmostragem = taxa;
RequisitarDados = requisitar;
if (pinoSDA != PINO_INVALIDO && pinoSCL != PINO_INVALIDO) {
if (I2CService::DefinirPinos(pinoSDA, pinoSCL) || !I2CService::I2CIniciado) {
inicializarDependenciasI2C();
}
}
//if (pinoSDA != PINO_INVALIDO && pinoSCL != PINO_INVALIDO) {
// if (I2CService::DefinirPinos(pinoSDA, pinoSCL) || !I2CService::I2CIniciado) {
// inicializarDependenciasI2C();
// }
//}
vTaskDelay(pdMS_TO_TICKS(100));

View File

@ -97,7 +97,7 @@ class Rele_v2 : public ComponenteCAN {
}
private:
bool DebugMode = true;
bool DebugMode = false;
bool AtuacaoNivelAlto = true;
Estado _Status = Desligado;

View File

@ -96,7 +96,7 @@ class SensorMagnetico_v2 : public ComponenteCAN {
}
private:
bool DebugMode = true;
bool DebugMode = false;
static const uint8_t REG_RAW_ANGLE = 0x0C;
void MostrarLog(String mensagem) {

View File

@ -100,7 +100,7 @@ class ServoAgro_v2 : public ComponenteCAN {
private:
bool DebugMode = true;
bool DebugMode = false;
Servo _Servo;
int _Angulo = 0;

View File

@ -334,11 +334,11 @@ void ProcessarCfg(std::vector<uint8_t> data) {
_TaxaAmostragem = taxa;
RequisitarDados = requisitar;
if (pinoSDA != PINO_INVALIDO && pinoSCL != PINO_INVALIDO) {
if (I2CService::DefinirPinos(pinoSDA, pinoSCL) || !I2CService::I2CIniciado) {
inicializarDependenciasI2C();
}
}
//if (pinoSDA != PINO_INVALIDO && pinoSCL != PINO_INVALIDO) {
// if (I2CService::DefinirPinos(pinoSDA, pinoSCL) || !I2CService::I2CIniciado) {
// inicializarDependenciasI2C();
// }
//}
vTaskDelay(pdMS_TO_TICKS(100));