ajustado eixo imu traseiro, refletido parametros recebidos da base na ihm, corrigido status desejado da bomba no atuador ao iniciar, watchdog para finalizar calibragem travada, retorno a base reinicia mpc, iniciar operacao nao zera leituras, verificacao da orientacao real do corredor

This commit is contained in:
Diego Freitas 2026-08-10 18:36:11 -03:00
parent 63cc8d7e5e
commit f5645ce227
13 changed files with 334 additions and 79 deletions

View File

@ -44,6 +44,12 @@ namespace AgroBase.Forms.IHM.Operacao.Parametros
this.paramAlturaArea = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField();
this.paramErvasOn = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField();
this.paramErvasOff = new AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField();
this.cabecaModeloLayout = new System.Windows.Forms.TableLayoutPanel();
this.lblCabecaModelo = new System.Windows.Forms.Label();
this.cmbCabecaModelo = new System.Windows.Forms.ComboBox();
this.classeAlvoLayout = new System.Windows.Forms.TableLayoutPanel();
this.lblClasseAlvo = new System.Windows.Forms.Label();
this.cmbClasseAlvo = new System.Windows.Forms.ComboBox();
this.rootLayout.SuspendLayout();
this.pnlAgitador.SuspendLayout();
this.agitadorLayout.SuspendLayout();
@ -52,6 +58,8 @@ namespace AgroBase.Forms.IHM.Operacao.Parametros
this.pulverizacaoLayout.SuspendLayout();
this.pulverizacaoHeaderLayout.SuspendLayout();
this.parametrosLayout.SuspendLayout();
this.cabecaModeloLayout.SuspendLayout();
this.classeAlvoLayout.SuspendLayout();
this.SuspendLayout();
//
// rootLayout
@ -370,14 +378,17 @@ namespace AgroBase.Forms.IHM.Operacao.Parametros
this.parametrosLayout.Controls.Add(this.paramAlturaArea, 1, 1);
this.parametrosLayout.Controls.Add(this.paramErvasOn, 0, 2);
this.parametrosLayout.Controls.Add(this.paramErvasOff, 1, 2);
this.parametrosLayout.Controls.Add(this.cabecaModeloLayout, 0, 3);
this.parametrosLayout.Controls.Add(this.classeAlvoLayout, 1, 3);
this.parametrosLayout.Dock = System.Windows.Forms.DockStyle.Fill;
this.parametrosLayout.Location = new System.Drawing.Point(0, 60);
this.parametrosLayout.Margin = new System.Windows.Forms.Padding(0);
this.parametrosLayout.Name = "parametrosLayout";
this.parametrosLayout.RowCount = 3;
this.parametrosLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33F));
this.parametrosLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33F));
this.parametrosLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.34F));
this.parametrosLayout.RowCount = 4;
this.parametrosLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.parametrosLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.parametrosLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.parametrosLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.parametrosLayout.Size = new System.Drawing.Size(437, 210);
this.parametrosLayout.TabIndex = 2;
//
@ -397,10 +408,10 @@ namespace AgroBase.Forms.IHM.Operacao.Parametros
0,
0,
0});
this.paramBicosEmUso.MinimumSize = new System.Drawing.Size(0, 60);
this.paramBicosEmUso.MinimumSize = new System.Drawing.Size(0, 45);
this.paramBicosEmUso.Name = "paramBicosEmUso";
this.paramBicosEmUso.Padding = new System.Windows.Forms.Padding(7, 5, 7, 5);
this.paramBicosEmUso.Size = new System.Drawing.Size(212, 63);
this.paramBicosEmUso.Padding = new System.Windows.Forms.Padding(4, 2, 4, 3);
this.paramBicosEmUso.Size = new System.Drawing.Size(212, 46);
this.paramBicosEmUso.TabIndex = 0;
this.paramBicosEmUso.Titulo = "Bicos em uso";
this.paramBicosEmUso.Unidade = "";
@ -421,10 +432,10 @@ namespace AgroBase.Forms.IHM.Operacao.Parametros
0,
0,
0});
this.paramPressaoLinha.MinimumSize = new System.Drawing.Size(0, 60);
this.paramPressaoLinha.MinimumSize = new System.Drawing.Size(0, 45);
this.paramPressaoLinha.Name = "paramPressaoLinha";
this.paramPressaoLinha.Padding = new System.Windows.Forms.Padding(7, 5, 7, 5);
this.paramPressaoLinha.Size = new System.Drawing.Size(213, 63);
this.paramPressaoLinha.Padding = new System.Windows.Forms.Padding(4, 2, 4, 3);
this.paramPressaoLinha.Size = new System.Drawing.Size(213, 46);
this.paramPressaoLinha.TabIndex = 1;
this.paramPressaoLinha.Titulo = "Pressão da linha";
this.paramPressaoLinha.Unidade = "psi";
@ -438,12 +449,12 @@ namespace AgroBase.Forms.IHM.Operacao.Parametros
//
this.paramInicioTela.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(36)))), ((int)(((byte)(41)))));
this.paramInicioTela.Dock = System.Windows.Forms.DockStyle.Fill;
this.paramInicioTela.Location = new System.Drawing.Point(2, 71);
this.paramInicioTela.Location = new System.Drawing.Point(2, 54);
this.paramInicioTela.Margin = new System.Windows.Forms.Padding(2, 2, 4, 4);
this.paramInicioTela.MinimumSize = new System.Drawing.Size(0, 60);
this.paramInicioTela.MinimumSize = new System.Drawing.Size(0, 45);
this.paramInicioTela.Name = "paramInicioTela";
this.paramInicioTela.Padding = new System.Windows.Forms.Padding(7, 5, 7, 5);
this.paramInicioTela.Size = new System.Drawing.Size(212, 63);
this.paramInicioTela.Padding = new System.Windows.Forms.Padding(4, 2, 4, 3);
this.paramInicioTela.Size = new System.Drawing.Size(212, 46);
this.paramInicioTela.TabIndex = 2;
this.paramInicioTela.Titulo = "Início da atuação";
this.paramInicioTela.Unidade = "%";
@ -457,17 +468,17 @@ namespace AgroBase.Forms.IHM.Operacao.Parametros
//
this.paramAlturaArea.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(36)))), ((int)(((byte)(41)))));
this.paramAlturaArea.Dock = System.Windows.Forms.DockStyle.Fill;
this.paramAlturaArea.Location = new System.Drawing.Point(222, 71);
this.paramAlturaArea.Location = new System.Drawing.Point(222, 54);
this.paramAlturaArea.Margin = new System.Windows.Forms.Padding(4, 2, 2, 4);
this.paramAlturaArea.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.paramAlturaArea.MinimumSize = new System.Drawing.Size(0, 60);
this.paramAlturaArea.MinimumSize = new System.Drawing.Size(0, 45);
this.paramAlturaArea.Name = "paramAlturaArea";
this.paramAlturaArea.Padding = new System.Windows.Forms.Padding(7, 5, 7, 5);
this.paramAlturaArea.Size = new System.Drawing.Size(213, 63);
this.paramAlturaArea.Padding = new System.Windows.Forms.Padding(4, 2, 4, 3);
this.paramAlturaArea.Size = new System.Drawing.Size(213, 46);
this.paramAlturaArea.TabIndex = 3;
this.paramAlturaArea.Titulo = "Altura da área";
this.paramAlturaArea.Unidade = "%";
@ -487,12 +498,12 @@ namespace AgroBase.Forms.IHM.Operacao.Parametros
0,
0,
65536});
this.paramErvasOn.Location = new System.Drawing.Point(2, 140);
this.paramErvasOn.Location = new System.Drawing.Point(2, 106);
this.paramErvasOn.Margin = new System.Windows.Forms.Padding(2, 2, 4, 0);
this.paramErvasOn.MinimumSize = new System.Drawing.Size(0, 60);
this.paramErvasOn.MinimumSize = new System.Drawing.Size(0, 45);
this.paramErvasOn.Name = "paramErvasOn";
this.paramErvasOn.Padding = new System.Windows.Forms.Padding(7, 5, 7, 5);
this.paramErvasOn.Size = new System.Drawing.Size(212, 70);
this.paramErvasOn.Padding = new System.Windows.Forms.Padding(4, 2, 4, 3);
this.paramErvasOn.Size = new System.Drawing.Size(212, 50);
this.paramErvasOn.TabIndex = 4;
this.paramErvasOn.Titulo = "Ervas para ligar";
this.paramErvasOn.Unidade = "%";
@ -512,12 +523,12 @@ namespace AgroBase.Forms.IHM.Operacao.Parametros
0,
0,
65536});
this.paramErvasOff.Location = new System.Drawing.Point(222, 140);
this.paramErvasOff.Location = new System.Drawing.Point(222, 106);
this.paramErvasOff.Margin = new System.Windows.Forms.Padding(4, 2, 2, 0);
this.paramErvasOff.MinimumSize = new System.Drawing.Size(0, 60);
this.paramErvasOff.MinimumSize = new System.Drawing.Size(0, 45);
this.paramErvasOff.Name = "paramErvasOff";
this.paramErvasOff.Padding = new System.Windows.Forms.Padding(7, 5, 7, 5);
this.paramErvasOff.Size = new System.Drawing.Size(213, 70);
this.paramErvasOff.Padding = new System.Windows.Forms.Padding(4, 2, 4, 3);
this.paramErvasOff.Size = new System.Drawing.Size(213, 50);
this.paramErvasOff.TabIndex = 5;
this.paramErvasOff.Titulo = "Ervas para desligar";
this.paramErvasOff.Unidade = "%";
@ -527,6 +538,100 @@ namespace AgroBase.Forms.IHM.Operacao.Parametros
0,
65536});
//
// cabecaModeloLayout
//
this.cabecaModeloLayout.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(36)))), ((int)(((byte)(41)))));
this.cabecaModeloLayout.ColumnCount = 1;
this.cabecaModeloLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.cabecaModeloLayout.Controls.Add(this.lblCabecaModelo, 0, 0);
this.cabecaModeloLayout.Controls.Add(this.cmbCabecaModelo, 0, 1);
this.cabecaModeloLayout.Dock = System.Windows.Forms.DockStyle.Fill;
this.cabecaModeloLayout.Location = new System.Drawing.Point(2, 158);
this.cabecaModeloLayout.Margin = new System.Windows.Forms.Padding(2, 2, 4, 0);
this.cabecaModeloLayout.Name = "cabecaModeloLayout";
this.cabecaModeloLayout.Padding = new System.Windows.Forms.Padding(7, 2, 7, 3);
this.cabecaModeloLayout.RowCount = 2;
this.cabecaModeloLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 17F));
this.cabecaModeloLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.cabecaModeloLayout.Size = new System.Drawing.Size(212, 52);
this.cabecaModeloLayout.TabIndex = 6;
//
// lblCabecaModelo
//
this.lblCabecaModelo.AutoEllipsis = true;
this.lblCabecaModelo.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblCabecaModelo.Font = new System.Drawing.Font("Segoe UI", 7F);
this.lblCabecaModelo.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(164)))), ((int)(((byte)(174)))), ((int)(((byte)(181)))));
this.lblCabecaModelo.Location = new System.Drawing.Point(7, 2);
this.lblCabecaModelo.Margin = new System.Windows.Forms.Padding(0);
this.lblCabecaModelo.Name = "lblCabecaModelo";
this.lblCabecaModelo.Size = new System.Drawing.Size(198, 17);
this.lblCabecaModelo.TabIndex = 0;
this.lblCabecaModelo.Text = "Cabeça de segmentação";
this.lblCabecaModelo.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// cmbCabecaModelo
//
this.cmbCabecaModelo.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(38)))), ((int)(((byte)(45)))), ((int)(((byte)(50)))));
this.cmbCabecaModelo.Dock = System.Windows.Forms.DockStyle.Fill;
this.cmbCabecaModelo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbCabecaModelo.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.cmbCabecaModelo.Font = new System.Drawing.Font("Segoe UI", 8F);
this.cmbCabecaModelo.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(241)))), ((int)(((byte)(245)))), ((int)(((byte)(247)))));
this.cmbCabecaModelo.FormattingEnabled = true;
this.cmbCabecaModelo.Location = new System.Drawing.Point(7, 19);
this.cmbCabecaModelo.Margin = new System.Windows.Forms.Padding(0);
this.cmbCabecaModelo.Name = "cmbCabecaModelo";
this.cmbCabecaModelo.Size = new System.Drawing.Size(198, 21);
this.cmbCabecaModelo.TabIndex = 1;
//
// classeAlvoLayout
//
this.classeAlvoLayout.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(36)))), ((int)(((byte)(41)))));
this.classeAlvoLayout.ColumnCount = 1;
this.classeAlvoLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.classeAlvoLayout.Controls.Add(this.lblClasseAlvo, 0, 0);
this.classeAlvoLayout.Controls.Add(this.cmbClasseAlvo, 0, 1);
this.classeAlvoLayout.Dock = System.Windows.Forms.DockStyle.Fill;
this.classeAlvoLayout.Location = new System.Drawing.Point(222, 158);
this.classeAlvoLayout.Margin = new System.Windows.Forms.Padding(4, 2, 2, 0);
this.classeAlvoLayout.Name = "classeAlvoLayout";
this.classeAlvoLayout.Padding = new System.Windows.Forms.Padding(7, 2, 7, 3);
this.classeAlvoLayout.RowCount = 2;
this.classeAlvoLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 17F));
this.classeAlvoLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.classeAlvoLayout.Size = new System.Drawing.Size(213, 52);
this.classeAlvoLayout.TabIndex = 7;
//
// lblClasseAlvo
//
this.lblClasseAlvo.AutoEllipsis = true;
this.lblClasseAlvo.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblClasseAlvo.Font = new System.Drawing.Font("Segoe UI", 7F);
this.lblClasseAlvo.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(164)))), ((int)(((byte)(174)))), ((int)(((byte)(181)))));
this.lblClasseAlvo.Location = new System.Drawing.Point(7, 2);
this.lblClasseAlvo.Margin = new System.Windows.Forms.Padding(0);
this.lblClasseAlvo.Name = "lblClasseAlvo";
this.lblClasseAlvo.Size = new System.Drawing.Size(199, 17);
this.lblClasseAlvo.TabIndex = 0;
this.lblClasseAlvo.Text = "Classe alvo";
this.lblClasseAlvo.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// cmbClasseAlvo
//
this.cmbClasseAlvo.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(38)))), ((int)(((byte)(45)))), ((int)(((byte)(50)))));
this.cmbClasseAlvo.Dock = System.Windows.Forms.DockStyle.Fill;
this.cmbClasseAlvo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbClasseAlvo.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.cmbClasseAlvo.Font = new System.Drawing.Font("Segoe UI", 8F);
this.cmbClasseAlvo.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(241)))), ((int)(((byte)(245)))), ((int)(((byte)(247)))));
this.cmbClasseAlvo.FormattingEnabled = true;
this.cmbClasseAlvo.Location = new System.Drawing.Point(7, 19);
this.cmbClasseAlvo.Margin = new System.Windows.Forms.Padding(0);
this.cmbClasseAlvo.Name = "cmbClasseAlvo";
this.cmbClasseAlvo.Size = new System.Drawing.Size(199, 21);
this.cmbClasseAlvo.TabIndex = 1;
//
// ucParametrosAtuador
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
@ -544,6 +649,8 @@ namespace AgroBase.Forms.IHM.Operacao.Parametros
this.pulverizacaoLayout.ResumeLayout(false);
this.pulverizacaoHeaderLayout.ResumeLayout(false);
this.parametrosLayout.ResumeLayout(false);
this.cabecaModeloLayout.ResumeLayout(false);
this.classeAlvoLayout.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -573,5 +680,11 @@ namespace AgroBase.Forms.IHM.Operacao.Parametros
private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField paramAlturaArea;
private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField paramErvasOn;
private AgroBase.Forms.IHM.Operacao.Parametros.Controls.HmiCompactNumericField paramErvasOff;
private System.Windows.Forms.TableLayoutPanel cabecaModeloLayout;
private System.Windows.Forms.Label lblCabecaModelo;
private System.Windows.Forms.ComboBox cmbCabecaModelo;
private System.Windows.Forms.TableLayoutPanel classeAlvoLayout;
private System.Windows.Forms.Label lblClasseAlvo;
private System.Windows.Forms.ComboBox cmbClasseAlvo;
}
}

