Ajustes cooler control e fix base
This commit is contained in:
parent
d2f6a9e03c
commit
18b795237f
|
|
@ -24,9 +24,9 @@ namespace AgroBase.Services
|
|||
// Estado interno
|
||||
public CoolerMode ModoAtual { get; private set; } = CoolerMode.Off;
|
||||
public Estado CoolerEntradaEstado { get; private set; } = Estado.Desligado;
|
||||
public Estado CoolerEntradaEstadoAnterior { get; private set; } = Estado.Desligado;
|
||||
public Estado CoolerEntradaEstadoRele => ReleCoolerEntrada?.StatusControle ?? Estado.Desligado;
|
||||
public Estado CoolerSaidaEstado { get; private set; } = Estado.Desligado;
|
||||
public Estado CoolerSaidaEstadoAnterior { get; private set; } = Estado.Desligado;
|
||||
public Estado CoolerSaidaEstadoRele => ReleCoolerSaida?.StatusControle ?? Estado.Desligado;
|
||||
|
||||
public double? TemperaturaFiltrada { get; private set; }
|
||||
public DateTime UltimaMudancaModo { get; private set; } = DateTime.MinValue;
|
||||
|
|
@ -167,15 +167,13 @@ namespace AgroBase.Services
|
|||
|
||||
private void EnviarComando()
|
||||
{
|
||||
if (ReleCoolerEntrada != null && CoolerEntradaEstadoAnterior != CoolerEntradaEstado)
|
||||
if (ReleCoolerEntrada != null && CoolerEntradaEstadoRele != CoolerEntradaEstado)
|
||||
{
|
||||
GeneralJoystick.EnviarComandoSensoriamento(ReleCoolerEntrada.Componente, ReleCoolerEntrada.ID, CoolerEntradaEstado);
|
||||
CoolerEntradaEstadoAnterior = CoolerEntradaEstado;
|
||||
}
|
||||
if (ReleCoolerSaida != null && CoolerSaidaEstadoAnterior != CoolerSaidaEstado)
|
||||
if (ReleCoolerSaida != null && CoolerSaidaEstadoRele != CoolerSaidaEstado)
|
||||
{
|
||||
GeneralJoystick.EnviarComandoSensoriamento(ReleCoolerSaida.Componente, ReleCoolerSaida.ID, CoolerSaidaEstado);
|
||||
CoolerSaidaEstadoAnterior = CoolerSaidaEstado;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,8 +91,9 @@ class ModuloSensoriamento(ModuloDiagnosticoBase):
|
|||
"em_uso": aferir
|
||||
}
|
||||
saude_individual.append(saude_mod)
|
||||
total_ativos += 1
|
||||
saude_total += saude
|
||||
if aferir:
|
||||
total_ativos += 1
|
||||
saude_total += saude
|
||||
if mandatorio:
|
||||
total_mandatorios += 1
|
||||
saude_mandatorios += saude
|
||||
|
|
@ -153,8 +154,9 @@ class ModuloSensoriamento(ModuloDiagnosticoBase):
|
|||
"em_uso": controlar
|
||||
}
|
||||
saude_individual.append(saude_mod)
|
||||
total_ativos += 1
|
||||
saude_total += saude
|
||||
if controlar:
|
||||
total_ativos += 1
|
||||
saude_total += saude
|
||||
if mandatorio:
|
||||
total_mandatorios += 1
|
||||
saude_mandatorios += saude
|
||||
|
|
@ -205,8 +207,9 @@ class ModuloSensoriamento(ModuloDiagnosticoBase):
|
|||
"em_uso": controlar
|
||||
}
|
||||
saude_individual.append(saude_mod)
|
||||
total_ativos += 1
|
||||
saude_total += saude
|
||||
if controlar:
|
||||
total_ativos += 1
|
||||
saude_total += saude
|
||||
if mandatorio:
|
||||
total_mandatorios += 1
|
||||
saude_mandatorios += saude
|
||||
|
|
@ -257,8 +260,9 @@ class ModuloSensoriamento(ModuloDiagnosticoBase):
|
|||
"em_uso": controlar
|
||||
}
|
||||
saude_individual.append(saude_mod)
|
||||
total_ativos += 1
|
||||
saude_total += saude
|
||||
if controlar:
|
||||
total_ativos += 1
|
||||
saude_total += saude
|
||||
if mandatorio:
|
||||
total_mandatorios += 1
|
||||
saude_mandatorios += saude
|
||||
|
|
@ -304,9 +308,9 @@ class ModuloSensoriamento(ModuloDiagnosticoBase):
|
|||
})
|
||||
|
||||
saude_final = (saude_mandatorios // total_mandatorios) if total_mandatorios > 0 else 100
|
||||
#saude_final = (saude_total // total_ativos) if total_ativos > 0 else 0
|
||||
saude_final = saude_final - penalidade_percentual_bateria
|
||||
|
||||
saude_final_ativos = (saude_total // total_ativos) if total_ativos > 0 else 0
|
||||
saude_final = saude_final_ativos - penalidade_percentual_bateria
|
||||
|
||||
status = StatusModulo.OPERANTE
|
||||
if not mod_conectado:
|
||||
status = StatusModulo.DESCONECTADO
|
||||
|
|
|
|||
|
|
@ -245,25 +245,26 @@ namespace OperationControl.Services
|
|||
Models.Variaveis.MostrarLog("Iniciando configuração do módulo GPS...");
|
||||
LeverArm = new GeoLeverArm(VariaveisControleOperacao.LeverArmFrontal, VariaveisControleOperacao.LeverArmLateral);
|
||||
BaseFix = new BaseFixService(PortaGps, this);
|
||||
BaseFix.FixLiberado = true;
|
||||
if (fixar)
|
||||
{
|
||||
bool sucesso = await BaseFix.FixarBaseViaNtripAsync(
|
||||
portaUsb: "com3",
|
||||
portaSaida: "com3",
|
||||
portaEntrada: "com3",
|
||||
startNtrip: async () =>
|
||||
{
|
||||
Models.Variaveis.MostrarLog("Iniciando correção NTRIP...");
|
||||
CorrecaoRTK_Ntrip = true;
|
||||
Task.Run(async () => await AplicarCorrecaoRTK_Ntrip());
|
||||
},
|
||||
stopNtrip: async () =>
|
||||
{
|
||||
Models.Variaveis.MostrarLog("Parando correção NTRIP...");
|
||||
CorrecaoRTK_Ntrip = false;
|
||||
},
|
||||
segsFixEstavel: TempoSurveryIn
|
||||
);
|
||||
portaUsb: "com3",
|
||||
portaSaida: "com3",
|
||||
portaEntrada: "com3",
|
||||
startNtrip: async () =>
|
||||
{
|
||||
Models.Variaveis.MostrarLog("Iniciando correção NTRIP...");
|
||||
CorrecaoRTK_Ntrip = true;
|
||||
Task.Run(async () => await AplicarCorrecaoRTK_Ntrip());
|
||||
},
|
||||
stopNtrip: async () =>
|
||||
{
|
||||
Models.Variaveis.MostrarLog("Parando correção NTRIP...");
|
||||
CorrecaoRTK_Ntrip = false;
|
||||
},
|
||||
segsFixEstavel: TempoSurveryIn
|
||||
);
|
||||
if (!sucesso)
|
||||
{
|
||||
Models.Variaveis.MostrarLog("Configurando módulo como base survery in...");
|
||||
|
|
@ -272,6 +273,10 @@ namespace OperationControl.Services
|
|||
await ConfigurarModuloBase(tempo_fixacao: TempoSurveryIn, porta_usb: "com3", porta_saida: "com3");
|
||||
BaseFix.inicioFix = DateTime.UtcNow;
|
||||
}
|
||||
else
|
||||
{
|
||||
Models.Variaveis.MostrarLog("Posição fixada utilizando o Ntrip com sucesso!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1214,6 +1219,15 @@ namespace OperationControl.Services
|
|||
public bool CorrecaoEmAndamento = false;
|
||||
public bool FixLiberado = false;
|
||||
|
||||
public void ReiniciarFix()
|
||||
{
|
||||
CorrecaoEmAndamento = false;
|
||||
inicioFix = null;
|
||||
inicioProcesso = null;
|
||||
fimProcesso = null;
|
||||
FixLiberado = false;
|
||||
}
|
||||
|
||||
// ===== 1) Função principal =====
|
||||
public async Task<bool> FixarBaseViaNtripAsync(string portaUsb = "com3", string portaEntrada = "com2", string portaSaida = "com2", string baseId = "957", int segsFixEstavel = 120, int maxJanelaSegs = 600, double madK = 3.5, Func<Task> startNtrip = null, Func<Task> stopNtrip = null)
|
||||
{
|
||||
|
|
@ -1341,7 +1355,9 @@ namespace OperationControl.Services
|
|||
if (gga is null) continue;
|
||||
|
||||
// Considera "RTK FIX" como qualidade válida
|
||||
if (!FixLiberado || !new List<TiposCorrecaoGPS>() { TiposCorrecaoGPS.RTKFixo }.Contains(gga.FixQuality))
|
||||
var modosValidos = new List<TiposCorrecaoGPS>() { TiposCorrecaoGPS.RTKFixo };
|
||||
if ((DateTime.UtcNow - inicioProcesso.Value).TotalSeconds > 120) modosValidos.Add(TiposCorrecaoGPS.RTKFlutuante);
|
||||
if (!FixLiberado || !modosValidos.Contains(gga.FixQuality))
|
||||
{
|
||||
inicioFix = null; // reset
|
||||
inicioTentativaFix = DateTime.UtcNow;
|
||||
|
|
@ -1356,7 +1372,7 @@ namespace OperationControl.Services
|
|||
}
|
||||
|
||||
amostras_pos.Add(gga);
|
||||
Models.Variaveis.MostrarLog("Nova coordenada registrada!");
|
||||
//Models.Variaveis.MostrarLog("Nova coordenada registrada!");
|
||||
|
||||
// Verifica se já temos FIX estável pelo período necessário
|
||||
if (Progresso >= 100)
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ namespace OperationControl.Windows
|
|||
{
|
||||
if (dados_base)
|
||||
{
|
||||
Variaveis.MostrarLog($"Atualizando dados da tela para a base");
|
||||
//Variaveis.MostrarLog($"Atualizando dados da tela para a base");
|
||||
|
||||
var gpsService = Variaveis.GpsService;
|
||||
lblDispositivos_Status.Content = VariaveisControleOperacao.StatusBase.ToString();
|
||||
|
|
@ -1723,28 +1723,29 @@ namespace OperationControl.Windows
|
|||
{
|
||||
if (!Variaveis.GpsService.BaseFix.FixLiberado)
|
||||
{
|
||||
bool fixar = false;
|
||||
if (Variaveis.GpsService.BaseFix.PosicaoBaseFixada)
|
||||
{
|
||||
var res = MessageBox.Show("Mudar posição da base?", "Tem certeza que deseja fixar a posição da base novamente?", MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||
if (res == MessageBoxResult.Yes)
|
||||
{
|
||||
btnGNSS_FixarBase.Content = "Parar";
|
||||
Variaveis.GpsService.BaseFix.FixLiberado = true;
|
||||
|
||||
Task.Run(async () => await Variaveis.GpsService.ConfigurarModulo(true));
|
||||
fixar = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fixar = true;
|
||||
}
|
||||
if (fixar)
|
||||
{
|
||||
btnGNSS_FixarBase.Content = "Parar";
|
||||
Variaveis.GpsService.BaseFix.FixLiberado = true;
|
||||
Task.Run(async () => await Variaveis.GpsService.ConfigurarModulo(true));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
btnGNSS_FixarBase.Content = "Fixar";
|
||||
Variaveis.GpsService.BaseFix.FixLiberado = false;
|
||||
Variaveis.GpsService.BaseFix.ReiniciarFix();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1798,7 +1799,7 @@ namespace OperationControl.Windows
|
|||
txtParametros_TempoOn.Text = controle.AtuDuracaoAtuacao.ToString();
|
||||
chbParametros_Pulverizador.IsChecked = controle.PulverizadorAutomatico;
|
||||
chbParametros_Frenagem.IsChecked = controle.FrenagemAutomaticaAoParar;
|
||||
chbParametros_Sonar.IsChecked = controle.SonarAtivado;
|
||||
chbParametros_ParadaObstaculo.IsChecked = controle.OakParadaPorObstaculo;
|
||||
}
|
||||
catch (Exception exUi)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue