Ajustes de tela e retorno a base

This commit is contained in:
Diego Freitas 2026-03-18 09:47:21 -03:00
parent a441b3997c
commit 8dfbbb599b
6 changed files with 80 additions and 62 deletions

View File

@ -425,8 +425,8 @@ namespace AgroBase.Forms.Operacoes
{
try
{
double angulo = Variaveis.OperacaoEmAndamento.Sensoriamento.Gps.OrientacaoReal;
double angulo2 = Variaveis.OperacaoEmAndamento.Sensoriamento.Gps.AnguloCarroDefinido;
double angulo = Variaveis.OperacaoEmAndamento.Sensoriamento.Gps?.OrientacaoReal ?? 0;
double angulo2 = Variaveis.OperacaoEmAndamento.Sensoriamento.Gps?.AnguloCarroDefinido ?? 0;
FuncoesGlobais.DesenharInclinacao((Panel)sender, e, (float)angulo, -90, (float)angulo2);
}
catch { }
@ -437,8 +437,8 @@ namespace AgroBase.Forms.Operacoes
var imu = Variaveis.OperacaoEmAndamento.Sensoriamento.IMU;
try
{
double angulo = imu.Rotacao;
double anguloCorrigido = imu.RotacaoCorrigida;
double angulo = imu?.Rotacao ?? 0;
double anguloCorrigido = imu?.RotacaoCorrigida ?? 0;
FuncoesGlobais.DesenharInclinacao((Panel)sender, e, (float)angulo, -270, (float)anguloCorrigido);
}
catch { }
@ -513,48 +513,52 @@ namespace AgroBase.Forms.Operacoes
private void AtualizarInformacoesGerais()
{
var _Sensoriamento = Variaveis.OperacaoEmAndamento.Sensoriamento;
var _Barramentos = _Sensoriamento.Bateria.Barramentos;
var _Bateria = _Sensoriamento?.Bateria;
var _Barramentos = _Bateria?.Barramentos;
var _Movimentacao = _Sensoriamento?.Movimentacao;
var _Atuador = _Sensoriamento?.Atuador;
var _IMU = _Sensoriamento?.IMU;
gridDados.Rows[0].Cells[1].Value = _Sensoriamento.TempoDecorrido.ToString("HH:mm:ss");
gridDados.Rows[1].Cells[1].Value = _Sensoriamento.Movimentacao.TempoMovimento.ToString("HH:mm:ss");
gridDados.Rows[2].Cells[1].Value = (_Sensoriamento.Movimentacao.VelocidadeMedia * 3.6).ToString("0.00");
gridDados.Rows[3].Cells[1].Value = _Sensoriamento.Trajetoria.DistanciaPercorrida.ToString("0.00");
gridDados.Rows[4].Cells[1].Value = (_Sensoriamento.Bateria.PercentualBateria.ToString("0.00"));
gridDados.Rows[5].Cells[1].Value = (_Sensoriamento.Bateria.TensaoInstantanea.ToString("0.00"));
gridDados.Rows[6].Cells[1].Value = (_Sensoriamento.Bateria.CorrenteInstantanea.ToString("0.00"));
gridDados.Rows[7].Cells[1].Value = TimeSpan.FromMinutes(_Sensoriamento.Bateria.TempoEstimadoRestanteMinutos).ToString(@"hh\:mm\:ss");
gridDados.Rows[8].Cells[1].Value = (_Sensoriamento.Bateria.DistanciaEstimadaRestanteMetros.ToString("0.00"));
gridDados.Rows[9].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB3V").Tensao).ToString("0.00");
gridDados.Rows[10].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB3V").Corrente).ToString("0.00");
gridDados.Rows[11].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB5V").Tensao).ToString("0.00");
gridDados.Rows[12].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB5V").Corrente).ToString("0.00");
gridDados.Rows[13].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB7V2").Tensao).ToString("0.00");
gridDados.Rows[14].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB7V2").Corrente).ToString("0.00");
gridDados.Rows[15].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB12V").Tensao).ToString("0.00");
gridDados.Rows[16].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB12V").Corrente).ToString("0.00");
gridDados.Rows[17].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB19V").Tensao).ToString("0.00");
gridDados.Rows[18].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB19V").Corrente).ToString("0.00");
gridDados.Rows[19].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB24V").Tensao).ToString("0.00");
gridDados.Rows[20].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB24V").Corrente).ToString("0.00");
gridDados.Rows[21].Cells[1].Value = _Sensoriamento.Atuador.PercentualReservatorio.ToString("0.00");
gridDados.Rows[22].Cells[1].Value = $"{_Sensoriamento.Atuador.MassaReservatorio:0.000} ({Variaveis.OperacaoEmAndamento.DispAtu?.Dados?.ContadorCarga?.MassaAtual_Kg_Calc ?? 0:0.000})";
gridDados.Rows[23].Cells[1].Value = $"{_Sensoriamento.Atuador.VolumeReservatorio:0.000}";
gridDados.Rows[24].Cells[1].Value = _Sensoriamento.Atuador.LPorMetro.ToString("0.000");
gridDados.Rows[25].Cells[1].Value = _Sensoriamento.Atuador.LPorMinuto.ToString("0.000");
gridDados.Rows[26].Cells[1].Value = TimeSpan.FromMinutes(_Sensoriamento.Atuador.TempoEstimadoRestanteMinutos).ToString(@"hh\:mm\:ss");
gridDados.Rows[27].Cells[1].Value = _Sensoriamento.Atuador.DistanciaEstimadaRestanteMetros.ToString("0.00");
gridDados.Rows[28].Cells[1].Value = _Sensoriamento.Atuador.PressaoLinha.ToString("0.00");
gridDados.Rows[29].Cells[1].Value = _Sensoriamento.Atuador.LeituraPotenciaBomba.ToString("0.00");
gridDados.Rows[30].Cells[1].Value = $"{_Sensoriamento.Atuador.VazaoInstantanea:0.000} ({Variaveis.OperacaoEmAndamento.DispAtu?.Dados?.VazaoFluxoMLpSInstantaneaCalc:0.000})";
gridDados.Rows[31].Cells[1].Value = $"{_Sensoriamento.Atuador.VazaoMedia:0.000}";
gridDados.Rows[32].Cells[1].Value = _Sensoriamento.Atuador.VolumeVazaoMl.ToString("0.00");
gridDados.Rows[33].Cells[1].Value = _Sensoriamento.Atuador.AnguloBarraEsquerda.ToString("0.00");
gridDados.Rows[34].Cells[1].Value = _Sensoriamento.Atuador.AnguloBarraDireita.ToString("0.00");
gridDados.Rows[35].Cells[1].Value = _Sensoriamento.Atuador.AnguloBarraAltura.ToString("0.00");
gridDados.Rows[1].Cells[1].Value = (_Movimentacao?.TempoMovimento ?? DateTime.Now).ToString("HH:mm:ss");
gridDados.Rows[2].Cells[1].Value = (_Movimentacao?.VelocidadeMedia ?? 0 * 3.6).ToString("0.00");
gridDados.Rows[3].Cells[1].Value = (_Sensoriamento.Trajetoria?.DistanciaPercorrida ?? 0).ToString("0.00");
gridDados.Rows[4].Cells[1].Value = ((_Bateria?.PercentualBateria ?? 0).ToString("0.00"));
gridDados.Rows[5].Cells[1].Value = ((_Bateria?.TensaoInstantanea ?? 0).ToString("0.00"));
gridDados.Rows[6].Cells[1].Value = ((_Bateria?.CorrenteInstantanea ?? 0).ToString("0.00"));
gridDados.Rows[7].Cells[1].Value = TimeSpan.FromMinutes(_Bateria?.TempoEstimadoRestanteMinutos ?? 0).ToString(@"hh\:mm\:ss");
gridDados.Rows[8].Cells[1].Value = ((_Bateria?.DistanciaEstimadaRestanteMetros ?? 0).ToString("0.00"));
gridDados.Rows[9].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB3V")?.Tensao ?? 0).ToString("0.00");
gridDados.Rows[10].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB3V")?.Corrente ?? 0).ToString("0.00");
gridDados.Rows[11].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB5V")?.Tensao ?? 0).ToString("0.00");
gridDados.Rows[12].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB5V")?.Corrente ?? 0).ToString("0.00");
gridDados.Rows[13].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB7V2")?.Tensao ?? 0).ToString("0.00");
gridDados.Rows[14].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB7V2")?.Corrente ?? 0).ToString("0.00");
gridDados.Rows[15].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB12V")?.Tensao ?? 0).ToString("0.00");
gridDados.Rows[16].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB12V")?.Corrente ?? 0).ToString("0.00");
gridDados.Rows[17].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB19V")?.Tensao ?? 0).ToString("0.00");
gridDados.Rows[18].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB19V")?.Corrente ?? 0).ToString("0.00");
gridDados.Rows[19].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB24V")?.Tensao ?? 0).ToString("0.00");
gridDados.Rows[20].Cells[1].Value = (_Barramentos.FirstOrDefault(x => x.ID == "AB24V")?.Corrente ?? 0).ToString("0.00");
gridDados.Rows[21].Cells[1].Value = (_Atuador?.PercentualReservatorio ?? 0).ToString("0.00");
gridDados.Rows[22].Cells[1].Value = $"{_Atuador?.MassaReservatorio ?? 0:0.000} ({Variaveis.OperacaoEmAndamento.DispAtu?.Dados?.ContadorCarga?.MassaAtual_Kg_Calc ?? 0:0.000})";
gridDados.Rows[23].Cells[1].Value = $"{_Atuador?.VolumeReservatorio ?? 0:0.000}";
gridDados.Rows[24].Cells[1].Value = (_Atuador?.LPorMetro ?? 0).ToString("0.000");
gridDados.Rows[25].Cells[1].Value = (_Atuador?.LPorMinuto ?? 0).ToString("0.000");
gridDados.Rows[26].Cells[1].Value = TimeSpan.FromMinutes(_Atuador?.TempoEstimadoRestanteMinutos ?? 0).ToString(@"hh\:mm\:ss");
gridDados.Rows[27].Cells[1].Value = (_Atuador?.DistanciaEstimadaRestanteMetros ?? 0).ToString("0.00");
gridDados.Rows[28].Cells[1].Value = (_Atuador?.PressaoLinha ?? 0).ToString("0.00");
gridDados.Rows[29].Cells[1].Value = (_Atuador?.LeituraPotenciaBomba ?? 0).ToString("0.00");
gridDados.Rows[30].Cells[1].Value = $"{_Atuador?.VazaoInstantanea ?? 0:0.000} ({Variaveis.OperacaoEmAndamento.DispAtu?.Dados?.VazaoFluxoMLpSInstantaneaCalc:0.000})";
gridDados.Rows[31].Cells[1].Value = $"{_Atuador?.VazaoMedia ?? 0:0.000}";
gridDados.Rows[32].Cells[1].Value = (_Atuador?.VolumeVazaoMl ?? 0).ToString("0.00");
gridDados.Rows[33].Cells[1].Value = (_Atuador?.AnguloBarraEsquerda ?? 0).ToString("0.00");
gridDados.Rows[34].Cells[1].Value = (_Atuador?.AnguloBarraDireita ?? 0).ToString("0.00");
gridDados.Rows[35].Cells[1].Value = (_Atuador?.AnguloBarraAltura ?? 0).ToString("0.00");
gridDados.Rows[36].Cells[1].Value = "";
gridDados.Rows[37].Cells[1].Value = (_Sensoriamento.IMU.InclinacaoLateral).ToString("0.00");
gridDados.Rows[38].Cells[1].Value = (_Sensoriamento.IMU.InclinacaoFrontal).ToString("0.00");
gridDados.Rows[39].Cells[1].Value = (_Sensoriamento.IMU.Rotacao).ToString("0.00");
gridDados.Rows[37].Cells[1].Value = (_IMU?.InclinacaoLateral ?? 0).ToString("0.00");
gridDados.Rows[38].Cells[1].Value = (_IMU?.InclinacaoFrontal ?? 0).ToString("0.00");
gridDados.Rows[39].Cells[1].Value = (_IMU?.Rotacao ?? 0).ToString("0.00");
}
#endregion

View File

@ -263,7 +263,7 @@ namespace AgroBase.Forms
{
GPSModel novaPosicao = null;
velocidadeCarroMs = FuncoesMatematicas.CalculaVelocidadeMsPercentual(Variaveis.OperacaoEmAndamento.SimulacaoRpmControle);
Console.WriteLine($"RPM SP: {Variaveis.OperacaoEmAndamento.SimulacaoRpmControle} ({velocidadeCarroMs:F2} ms)");
//Console.WriteLine($"RPM SP: {Variaveis.OperacaoEmAndamento.SimulacaoRpmControle} ({velocidadeCarroMs:F2} ms)");
Variaveis.OperacaoEmAndamento.DispMvd.Dados.VelocidadeMedia = velocidadeCarroMs;
@ -279,6 +279,7 @@ namespace AgroBase.Forms
double anguloControle = 0.0;
TipoMovimentoDirecional tipoMovimento = Variaveis.OperacaoEmAndamento.Controle.TipoMovimento;
double veloccidade = (Variaveis.OperacaoEmAndamento.StatusAtual == StatusOperacao.Concluido || Variaveis.OperacaoEmAndamento.StatusAtual == StatusOperacao.Aguardando) ? 0 : velocidadeCarroMs;
var tipoControle = Variaveis.OperacaoEmAndamento.Parametros.Controle.DirTipoMovimento;
@ -289,11 +290,6 @@ namespace AgroBase.Forms
}
else
{
if (Variaveis.OperacaoEmAndamento.StatusAtual == StatusOperacao.Concluido || Variaveis.OperacaoEmAndamento.StatusAtual == StatusOperacao.Aguardando)
{
return;
}
anguloControle = double.Parse(txtAnguloControle.Text);
bool atualizarAnguloControle = (ticksControle >= ticksControleMax);
@ -317,7 +313,7 @@ namespace AgroBase.Forms
//GPSModel pos = NovaPosicaoSimulacao(velocidadeMs, tempoPassado);
if (novaPosicao == null)
{
novaPosicao = VariaveisEquipamento.SimularNovaPosicao(tipoMovimento, anguloControle, velocidadeCarroMs, tempoPassado, anguloAtual, _Gps);
novaPosicao = VariaveisEquipamento.SimularNovaPosicao(tipoMovimento, anguloControle, veloccidade, tempoPassado, anguloAtual, _Gps);
}
posicaoAtual = novaPosicao;
@ -328,7 +324,7 @@ namespace AgroBase.Forms
// Atualiza a interface gráfica
txtAnguloGPS.Text = posicaoAtual.OrientacaoReal.ToString("0.00");
txtVelocidade.Text = velocidadeCarroMs.ToString("0.00");
txtVelocidade.Text = veloccidade.ToString("0.00");
txtDistanciaGPS.Text = posicaoAtual.Distancia.ToString("0.0000");
txtLatitude.Text = posicaoAtual.Latitude.ToString();
txtLongitude.Text = posicaoAtual.Longitude.ToString();
@ -554,11 +550,7 @@ namespace AgroBase.Forms
private void btnRetornarBase_Click(object sender, EventArgs e)
{
Variaveis.OperacaoEmAndamento.Trajetoria.IniciarRetornoBase(VariaveisOperacao.PosicaoBase);
if (!Variaveis.OperacaoEmAndamento.Iniciado)
{
Variaveis.OperacaoEmAndamento.Iniciado = true;
Variaveis.OperacaoEmAndamento.Simulando = true;
}
Variaveis.OperacaoEmAndamento.Simulando = true;
}
private void btnFixarBase_Click(object sender, EventArgs e)

View File

@ -1049,6 +1049,7 @@ namespace AgroBase.Models
GPSTrajetoria = new List<GPSModel>();
Trajetoria?.ProjetarTrajetoriaFixa();
Trajetoria.VerificacaoInicialMeioRuaConcluida = false;
RedisService.Publish(CmdKey.ManagerWorkerRx, JsonConvert.SerializeObject(new { cmd = ManagerWorkerCommandType.IniciarMPC }));
await RealizarCalibragemInicialAsync(true);
@ -1190,6 +1191,7 @@ namespace AgroBase.Models
GPSTrajetoria = new List<GPSModel>();
Trajetoria?.ProjetarTrajetoriaFixa();
Trajetoria.VerificacaoInicialMeioRuaConcluida = false;
RedisService.Publish(CmdKey.ManagerWorkerRx, JsonConvert.SerializeObject(new { cmd = ManagerWorkerCommandType.IniciarMPC }));
}

View File

@ -30,7 +30,7 @@ namespace AgroBase.Models
private double DistanciaPrimeirosPontosProjecao { get; set; } = 3.0; // Distancia máxima para projetar os primeiros pontos com distancia menor
public static double LarguraCorredorPadrao { get; set; } = 1.5; // Largura de um corredor padrão
private int JanelaAtualizacaoDePontos { get; set; } = 20; // Define o tamanho da janela de pontos a atualizar
private bool VerificacaoInicialMeioRuaConcluida { get; set; } = false; // Realiza a verificacao inicial para saber se o robo deve comecar a operacao do meio da rua
public bool VerificacaoInicialMeioRuaConcluida { get; set; } = false; // Realiza a verificacao inicial para saber se o robo deve comecar a operacao do meio da rua
#endregion
@ -1569,6 +1569,7 @@ namespace AgroBase.Models
_Corredores.ForEach(x => x.Ultimo = x.Idx == _Corredores.Count() - 1);
DistanciaTotal = GPSUtils.DistanciaDoTrecho(_trajetoriaFixa.Where(x => x.Tipo != TipoPontoRua.PosicaoRobo).Select(x => x.Posicao).ToList());
DistanciaPercorrida = 0.0;
RetornandoBase = false;
@ -1830,6 +1831,12 @@ namespace AgroBase.Models
LoopAtualizaDados();
if (!Variaveis.OperacaoEmAndamento.Iniciado)
{
Variaveis.OperacaoEmAndamento.Iniciado = true;
Variaveis.OperacaoEmAndamento.Simulando = !GPSService.Iniciado;
}
RedisService.AtualizarCampos(CtxKey.DadosOperacao, ("configurado", false));
}
@ -1839,6 +1846,10 @@ namespace AgroBase.Models
GPSModel posicaoAtual = Variaveis.OperacaoEmAndamento.Sensoriamento.Gps;
double distancia = GPSUtils.DistanciaEntrePontos(posicaoAtual, baseGps);
if (distancia < 5)
return (false, pontos);
VerificaInicioOperacaoMeioRua(false);
AtualizarDadosTrajetoria();
@ -2911,6 +2922,15 @@ namespace AgroBase.Models
// ==========================
// 3) Aplicação da trava + liberação humana
// ==========================
void DestravarCorredoresAte(int _idxCorredor)
{
for (int i = 0; i <= _idxCorredor; i++)
{
_corredoresTravados.Remove(i);
_inicioCriticoUtc.Remove(i);
}
}
bool corredorTravado = _corredoresTravados.Contains(idxCorredor);
AutonomiaCorredorStatus statusFinal = statusBase;
@ -2947,8 +2967,7 @@ namespace AgroBase.Models
(string.IsNullOrEmpty(motivoBase) ? "Liberado" : motivoBase);
// Destrava o corredor
_corredoresTravados.Remove(idxCorredor);
_inicioCriticoUtc.Remove(idxCorredor);
DestravarCorredoresAte(idxCorredor);
}
else
{
@ -2964,8 +2983,7 @@ namespace AgroBase.Models
motivosBloqueio.Clear();
// Destrava o corredor (o operador assumiu)
_corredoresTravados.Remove(idxCorredor);
_inicioCriticoUtc.Remove(idxCorredor);
DestravarCorredoresAte(idxCorredor);
}
}
}

View File

@ -298,6 +298,8 @@ namespace AgroBase.Services.Operadores
public static void AtualizarDadosControleOperacao()
{
var pControle = Variaveis.OperacaoEmAndamento.Parametros.Controle;
if (pControle == null)
return;
RedisService.AtualizarCampos(
CtxKey.DadosControle,
("pulverizador_automatico", pControle.PulverizadorAutomatico),