View File

@ -12,6 +12,14 @@ namespace AgroBase.Forms.IHM.Operacao.Parametros
public ucParametrosAtuador()
{
InitializeComponent();
cmbCabecaModelo.Items.Clear();
cmbCabecaModelo.Items.AddRange(Enum.GetNames(typeof(Enums.CabecasModelo)));
cmbCabecaModelo.SelectedIndex = 0;
cmbClasseAlvo.Items.Clear();
cmbClasseAlvo.Items.AddRange(new string[] { "chao", "cana", "erva" });
cmbClasseAlvo.SelectedIndex = 2;
VincularEventos();
}
@ -31,6 +39,9 @@ namespace AgroBase.Forms.IHM.Operacao.Parametros
paramAlturaArea.ValueChanged += Controle_Alterado;
paramErvasOn.ValueChanged += Controle_Alterado;
paramErvasOff.ValueChanged += Controle_Alterado;
cmbCabecaModelo.SelectedValueChanged += Controle_Alterado;
cmbClasseAlvo.SelectedValueChanged += Controle_Alterado;
}
public void DefinirOperacao(OperacaoModel operacao)
@ -61,6 +72,9 @@ namespace AgroBase.Forms.IHM.Operacao.Parametros
paramAlturaArea.Value = (decimal)(parametros?.AtuAlturaAreaPulverizacao ?? 0);
paramErvasOn.Value = (decimal)(parametros?.AtuPercentualErvasBicoOn ?? 0);
paramErvasOff.Value = (decimal)(parametros?.AtuPercentualErvasBicoOff ?? 0);
cmbCabecaModelo.SelectedIndex = (int)(parametros?.AtuModeloCabeca ?? 0);
cmbClasseAlvo.SelectedItem = parametros?.AtuClasseAlvo ?? "erva";
}
finally
{
@ -94,6 +108,9 @@ namespace AgroBase.Forms.IHM.Operacao.Parametros
parametros.AtuAlturaAreaPulverizacao = (double)paramAlturaArea.Value;
parametros.AtuPercentualErvasBicoOn = (double)paramErvasOn.Value;
parametros.AtuPercentualErvasBicoOff = (double)paramErvasOff.Value;
parametros.AtuModeloCabeca = (Enums.CabecasModelo)cmbCabecaModelo.SelectedIndex;
parametros.AtuClasseAlvo = cmbClasseAlvo.Text;
}
}
}

