diff --git a/AgroBase/AgroBase/Forms/Operacoes/frmParametrizacaoOperacao.Designer.cs b/AgroBase/AgroBase/Forms/Operacoes/frmParametrizacaoOperacao.Designer.cs index 67cf71a82..1d6089bf2 100644 --- a/AgroBase/AgroBase/Forms/Operacoes/frmParametrizacaoOperacao.Designer.cs +++ b/AgroBase/AgroBase/Forms/Operacoes/frmParametrizacaoOperacao.Designer.cs @@ -33,6 +33,9 @@ this.lblOperacao = new System.Windows.Forms.Label(); this.gpbModulos = new System.Windows.Forms.GroupBox(); this.gpbP_Knt = new System.Windows.Forms.GroupBox(); + this.lblAnteciparManobraM = new System.Windows.Forms.Label(); + this.txtAnteciparManobraM = new System.Windows.Forms.TextBox(); + this.lblAnteciparManobra = new System.Windows.Forms.Label(); this.chbMatrizCusto = new System.Windows.Forms.CheckBox(); this.chbImuParadaInclinacao = new System.Windows.Forms.CheckBox(); this.chbOakParadaObstaculo = new System.Windows.Forms.CheckBox(); @@ -88,9 +91,7 @@ this.nudCapacidadereservatorio = new System.Windows.Forms.NumericUpDown(); this.lblUnCapcaidadereservatorio = new System.Windows.Forms.Label(); this.lblCapacidadereservatorio = new System.Windows.Forms.Label(); - this.lblAnteciparManobra = new System.Windows.Forms.Label(); - this.txtAnteciparManobraM = new System.Windows.Forms.TextBox(); - this.lblAnteciparManobraM = new System.Windows.Forms.Label(); + this.chbFrenagem = new System.Windows.Forms.CheckBox(); this.gpbModulos.SuspendLayout(); this.gpbP_Knt.SuspendLayout(); this.gpbP_Sen.SuspendLayout(); @@ -165,6 +166,7 @@ // // gpbP_Knt // + this.gpbP_Knt.Controls.Add(this.chbFrenagem); this.gpbP_Knt.Controls.Add(this.lblAnteciparManobraM); this.gpbP_Knt.Controls.Add(this.txtAnteciparManobraM); this.gpbP_Knt.Controls.Add(this.lblAnteciparManobra); @@ -179,11 +181,40 @@ this.gpbP_Knt.TabStop = false; this.gpbP_Knt.Text = "Ajustes"; // + // lblAnteciparManobraM + // + this.lblAnteciparManobraM.AutoSize = true; + this.lblAnteciparManobraM.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblAnteciparManobraM.Location = new System.Drawing.Point(89, 158); + this.lblAnteciparManobraM.Name = "lblAnteciparManobraM"; + this.lblAnteciparManobraM.Size = new System.Drawing.Size(21, 18); + this.lblAnteciparManobraM.TabIndex = 17; + this.lblAnteciparManobraM.Text = "m"; + // + // txtAnteciparManobraM + // + this.txtAnteciparManobraM.Location = new System.Drawing.Point(10, 151); + this.txtAnteciparManobraM.Name = "txtAnteciparManobraM"; + this.txtAnteciparManobraM.Size = new System.Drawing.Size(73, 26); + this.txtAnteciparManobraM.TabIndex = 16; + this.txtAnteciparManobraM.Text = "0"; + this.txtAnteciparManobraM.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // lblAnteciparManobra + // + this.lblAnteciparManobra.AutoSize = true; + this.lblAnteciparManobra.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblAnteciparManobra.Location = new System.Drawing.Point(7, 131); + this.lblAnteciparManobra.Name = "lblAnteciparManobra"; + this.lblAnteciparManobra.Size = new System.Drawing.Size(132, 18); + this.lblAnteciparManobra.TabIndex = 15; + this.lblAnteciparManobra.Text = "Antecipar manobra"; + // // chbMatrizCusto // this.chbMatrizCusto.AutoSize = true; this.chbMatrizCusto.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F); - this.chbMatrizCusto.Location = new System.Drawing.Point(10, 100); + this.chbMatrizCusto.Location = new System.Drawing.Point(10, 80); this.chbMatrizCusto.Margin = new System.Windows.Forms.Padding(6); this.chbMatrizCusto.Name = "chbMatrizCusto"; this.chbMatrizCusto.Size = new System.Drawing.Size(132, 22); @@ -195,7 +226,7 @@ // this.chbImuParadaInclinacao.AutoSize = true; this.chbImuParadaInclinacao.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.chbImuParadaInclinacao.Location = new System.Drawing.Point(10, 66); + this.chbImuParadaInclinacao.Location = new System.Drawing.Point(9, 56); this.chbImuParadaInclinacao.Margin = new System.Windows.Forms.Padding(6); this.chbImuParadaInclinacao.Name = "chbImuParadaInclinacao"; this.chbImuParadaInclinacao.Size = new System.Drawing.Size(170, 22); @@ -813,34 +844,17 @@ this.lblCapacidadereservatorio.TabIndex = 9; this.lblCapacidadereservatorio.Text = "Capacidade reservatório"; // - // lblAnteciparManobra + // chbFrenagem // - this.lblAnteciparManobra.AutoSize = true; - this.lblAnteciparManobra.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblAnteciparManobra.Location = new System.Drawing.Point(7, 131); - this.lblAnteciparManobra.Name = "lblAnteciparManobra"; - this.lblAnteciparManobra.Size = new System.Drawing.Size(132, 18); - this.lblAnteciparManobra.TabIndex = 15; - this.lblAnteciparManobra.Text = "Antecipar manobra"; - // - // txtAnteciparManobraM - // - this.txtAnteciparManobraM.Location = new System.Drawing.Point(10, 151); - this.txtAnteciparManobraM.Name = "txtAnteciparManobraM"; - this.txtAnteciparManobraM.Size = new System.Drawing.Size(73, 26); - this.txtAnteciparManobraM.TabIndex = 16; - this.txtAnteciparManobraM.Text = "0"; - this.txtAnteciparManobraM.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - // - // lblAnteciparManobraM - // - this.lblAnteciparManobraM.AutoSize = true; - this.lblAnteciparManobraM.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblAnteciparManobraM.Location = new System.Drawing.Point(89, 158); - this.lblAnteciparManobraM.Name = "lblAnteciparManobraM"; - this.lblAnteciparManobraM.Size = new System.Drawing.Size(21, 18); - this.lblAnteciparManobraM.TabIndex = 17; - this.lblAnteciparManobraM.Text = "m"; + this.chbFrenagem.AutoSize = true; + this.chbFrenagem.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F); + this.chbFrenagem.Location = new System.Drawing.Point(10, 104); + this.chbFrenagem.Margin = new System.Windows.Forms.Padding(6); + this.chbFrenagem.Name = "chbFrenagem"; + this.chbFrenagem.Size = new System.Drawing.Size(153, 22); + this.chbFrenagem.TabIndex = 18; + this.chbFrenagem.Text = "Frenagem ao parar"; + this.chbFrenagem.UseVisualStyleBackColor = true; // // frmParametrizacaoOperacao // @@ -954,5 +968,6 @@ private System.Windows.Forms.Label lblAnteciparManobraM; private System.Windows.Forms.TextBox txtAnteciparManobraM; private System.Windows.Forms.Label lblAnteciparManobra; + private System.Windows.Forms.CheckBox chbFrenagem; } } \ No newline at end of file diff --git a/AgroBase/AgroBase/Forms/Operacoes/frmParametrizacaoOperacao.cs b/AgroBase/AgroBase/Forms/Operacoes/frmParametrizacaoOperacao.cs index 2082a0606..ae385bfb2 100644 --- a/AgroBase/AgroBase/Forms/Operacoes/frmParametrizacaoOperacao.cs +++ b/AgroBase/AgroBase/Forms/Operacoes/frmParametrizacaoOperacao.cs @@ -77,6 +77,9 @@ namespace AgroBase.Forms.Operacoes chbImuParadaInclinacao.Checked = _Parametros.Controle.ImuParadaPorInclinacao; chbOakParadaObstaculo.Checked = _Parametros.Controle.OakParadaPorObstaculo; + chbMatrizCusto.Checked = _Parametros.Controle.MpcMatrizCusto; + chbFrenagem.Checked = _Parametros.Controle.FrenagemAutomaticaAoParar; + txtAnteciparManobraM.Text = _Parametros.Controle.AnteciparManobraCorredorM.ToString(); } @@ -134,6 +137,8 @@ namespace AgroBase.Forms.Operacoes { Variaveis.OperacaoEmAndamento.Parametros.Controle.ImuParadaPorInclinacao = chbImuParadaInclinacao.Checked; Variaveis.OperacaoEmAndamento.Parametros.Controle.OakParadaPorObstaculo = chbOakParadaObstaculo.Checked; + Variaveis.OperacaoEmAndamento.Parametros.Controle.MpcMatrizCusto = chbMatrizCusto.Checked; + Variaveis.OperacaoEmAndamento.Parametros.Controle.FrenagemAutomaticaAoParar = chbFrenagem.Checked; Variaveis.OperacaoEmAndamento.Parametros.ModulosMandatorios = ModulosMandatorios.Where(x => x.Utilizar).ToList(); Variaveis.OperacaoEmAndamento.Parametros.Controle.PulverizadorAutomatico = chbPulverizadorAutomatico.Checked; diff --git a/AgroBase/AgroBase/Forms/Operacoes/frmResultadosOperacao.Designer.cs b/AgroBase/AgroBase/Forms/Operacoes/frmResultadosOperacao.Designer.cs index 98c35da96..bb211da08 100644 --- a/AgroBase/AgroBase/Forms/Operacoes/frmResultadosOperacao.Designer.cs +++ b/AgroBase/AgroBase/Forms/Operacoes/frmResultadosOperacao.Designer.cs @@ -89,14 +89,15 @@ this.panel2 = new System.Windows.Forms.Panel(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabSituacao = new System.Windows.Forms.TabPage(); + this.rtbImpedimento = new System.Windows.Forms.RichTextBox(); this.label117 = new System.Windows.Forms.Label(); this.tvwFalhas = new System.Windows.Forms.TreeView(); - this.lblManual = new System.Windows.Forms.Label(); - this.lblOperacao = new System.Windows.Forms.Label(); this.pnlManual = new System.Windows.Forms.Panel(); + this.lblManual = new System.Windows.Forms.Label(); this.pnlOperacao = new System.Windows.Forms.Panel(); - this.lblAutomatico = new System.Windows.Forms.Label(); + this.lblOperacao = new System.Windows.Forms.Label(); this.pnlAutomatico = new System.Windows.Forms.Panel(); + this.lblAutomatico = new System.Windows.Forms.Label(); this.tabDirecional = new System.Windows.Forms.TabPage(); this.txtDIR_Status_DT = new System.Windows.Forms.TextBox(); this.label126 = new System.Windows.Forms.Label(); @@ -387,17 +388,17 @@ this.txtSonarDistanciaObstaculo = new System.Windows.Forms.TextBox(); this.label97 = new System.Windows.Forms.Label(); this.tabSegmentacao = new System.Windows.Forms.TabPage(); - this.txtTempoManobrando = new System.Windows.Forms.TextBox(); + this.txtDistanciaRestante = new System.Windows.Forms.TextBox(); this.label142 = new System.Windows.Forms.Label(); - this.txtTempoDirecionando = new System.Windows.Forms.TextBox(); + this.txtDistanciaForaRuaContinuo = new System.Windows.Forms.TextBox(); this.label143 = new System.Windows.Forms.Label(); - this.txtTempoParado = new System.Windows.Forms.TextBox(); + this.txtCorredorConfirmado = new System.Windows.Forms.TextBox(); this.label144 = new System.Windows.Forms.Label(); - this.txtTempoSaindoRua = new System.Windows.Forms.TextBox(); + this.txtJaAntecipado = new System.Windows.Forms.TextBox(); this.label139 = new System.Windows.Forms.Label(); - this.txtTempoCaminhandoRua = new System.Windows.Forms.TextBox(); + this.txtTempoDentroRuaTotal = new System.Windows.Forms.TextBox(); this.label140 = new System.Windows.Forms.Label(); - this.txtTempoEntrandoRua = new System.Windows.Forms.TextBox(); + this.txtTempoForaRuaContinuo = new System.Windows.Forms.TextBox(); this.label141 = new System.Windows.Forms.Label(); this.chbDesenharCorredor = new System.Windows.Forms.CheckBox(); this.txtCamCaminhoStatusCarro = new System.Windows.Forms.TextBox(); @@ -408,6 +409,11 @@ this.label101 = new System.Windows.Forms.Label(); this.pnlCaminho = new System.Windows.Forms.Panel(); this.tabCPU = new System.Windows.Forms.TabPage(); + this.lblVentilacaoTemperatura = new System.Windows.Forms.Label(); + this.lblVentilacaoRLOUT = new System.Windows.Forms.Label(); + this.lblVentilacaoRLIN = new System.Windows.Forms.Label(); + this.lblVentilacaoModo = new System.Windows.Forms.Label(); + this.label145 = new System.Windows.Forms.Label(); this.gpbCpu_Analise = new System.Windows.Forms.GroupBox(); this.txtCpu_Maximo = new System.Windows.Forms.TextBox(); this.label107 = new System.Windows.Forms.Label(); @@ -525,12 +531,6 @@ this.label36 = new System.Windows.Forms.Label(); this.txtMomento = new System.Windows.Forms.TextBox(); this.btnPlay = new System.Windows.Forms.Button(); - this.rtbImpedimento = new System.Windows.Forms.RichTextBox(); - this.label145 = new System.Windows.Forms.Label(); - this.lblVentilacaoModo = new System.Windows.Forms.Label(); - this.lblVentilacaoRLIN = new System.Windows.Forms.Label(); - this.lblVentilacaoRLOUT = new System.Windows.Forms.Label(); - this.lblVentilacaoTemperatura = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.trbMomento)).BeginInit(); this.panel1.SuspendLayout(); this.tabControl4.SuspendLayout(); @@ -1025,6 +1025,16 @@ this.tabSituacao.Text = "Situação"; this.tabSituacao.UseVisualStyleBackColor = true; // + // rtbImpedimento + // + this.rtbImpedimento.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.rtbImpedimento.Location = new System.Drawing.Point(9, 6); + this.rtbImpedimento.Name = "rtbImpedimento"; + this.rtbImpedimento.ReadOnly = true; + this.rtbImpedimento.Size = new System.Drawing.Size(425, 145); + this.rtbImpedimento.TabIndex = 20; + this.rtbImpedimento.Text = ""; + // // label117 // this.label117.AutoSize = true; @@ -1045,6 +1055,14 @@ this.tvwFalhas.Size = new System.Drawing.Size(484, 342); this.tvwFalhas.TabIndex = 18; // + // pnlManual + // + this.pnlManual.Controls.Add(this.lblManual); + this.pnlManual.Location = new System.Drawing.Point(440, 6); + this.pnlManual.Name = "pnlManual"; + this.pnlManual.Size = new System.Drawing.Size(50, 50); + this.pnlManual.TabIndex = 14; + // // lblManual // this.lblManual.AutoSize = true; @@ -1055,6 +1073,14 @@ this.lblManual.TabIndex = 16; this.lblManual.Text = "MN"; // + // pnlOperacao + // + this.pnlOperacao.Controls.Add(this.lblOperacao); + this.pnlOperacao.Location = new System.Drawing.Point(440, 62); + this.pnlOperacao.Name = "pnlOperacao"; + this.pnlOperacao.Size = new System.Drawing.Size(50, 50); + this.pnlOperacao.TabIndex = 15; + // // lblOperacao // this.lblOperacao.AutoSize = true; @@ -1065,21 +1091,13 @@ this.lblOperacao.TabIndex = 17; this.lblOperacao.Text = "OP"; // - // pnlManual + // pnlAutomatico // - this.pnlManual.Controls.Add(this.lblManual); - this.pnlManual.Location = new System.Drawing.Point(440, 6); - this.pnlManual.Name = "pnlManual"; - this.pnlManual.Size = new System.Drawing.Size(50, 50); - this.pnlManual.TabIndex = 14; - // - // pnlOperacao - // - this.pnlOperacao.Controls.Add(this.lblOperacao); - this.pnlOperacao.Location = new System.Drawing.Point(440, 62); - this.pnlOperacao.Name = "pnlOperacao"; - this.pnlOperacao.Size = new System.Drawing.Size(50, 50); - this.pnlOperacao.TabIndex = 15; + this.pnlAutomatico.Controls.Add(this.lblAutomatico); + this.pnlAutomatico.Location = new System.Drawing.Point(440, 118); + this.pnlAutomatico.Name = "pnlAutomatico"; + this.pnlAutomatico.Size = new System.Drawing.Size(50, 50); + this.pnlAutomatico.TabIndex = 12; // // lblAutomatico // @@ -1091,14 +1109,6 @@ this.lblAutomatico.TabIndex = 13; this.lblAutomatico.Text = "AT"; // - // pnlAutomatico - // - this.pnlAutomatico.Controls.Add(this.lblAutomatico); - this.pnlAutomatico.Location = new System.Drawing.Point(440, 118); - this.pnlAutomatico.Name = "pnlAutomatico"; - this.pnlAutomatico.Size = new System.Drawing.Size(50, 50); - this.pnlAutomatico.TabIndex = 12; - // // tabDirecional // this.tabDirecional.Controls.Add(this.txtDIR_Status_DT); @@ -4331,17 +4341,17 @@ // // tabSegmentacao // - this.tabSegmentacao.Controls.Add(this.txtTempoManobrando); + this.tabSegmentacao.Controls.Add(this.txtDistanciaRestante); this.tabSegmentacao.Controls.Add(this.label142); - this.tabSegmentacao.Controls.Add(this.txtTempoDirecionando); + this.tabSegmentacao.Controls.Add(this.txtDistanciaForaRuaContinuo); this.tabSegmentacao.Controls.Add(this.label143); - this.tabSegmentacao.Controls.Add(this.txtTempoParado); + this.tabSegmentacao.Controls.Add(this.txtCorredorConfirmado); this.tabSegmentacao.Controls.Add(this.label144); - this.tabSegmentacao.Controls.Add(this.txtTempoSaindoRua); + this.tabSegmentacao.Controls.Add(this.txtJaAntecipado); this.tabSegmentacao.Controls.Add(this.label139); - this.tabSegmentacao.Controls.Add(this.txtTempoCaminhandoRua); + this.tabSegmentacao.Controls.Add(this.txtTempoDentroRuaTotal); this.tabSegmentacao.Controls.Add(this.label140); - this.tabSegmentacao.Controls.Add(this.txtTempoEntrandoRua); + this.tabSegmentacao.Controls.Add(this.txtTempoForaRuaContinuo); this.tabSegmentacao.Controls.Add(this.label141); this.tabSegmentacao.Controls.Add(this.chbDesenharCorredor); this.tabSegmentacao.Controls.Add(this.txtCamCaminhoStatusCarro); @@ -4359,15 +4369,15 @@ this.tabSegmentacao.Text = "Segmentação"; this.tabSegmentacao.UseVisualStyleBackColor = true; // - // txtTempoManobrando + // txtDistanciaRestante // - this.txtTempoManobrando.Location = new System.Drawing.Point(253, 498); - this.txtTempoManobrando.Margin = new System.Windows.Forms.Padding(2); - this.txtTempoManobrando.Name = "txtTempoManobrando"; - this.txtTempoManobrando.ReadOnly = true; - this.txtTempoManobrando.Size = new System.Drawing.Size(101, 20); - this.txtTempoManobrando.TabIndex = 59; - this.txtTempoManobrando.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.txtDistanciaRestante.Location = new System.Drawing.Point(253, 498); + this.txtDistanciaRestante.Margin = new System.Windows.Forms.Padding(2); + this.txtDistanciaRestante.Name = "txtDistanciaRestante"; + this.txtDistanciaRestante.ReadOnly = true; + this.txtDistanciaRestante.Size = new System.Drawing.Size(101, 20); + this.txtDistanciaRestante.TabIndex = 59; + this.txtDistanciaRestante.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // label142 // @@ -4375,19 +4385,19 @@ this.label142.Location = new System.Drawing.Point(250, 482); this.label142.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.label142.Name = "label142"; - this.label142.Size = new System.Drawing.Size(103, 13); + this.label142.Size = new System.Drawing.Size(97, 13); this.label142.TabIndex = 58; - this.label142.Text = "Tempo Manobrando"; + this.label142.Text = "Distancia Restante"; // - // txtTempoDirecionando + // txtDistanciaForaRuaContinuo // - this.txtTempoDirecionando.Location = new System.Drawing.Point(253, 460); - this.txtTempoDirecionando.Margin = new System.Windows.Forms.Padding(2); - this.txtTempoDirecionando.Name = "txtTempoDirecionando"; - this.txtTempoDirecionando.ReadOnly = true; - this.txtTempoDirecionando.Size = new System.Drawing.Size(101, 20); - this.txtTempoDirecionando.TabIndex = 57; - this.txtTempoDirecionando.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.txtDistanciaForaRuaContinuo.Location = new System.Drawing.Point(253, 460); + this.txtDistanciaForaRuaContinuo.Margin = new System.Windows.Forms.Padding(2); + this.txtDistanciaForaRuaContinuo.Name = "txtDistanciaForaRuaContinuo"; + this.txtDistanciaForaRuaContinuo.ReadOnly = true; + this.txtDistanciaForaRuaContinuo.Size = new System.Drawing.Size(101, 20); + this.txtDistanciaForaRuaContinuo.TabIndex = 57; + this.txtDistanciaForaRuaContinuo.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // label143 // @@ -4395,19 +4405,19 @@ this.label143.Location = new System.Drawing.Point(250, 444); this.label143.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.label143.Name = "label143"; - this.label143.Size = new System.Drawing.Size(106, 13); + this.label143.Size = new System.Drawing.Size(123, 13); this.label143.TabIndex = 56; - this.label143.Text = "Tempo Direcionando"; + this.label143.Text = "Distancia Fora Rua Cont"; // - // txtTempoParado + // txtCorredorConfirmado // - this.txtTempoParado.Location = new System.Drawing.Point(253, 422); - this.txtTempoParado.Margin = new System.Windows.Forms.Padding(2); - this.txtTempoParado.Name = "txtTempoParado"; - this.txtTempoParado.ReadOnly = true; - this.txtTempoParado.Size = new System.Drawing.Size(101, 20); - this.txtTempoParado.TabIndex = 55; - this.txtTempoParado.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.txtCorredorConfirmado.Location = new System.Drawing.Point(253, 422); + this.txtCorredorConfirmado.Margin = new System.Windows.Forms.Padding(2); + this.txtCorredorConfirmado.Name = "txtCorredorConfirmado"; + this.txtCorredorConfirmado.ReadOnly = true; + this.txtCorredorConfirmado.Size = new System.Drawing.Size(101, 20); + this.txtCorredorConfirmado.TabIndex = 55; + this.txtCorredorConfirmado.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // label144 // @@ -4415,19 +4425,19 @@ this.label144.Location = new System.Drawing.Point(250, 406); this.label144.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.label144.Name = "label144"; - this.label144.Size = new System.Drawing.Size(77, 13); + this.label144.Size = new System.Drawing.Size(103, 13); this.label144.TabIndex = 54; - this.label144.Text = "Tempo Parado"; + this.label144.Text = "Corredor Confirmado"; // - // txtTempoSaindoRua + // txtJaAntecipado // - this.txtTempoSaindoRua.Location = new System.Drawing.Point(126, 497); - this.txtTempoSaindoRua.Margin = new System.Windows.Forms.Padding(2); - this.txtTempoSaindoRua.Name = "txtTempoSaindoRua"; - this.txtTempoSaindoRua.ReadOnly = true; - this.txtTempoSaindoRua.Size = new System.Drawing.Size(101, 20); - this.txtTempoSaindoRua.TabIndex = 53; - this.txtTempoSaindoRua.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.txtJaAntecipado.Location = new System.Drawing.Point(126, 497); + this.txtJaAntecipado.Margin = new System.Windows.Forms.Padding(2); + this.txtJaAntecipado.Name = "txtJaAntecipado"; + this.txtJaAntecipado.ReadOnly = true; + this.txtJaAntecipado.Size = new System.Drawing.Size(101, 20); + this.txtJaAntecipado.TabIndex = 53; + this.txtJaAntecipado.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // label139 // @@ -4435,19 +4445,19 @@ this.label139.Location = new System.Drawing.Point(123, 481); this.label139.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.label139.Name = "label139"; - this.label139.Size = new System.Drawing.Size(93, 13); + this.label139.Size = new System.Drawing.Size(75, 13); this.label139.TabIndex = 52; - this.label139.Text = "TempoSaindoRua"; + this.label139.Text = "Ja Antecipado"; // - // txtTempoCaminhandoRua + // txtTempoDentroRuaTotal // - this.txtTempoCaminhandoRua.Location = new System.Drawing.Point(126, 459); - this.txtTempoCaminhandoRua.Margin = new System.Windows.Forms.Padding(2); - this.txtTempoCaminhandoRua.Name = "txtTempoCaminhandoRua"; - this.txtTempoCaminhandoRua.ReadOnly = true; - this.txtTempoCaminhandoRua.Size = new System.Drawing.Size(101, 20); - this.txtTempoCaminhandoRua.TabIndex = 51; - this.txtTempoCaminhandoRua.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.txtTempoDentroRuaTotal.Location = new System.Drawing.Point(126, 459); + this.txtTempoDentroRuaTotal.Margin = new System.Windows.Forms.Padding(2); + this.txtTempoDentroRuaTotal.Name = "txtTempoDentroRuaTotal"; + this.txtTempoDentroRuaTotal.ReadOnly = true; + this.txtTempoDentroRuaTotal.Size = new System.Drawing.Size(101, 20); + this.txtTempoDentroRuaTotal.TabIndex = 51; + this.txtTempoDentroRuaTotal.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // label140 // @@ -4455,19 +4465,19 @@ this.label140.Location = new System.Drawing.Point(123, 443); this.label140.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.label140.Name = "label140"; - this.label140.Size = new System.Drawing.Size(122, 13); + this.label140.Size = new System.Drawing.Size(98, 13); this.label140.TabIndex = 50; - this.label140.Text = "Tempo CaminhandoRua"; + this.label140.Text = "Tempo Dentro Rua"; // - // txtTempoEntrandoRua + // txtTempoForaRuaContinuo // - this.txtTempoEntrandoRua.Location = new System.Drawing.Point(126, 421); - this.txtTempoEntrandoRua.Margin = new System.Windows.Forms.Padding(2); - this.txtTempoEntrandoRua.Name = "txtTempoEntrandoRua"; - this.txtTempoEntrandoRua.ReadOnly = true; - this.txtTempoEntrandoRua.Size = new System.Drawing.Size(101, 20); - this.txtTempoEntrandoRua.TabIndex = 49; - this.txtTempoEntrandoRua.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.txtTempoForaRuaContinuo.Location = new System.Drawing.Point(126, 421); + this.txtTempoForaRuaContinuo.Margin = new System.Windows.Forms.Padding(2); + this.txtTempoForaRuaContinuo.Name = "txtTempoForaRuaContinuo"; + this.txtTempoForaRuaContinuo.ReadOnly = true; + this.txtTempoForaRuaContinuo.Size = new System.Drawing.Size(101, 20); + this.txtTempoForaRuaContinuo.TabIndex = 49; + this.txtTempoForaRuaContinuo.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // label141 // @@ -4475,9 +4485,9 @@ this.label141.Location = new System.Drawing.Point(123, 405); this.label141.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.label141.Name = "label141"; - this.label141.Size = new System.Drawing.Size(106, 13); + this.label141.Size = new System.Drawing.Size(112, 13); this.label141.TabIndex = 48; - this.label141.Text = "Tempo EntrandoRua"; + this.label141.Text = "Tempo Fora Rua Cont"; // // chbDesenharCorredor // @@ -4577,6 +4587,56 @@ this.tabCPU.Text = "CPU"; this.tabCPU.UseVisualStyleBackColor = true; // + // lblVentilacaoTemperatura + // + this.lblVentilacaoTemperatura.AutoSize = true; + this.lblVentilacaoTemperatura.Location = new System.Drawing.Point(226, 438); + this.lblVentilacaoTemperatura.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.lblVentilacaoTemperatura.Name = "lblVentilacaoTemperatura"; + this.lblVentilacaoTemperatura.Size = new System.Drawing.Size(73, 13); + this.lblVentilacaoTemperatura.TabIndex = 141; + this.lblVentilacaoTemperatura.Text = "Temperatura: "; + // + // lblVentilacaoRLOUT + // + this.lblVentilacaoRLOUT.AutoSize = true; + this.lblVentilacaoRLOUT.Location = new System.Drawing.Point(226, 472); + this.lblVentilacaoRLOUT.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.lblVentilacaoRLOUT.Name = "lblVentilacaoRLOUT"; + this.lblVentilacaoRLOUT.Size = new System.Drawing.Size(50, 13); + this.lblVentilacaoRLOUT.TabIndex = 140; + this.lblVentilacaoRLOUT.Text = "RLOUT: "; + // + // lblVentilacaoRLIN + // + this.lblVentilacaoRLIN.AutoSize = true; + this.lblVentilacaoRLIN.Location = new System.Drawing.Point(226, 455); + this.lblVentilacaoRLIN.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.lblVentilacaoRLIN.Name = "lblVentilacaoRLIN"; + this.lblVentilacaoRLIN.Size = new System.Drawing.Size(38, 13); + this.lblVentilacaoRLIN.TabIndex = 139; + this.lblVentilacaoRLIN.Text = "RLIN: "; + // + // lblVentilacaoModo + // + this.lblVentilacaoModo.AutoSize = true; + this.lblVentilacaoModo.Location = new System.Drawing.Point(226, 422); + this.lblVentilacaoModo.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.lblVentilacaoModo.Name = "lblVentilacaoModo"; + this.lblVentilacaoModo.Size = new System.Drawing.Size(40, 13); + this.lblVentilacaoModo.TabIndex = 138; + this.lblVentilacaoModo.Text = "Modo: "; + // + // label145 + // + this.label145.AutoSize = true; + this.label145.Location = new System.Drawing.Point(226, 406); + this.label145.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label145.Name = "label145"; + this.label145.Size = new System.Drawing.Size(57, 13); + this.label145.TabIndex = 137; + this.label145.Text = "Ventilação"; + // // gpbCpu_Analise // this.gpbCpu_Analise.Controls.Add(this.txtCpu_Maximo); @@ -5848,66 +5908,6 @@ this.btnPlay.UseVisualStyleBackColor = true; this.btnPlay.Click += new System.EventHandler(this.btnPlay_Click); // - // rtbImpedimento - // - this.rtbImpedimento.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.rtbImpedimento.Location = new System.Drawing.Point(9, 6); - this.rtbImpedimento.Name = "rtbImpedimento"; - this.rtbImpedimento.ReadOnly = true; - this.rtbImpedimento.Size = new System.Drawing.Size(425, 145); - this.rtbImpedimento.TabIndex = 20; - this.rtbImpedimento.Text = ""; - // - // label145 - // - this.label145.AutoSize = true; - this.label145.Location = new System.Drawing.Point(226, 406); - this.label145.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); - this.label145.Name = "label145"; - this.label145.Size = new System.Drawing.Size(57, 13); - this.label145.TabIndex = 137; - this.label145.Text = "Ventilação"; - // - // lblVentilacaoModo - // - this.lblVentilacaoModo.AutoSize = true; - this.lblVentilacaoModo.Location = new System.Drawing.Point(226, 422); - this.lblVentilacaoModo.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); - this.lblVentilacaoModo.Name = "lblVentilacaoModo"; - this.lblVentilacaoModo.Size = new System.Drawing.Size(40, 13); - this.lblVentilacaoModo.TabIndex = 138; - this.lblVentilacaoModo.Text = "Modo: "; - // - // lblVentilacaoRLIN - // - this.lblVentilacaoRLIN.AutoSize = true; - this.lblVentilacaoRLIN.Location = new System.Drawing.Point(226, 455); - this.lblVentilacaoRLIN.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); - this.lblVentilacaoRLIN.Name = "lblVentilacaoRLIN"; - this.lblVentilacaoRLIN.Size = new System.Drawing.Size(38, 13); - this.lblVentilacaoRLIN.TabIndex = 139; - this.lblVentilacaoRLIN.Text = "RLIN: "; - // - // lblVentilacaoRLOUT - // - this.lblVentilacaoRLOUT.AutoSize = true; - this.lblVentilacaoRLOUT.Location = new System.Drawing.Point(226, 472); - this.lblVentilacaoRLOUT.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); - this.lblVentilacaoRLOUT.Name = "lblVentilacaoRLOUT"; - this.lblVentilacaoRLOUT.Size = new System.Drawing.Size(50, 13); - this.lblVentilacaoRLOUT.TabIndex = 140; - this.lblVentilacaoRLOUT.Text = "RLOUT: "; - // - // lblVentilacaoTemperatura - // - this.lblVentilacaoTemperatura.AutoSize = true; - this.lblVentilacaoTemperatura.Location = new System.Drawing.Point(226, 438); - this.lblVentilacaoTemperatura.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); - this.lblVentilacaoTemperatura.Name = "lblVentilacaoTemperatura"; - this.lblVentilacaoTemperatura.Size = new System.Drawing.Size(73, 13); - this.lblVentilacaoTemperatura.TabIndex = 141; - this.lblVentilacaoTemperatura.Text = "Temperatura: "; - // // frmResultadosOperacao // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -6505,17 +6505,17 @@ private System.Windows.Forms.DataGridView dtComandosAtu; private System.Windows.Forms.TabPage tabMPC; private System.Windows.Forms.TreeView tvwMPC; - private System.Windows.Forms.TextBox txtTempoManobrando; + private System.Windows.Forms.TextBox txtDistanciaRestante; private System.Windows.Forms.Label label142; - private System.Windows.Forms.TextBox txtTempoDirecionando; + private System.Windows.Forms.TextBox txtDistanciaForaRuaContinuo; private System.Windows.Forms.Label label143; - private System.Windows.Forms.TextBox txtTempoParado; + private System.Windows.Forms.TextBox txtCorredorConfirmado; private System.Windows.Forms.Label label144; - private System.Windows.Forms.TextBox txtTempoSaindoRua; + private System.Windows.Forms.TextBox txtJaAntecipado; private System.Windows.Forms.Label label139; - private System.Windows.Forms.TextBox txtTempoCaminhandoRua; + private System.Windows.Forms.TextBox txtTempoDentroRuaTotal; private System.Windows.Forms.Label label140; - private System.Windows.Forms.TextBox txtTempoEntrandoRua; + private System.Windows.Forms.TextBox txtTempoForaRuaContinuo; private System.Windows.Forms.Label label141; private System.Windows.Forms.TabPage tabTopDown; private System.Windows.Forms.TabPage tabFrontal; diff --git a/AgroBase/AgroBase/Forms/Operacoes/frmResultadosOperacao.cs b/AgroBase/AgroBase/Forms/Operacoes/frmResultadosOperacao.cs index 90c50df82..9aeb40294 100644 --- a/AgroBase/AgroBase/Forms/Operacoes/frmResultadosOperacao.cs +++ b/AgroBase/AgroBase/Forms/Operacoes/frmResultadosOperacao.cs @@ -675,6 +675,20 @@ namespace AgroBase.Forms.Operacoes MostrarValor = true }, new GraficoInterativoSerieModel() + { + Titulo = "V 19v", + Valores = LogsSensoriamento.Select(x => (double?)(x?.Sensores?.FirstOrDefault(y => y.ID.Contains("19V"))?.ValoresLeituras?.FirstOrDefault(z => z.funcao == FuncoesPinout.Tensao)?.atual?.valor) ?? 0).ToList(), + Visivel = true, + MostrarValor = true + }, + new GraficoInterativoSerieModel() + { + Titulo = "A 19v", + Valores = LogsSensoriamento.Select(x => (double?)(x?.Sensores?.FirstOrDefault(y => y.ID.Contains("19V"))?.ValoresLeituras?.FirstOrDefault(z => z.funcao == FuncoesPinout.Corrente)?.atual?.valor) ?? 0).ToList(), + Visivel = true, + MostrarValor = true + }, + new GraficoInterativoSerieModel() { Titulo = "V 24v", Valores = LogsSensoriamento.Select(x => (double?)(x?.Sensores?.FirstOrDefault(y => y.ID.Contains("24V"))?.ValoresLeituras?.FirstOrDefault(z => z.funcao == FuncoesPinout.Tensao)?.atual?.valor) ?? 0).ToList(), @@ -1142,8 +1156,8 @@ namespace AgroBase.Forms.Operacoes lblPercentualBateria.Text = $"Bateria {Log.Bateria.PercentualBateria.ToString("0.00")}%"; FuncoesGlobais.PreencheValorProgressBar(pgbPercentualBateria, Log.Bateria.PercentualBateria); - lblBateriaConsumida.Text = $"Consumido {Log.Bateria.PercentualBateriaConsumida.ToString("0.00")}%"; - FuncoesGlobais.PreencheValorProgressBar(pgbBateriaConsumida, Log.Bateria.PercentualBateriaConsumida); + lblBateriaConsumida.Text = $"Consumido {Log.Bateria.PercentualBateriaConsumidaOperacao.ToString("0.00")}%"; + FuncoesGlobais.PreencheValorProgressBar(pgbBateriaConsumida, Log.Bateria.PercentualBateriaConsumidaOperacao); lblPercentualReservatorio.Text = $"Reservatório {LogAtu.PercentualReservatorio.ToString("0.00")}%"; FuncoesGlobais.PreencheValorProgressBar(pgbPercentualReservatorio, LogAtu.PercentualReservatorio); @@ -1626,19 +1640,12 @@ namespace AgroBase.Forms.Operacoes txtCamCaminhoErroAngular.Text = (Log.OperadorVisual?.Analises?.segmentacao?.erro_angular ?? 0).ToString("0.00"); txtCamCaminhoErroLateral.Text = $"{(Log.OperadorVisual?.Analises?.segmentacao?.erro_lateral_pct ?? 0):F2}% ({CalcularErroLateralPctImagem(Log.OperadorVisual?.Analises?.segmentacao?.width ?? 0, Log.OperadorVisual?.Analises?.segmentacao?.centros_corredor):F2}%)"; txtCamCaminhoStatusCarro.Text = (Log.OperadorVisual?.Analises?.segmentacao?.status_corredor ?? Enums.StatusCarroMapa.Parado).ToString(); - txtTempoEntrandoRua.Text = $"{(Log.Trajetoria?.CorredorAtual?.DadosVisuais?.TempoForaRuaContinuo ?? 0):F2} s"; - txtTempoCaminhandoRua.Text = $"{(Log.Trajetoria?.CorredorAtual?.DadosVisuais?.TempoDentroRuaTotal ?? 0):F2} s"; - txtTempoSaindoRua.Text = $"{(Log.Trajetoria?.CorredorAtual?.DadosVisuais?.JaAntecipado ?? false)}"; - txtTempoParado.Text = $"{(Log.Trajetoria?.CorredorAtual?.DadosVisuais?.CorredorConfirmado ?? false)}"; - txtTempoDirecionando.Text = $"{(Log.Trajetoria?.CorredorAtual?.DadosVisuais?.DistanciaForaRuaContinuo ?? 0):F2} m"; - txtTempoManobrando.Text = $"{(Log.Trajetoria?.CorredorAtual?.DadosVisuais?.DistanciaRestanteAnterior ?? 0):F2} m"; - - //txtTempoEntrandoRua.Text = Log.Trajetoria.CorredorAtual.TempoPorStatus.FirstOrDefault(x => x.Key == Enums.StatusCarroMapa.EntrandoRua).Value.ToString("0.00") + " s"; - //txtTempoCaminhandoRua.Text = Log.Trajetoria.CorredorAtual.TempoPorStatus.FirstOrDefault(x => x.Key == Enums.StatusCarroMapa.CaminhandoRua).Value.ToString("0.00") + " s"; - //txtTempoSaindoRua.Text = Log.Trajetoria.CorredorAtual.TempoPorStatus.FirstOrDefault(x => x.Key == Enums.StatusCarroMapa.SaindoRua).Value.ToString("0.00") + " s"; - //txtTempoParado.Text = Log.Trajetoria.CorredorAtual.TempoPorStatus.FirstOrDefault(x => x.Key == Enums.StatusCarroMapa.Parado).Value.ToString("0.00") + " s"; - //txtTempoDirecionando.Text = Log.Trajetoria.CorredorAtual.TempoPorStatus.FirstOrDefault(x => x.Key == Enums.StatusCarroMapa.Direcionando).Value.ToString("0.00") + " s"; - //txtTempoManobrando.Text = Log.Trajetoria.CorredorAtual.TempoPorStatus.FirstOrDefault(x => x.Key == Enums.StatusCarroMapa.Manobrando).Value.ToString("0.00") + " s"; + txtTempoForaRuaContinuo.Text = $"{(Log.Trajetoria?.CorredorAtual?.DadosVisuais?.TempoForaRuaContinuo ?? 0):F2} s"; + txtTempoDentroRuaTotal.Text = $"{(Log.Trajetoria?.CorredorAtual?.DadosVisuais?.TempoDentroRuaTotal ?? 0):F2} s"; + txtJaAntecipado.Text = (Log.Trajetoria?.CorredorAtual?.DadosVisuais?.JaAntecipado ?? false) ? "Sim" : "Não"; + txtCorredorConfirmado.Text = (Log.Trajetoria?.CorredorAtual?.DadosVisuais?.CorredorConfirmado ?? false) ? "Sim" : "Não"; + txtDistanciaForaRuaContinuo.Text = $"{(Log.Trajetoria?.CorredorAtual?.DadosVisuais?.DistanciaForaRuaContinuo ?? 0):F2} m"; + txtDistanciaRestante.Text = $"{(Log.Trajetoria?.CorredorAtual?.DadosVisuais?.DistanciaRestanteAnterior ?? 0):F2} m"; pnlCaminho.BackgroundImage = CarregarImagemCamera(pathImagensCaminho, "_segmentacao"); pnlCaminho.BackgroundImageLayout = ImageLayout.Zoom; diff --git a/AgroBase/AgroBase/Models/GeneralJoystick.cs b/AgroBase/AgroBase/Models/GeneralJoystick.cs index 95bf109e9..7b63561ab 100644 --- a/AgroBase/AgroBase/Models/GeneralJoystick.cs +++ b/AgroBase/AgroBase/Models/GeneralJoystick.cs @@ -911,7 +911,7 @@ namespace AgroBase { List ComandosImpedidos = new List(); var Sonar = Variaveis.OperacaoEmAndamento.Sensoriamento.OperadorVisual; - var DeveParar = (Sonar?.Iniciado ?? false) && (Sonar?.Resumo?.DeveParar ?? false); + var DeveParar = (Sonar?.Resumo?.DeveParar ?? false); if (DeveParar) { ComandosImpedidos.Add(Keys.Up); diff --git a/AgroBase/AgroBase/Models/Operacoes/OperacaoModel.cs b/AgroBase/AgroBase/Models/Operacoes/OperacaoModel.cs index 2dcb32ec1..e903cb5ae 100644 --- a/AgroBase/AgroBase/Models/Operacoes/OperacaoModel.cs +++ b/AgroBase/AgroBase/Models/Operacoes/OperacaoModel.cs @@ -3181,6 +3181,7 @@ namespace AgroBase.Models BmsLigado = BmsLigado, _dt = _dt, PercentualBateriaConsumida = PercentualBateriaConsumida, + PercentualBateriaConsumidaOperacao = PercentualBateriaConsumidaOperacao, PercentualBateria = PercentualBateria, CorrenteInstantanea = CorrenteInstantanea, TensaoInstantanea = TensaoInstantanea, diff --git a/AgroBase/AgroBase/Models/Operadores/VisualWorkerModel.cs b/AgroBase/AgroBase/Models/Operadores/VisualWorkerModel.cs index 26a085bad..498a24473 100644 --- a/AgroBase/AgroBase/Models/Operadores/VisualWorkerModel.cs +++ b/AgroBase/AgroBase/Models/Operadores/VisualWorkerModel.cs @@ -630,6 +630,7 @@ namespace AgroBase.Models.Operadores public string reason { get; set; } public string reason_detail { get; set; } public VisualWorkerMessageMatrizConfiancaBlockDecisionModel decision { get; set; } + public VisualWorkerMessageMatrizConfiancaBlockDecisionTrendModel trend { get; set; } public VisualWorkerMessageMatrizConfiancaBlockModel Clone() { @@ -641,7 +642,8 @@ namespace AgroBase.Models.Operadores blocked_raw = blocked_raw, reason = reason, reason_detail = reason_detail, - decision = decision.Clone() + decision = decision?.Clone(), + trend = trend?.Clone() }; } } @@ -655,6 +657,9 @@ namespace AgroBase.Models.Operadores public int frames_off { get; set; } public int N_on { get; set; } public int N_off { get; set; } + public string mode { get; set; } + public double risk_ema { get; set; } + public int frames_risk_on { get; set; } public VisualWorkerMessageMatrizConfiancaBlockDecisionModel Clone() { @@ -667,6 +672,38 @@ namespace AgroBase.Models.Operadores frames_off = frames_off, N_on = N_on, N_off = N_off, + mode = mode, + frames_risk_on = frames_risk_on, + risk_ema = risk_ema + }; + } + } + + public class VisualWorkerMessageMatrizConfiancaBlockDecisionTrendModel + { + public double risk_raw { get; set; } + public double risk_ema { get; set; } + public string band { get; set; } + public double delta_central { get; set; } + public double delta_side_bias { get; set; } + public double approaching_obs_m { get; set; } + public double approaching_det_m { get; set; } + public int frames_risk_on { get; set; } + public int frames_risk_off { get; set; } + + public VisualWorkerMessageMatrizConfiancaBlockDecisionTrendModel Clone() + { + return new VisualWorkerMessageMatrizConfiancaBlockDecisionTrendModel() + { + risk_raw = risk_raw, + risk_ema = risk_ema, + band = band, + delta_central = delta_central, + delta_side_bias = delta_side_bias, + approaching_obs_m = approaching_obs_m, + approaching_det_m = approaching_det_m, + frames_risk_on = frames_risk_on, + frames_risk_off = frames_risk_off }; } } diff --git a/AgroBase/AgroBase/Models/TrajetoriaMapaOperacaoModel.cs b/AgroBase/AgroBase/Models/TrajetoriaMapaOperacaoModel.cs index 7da79d84d..56e136560 100644 --- a/AgroBase/AgroBase/Models/TrajetoriaMapaOperacaoModel.cs +++ b/AgroBase/AgroBase/Models/TrajetoriaMapaOperacaoModel.cs @@ -886,7 +886,7 @@ namespace AgroBase.Models CorredorAtual.DadosVisuais.JaAntecipado = podeUsarSegmentacao && pertoDoFim && foraDoCorredorAgora && foraContinuoSuficiente; - Console.WriteLine($"podeUsarSegmentacao: {podeUsarSegmentacao}, pertoDoFim: {pertoDoFim}, foraDoCorredorAgora: {foraDoCorredorAgora}, foraContinuoSuficiente: {foraContinuoSuficiente}"); + //Console.WriteLine($"podeUsarSegmentacao: {podeUsarSegmentacao}, pertoDoFim: {pertoDoFim}, foraDoCorredorAgora: {foraDoCorredorAgora}, foraContinuoSuficiente: {foraContinuoSuficiente}"); if (CorredorAtual.DadosVisuais.JaAntecipado) { diff --git a/AgroBase/AgroBase/Services/CoulombCounterService.cs b/AgroBase/AgroBase/Services/CoulombCounterService.cs index 439b73300..f9d02dab5 100644 --- a/AgroBase/AgroBase/Services/CoulombCounterService.cs +++ b/AgroBase/AgroBase/Services/CoulombCounterService.cs @@ -78,20 +78,7 @@ namespace AgroBase.Services private double _energiaTotalNoFimOperacao_Wh; // Derivados da operação - public double ConsumidoOperacao_C - { - get - { - if (!OperacaoAtiva && !OperacaoFinalizada) - return 0; - - double referenciaFim = OperacaoFinalizada - ? _consumidoTotalNoFimOperacao_C - : ConsumidoTotal_C; - - return Math.Max(0, referenciaFim - _consumidoTotalNoInicioOperacao_C); - } - } + public double ConsumidoOperacao_C { get; set; } public double ConsumidoOperacao_Ah => ConsumidoOperacao_C / 3600.0; public double PercentualConsumidoOperacao @@ -110,12 +97,7 @@ namespace AgroBase.Services { get { - if (!OperacaoAtiva && !OperacaoFinalizada) - return 0; - - if (_cargaInicioOperacao_C <= 0) - return 0; - + if (_cargaInicioOperacao_C <= 0) return 0; double calc = (ConsumidoOperacao_C / _cargaInicioOperacao_C) * 100.0; return FuncoesMatematicas.Clamp(calc, 0, 100); } @@ -309,6 +291,11 @@ namespace AgroBase.Services double deltaCoulombs = correnteDescarga_A * _dt; ConsumidoTotal_C += deltaCoulombs; ConsumidoTotal_C = FuncoesMatematicas.Clamp(ConsumidoTotal_C, 0, CargaMaxima_C); + if (OperacaoAtiva && !OperacaoFinalizada) + { + ConsumidoOperacao_C += deltaCoulombs; + ConsumidoOperacao_C = FuncoesMatematicas.Clamp(ConsumidoOperacao_C, 0, CargaMaxima_C); + } // Estado absoluto do pack sempre baseado no total da instância double cargaAtualCalculada = _cargaInicialInstancia_C - ConsumidoTotal_C; diff --git a/AgroBase/AgroBase/Services/DalyBMSService.cs b/AgroBase/AgroBase/Services/DalyBMSService.cs index 07cdfc0df..5a5d07b98 100644 --- a/AgroBase/AgroBase/Services/DalyBMSService.cs +++ b/AgroBase/AgroBase/Services/DalyBMSService.cs @@ -68,7 +68,12 @@ namespace AgroBase.Services public static void AtualizarDados() { if (!Iniciado) + { + var d = SerialService.DispositivosMapeados.FirstOrDefault(x => x.Dispositivo == Dispositivo); + if (d != null) + SerialService.DispositivosMapeados.Remove(d); return; + } double dt = (DateTime.Now - UltimaAtualizacao).TotalSeconds; if (dt < TempoAtualizacao) diff --git a/AgroBase/AgroBase/Services/Operadores/HealthWorkerService.cs b/AgroBase/AgroBase/Services/Operadores/HealthWorkerService.cs index 0a21dda73..a96a42d75 100644 --- a/AgroBase/AgroBase/Services/Operadores/HealthWorkerService.cs +++ b/AgroBase/AgroBase/Services/Operadores/HealthWorkerService.cs @@ -218,7 +218,7 @@ namespace AgroBase.Services.Operadores ("camera_solo_id", Variaveis.OperacaoEmAndamento.DispSen?.Dados?.CamerasSolo?.FirstOrDefault()?.Id ?? ""), ("path_ia_model_ruas_seg", VersionamentoService.ArquivoModeloSegStreetDetector.CaminhoCompleto), ("path_ia_labelmap_ruas_seg", VersionamentoService.ArquivoLabelmapSegStreetDetector.CaminhoCompleto), - ("path_ia_norm_stats_ruas_seg", VersionamentoService.ArquivoModeloNormstatsWeedDetector.CaminhoCompleto), + ("path_ia_norm_stats_ruas_seg", VersionamentoService.ArquivoModeloNormstatsStreetDetector.CaminhoCompleto), ("ia_backbone_ruas_seg", "nvidia/segformer-b0-finetuned-ade-512-512"), ("path_ia_model_ruas_det", VersionamentoService.ArquivoModeloDetStreetDetector.CaminhoCompleto), ("path_ia_model_ervas", VersionamentoService.ArquivoModeloWeedDetector.CaminhoCompleto), @@ -353,6 +353,7 @@ namespace AgroBase.Services.Operadores ("frenagem_automatica", pControle.FrenagemAutomaticaAoParar), ("oak_parada_por_bloqueio", pControle.OakParadaPorObstaculo), ("imu_parada_por_inclinacao", pControle.ImuParadaPorInclinacao), + ("mpc_matriz_custo", pControle.MpcMatrizCusto), ("pressao_linha", pControle.AtuPressaoLinha), diff --git a/AgroBase/AgroBase/bin/x64/Debug/Python/Scripts/workers/manager_worker/modulos/direcional.py b/AgroBase/AgroBase/bin/x64/Debug/Python/Scripts/workers/manager_worker/modulos/direcional.py index 49c449415..2538c4586 100644 --- a/AgroBase/AgroBase/bin/x64/Debug/Python/Scripts/workers/manager_worker/modulos/direcional.py +++ b/AgroBase/AgroBase/bin/x64/Debug/Python/Scripts/workers/manager_worker/modulos/direcional.py @@ -18,8 +18,7 @@ def definir_comando(pid: PIDAdaptativo, envio_necessario: bool): _trajetoria = _contexto.get("Trajetoria", {}) _snr = ContextoGlobalRedis.get_modulo(T_Code.Snr) - visual_worker_ativado = _controle.get("sonar_ativado", False) - usa_matriz_custo = _controle.get("usa_matriz_custo", False) + usa_matriz_custo = _controle.get("mpc_matriz_custo", False) visual_worker_operante = (_snr.get("saude", {}).get("status", StatusModulo.DESCONECTADO.value)) == StatusModulo.OPERANTE.value _dados_vw = ContextoGlobalRedis.get(CtxKey.DadosVisualWorker, {}) _snapshot_vw = _dados_vw.get("matriz_confianca") @@ -31,13 +30,23 @@ def definir_comando(pid: PIDAdaptativo, envio_necessario: bool): if not _snapshot_vw: visual_worker_atualizado = False else: - visual_worker_atualizado = (time.perf_counter() - _snapshot_vw.get("ts", 0.0) <= 1.0) + visual_worker_atualizado = (time.time() - _snapshot_vw.get("ts", 0.0) <= 1.0) if visual_worker_atualizado: custo, conf, anom, nav = unpack_snapshot(_snapshot_vw) dists = _snapshot_vw.get("row_dist_m", None) escalas = _snapshot_vw.get("row_scale_x_m", None) block = _snapshot_vw.get("block", None) - + matriz_valida = ( + visual_worker_operante + and visual_worker_atualizado + and _snapshot_vw is not None + and custo is not None + and nav is not None + and dists is not None + and escalas is not None + and block is not None + ) + _gps = ContextoGlobalRedis.get_modulo(T_Code.Gps) _gps_pos_atualizada = _gps.get("heartbeat", 0) != _gps.get("old_heartbeat", 0) _gps_passos_travados = 0 @@ -82,17 +91,16 @@ def definir_comando(pid: PIDAdaptativo, envio_necessario: bool): "PassosAtraso": _operacao.get("Dir", {}).get("mpc", {}).get("passos_atraso", 1), }, "VisualWorker": { - "Ativado": visual_worker_ativado, + "Ativado": usa_matriz_custo, "Operante": visual_worker_operante, "Atualizado": visual_worker_atualizado, "MatrizCusto": { "EmUso": usa_matriz_custo, - "Valida": visual_worker_ativado and visual_worker_operante and visual_worker_atualizado, + "Valida": matriz_valida, "Custo": custo, "Navegavel": nav, "DistanciasRef": dists, - "EscalasX": escalas, - "Block": block + "EscalasX": escalas, }, }, "Equipamento": { diff --git a/AgroBase/AgroBase/bin/x64/Debug/Python/Scripts/workers/manager_worker/modulos/mpc.py b/AgroBase/AgroBase/bin/x64/Debug/Python/Scripts/workers/manager_worker/modulos/mpc.py index c389f02df..321d58a8a 100644 --- a/AgroBase/AgroBase/bin/x64/Debug/Python/Scripts/workers/manager_worker/modulos/mpc.py +++ b/AgroBase/AgroBase/bin/x64/Debug/Python/Scripts/workers/manager_worker/modulos/mpc.py @@ -1078,7 +1078,7 @@ class ControladorMPC: tipos_validos = [TipoMovimentoDirecional.MovimentoArco] elif abs(e_ori) > 15.0: tipos_validos = [TipoMovimentoDirecional.RodasDianteiras, TipoMovimentoDirecional.MovimentoArco] - elif abs(e_ori <= 3.0 and e_lat <= 0.2): + elif abs(e_ori) <= 3.0 and abs(e_lat) <= 0.2: tipos_validos = [TipoMovimentoDirecional.MovimentoDiagonal] else: tipos_validos = [TipoMovimentoDirecional.RodasDianteiras] @@ -1135,15 +1135,16 @@ class ControladorMPC: mask_any = np.logical_or.reduce(masks) if mask_any.any(): angulos_raw = [g for g, ok in zip(ang_all, mask_any) if ok] + permitidos = set() else: # tudo barrado → fallback mínimo ao redor do ideal - ai = angulo_ideal_deg; passo_fb = 1.0 + ai = angulo_ideal_deg + passo_fb = 1.0 angulos_raw = [float(np.clip(round(ai + d, 2), -self.angulo_max_graus, self.angulo_max_graus)) for d in (-2*passo_fb, -passo_fb, 0.0, passo_fb, 2*passo_fb)] # constrói set de (tipo,angulo) permitidos (apenas onde mask_any é True) allowed_angles = {float(round(g, 2)) for g, ok in zip(ang_all, mask_any) if ok} - permitidos = set() for t, mask_t in zip(tipos_validos, masks): for g, ok in zip(ang_all, mask_t): g2 = float(round(g, 2)) @@ -1416,6 +1417,8 @@ class ControladorMPC: if not cand_idx: cand_idx = ordem_global[:K_per].tolist() + #print(f"testando {tipo} - permitidos: {permitidos}, cand_idx: {cand_idx}") + # avalia os candidatos deste tipo for idx in cand_idx: if ms_left() <= margem_ms: @@ -1433,6 +1436,7 @@ class ControladorMPC: try: traj = self._simular_trajetoria_curta(p_atual, tipo, ang_rad, velocidade, distancia_sim_m) custo, valido = self._avaliar_trajetoria_matriz_custo(tipo, ang_rad, traj, p_ref, dados_matriz_custo) + #print(f"avaliando {tipo} {np.degrees(ang_rad):.2f} - custo: {custo}, valido: {valido}") if valido: custo_total = float(custo) + float(c_ideal) @@ -1455,6 +1459,7 @@ class ControladorMPC: # ---- fail-safe: se nada válido, devolve top heurístico (sem matriz) if not tipos_validos: + #print("sem tipos validos") custos_candidatos = {} for tipo in tipos: for idx in ordem_global[:max(3, Kdyn_total)]: @@ -1465,7 +1470,7 @@ class ControladorMPC: # devolve ângulos (rad) correspondentes ang_out = [float(angulos_rad[idx]) for idx in ordem_global[:max(3, Kdyn_total)]] return tipos, ang_out, custos_candidatos - + #print(tipos_validos, angulos_validos, custos_candidatos) return tipos_validos, angulos_validos, custos_candidatos except Exception as e: @@ -1600,13 +1605,22 @@ class ControladorMPC: custo_total = float(np.sum(seg_sum[valid_mask])) cells = int(np.sum(seg_len[valid_mask])) - # se houve qualquer bloqueio em algum ponto da trajetória, sinaliza inválido (mantém custo parcial médio) - invalido = bool(np.any(blocked_any)) - if cells <= 0: return float("inf"), False + + custo_medio = custo_total / cells - return (custo_total / cells), (not invalido) + # se houve qualquer bloqueio em algum ponto da trajetória, sinaliza inválido (mantém custo parcial médio) + #invalido = bool(np.any(blocked_any)) + + frac_bloq = float(np.mean(blocked_any.astype(np.float32))) + if frac_bloq >= 0.45: + return float("inf"), False + + invalido = frac_bloq > 0.20 + penal_bloq = 0.5 * frac_bloq + + return custo_medio + penal_bloq, (not invalido) except Exception as e: mostrar_log(f"❌ Erro ao avaliar trajetoria na matriz: {e}") diff --git a/AgroBase/AgroBase/bin/x64/Debug/Python/Scripts/workers/visual_worker/camera_manager.py b/AgroBase/AgroBase/bin/x64/Debug/Python/Scripts/workers/visual_worker/camera_manager.py index 159050278..59bed88c3 100644 --- a/AgroBase/AgroBase/bin/x64/Debug/Python/Scripts/workers/visual_worker/camera_manager.py +++ b/AgroBase/AgroBase/bin/x64/Debug/Python/Scripts/workers/visual_worker/camera_manager.py @@ -84,7 +84,7 @@ class CameraManager: self.grid_ref_shape = (15, 10) self.grid_ref_base = self.gerar_grid_ref() self.grid_ref = self.grid_ref_base.copy() - self.data_fuser = CostmapFuser(grid_shape=self.grid_ref_shape, K=3, M=2, fuse_method="max", block_thr=0.7, central_cols=None, y_range_m=(0.5,5.0), near_is_bottom=True, fov_h_rad=np.radians(self.camera.parametros["fov_h"]), robot_width=self.largura_robo_m) + self.data_fuser = CostmapFuser(grid_shape=self.grid_ref_shape, K=3, M=2, central_cols=None, y_range_m=(0.5,5.0), near_is_bottom=True, fov_h_rad=np.radians(self.camera.parametros["fov_h"]), robot_width=self.largura_robo_m) self.seg_runner = SegformerNavRunner(seg_config) self.segmentacao_manager = SegmentacaoManager(color_map=self.seg_runner.colormap_rgb, classes=self.seg_runner.classes) @@ -125,27 +125,29 @@ class CameraManager: grid = self._gerar_grid_referencia_geometrico() if grid is None or len(grid) != self.grid_ref_shape[1]: - raise ValueError("grid_ref inválido ou com tamanho incorreto") + self.mostrar_log("grid_ref inválido ou com tamanho incorreto") + return None grid = np.asarray(grid, dtype=np.float32) if not np.all(np.isfinite(grid)): - raise ValueError("grid_ref contém NaN/Inf") + self.mostrar_log("grid_ref contém NaN/Inf") + return None if np.any(grid <= 0): - raise ValueError("grid_ref contém valores <= 0") + self.mostrar_log("grid_ref contém valores <= 0") + return None # monotonicidade esperada diffs = np.diff(grid) if not np.all(diffs > 0): self.mostrar_log(f"[WARN] grid_ref não monotônico: {grid.tolist()}") - self.grid_ref = grid + return grid except Exception as e: self.mostrar_log(f"Erro ao gerar grid_ref: {e}") - # fallback linear seguro - self.grid_ref = np.linspace(0.5, 5.0, self.grid_ref_shape[1], dtype=np.float32) + return None def _gerar_grid_referencia_geometrico(self, angulo_inclinacao_graus=28.91, altura_camera_m=0.74): try: @@ -169,7 +171,7 @@ class CameraManager: dtype=np.float32 ) - d = d[::-1] + #d = d[::-1] return d except Exception as e: @@ -207,6 +209,7 @@ class CameraManager: if not np.all(np.isfinite(grid_ref_fixed)) or np.any(grid_ref_fixed <= 0): return self.grid_ref_base.copy() + #print(f"angulo: {pitch_graus:.2f}, {grid_ref_fixed}") return grid_ref_fixed except Exception as e: @@ -397,7 +400,7 @@ class CameraManager: self.mostrar_log(f"Erro no loop de stream: {e}") finally: latencia = time.time() - t0 - freq = self.camera.stream._op_fps + freq = self.camera.stream._op_fps if self.camera is not None else 1.0 time.sleep(max(0, (1.0 / freq) - latencia)) threading.Thread(target=loop, daemon=True).start() @@ -689,11 +692,11 @@ class CameraManager: deteccoes=None, # lista de dicts det_params=None, usar_depth: bool = True, - anom_tau_up=0.22, - anom_satur_up_m=0.50, - anom_tau_down=0.18, - anom_satur_down_m=0.40, - anom_down_weight=0.70, + anom_tau_up=0.15, + anom_satur_up_m=0.35, + anom_tau_down=0.30, + anom_satur_down_m=0.55, + anom_down_weight=0.65, ): """ Constrói uma grid de confiança/risco por célula. @@ -807,6 +810,10 @@ class CameraManager: if valid >= max(int(min_valid_frac * n), 1): z_med[j, i] = np.nanmedian(vals) / 1000.0 # mm -> m + #z_med_linha = np.nanmedian(z_med, axis=1) + #print("grid_ref: ", grid_ref) + #print("z_med_ln: ", z_med_linha) + # -------------------------------------------------- # 6) Confiança da célula # -------------------------------------------------- diff --git a/AgroBase/AgroBase/bin/x64/Debug/Python/Scripts/workers/visual_worker/processamento/costmap_fuser.py b/AgroBase/AgroBase/bin/x64/Debug/Python/Scripts/workers/visual_worker/processamento/costmap_fuser.py index 280f50714..d9baff6c4 100644 --- a/AgroBase/AgroBase/bin/x64/Debug/Python/Scripts/workers/visual_worker/processamento/costmap_fuser.py +++ b/AgroBase/AgroBase/bin/x64/Debug/Python/Scripts/workers/visual_worker/processamento/costmap_fuser.py @@ -65,6 +65,17 @@ class CostmapFuser: "last_decision": "LIVRE" } + self._trend_state = { + "risk_ema": 0.0, + "d_obs_prev": None, + "central_prev": None, + "side_bias_prev": None, + "conf_prev": None, + "frames_risk_on": 0, + "frames_risk_off": 0, + "risk_band": "free" + } + self.seq = 0 def _stack(self, lst, fallback_val=0.0): @@ -416,6 +427,19 @@ class CostmapFuser: right = float(unsafe[:, midc:c1].mean()) if (c1 > midc) else 0.0 side_bias_val = float(np.clip((right - left) / max(1e-6, (right + left + 1e-6)), -1.0, 1.0)) + # ----------------------------- + # 7.5) Tendências temporais + # ----------------------------- + central_unsafe_max = float(np.max(coverage_central_unsafe)) + trend = self._compute_trend_metrics( + central_unsafe_max=central_unsafe_max, + global_cov_unsafe=global_cov_unsafe, + conf_mean=conf_mean, + d_obs_true_min_m=d_obs_true_min_m_z, + d_det_true_min_m=d_det_true_min_m_z, + side_bias=side_bias_val + ) + # ----------------------------- # 8) Classificação raw # ----------------------------- @@ -435,7 +459,6 @@ class CostmapFuser: reason = "free" reason_detail = "Caminho livre." - central_unsafe_max = float(np.max(coverage_central_unsafe)) central_conf_max = float(np.max(coverage_central_conf)) central_detcrit_max = float(np.max(coverage_central_detcrit)) @@ -458,8 +481,10 @@ class CostmapFuser: strength_txt = f", score={s_best:.2f}" reason_detail = ( - f"Detecção crítica na faixa central: {lbl_txt}{strength_txt}, " - f"d={_fmt_m(d_used)}, cobertura_detcrit_max={central_detcrit_max:.2f}." + f"Deteccao critica no centro: {lbl_txt}. " + f"Distancia estimada: {_fmt_m(d_used)}. " + f"Ocupacao critica da faixa central: {central_detcrit_max:.0%}." + + (f" Confiança da deteccao: {s_best:.2f}." if s_best > 0 else "") ) # 8.2 obstáculo físico/fundido @@ -470,9 +495,11 @@ class CostmapFuser: d_used = _min_non_none(d_obs_true_min_m_z, d_block_line_m_z) reason_detail = ( - f"Faixa central bloqueada por anomalia/custo suportado " - f"(cov={central_unsafe_max:.2f} >= {rho_block_central:.2f}), " - f"d*={_fmt_m(d_used)} [linha={_fmt_m(d_block_line_m_z)}; pixel={_fmt_m(d_obs_true_min_m_z)}]." + f"Faixa central bloqueada a frente. " + f"Cobertura bloqueada: {central_unsafe_max:.0%} " + f"(limite: {rho_block_central:.0%}). " + f"Distancia estimada: {_fmt_m(d_used)} " + f"[linha: {j_block} | pixel: {_fmt_m(d_obs_true_min_m_z)}]." ) # 8.3 percepção degradada / blackout @@ -480,9 +507,10 @@ class CostmapFuser: blocked_raw = False reason = "blackout" reason_detail = ( - f"Percepção degradada: frac_conf_baixa={global_cov_conf:.2f}, " - f"conf_media={conf_mean:.2f}. " - f"Isto indica incerteza perceptiva, não obstáculo confirmado." + f"Percepcao degradada. " + f"Grande parte da area esta com baixa confianca ({global_cov_conf:.0%}) " + f"e a confianca media esta em {conf_mean:.0%}. " + f"Ha incerteza na leitura do cenario, sem obstaculo confirmado." ) # 8.4 corredor estreito / cautela @@ -492,8 +520,9 @@ class CostmapFuser: lado = "direita" if right > left else "esquerda" lado_frac = max(left, right) reason_detail = ( - f"Corredor estreito: lateral {lado} fechada (frac={lado_frac:.2f}), " - f"central_unsafe_max={central_unsafe_max:.2f}." + f"Corredor estreito a frente. " + f"A lateral {lado} esta mais fechada ({lado_frac:.0%}) " + f"e a regiao central ja mostra restricao de {central_unsafe_max:.0%}." ) # ----------------------------- @@ -524,13 +553,29 @@ class CostmapFuser: elif reason == "obstacle": d_stop_ref = _min_non_none(d_block_line_m_z, d_obs_true_min_m_z) + trend_band = "free" + risk_ema = 0.0 + frames_risk_on = 0 + + if trend is not None: + trend_band = str(trend.get("band", "free")) + risk_ema = float(trend.get("risk_ema", 0.0)) + frames_risk_on = int(trend.get("frames_risk_on", 0)) + + trend_watch = trend_band in ("watch", "slowdown", "prepare_stop") + trend_slow = trend_band in ("slowdown", "prepare_stop") + trend_stop = (trend_band == "prepare_stop" and frames_risk_on >= 2) + stop_now = False v_max_sug = None mode = "free" + # ------------------------- + # 1) Casos duros + # ------------------------- if reason == "detected_critical": mode = "stop" - stop_now = True if (d_stop_ref is None or d_stop_ref <= dist_necessaria + 0.3) else True + stop_now = True elif reason == "obstacle": if (d_stop_ref is not None) and np.isfinite(d_stop_ref) and (d_stop_ref <= dist_necessaria): @@ -542,17 +587,49 @@ class CostmapFuser: if (d_stop_ref is not None) and np.isfinite(d_stop_ref) and (d_stop_ref > margem_parada): v_max_sug = float(np.sqrt(max(0.0, 2.0 * a_max_freio * (d_stop_ref - margem_parada)))) + # ------------------------- + # 2) Casos moles modulados por trend + # ------------------------- elif reason == "blackout": - mode = "caution" - stop_now = bool(blackout_imediato) + if trend_stop: + mode = "stop" + stop_now = True + elif trend_slow: + mode = "slowdown" + stop_now = False + elif trend_watch: + mode = "watch" + stop_now = False + else: + mode = "caution" + stop_now = False elif reason == "narrow": - mode = "slowdown" - stop_now = False + if trend_band == "prepare_stop" and (d_obs_true_min_m_z is not None) and (d_obs_true_min_m_z <= dist_necessaria * 1.20): + mode = "stop" + stop_now = True + elif trend_band in ("slowdown", "prepare_stop"): + mode = "slowdown" + stop_now = False + if (d_obs_true_min_m_z is not None) and np.isfinite(d_obs_true_min_m_z) and (d_obs_true_min_m_z > margem_parada): + v_max_sug = float(np.sqrt(max(0.0, 2.0 * a_max_freio * (d_obs_true_min_m_z - margem_parada)))) + else: + mode = "watch" + stop_now = False - else: - mode = "free" - stop_now = False + else: # reason == "free" + if trend_band == "prepare_stop" and frames_risk_on >= 2: + mode = "slowdown" + stop_now = False + elif trend_band == "slowdown": + mode = "slowdown" + stop_now = False + elif trend_band == "watch": + mode = "watch" + stop_now = False + else: + mode = "free" + stop_now = False st = self._blk_state @@ -575,7 +652,10 @@ class CostmapFuser: "v_max_sugerida_mps": v_max_sug, "frames_on": int(st["on"]), "frames_off": int(st["off"]), - "mode": mode + "mode": mode, + "trend_band": trend_band, + "risk_ema": risk_ema, + "frames_risk_on": frames_risk_on }) st["reason"] = reason @@ -617,6 +697,8 @@ class CostmapFuser: "j_obs_true_min": None if j_obs_true_min is None else int(j_obs_true_min), "j_det_true_min": None if j_det_true_min is None else int(j_det_true_min), + "trend": trend, + "decision": decision } @@ -646,6 +728,7 @@ class CostmapFuser: "j_block": None, "j_obs_true_min": None, "j_det_true_min": None, + "trend": {}, "decision": { "parar": False, "dist_necessaria": None, @@ -658,6 +741,115 @@ class CostmapFuser: } } + def _compute_trend_metrics( + self, + central_unsafe_max, + global_cov_unsafe, + conf_mean, + d_obs_true_min_m, + d_det_true_min_m, + side_bias, + alpha_risk=0.35 + ): + st = self._trend_state + + # valores anteriores + d_obs_prev = st["d_obs_prev"] + central_prev = st["central_prev"] + side_prev = st["side_bias_prev"] + conf_prev = st["conf_prev"] + + # ------------------------- + # 1) deltas / tendência + # ------------------------- + delta_central = 0.0 if central_prev is None else (central_unsafe_max - central_prev) + delta_side = 0.0 if side_prev is None else abs(side_bias - side_prev) + delta_conf = 0.0 if conf_prev is None else (conf_prev - conf_mean) # queda de confiança => risco + + approaching_obs = 0.0 + if d_obs_prev is not None and d_obs_true_min_m is not None: + dd = d_obs_prev - d_obs_true_min_m # positivo => obstáculo aproximando + approaching_obs = max(0.0, dd) + + approaching_det = 0.0 + if st.get("d_det_prev") is not None and d_det_true_min_m is not None: + dd = st["d_det_prev"] - d_det_true_min_m + approaching_det = max(0.0, dd) + + # ------------------------- + # 2) normalizações + # ------------------------- + risco_central = float(np.clip(central_unsafe_max, 0.0, 1.0)) + risco_global = float(np.clip(global_cov_unsafe, 0.0, 1.0)) + risco_conf = float(np.clip(1.0 - conf_mean, 0.0, 1.0)) + + risco_crescendo = float(np.clip(delta_central / 0.20, 0.0, 1.0)) + risco_lateral = float(np.clip(delta_side / 0.25, 0.0, 1.0)) + risco_aprox_obs = float(np.clip(approaching_obs / 0.40, 0.0, 1.0)) + risco_aprox_det = float(np.clip(approaching_det / 0.40, 0.0, 1.0)) + + # ------------------------- + # 3) score bruto + # ------------------------- + risk_raw = ( + 0.30 * risco_central + + 0.15 * risco_global + + 0.15 * risco_conf + + 0.15 * risco_crescendo + + 0.10 * risco_lateral + + 0.10 * risco_aprox_obs + + 0.05 * risco_aprox_det + ) + + risk_raw = float(np.clip(risk_raw, 0.0, 1.0)) + + # ------------------------- + # 4) EMA temporal + # ------------------------- + risk_ema_prev = float(st["risk_ema"]) + risk_ema = (1.0 - alpha_risk) * risk_ema_prev + alpha_risk * risk_raw + + # ------------------------- + # 5) faixa de risco + # ------------------------- + if risk_ema >= 0.78: + band = "prepare_stop" + elif risk_ema >= 0.58: + band = "slowdown" + elif risk_ema >= 0.38: + band = "watch" + else: + band = "free" + + # persistência leve do risco + if band in ("watch", "slowdown", "prepare_stop"): + st["frames_risk_on"] += 1 + st["frames_risk_off"] = 0 + else: + st["frames_risk_off"] += 1 + st["frames_risk_on"] = 0 + + # salva histórico + st["risk_ema"] = float(risk_ema) + st["d_obs_prev"] = None if d_obs_true_min_m is None else float(d_obs_true_min_m) + st["d_det_prev"] = None if d_det_true_min_m is None else float(d_det_true_min_m) + st["central_prev"] = float(central_unsafe_max) + st["side_bias_prev"] = float(side_bias) + st["conf_prev"] = float(conf_mean) + st["risk_band"] = band + + return { + "risk_raw": float(risk_raw), + "risk_ema": float(risk_ema), + "band": band, + "delta_central": float(delta_central), + "delta_side_bias": float(delta_side), + "approaching_obs_m": float(approaching_obs), + "approaching_det_m": float(approaching_det), + "frames_risk_on": int(st["frames_risk_on"]), + "frames_risk_off": int(st["frames_risk_off"]) + } + def _row_scale_x(self, row_dist_m): """metros por célula em X para cada linha, dado FOV_H.""" try: @@ -696,7 +888,7 @@ class CostmapFuser: """ try: if ts is None: - ts = time.perf_counter() + ts = time.time() # ----------------------------- # 1) Leitura e validação básica @@ -856,11 +1048,11 @@ class CostmapFuser: nav_f=nav_f, zmed_f=zmed_f, row_dist_m=row_dist_m, - row_scale_x=row_scale_x, + row_scale_x_m=row_scale_x, central_cols=self.central_cols, use_persistence=True, velocidade_mps=velocidade_ms, - a_max_freio=0.5, + a_max_freio=0.2, margem_parada=0.60, N_on=2, N_off=3,