View File

@ -256,6 +256,7 @@ namespace AgroBase.Forms.IHM.Operacao
public void AtualizarDadosControle(OperacaoControleModel controle, OperacaoParametrosControleModel parametros)
{
_modoManualAtivado = parametros.ControleManualAcionado;
bool operacaoManual = (op?.Parametros?.Modo ?? ModoOperacao.NaoDefinido) == ModoOperacao.Manual;
btnControleManual.Enabled = !operacaoManual;
MudarStatusModoManual(_modoManualAtivado || operacaoManual);

View File

@ -340,7 +340,7 @@ namespace AgroBase.Forms.IHM.Operacao
this.txtDescricaoOperacao.Margin = new System.Windows.Forms.Padding(3, 1, 5, 3);
this.txtDescricaoOperacao.MaxLength = 120;
this.txtDescricaoOperacao.Name = "txtDescricaoOperacao";
this.txtDescricaoOperacao.Size = new System.Drawing.Size(190, 29);
this.txtDescricaoOperacao.Size = new System.Drawing.Size(190, 21);
this.txtDescricaoOperacao.TabIndex = 1;
//
// campoRegistroLayout
@ -406,6 +406,7 @@ namespace AgroBase.Forms.IHM.Operacao
this.btnRedefinir.IconText = "↻";
this.btnRedefinir.Location = new System.Drawing.Point(491, 0);
this.btnRedefinir.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.btnRedefinir.MinimumSize = new System.Drawing.Size(60, 34);
this.btnRedefinir.Name = "btnRedefinir";
this.btnRedefinir.Size = new System.Drawing.Size(132, 50);
this.btnRedefinir.TabIndex = 3;
@ -422,6 +423,7 @@ namespace AgroBase.Forms.IHM.Operacao
this.btnSalvar.IconText = "▣";
this.btnSalvar.Location = new System.Drawing.Point(626, 0);
this.btnSalvar.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.btnSalvar.MinimumSize = new System.Drawing.Size(60, 34);
this.btnSalvar.Name = "btnSalvar";
this.btnSalvar.Size = new System.Drawing.Size(142, 50);
this.btnSalvar.TabIndex = 4;
@ -442,6 +444,7 @@ namespace AgroBase.Forms.IHM.Operacao
this.footerLayout.ResumeLayout(false);
this.campoModoLayout.ResumeLayout(false);
this.campoDescricaoLayout.ResumeLayout(false);
this.campoDescricaoLayout.PerformLayout();
this.campoRegistroLayout.ResumeLayout(false);
this.ResumeLayout(false);

View File

@ -1,8 +1,6 @@
using AgroBase.Forms.IHM.Controls;
using AgroBase.Forms.IHM.Operacao.Parametros;
using AgroBase.Models;
using AgroBase.Models.Components;
using Emgu.CV;
using System;
using System.Collections.Generic;
using System.Drawing;
@ -282,6 +280,10 @@ namespace AgroBase.Forms.IHM.Operacao
}
public void AtualizarParametrosTela(OperacaoModel op)
{
DefinirOperacaoParametrizando(op, true);
}
public void AtualizarDadosTela()
{
operacaoParametrizando?.Mapa?.AtualizarInteratividadeMapaAsync(parametrizacao: true);

View File

@ -21,7 +21,7 @@ namespace AgroBase.Forms.IHM
public frmMenu frmMenu = new frmMenu();
private frmAjustes _frmAjustes;
private frmDiagnosticos _frmDiagnosticos;
private frmOperacao _frmOperacao;
public frmOperacao _frmOperacao;
//private frmTestes _frmTestes;
private StatusOperacaoControl cardBateria;

View File

@ -73,6 +73,11 @@ namespace AgroBase.Forms.IHM
}
}
public void AtualizarParametrosTela(OperacaoModel op)
{
_ucParametros.AtualizarParametrosTela(op);
}

View File

@ -349,7 +349,7 @@ namespace AgroBase.Forms
double anguloControle = 0.0;
TipoMovimentoDirecional tipoMovimento = Variaveis.OperacaoEmAndamento.Controle.TipoMovimento;
double veloccidade = (new List<StatusOperacao>() { StatusOperacao.Concluido, StatusOperacao.Aguardando, StatusOperacao.Parametrizando }.Contains(Variaveis.OperacaoEmAndamento.Sensoriamento.Operacao.StatusOperacaoAtual)) ? 0 : velocidadeCarroMs;
double veloccidade = Variaveis.OperacaoEmAndamento.Sensoriamento.Operacao.StatusOperacaoAtual != StatusOperacao.EmAndamento ? 0 : velocidadeCarroMs;
var tipoControle = Variaveis.OperacaoEmAndamento.Parametros.Controle.DirTipoMovimento;

View File

@ -1233,18 +1233,21 @@ namespace AgroBase.Models.Modules
Dados.PercentualErvasTerreno = 0;
Dados.BombasPressurizadoras.ForEach(x => x.Funcoes = x.Funcoes.Distinct().ToList());
ReiniciarLeituras(Dados);
ReiniciarLeituras(Dados, true);
PrepararAtuadorParaOperacao(Dados, resetarComandos: true);
}
public void ReiniciarLeituras(AtuadorModel Dados)
public void ReiniciarLeituras(AtuadorModel Dados, bool apagarValoresLeituras)
{
Dados.Sensores.ForEach(x =>
{
if (apagarValoresLeituras)
{
x.ValoresLeituras.ForEach(l =>
{
l.atual = new CanCommandFreqModel<dynamic>();
});
}
});
Dados.BicosPulverizadores.ForEach(x =>
@ -1267,10 +1270,13 @@ namespace AgroBase.Models.Modules
x.ReiniciarHistoricoAtuacao(true);
if (apagarValoresLeituras)
{
x.ValoresLeituras.ForEach(l =>
{
l.atual = new CanCommandFreqModel<dynamic>();
});
}
});
Dados.BombasPressurizadoras.ForEach(x =>
@ -1289,10 +1295,13 @@ namespace AgroBase.Models.Modules
x.UltimaPressaoDesejada = 0;
x.UltimoComandoEnviado = DateTime.MinValue;
if (apagarValoresLeituras)
{
x.ValoresLeituras.ForEach(l =>
{
l.atual = new CanCommandFreqModel<dynamic>();
});
}
});
Dados.VolumeVazadoML = 0;
@ -1967,10 +1976,13 @@ namespace AgroBase.Models.Modules
dispAtu.AdicionarMensagemFila(bomba.ID_Num, dado, dado, data, false);
if (ehComandoEstado)
{
bomba.UltimoComandoEnviado = DateTime.Now;
bomba.UltimoStatusDesejado = status;
if (potencia.HasValue) bomba.UltimaPotenciaDesejada = potencia.Value;
if (pressao.HasValue) bomba.UltimaPressaoDesejada = pressao.Value;
}
if (!setarControle)
{

View File

@ -1,4 +1,5 @@
using AgroBase.Comum;
using AgroBase.Forms;
using AgroBase.Forms.Operacoes;
using AgroBase.Models.Modules;
using AgroBase.Models.Operacoes;
@ -220,6 +221,28 @@ namespace AgroBase.Models
return itens.TryGetValue(id, out bool ok) && ok;
}
}
internal bool TodosModulosMandatoriosCalibrados()
{
var op = Sensoriamento?.Operacao;
var obrigatorios = Parametros?.ModulosMandatorios?
.Where(x => x.Mandatorio && x.Utilizar)
.ToList();
if (op?.ModsCalibragem == null || obrigatorios == null || obrigatorios.Count == 0)
{
return false;
}
foreach (var modulo in obrigatorios)
{
if (!op.ModsCalibragem.TryGetValue(modulo.Dispositivo, out var itens) || itens == null || itens.Count == 0 || itens.Any(x => !x.Value))
{
return false;
}
}
return true;
}
private readonly object _eventosLock = new object();
@ -297,6 +320,17 @@ namespace AgroBase.Models
Sensoriamento?.AtualizarDados();
}
}
internal void SubstituirOperacaoSnapshot(OperacaoSensoriamentoConjuntoModel conjunto, OperacaoSensoriamentoLogModel novoSnapshot)
{
if (conjunto == null || novoSnapshot == null)
return;
lock (_sensoriamentoStateLock)
{
novoSnapshot.CopiarEstadoRuntimeDe(conjunto.Operacao);
conjunto.Operacao = novoSnapshot;
}
}
public Form frmOperacao { get; set; }
@ -307,7 +341,7 @@ namespace AgroBase.Models
public double SimulacaoRpmControle { get; set; } = 0;
public int TempoIniciarOperacao { get; set; } = 10;
public int TempoAguardarRetomada { get; set; } = 5;
public int TempoAguardarRetomada { get; set; } = 10;
public string ID { get; set; }
@ -368,7 +402,6 @@ namespace AgroBase.Models
}
#region PARAMETRIZACAO
private bool EhOperacaoAtual(string origem)
@ -1285,6 +1318,8 @@ namespace AgroBase.Models
RedisService.AtualizarCampos(CtxKey.DadosOperacao, ("configurado", false));
frmInstancial.frmIHM?._frmOperacao?.AtualizarParametrosTela(novaOp);
return novaOp;
}
@ -1324,8 +1359,8 @@ namespace AgroBase.Models
op.AtualizarSensoriamentoSeguro();
dispMvd?.Dados?.ReiniciarLeituras(dispMvd?.Dados);
dispAtu?.Dados?.ReiniciarLeituras(dispAtu?.Dados);
dispSen?.Dados?.ReiniciarLeituras(dispSen?.Dados);
dispAtu?.Dados?.ReiniciarLeituras(dispAtu?.Dados, false);
//dispSen?.Dados?.ReiniciarLeituras(dispSen?.Dados);
dispAtu?.Dados?.PrepararAtuadorParaOperacao();
op.Sensoriamento.Operacao.ModsCalibragem = new Dictionary<T_Code, Dictionary<string, bool>>()
@ -1358,9 +1393,9 @@ namespace AgroBase.Models
op.idxLog = 0;
op.IniciarTimerLogsOperacao();
await op.RealizarCalibragemInicialAsync(true);
RedisService.Publish(CmdKey.ManagerWorkerRx, JsonConvert.SerializeObject(new { cmd = ManagerWorkerCommandType.IniciarMPC }));
await op.RealizarCalibragemInicialAsync(true);
}
public async Task FinalizarOperacao()
@ -1462,8 +1497,8 @@ namespace AgroBase.Models
op.AtualizarSensoriamentoSeguro();
dispMvd?.Dados?.ReiniciarLeituras(dispMvd.Dados);
dispAtu?.Dados?.ReiniciarLeituras(dispAtu.Dados);
dispSen?.Dados?.ReiniciarLeituras(dispSen.Dados);
dispAtu?.Dados?.ReiniciarLeituras(dispAtu.Dados, false);
//dispSen?.Dados?.ReiniciarLeituras(dispSen.Dados);
RedisService.AtualizarCampos(CtxKey.DadosOperacao, ("configurado", false));
WeedWorkerService.ReiniciarLeituraAnalise();
@ -1514,8 +1549,8 @@ namespace AgroBase.Models
op.ID = "";
dispMvd?.Dados?.ReiniciarLeituras(dispMvd.Dados);
dispAtu?.Dados?.ReiniciarLeituras(dispAtu.Dados);
dispSen?.Dados?.ReiniciarLeituras(dispSen.Dados);
dispAtu?.Dados?.ReiniciarLeituras(dispAtu.Dados, false);
//dispSen?.Dados?.ReiniciarLeituras(dispSen.Dados);
op.Controle.Angulo = 0;
op.Controle.PercentualVelocidadeSP = 0;
@ -2118,15 +2153,17 @@ namespace AgroBase.Models
if (op.Parametros?.Modo == ModoOperacao.Manual)
{
bool carroEmMovimento = op.Controle?.RPM_SP > 0;
var Sonar = op.Sensoriamento?.OperadorVisual;
Sonar?.Resumo?.AtualizarStatusBloqueioManual(Sonar, true);
if (Sonar?.Resumo?.EnviarComandoParada ?? false)
if (carroEmMovimento && (Sonar?.Resumo?.EnviarComandoParada ?? false))
{
Variaveis.MostrarLog($"[OperacaoModel] Deve enviar o comando de parada em tmrLeituras_Tick por trava do Visual Worker: {Sonar?.Analises?.matriz_confianca?.block?.reason}");
GeneralJoystick.PararCarroControle($"Deve enviar o comando de parada em tmrLeituras_Tick por trava do Visual Worker: {Sonar?.Analises?.matriz_confianca?.block?.reason}");
}
if (!op.Sensoriamento.Operacao.OperacaoLiberada)
if (carroEmMovimento &&!op.Sensoriamento.Operacao.OperacaoLiberada)
{
Variaveis.MostrarLog($"[OperacaoModel] Deve enviar o comando de parada em tmrLeituras_Tick por Operacao Bloqueada: {op?.Sensoriamento?.Operacao?.ErroOperacaoLiberada}");
GeneralJoystick.PararCarroControle($"Deve enviar o comando de parada em tmrLeituras_Tick por Operacao Bloqueada: {op?.Sensoriamento?.Operacao?.ErroOperacaoLiberada}");
@ -3138,11 +3175,18 @@ namespace AgroBase.Models
AudioAlertaService.AlertaSonoroPorStatus(op.Sensoriamento.Operacao.StatusOperacaoAtual);
}
if (op.idxLog % 5 == 0 && !op.CalibrandoRuntime && op.PodeTentarCalibragemAutomatica())
if (op.idxLog % 5 == 0)
{
if (!op.CalibrandoRuntime && op.PodeTentarCalibragemAutomatica())
{
op.RegistrarTentativaCalibragem();
_ = Task.Run(async () => await op.RealizarCalibragemInicialAsync(false));
}
if (op.CalibrandoRuntime && op.TodosModulosMandatoriosCalibrados())
{
op.DefinirEstadoCalibragemRuntime(false);
}
}
}
private async Task<bool> SalvarLogsSeguroAsync(bool fim)
@ -4017,7 +4061,7 @@ namespace AgroBase.Models
saude_geral < 80.0 ? StatusModulo.Alerta :
StatusModulo.Operante;
Operacao = operacaoAtualizada;
op.SubstituirOperacaoSnapshot(this, operacaoAtualizada);
if (statusMudou)
{
@ -5265,6 +5309,16 @@ namespace AgroBase.Models
DataInicio = origem.DataInicio;
DataFim = origem.DataFim;
StatusOperacaoAnterior = origem.StatusOperacaoAnterior;
ModsCalibragem =
origem.ModsCalibragem?
.ToDictionary(
x => x.Key,
x => new Dictionary<string, bool>(
x.Value ?? new Dictionary<string, bool>()
)
)
?? new Dictionary<T_Code, Dictionary<string, bool>>();
}

View File

@ -33,8 +33,9 @@ namespace AgroBase.Models
public bool VerificacaoInicialMeioRuaConcluida { get; set; } = false; // Realiza a verificacao inicial para saber se o robo deve comecar a operacao do meio da rua
private int JanelaBuscaAvancoPontos { get; set; } = 14;
private double MargemExtraAvancoM { get; set; } = 0.35;
private double DistanciaConclusaoTrajetoriaM { get; set; } = 3.0;
private double DistanciaConclusaoTrajetoriaM { get; set; } = 2.0;
private double DistanciaRestanteMaximaParaTrocarCorredorM { get; set; } = 1.0;
private double DistanciaExtensaoCorredorM { get; set; } = 0.50;
private int PontosRestantesMaximosParaTrocarCorredor { get; set; } = 0;
private int MaxTentativasRecuperacaoTrajetoria { get; set; } = 3;
private double ToleranciaLateralRecuperacaoM { get; set; } = 1.5;
@ -2011,6 +2012,25 @@ namespace AgroBase.Models
// Remover pontos que estão a menos de 1m de distância
corredor = RemoverPontosMuitoProximos(corredor, DistanciaEntrePontos, primeiraDistancia, DistanciaEntrePontosCurva);
// Estender o corredor 50 cm em cada extremidade
if (corredor.Count >= 2)
{
var primeiroPonto = corredor[0];
var segundoPonto = corredor[1];
var penultimoPonto = corredor[corredor.Count - 2];
var ultimoPonto = corredor[corredor.Count - 1];
double anguloInicial = GPSUtils.CalcularOrientacao(primeiroPonto, segundoPonto);
double anguloAnterior = (anguloInicial + 180.0) % 360.0;
var pontoAntesDoCorredor = GPSUtils.ProjetarPontoDeslocado(primeiroPonto, DistanciaExtensaoCorredorM, anguloAnterior);
double anguloFinal = GPSUtils.CalcularOrientacao(penultimoPonto, ultimoPonto);
var pontoDepoisDoCorredor = GPSUtils.ProjetarPontoDeslocado(ultimoPonto, DistanciaExtensaoCorredorM, anguloFinal);
corredor.Insert(0, pontoAntesDoCorredor);
corredor.Add(pontoDepoisDoCorredor);
}
// Calcular largura média entre as duas ruas
double larguraCorredor = CalcularLarguraMediaDoCorredor(rua1, rua2);
@ -2165,22 +2185,48 @@ namespace AgroBase.Models
};
int idxCorredorDentro = VerificaEquipamentoDentroCorredor(PontoRobo.Posicao);
if (idxCorredorDentro > -1)
if (idxCorredorDentro >= 0 && idxCorredorDentro < Corredores.Count && Corredores[idxCorredorDentro]?.Count >= 2 && PontoRobo.Posicao != null)
{
var corredor = Corredores[idxCorredorDentro];
double orientacaoCorredor = GPSUtils.CalcularOrientacao(corredor[0], corredor[1]);
double difOri = Math.Abs(orientacaoCorredor - PontoRobo.Posicao?.OrientacaoReal ?? 0);
bool alinhado = difOri < 180;
if (idxCorredorDentro % 2 == 0)
double orientacaoRobo = PontoRobo.Posicao.OrientacaoReal;
// Diferença angular circular entre 0° e 180°
double diferencaAngular = Math.Abs(((orientacaoRobo - orientacaoCorredor + 540.0) % 360.0) - 180.0);
// Menos de 90°: robô olha no sentido corredor[0] -> corredor[^1]
// Mais de 90°: robô olha no sentido corredor[^1] -> corredor[0]
bool alinhadoComOrdemCorredor = diferencaAngular < 90.0;
// O extremo considerado é aquele para o qual o robô está olhando
var pontoDestino = alinhadoComOrdemCorredor ? corredor[corredor.Count - 1] : corredor[0];
double distanciaDestino = GPSUtils.DistanciaEntrePontos(PontoRobo.Posicao, pontoDestino);
if (!double.IsNaN(distanciaDestino) && !double.IsInfinity(distanciaDestino) && distanciaDestino > 5.0)
{
direcaoAtual = alinhado ? DirecaoCarroRua.Ida : DirecaoCarroRua.Volta;
/*
* A lista do corredor sempre está no sentido:
* corredor[0] -> corredor[^1].
*
* Nos corredores pares, esse sentido representa Ida.
* Nos corredores ímpares, esse sentido representa Volta.
*/
bool corredorPar = idxCorredorDentro % 2 == 0;
if (alinhadoComOrdemCorredor)
{
direcaoAtual = corredorPar ? DirecaoCarroRua.Ida : DirecaoCarroRua.Volta;
}
else
{
direcaoAtual = alinhado ? DirecaoCarroRua.Volta : DirecaoCarroRua.Ida;
direcaoAtual = corredorPar ? DirecaoCarroRua.Volta : DirecaoCarroRua.Ida;
}
PontoRobo.Direcao = direcaoAtual;
}
}
_trajetoriaFixa.Add(PontoRobo);
@ -2329,7 +2375,7 @@ namespace AgroBase.Models
}
double percentualAcrescimoPontoAberturaCurva = 0.8;
double distancia_projetar = !ultimoCorredor ? (DistanciaProjecaoRua * percentualAcrescimoPontoAberturaCurva) : (DistanciaProjecaoRua * percentualAcrescimoPontoAberturaCurva);
double distancia_projetar = !ultimoCorredor ? (DistanciaProjecaoRua * percentualAcrescimoPontoAberturaCurva) : DistanciaProjecaoRua;
GPSModel ultimoPontoCorredorAtual = CorredorAtual.Last();
double anguloProjetar2 = GPSUtils.CalcularOrientacao(CorredorAtual.Skip(CorredorAtual.Count() - 2).FirstOrDefault(), ultimoPontoCorredorAtual);
@ -2684,6 +2730,8 @@ namespace AgroBase.Models
}
RedisService.AtualizarCampos(CtxKey.DadosOperacao, ("configurado", false));
RedisService.Publish(CmdKey.ManagerWorkerRx, JsonConvert.SerializeObject(new { cmd = ManagerWorkerCommandType.IniciarMPC }));
}
private (bool valido, List<GPSModel> pontos) GerarTrajetoriaRetornoAutomatico(GPSModel baseGps)

View File

@ -1176,7 +1176,7 @@ namespace AgroBase.Services.Operadores
tempo_com_potencia = bomba.TempoComPotencia,
potencia_media_ativa = bomba.PotenciaMediaAtiva,
comando_solicitado = bomba.ComandoAtuar,
comando_solicitado = bomba.Comandar && bomba.ComandoAtuar,
status_desejado_fisico = bomba.UltimoStatusDesejado,
potencia_desejada_fisica = bomba.UltimaPotenciaDesejada,
pressao_desejada_fisica = bomba.UltimaPressaoDesejada,

View File

@ -182,7 +182,7 @@ class CameraMultispectral:
modo=self.imu_modo,
gyro_unidade="rad_s",
referencial_robo="r,p,y",
sinal_roll=1.0,
sinal_roll=-1.0,
sinal_pitch=-1.0,
sinal_yaw=-1.0,
)