857 lines
36 KiB
C#
857 lines
36 KiB
C#
using AgroBase.Models.Operacoes;
|
|
using OperationControl.Models;
|
|
using OperationControl.ViewModels.Base;
|
|
using System.Collections.ObjectModel;
|
|
using static AgroBase.Models.Enums;
|
|
using System.Windows.Input;
|
|
using OperationControl.Helpers;
|
|
using static AgroBase.Services.CoolerControlService;
|
|
|
|
namespace OperationControl.ViewModels.Views.Operacao.Diagnostico
|
|
{
|
|
public class DiagnosticoOpcoesViewModel : NotifyBase
|
|
{
|
|
private DiagnosticoModuloItemViewModel _itemAtual;
|
|
private OperacaoParametrosModel _dadosAtual;
|
|
|
|
#region VISIBILIDADES
|
|
|
|
private bool _mostrarOpcoesSemDados = true;
|
|
public bool MostrarOpcoesSemDados { get => _mostrarOpcoesSemDados; set => SetProperty(ref _mostrarOpcoesSemDados, value); }
|
|
|
|
private bool _mostrarOpcoesSensoriamento;
|
|
public bool MostrarOpcoesSensoriamento { get => _mostrarOpcoesSensoriamento; set => SetProperty(ref _mostrarOpcoesSensoriamento, value); }
|
|
|
|
private bool _mostrarOpcoesAtuador;
|
|
public bool MostrarOpcoesAtuador { get => _mostrarOpcoesAtuador; set => SetProperty(ref _mostrarOpcoesAtuador, value); }
|
|
|
|
private bool _mostrarOpcoesBico;
|
|
public bool MostrarOpcoesBico { get => _mostrarOpcoesBico; set => SetProperty(ref _mostrarOpcoesBico, value); }
|
|
|
|
private bool _mostrarOpcoesBomba;
|
|
public bool MostrarOpcoesBomba { get => _mostrarOpcoesBomba; set => SetProperty(ref _mostrarOpcoesBomba, value); }
|
|
|
|
private bool _mostrarOpcoesDirecional;
|
|
public bool MostrarOpcoesDirecional { get => _mostrarOpcoesDirecional; set => SetProperty(ref _mostrarOpcoesDirecional, value); }
|
|
|
|
private bool _mostrarOpcoesGps;
|
|
public bool MostrarOpcoesGps { get => _mostrarOpcoesGps; set => SetProperty(ref _mostrarOpcoesGps, value); }
|
|
|
|
private bool _mostrarOpcoesTrajetoria;
|
|
public bool MostrarOpcoesTrajetoria { get => _mostrarOpcoesTrajetoria; set => SetProperty(ref _mostrarOpcoesTrajetoria, value); }
|
|
|
|
private bool _mostrarOpcoesRele;
|
|
public bool MostrarOpcoesRele { get => _mostrarOpcoesRele; set => SetProperty(ref _mostrarOpcoesRele, value); }
|
|
|
|
private bool _mostrarOpcoesServo;
|
|
public bool MostrarOpcoesServo { get => _mostrarOpcoesServo; set => SetProperty(ref _mostrarOpcoesServo, value); }
|
|
|
|
private bool _mostrarOpcoesNpc;
|
|
public bool MostrarOpcoesNpc { get => _mostrarOpcoesNpc; set => SetProperty(ref _mostrarOpcoesNpc, value); }
|
|
|
|
#endregion
|
|
|
|
#region CAMPOS ATUADOR MOD
|
|
|
|
private double _barraAltura;
|
|
public double BarraAltura { get => _barraAltura; set => SetProperty(ref _barraAltura, value); }
|
|
|
|
private string _barraAlturaTexto = "0 cm";
|
|
public string BarraAlturaTexto { get => _barraAlturaTexto; set => SetProperty(ref _barraAlturaTexto, value); }
|
|
|
|
#endregion
|
|
|
|
#region BICO
|
|
|
|
private string _bicoTitulo = "Bico - Testes";
|
|
public string BicoTitulo { get => _bicoTitulo; set => SetProperty(ref _bicoTitulo, value); }
|
|
|
|
private double _bicoAngulo;
|
|
public double BicoAngulo
|
|
{
|
|
get => _bicoAngulo;
|
|
set
|
|
{
|
|
if (SetProperty(ref _bicoAngulo, value))
|
|
BicoAnguloTexto = $"{Convert.ToInt32(value):00}°";
|
|
}
|
|
}
|
|
|
|
private string _bicoAnguloTexto = "00°";
|
|
public string BicoAnguloTexto { get => _bicoAnguloTexto; set => SetProperty(ref _bicoAnguloTexto, value); }
|
|
|
|
private double _bicoAnguloAbertura = 0;
|
|
public double BicoAnguloAbertura { get => _bicoAnguloAbertura; set => SetProperty(ref _bicoAnguloAbertura, value); }
|
|
|
|
private string _txtBicoComando = "—";
|
|
public string TxtBicoComando { get => _txtBicoComando; set => SetProperty(ref _txtBicoComando, value); }
|
|
|
|
private string _txtBicoStatusReal = "—";
|
|
public string TxtBicoStatusReal { get => _txtBicoStatusReal; set => SetProperty(ref _txtBicoStatusReal, value); }
|
|
|
|
private string _txtBicoTempoLigado = "00:00:00";
|
|
public string TxtBicoTempoLigado { get => _txtBicoTempoLigado; set => SetProperty(ref _txtBicoTempoLigado, value); }
|
|
|
|
private string _txtBicoVazao = "0,0 mL/s";
|
|
public string TxtBicoVazao { get => _txtBicoVazao; set => SetProperty(ref _txtBicoVazao, value); }
|
|
|
|
private string _txtBicoPressao = "0,0 psi";
|
|
public string TxtBicoPressao { get => _txtBicoPressao; set => SetProperty(ref _txtBicoPressao, value); }
|
|
|
|
private string _txtBicoAtuacoes = "—";
|
|
public string TxtBicoAtuacoes { get => _txtBicoAtuacoes; set => SetProperty(ref _txtBicoAtuacoes, value); }
|
|
|
|
#endregion
|
|
|
|
#region BOMBA
|
|
|
|
private string _bombaTitulo = "Bomba - Testes";
|
|
public string BombaTitulo { get => _bombaTitulo; set => SetProperty(ref _bombaTitulo, value); }
|
|
|
|
private double _bombaPressaoAlvo;
|
|
public double BombaPressaoAlvo
|
|
{
|
|
get => _bombaPressaoAlvo;
|
|
set
|
|
{
|
|
if (SetProperty(ref _bombaPressaoAlvo, value))
|
|
BombaPressaoAlvoTexto = $"{value:0} psi";
|
|
}
|
|
}
|
|
|
|
private string _bombaPressaoAlvoTexto = "0 psi";
|
|
public string BombaPressaoAlvoTexto { get => _bombaPressaoAlvoTexto; set => SetProperty(ref _bombaPressaoAlvoTexto, value); }
|
|
|
|
private string _txtBombaComando = "—";
|
|
public string TxtBombaComando { get => _txtBombaComando; set => SetProperty(ref _txtBombaComando, value); }
|
|
|
|
private string _txtBombaStatusReal = "—";
|
|
public string TxtBombaStatusReal { get => _txtBombaStatusReal; set => SetProperty(ref _txtBombaStatusReal, value); }
|
|
|
|
private string _txtBombaPressaoLinha = "0,0 psi";
|
|
public string TxtBombaPressaoLinha { get => _txtBombaPressaoLinha; set => SetProperty(ref _txtBombaPressaoLinha, value); }
|
|
|
|
private string _txtBombaPotencia = "0 %";
|
|
public string TxtBombaPotencia { get => _txtBombaPotencia; set => SetProperty(ref _txtBombaPotencia, value); }
|
|
|
|
#endregion
|
|
|
|
#region DIRECIONAL
|
|
|
|
public ObservableCollection<TipoMovimentoDirecional> DirMovimentosDisponiveis { get; } = new();
|
|
public ObservableCollection<Direcao> DirDirecoesDisponiveis { get; } = new();
|
|
|
|
private TipoMovimentoDirecional _dirMovimentoSelecionado;
|
|
public TipoMovimentoDirecional DirMovimentoSelecionado { get => _dirMovimentoSelecionado; set => SetProperty(ref _dirMovimentoSelecionado, value); }
|
|
|
|
private Direcao _dirDirecaoSelecionada;
|
|
public Direcao DirDirecaoSelecionada { get => _dirDirecaoSelecionada; set => SetProperty(ref _dirDirecaoSelecionada, value); }
|
|
|
|
private double _dirAngulo;
|
|
public double DirAngulo
|
|
{
|
|
get => _dirAngulo;
|
|
set
|
|
{
|
|
if (SetProperty(ref _dirAngulo, value))
|
|
DirAnguloTexto = $"{Convert.ToInt32(value)}°";
|
|
}
|
|
}
|
|
|
|
private string _dirAnguloTexto = "0°";
|
|
public string DirAnguloTexto { get => _dirAnguloTexto; set => SetProperty(ref _dirAnguloTexto, value); }
|
|
|
|
private string _dirTitulo = "Direcional - Testes";
|
|
public string DirTitulo { get => _dirTitulo; set => SetProperty(ref _dirTitulo, value); }
|
|
|
|
private string _txtDirSentidoSP = "—";
|
|
public string TxtDirSentidoSP { get => _txtDirSentidoSP; set => SetProperty(ref _txtDirSentidoSP, value); }
|
|
|
|
private string _txtDirSentido = "—";
|
|
public string TxtDirSentido { get => _txtDirSentido; set => SetProperty(ref _txtDirSentido, value); }
|
|
|
|
private string _txtDirAnguloSP = "0°";
|
|
public string TxtDirAnguloSP { get => _txtDirAnguloSP; set => SetProperty(ref _txtDirAnguloSP, value); }
|
|
|
|
private string _txtDirAngulo = "0°";
|
|
public string TxtDirAngulo { get => _txtDirAngulo; set => SetProperty(ref _txtDirAngulo, value); }
|
|
|
|
#endregion
|
|
|
|
#region GPS
|
|
|
|
private double _gpsLeverArmLateral;
|
|
public double GpsLeverArmLateral
|
|
{
|
|
get => _gpsLeverArmLateral;
|
|
set
|
|
{
|
|
if (SetProperty(ref _gpsLeverArmLateral, value))
|
|
GpsLeverArmLateralTexto = $"{(value * 10.0):00} cm";
|
|
}
|
|
}
|
|
|
|
private string _gpsLeverArmLateralTexto = "00 cm";
|
|
public string GpsLeverArmLateralTexto { get => _gpsLeverArmLateralTexto; set => SetProperty(ref _gpsLeverArmLateralTexto, value); }
|
|
|
|
private double _gpsLeverArmFrontal;
|
|
public double GpsLeverArmFrontal
|
|
{
|
|
get => _gpsLeverArmFrontal;
|
|
set
|
|
{
|
|
if (SetProperty(ref _gpsLeverArmFrontal, value))
|
|
GpsLeverArmFrontalTexto = $"{(value * 10.0):00} cm";
|
|
}
|
|
}
|
|
|
|
private string _gpsLeverArmFrontalTexto = "00 cm";
|
|
public string GpsLeverArmFrontalTexto { get => _gpsLeverArmFrontalTexto; set => SetProperty(ref _gpsLeverArmFrontalTexto, value); }
|
|
|
|
private string _txtGpsCorrecao = "SemCorreção";
|
|
public string TxtGpsCorrecao { get => _txtGpsCorrecao; set => SetProperty(ref _txtGpsCorrecao, value); }
|
|
|
|
private string _txtGpsIdade = "0";
|
|
public string TxtGpsIdade { get => _txtGpsIdade; set => SetProperty(ref _txtGpsIdade, value); }
|
|
|
|
private string _txtGpsPrecisao = "0";
|
|
public string TxtGpsPrecisao { get => _txtGpsPrecisao; set => SetProperty(ref _txtGpsPrecisao, value); }
|
|
|
|
private string _txtGpsNSatelites = "0";
|
|
public string TxtGpsNSatelites { get => _txtGpsNSatelites; set => SetProperty(ref _txtGpsNSatelites, value); }
|
|
|
|
private string _txtGpsDistBase = "0";
|
|
public string TxtGpsDistBase { get => _txtGpsDistBase; set => SetProperty(ref _txtGpsDistBase, value); }
|
|
|
|
private string _txtGpsOrientacao = "0";
|
|
public string TxtGpsOrientacao { get => _txtGpsOrientacao; set => SetProperty(ref _txtGpsOrientacao, value); }
|
|
|
|
#endregion
|
|
|
|
#region TRAJETORIA
|
|
|
|
private bool _trajetoriaBatLiberada;
|
|
public bool TrajetoriaBatLiberada { get => _trajetoriaBatLiberada; set => SetProperty(ref _trajetoriaBatLiberada, value); }
|
|
|
|
private bool _trajetoriaHerbLiberado;
|
|
public bool TrajetoriaHerbLiberado { get => _trajetoriaHerbLiberado; set => SetProperty(ref _trajetoriaHerbLiberado, value); }
|
|
|
|
private bool _trajetoriaPodeConfirmar = true;
|
|
public bool TrajetoriaPodeConfirmar { get => _trajetoriaPodeConfirmar; set => SetProperty(ref _trajetoriaPodeConfirmar, value); }
|
|
|
|
private string _txtTrajetoriaDistCorredor = "0,00 m";
|
|
public string TxtTrajetoriaDistCorredor { get => _txtTrajetoriaDistCorredor; set => SetProperty(ref _txtTrajetoriaDistCorredor, value); }
|
|
|
|
private string _txtTrajetoriaDistBateria = "0,00 m";
|
|
public string TxtTrajetoriaDistBateria { get => _txtTrajetoriaDistBateria; set => SetProperty(ref _txtTrajetoriaDistBateria, value); }
|
|
|
|
private string _txtTrajetoriaDistPulverizador = "0,00 m";
|
|
public string TxtTrajetoriaDistPulverizador { get => _txtTrajetoriaDistPulverizador; set => SetProperty(ref _txtTrajetoriaDistPulverizador, value); }
|
|
|
|
private string _txtTrajetoriaStatus = "Desconhecido";
|
|
public string TxtTrajetoriaStatus { get => _txtTrajetoriaStatus; set => SetProperty(ref _txtTrajetoriaStatus, value); }
|
|
|
|
private string _txtTrajetoriaBatOk = "Não";
|
|
public string TxtTrajetoriaBatOk { get => _txtTrajetoriaBatOk; set => SetProperty(ref _txtTrajetoriaBatOk, value); }
|
|
|
|
private string _txtTrajetoriaHerbOk = "Não";
|
|
public string TxtTrajetoriaHerbOk { get => _txtTrajetoriaHerbOk; set => SetProperty(ref _txtTrajetoriaHerbOk, value); }
|
|
|
|
#endregion
|
|
|
|
#region RELE
|
|
|
|
private string _releTitulo = "Relé - Testes";
|
|
public string ReleTitulo { get => _releTitulo; set => SetProperty(ref _releTitulo, value); }
|
|
|
|
private string _txtReleComando = "—";
|
|
public string TxtReleComando { get => _txtReleComando; set => SetProperty(ref _txtReleComando, value); }
|
|
|
|
private string _txtReleStatusReal = "—";
|
|
public string TxtReleStatusReal { get => _txtReleStatusReal; set => SetProperty(ref _txtReleStatusReal, value); }
|
|
|
|
#endregion
|
|
|
|
#region SERVO
|
|
|
|
private double _servoAngulo;
|
|
public double ServoAngulo
|
|
{
|
|
get => _servoAngulo;
|
|
set
|
|
{
|
|
if (SetProperty(ref _servoAngulo, value))
|
|
ServoAnguloTexto = $"{Convert.ToInt32(value):0}°";
|
|
}
|
|
}
|
|
|
|
private string _servoAnguloTexto = "0°";
|
|
public string ServoAnguloTexto { get => _servoAnguloTexto; set => SetProperty(ref _servoAnguloTexto, value); }
|
|
|
|
private string _txtServoComando = "—";
|
|
public string TxtServoComando { get => _txtServoComando; set => SetProperty(ref _txtServoComando, value); }
|
|
|
|
private string _txtServoLeitura = "—";
|
|
public string TxtServoLeitura { get => _txtServoLeitura; set => SetProperty(ref _txtServoLeitura, value); }
|
|
|
|
private string _txtServoIncremental = "—";
|
|
public string TxtServoIncremental { get => _txtServoIncremental; set => SetProperty(ref _txtServoIncremental, value); }
|
|
|
|
#endregion
|
|
|
|
#region NPC
|
|
|
|
public ObservableCollection<CoolerMode> NpcCoolerModosDisponiveis { get; } = new();
|
|
private bool _npcCoolerEntradaHabilitado;
|
|
public bool NpcCoolerEntradaHabilitado
|
|
{
|
|
get => _npcCoolerEntradaHabilitado;
|
|
set => SetProperty(ref _npcCoolerEntradaHabilitado, value);
|
|
}
|
|
|
|
private bool _npcCoolerSaidaHabilitado;
|
|
public bool NpcCoolerSaidaHabilitado
|
|
{
|
|
get => _npcCoolerSaidaHabilitado;
|
|
set => SetProperty(ref _npcCoolerSaidaHabilitado, value);
|
|
}
|
|
|
|
private CoolerMode _npcCoolerModoSelecionado;
|
|
public CoolerMode NpcCoolerModoSelecionado
|
|
{
|
|
get => _npcCoolerModoSelecionado;
|
|
set
|
|
{
|
|
if (SetProperty(ref _npcCoolerModoSelecionado, value))
|
|
{
|
|
AtualizarEstadoCoolerModo();
|
|
}
|
|
}
|
|
}
|
|
private void AtualizarEstadoCoolerModo()
|
|
{
|
|
switch (NpcCoolerModoSelecionado)
|
|
{
|
|
case CoolerMode.Off:
|
|
NpcCoolerEntradaHabilitado = false;
|
|
NpcCoolerSaidaHabilitado = false;
|
|
NpcCoolerEntrada = false;
|
|
NpcCoolerSaida = false;
|
|
break;
|
|
|
|
case CoolerMode.Manual:
|
|
NpcCoolerEntradaHabilitado = true;
|
|
NpcCoolerSaidaHabilitado = true;
|
|
NpcCoolerEntrada = false;
|
|
NpcCoolerSaida = false;
|
|
break;
|
|
|
|
default:
|
|
NpcCoolerEntradaHabilitado = false;
|
|
NpcCoolerSaidaHabilitado = false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
private bool _npcCoolerEntrada;
|
|
public bool NpcCoolerEntrada { get => _npcCoolerEntrada; set => SetProperty(ref _npcCoolerEntrada, value); }
|
|
|
|
private bool _npcCoolerSaida;
|
|
public bool NpcCoolerSaida { get => _npcCoolerSaida; set => SetProperty(ref _npcCoolerSaida, value); }
|
|
|
|
private double _npcCoolerTempOn = 0;
|
|
public double NpcCoolerTempOn { get => _npcCoolerTempOn; set => SetProperty(ref _npcCoolerTempOn, value); }
|
|
|
|
private double _npcCoolerTempTurbo = 0;
|
|
public double NpcCoolerTempTurbo { get => _npcCoolerTempTurbo; set => SetProperty(ref _npcCoolerTempTurbo, value); }
|
|
|
|
private string _txtNpcCoolerModo = "—";
|
|
public string TxtNpcCoolerModo { get => _txtNpcCoolerModo; set => SetProperty(ref _txtNpcCoolerModo, value); }
|
|
|
|
private string _txtNpcCoolerTemperatura = "—";
|
|
public string TxtNpcCoolerTemperatura { get => _txtNpcCoolerTemperatura; set => SetProperty(ref _txtNpcCoolerTemperatura, value); }
|
|
|
|
private string _txtNpcCoolerEntrada = "—";
|
|
public string TxtNpcCoolerEntrada { get => _txtNpcCoolerEntrada; set => SetProperty(ref _txtNpcCoolerEntrada, value); }
|
|
|
|
private string _txtNpcCoolerSaida = "—";
|
|
public string TxtNpcCoolerSaida { get => _txtNpcCoolerSaida; set => SetProperty(ref _txtNpcCoolerSaida, value); }
|
|
|
|
#endregion
|
|
|
|
#region COMMANDS
|
|
|
|
public ICommand SensoriamentoReiniciarCommand { get; }
|
|
public ICommand AtuadorReiniciarCommand { get; }
|
|
public ICommand BarraMoverCommand { get; }
|
|
|
|
public ICommand BicoLigarCommand { get; }
|
|
public ICommand BicoDesligarCommand { get; }
|
|
public ICommand BicoMoverCommand { get; }
|
|
public ICommand BicoSalvarAnguloAberturaCommand { get; }
|
|
|
|
public ICommand BombaLigarCommand { get; }
|
|
public ICommand BombaDesligarCommand { get; }
|
|
|
|
public ICommand DirReferenciarCommand { get; }
|
|
public ICommand DirMovimentarCommand { get; }
|
|
|
|
public ICommand GpsSalvarCommand { get; }
|
|
public ICommand TrajetoriaConfirmarCommand { get; }
|
|
|
|
public ICommand ReleLigarCommand { get; }
|
|
public ICommand ReleDesligarCommand { get; }
|
|
|
|
public ICommand ServoEnviarCommand { get; }
|
|
public ICommand NpcCoolerEnviarCommand { get; }
|
|
|
|
#endregion
|
|
|
|
public DiagnosticoOpcoesViewModel()
|
|
{
|
|
DirDirecoesDisponiveis = new ObservableCollection<Direcao>() { Direcao.Parado, Direcao.Esquerda, Direcao.Direita };
|
|
|
|
foreach (var modo in Enum.GetValues<TipoMovimentoDirecional>())
|
|
DirMovimentosDisponiveis.Add(modo);
|
|
|
|
foreach (var modo in Enum.GetValues<CoolerMode>())
|
|
NpcCoolerModosDisponiveis.Add(modo);
|
|
|
|
SensoriamentoReiniciarCommand = new RelayCommand(_ => SensoriamentoReiniciar());
|
|
AtuadorReiniciarCommand = new RelayCommand(_ => AtuadorReiniciar());
|
|
BarraMoverCommand = new RelayCommand(_ => BarraMover());
|
|
|
|
BicoLigarCommand = new RelayCommand(_ => BicoLigar());
|
|
BicoDesligarCommand = new RelayCommand(_ => BicoDesligar());
|
|
BicoMoverCommand = new RelayCommand(_ => BicoMover());
|
|
BicoSalvarAnguloAberturaCommand = new RelayCommand(_ => BicoSalvarAnguloAbertura());
|
|
|
|
BombaLigarCommand = new RelayCommand(_ => BombaLigar());
|
|
BombaDesligarCommand = new RelayCommand(_ => BombaDesligar());
|
|
|
|
DirReferenciarCommand = new RelayCommand(_ => DirReferenciar());
|
|
DirMovimentarCommand = new RelayCommand(_ => DirMovimentar());
|
|
|
|
GpsSalvarCommand = new RelayCommand(_ => GpsSalvar());
|
|
TrajetoriaConfirmarCommand = new RelayCommand(_ => TrajetoriaConfirmar());
|
|
|
|
ReleLigarCommand = new RelayCommand(_ => ReleLigar());
|
|
ReleDesligarCommand = new RelayCommand(_ => ReleDesligar());
|
|
|
|
ServoEnviarCommand = new RelayCommand(_ => ServoEnviar());
|
|
NpcCoolerEnviarCommand = new RelayCommand(_ => NpcCoolerEnviar());
|
|
}
|
|
|
|
public void Atualizar(DiagnosticoModuloItemViewModel item, OperacaoParametrosModel dados, bool clicado)
|
|
{
|
|
_itemAtual = item;
|
|
_dadosAtual = dados;
|
|
|
|
if (clicado)
|
|
{
|
|
ResetarVisibilidades();
|
|
ResetarCampos();
|
|
}
|
|
|
|
if (_itemAtual == null || _dadosAtual?.DadosLeitura == null)
|
|
{
|
|
MostrarOpcoesSemDados = true;
|
|
return;
|
|
}
|
|
|
|
var rover = _dadosAtual.DadosLeitura;
|
|
|
|
switch (_itemAtual.Modulo)
|
|
{
|
|
case T_Code.Atu:
|
|
switch (_itemAtual.SCode)
|
|
{
|
|
case S_Code.sMOD:
|
|
MostrarOpcoesAtuador = true;
|
|
if (clicado)
|
|
{
|
|
BarraAltura = rover.Controle?.AlturaBarra ?? 0;
|
|
}
|
|
break;
|
|
|
|
case S_Code.sBIC:
|
|
MostrarOpcoesBico = true;
|
|
PreencherBico(rover, clicado);
|
|
break;
|
|
|
|
case S_Code.sBMB:
|
|
MostrarOpcoesBomba = true;
|
|
PreencherBomba(rover, clicado);
|
|
break;
|
|
|
|
case S_Code.sSRV:
|
|
MostrarOpcoesServo = true;
|
|
PreencherServoAtuador(rover, clicado);
|
|
break;
|
|
|
|
default:
|
|
MostrarOpcoesSemDados = true;
|
|
break;
|
|
}
|
|
break;
|
|
|
|
case T_Code.Sen:
|
|
switch (_itemAtual.SCode)
|
|
{
|
|
case S_Code.sMOD:
|
|
MostrarOpcoesSensoriamento = true;
|
|
break;
|
|
|
|
case S_Code.sRLE:
|
|
MostrarOpcoesRele = true;
|
|
PreencherRele(rover, clicado);
|
|
break;
|
|
|
|
case S_Code.sSRV:
|
|
MostrarOpcoesServo = true;
|
|
PreencherServoSensoriamento(rover, clicado);
|
|
break;
|
|
|
|
default:
|
|
MostrarOpcoesSemDados = true;
|
|
break;
|
|
}
|
|
break;
|
|
|
|
case T_Code.Dir:
|
|
MostrarOpcoesDirecional = true;
|
|
PreencherDirecional(rover, clicado);
|
|
break;
|
|
|
|
case T_Code.Gps:
|
|
MostrarOpcoesGps = true;
|
|
PreencherGps(rover, clicado);
|
|
break;
|
|
|
|
case T_Code.Trj:
|
|
MostrarOpcoesTrajetoria = true;
|
|
PreencherTrajetoria(rover, clicado);
|
|
break;
|
|
|
|
case T_Code.Npc:
|
|
MostrarOpcoesNpc = true;
|
|
PreencherNpc(rover, clicado);
|
|
break;
|
|
|
|
default:
|
|
MostrarOpcoesSemDados = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
#region PREENCHIMENTO
|
|
|
|
private void PreencherBico(OperacaoParametrosDadosModel rover, bool clicado)
|
|
{
|
|
var bico = rover?.Atuador?.Bicos?.FirstOrDefault(x => x.ID == _itemAtual.LabelModulo);
|
|
BicoTitulo = $"Bico {_itemAtual.LabelModulo} - Testes";
|
|
TxtBicoComando = (bico?.ComandoEstado ?? false) ? "Ligado" : "Desligado";
|
|
TxtBicoStatusReal = (bico?.LeituraEstado ?? false) ? "Ligado" : "Desligado";
|
|
TxtBicoTempoLigado = $"{bico?.TempoAtuado ?? 0:0.##} ms";
|
|
TxtBicoVazao = $"{bico?.VazaoInstantaneaMLs ?? 0:0.##} mL/s";
|
|
TxtBicoPressao = $"{rover?.Atuador?.PressaoLinhaPsi ?? 0:0.##} psi";
|
|
TxtBicoAtuacoes = $"{bico?.QtdAtuacoes ?? 0}";
|
|
if (clicado)
|
|
{
|
|
BicoAngulo = bico?.ComandoAngulo ?? 0;
|
|
BicoAnguloAbertura = bico?.AnguloAbertura ?? 0;
|
|
}
|
|
}
|
|
|
|
private void PreencherBomba(OperacaoParametrosDadosModel rover, bool clicado)
|
|
{
|
|
var bomba = rover?.Atuador?.Bombas?.FirstOrDefault(x => x.ID == _itemAtual.LabelModulo);
|
|
BombaTitulo = $"Bomba {_itemAtual.LabelModulo} - Testes";
|
|
TxtBombaComando = (bomba?.ComandoEstado ?? false) ? "Ligado" : "Desligado";
|
|
TxtBombaStatusReal = (bomba?.LeituraEstado ?? false) ? "Ligado" : "Desligado";
|
|
TxtBombaPressaoLinha = $"{rover?.Atuador?.PressaoLinhaPsi ?? 0:0.##} psi";
|
|
TxtBombaPotencia = $"{bomba?.Potencia ?? 0:0.#} %";
|
|
if (clicado)
|
|
{
|
|
BombaPressaoAlvo = bomba?.Potencia ?? 0;
|
|
}
|
|
}
|
|
|
|
private void PreencherDirecional(OperacaoParametrosDadosModel rover, bool clicado)
|
|
{
|
|
var mod = rover?.Direcional?.Modulos?.FirstOrDefault(x => x.Mod_ID == _itemAtual.LabelModulo);
|
|
DirTitulo = $"Direcional {_itemAtual.LabelModulo} - Testes";
|
|
TxtDirSentidoSP = $"{mod?.Sentido_SP ?? Sentido.Parado}";
|
|
TxtDirSentido = $"{mod?.SentidoReal ?? Sentido.Parado}";
|
|
TxtDirAnguloSP = $"{mod?.Angulo_SP ?? 0:0.00}°";
|
|
TxtDirAngulo = $"{mod?.AnguloDriver ?? 0:0.00}°";
|
|
if (clicado)
|
|
{
|
|
DirAngulo = mod?.Angulo_SP ?? 0;
|
|
}
|
|
}
|
|
|
|
private void PreencherGps(OperacaoParametrosDadosModel rover, bool clicado)
|
|
{
|
|
var dados = rover?.Gnss;
|
|
TxtGpsCorrecao = $"{dados?.QualidadeFix ?? TiposCorrecaoGPS.SemCorrecao}";
|
|
TxtGpsIdade = $"{dados?.IdadeCorrecao ?? -1}";
|
|
TxtGpsPrecisao = $"{dados?.PrecisaoCm ?? -1}";
|
|
TxtGpsNSatelites = $"{dados?.NumeroSatelites ?? 0}";
|
|
TxtGpsDistBase = "0";
|
|
TxtGpsOrientacao = $"{dados?.OrientacaoReal ?? 0}";
|
|
if (clicado)
|
|
{
|
|
GpsLeverArmLateral = (dados?.LeverArmLateral ?? 0) / 10.0;
|
|
GpsLeverArmFrontal = (dados?.LeverArmFrontal ?? 0) / 10.0;
|
|
}
|
|
}
|
|
|
|
private void PreencherTrajetoria(OperacaoParametrosDadosModel rover, bool clicado)
|
|
{
|
|
var dados = rover?.Trajetoria?.AutonomiaCorredor;
|
|
TxtTrajetoriaDistCorredor = $"{dados?.DistanciaCorredor_m ?? 0:0.00} m";
|
|
TxtTrajetoriaDistBateria = $"{dados?.DistanciaSeguraBateria_m ?? 0:0.00} m";
|
|
TxtTrajetoriaDistPulverizador = $"{dados?.DistanciaSeguraHerbicida_m ?? 0:0.00} m";
|
|
TxtTrajetoriaStatus = $"{dados?.Status ?? AgroBase.Models.AutonomiaCorredorStatus.Desconhecido}";
|
|
TxtTrajetoriaBatOk = (dados?.BateriaSuficiente ?? false) ? "Sim" : "Não";
|
|
TxtTrajetoriaHerbOk = (dados?.HerbicidaSuficiente ?? false) ? "Sim" : "Não";
|
|
TrajetoriaPodeConfirmar = !(dados?.Liberado ?? false);
|
|
if (clicado)
|
|
{
|
|
TrajetoriaBatLiberada = dados?.BateriaSuficiente ?? false;
|
|
TrajetoriaHerbLiberado = dados?.HerbicidaSuficiente ?? false;
|
|
}
|
|
}
|
|
|
|
private void PreencherRele(OperacaoParametrosDadosModel rover, bool clicado)
|
|
{
|
|
var rele = rover?.Sensoriamento?.Reles?.FirstOrDefault(x => x.ID == _itemAtual.LabelModulo);
|
|
ReleTitulo = $"Relé {_itemAtual.LabelModulo} - Testes";
|
|
TxtReleComando = (rele?.ComandoEstado ?? false) ? "Ligado" : "Desligado";
|
|
TxtReleStatusReal = (rele?.LeituraEstado ?? false) ? "Ligado" : "Desligado";
|
|
}
|
|
|
|
private void PreencherServoSensoriamento(OperacaoParametrosDadosModel rover, bool clicado)
|
|
{
|
|
var servo = rover?.Sensoriamento?.Servos?.FirstOrDefault(x => x.ID == _itemAtual.LabelModulo);
|
|
TxtServoComando = $"{servo?.ComandoAngulo ?? 0}°";
|
|
TxtServoLeitura = $"{servo?.LeituraAngulo ?? 0}°";
|
|
TxtServoIncremental = (servo?.Incremental ?? false) ? "Incremental" : "Decremental";
|
|
if (clicado)
|
|
{
|
|
ServoAngulo = servo?.ComandoAngulo ?? 0;
|
|
}
|
|
}
|
|
|
|
private void PreencherServoAtuador(OperacaoParametrosDadosModel rover, bool clicado)
|
|
{
|
|
var servo = rover?.Atuador?.Servos?.FirstOrDefault(x => x.ID == _itemAtual.LabelModulo);
|
|
TxtServoComando = $"{servo?.ComandoAngulo ?? 0}°";
|
|
TxtServoLeitura = $"{servo?.LeituraAngulo ?? 0}°";
|
|
TxtServoIncremental = (servo?.Incremental ?? false) ? "Incremental" : "Decremental";
|
|
if (clicado)
|
|
{
|
|
ServoAngulo = servo?.ComandoAngulo ?? 0;
|
|
}
|
|
}
|
|
|
|
private void PreencherNpc(OperacaoParametrosDadosModel rover, bool clicado)
|
|
{
|
|
var dados = rover?.Refrigeracao;
|
|
TxtNpcCoolerModo = $"{dados?.Modo}";
|
|
TxtNpcCoolerTemperatura = $"{dados?.Temperatura ?? 0:0.00} °C";
|
|
TxtNpcCoolerEntrada = $"{dados?.EstadoEntrada} ({dados?.LeituraEntrada})";
|
|
TxtNpcCoolerSaida = $"{dados?.EstadoSaida} ({dados?.LeituraSaida})";
|
|
if (clicado)
|
|
{
|
|
NpcCoolerModoSelecionado = dados?.Modo ?? CoolerMode.Off;
|
|
NpcCoolerEntrada = (dados?.EstadoEntrada ?? Estado.Desligado) == Estado.Ligado;
|
|
NpcCoolerSaida = (dados?.EstadoSaida ?? Estado.Desligado) == Estado.Ligado;
|
|
NpcCoolerTempOn = dados?.TemperaturaLigar ?? 0;
|
|
NpcCoolerTempTurbo = dados?.TemperaturaTurbo ?? 0;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region RESET
|
|
|
|
private void ResetarVisibilidades()
|
|
{
|
|
MostrarOpcoesSemDados = false;
|
|
MostrarOpcoesSensoriamento = false;
|
|
MostrarOpcoesAtuador = false;
|
|
MostrarOpcoesBico = false;
|
|
MostrarOpcoesBomba = false;
|
|
MostrarOpcoesDirecional = false;
|
|
MostrarOpcoesGps = false;
|
|
MostrarOpcoesTrajetoria = false;
|
|
MostrarOpcoesRele = false;
|
|
MostrarOpcoesServo = false;
|
|
MostrarOpcoesNpc = false;
|
|
}
|
|
|
|
private void ResetarCampos()
|
|
{
|
|
BarraAltura = 0;
|
|
BicoAngulo = 0;
|
|
BicoAnguloAbertura = 0;
|
|
BombaPressaoAlvo = 0;
|
|
DirAngulo = 0;
|
|
GpsLeverArmLateral = 0;
|
|
GpsLeverArmFrontal = 0;
|
|
TrajetoriaBatLiberada = false;
|
|
TrajetoriaHerbLiberado = false;
|
|
ServoAngulo = 0;
|
|
NpcCoolerEntrada = false;
|
|
NpcCoolerSaida = false;
|
|
NpcCoolerTempOn = 0;
|
|
NpcCoolerTempTurbo = 0;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region COMMAND ACTIONS
|
|
|
|
private void SensoriamentoReiniciar()
|
|
{
|
|
if (_itemAtual?.Modulo != T_Code.Sen) return;
|
|
if (MessageBox.Show("Tem certeza que deseja reiniciar o módulo Sensoriamento?", "Reiniciar Módulo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
{
|
|
VariaveisControleOperacao.EnviarComandoSensoriamento(_itemAtual.LabelModulo, true);
|
|
}
|
|
}
|
|
|
|
private void AtuadorReiniciar()
|
|
{
|
|
if (_itemAtual?.Modulo != T_Code.Atu) return;
|
|
if (MessageBox.Show("Tem certeza que deseja reiniciar o módulo Atuador?", "Reiniciar Módulo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
{
|
|
VariaveisControleOperacao.EnviarComandoAtuador(_itemAtual.LabelModulo, true);
|
|
}
|
|
}
|
|
|
|
private void BarraMover()
|
|
{
|
|
if (_itemAtual?.Modulo != T_Code.Atu) return;
|
|
VariaveisControleOperacao.EnviarComandoAtuador(_itemAtual.LabelModulo, altura: Convert.ToInt32(BarraAltura));
|
|
}
|
|
|
|
private void BicoLigar()
|
|
{
|
|
if (_itemAtual?.Modulo != T_Code.Atu || _itemAtual.SCode != S_Code.sBIC) return;
|
|
VariaveisControleOperacao.EnviarComandoAtuador(_itemAtual.LabelModulo, status: true);
|
|
}
|
|
|
|
private void BicoDesligar()
|
|
{
|
|
if (_itemAtual?.Modulo != T_Code.Atu || _itemAtual.SCode != S_Code.sBIC) return;
|
|
VariaveisControleOperacao.EnviarComandoAtuador(_itemAtual.LabelModulo, status: false);
|
|
}
|
|
|
|
private void BicoMover()
|
|
{
|
|
if (_itemAtual?.Modulo != T_Code.Atu || _itemAtual.SCode != S_Code.sBIC) return;
|
|
VariaveisControleOperacao.EnviarComandoAtuador(_itemAtual.LabelModulo, angulo_controle: Convert.ToInt32(BicoAngulo));
|
|
}
|
|
|
|
private void BicoSalvarAnguloAbertura()
|
|
{
|
|
if (_itemAtual?.Modulo != T_Code.Atu || _itemAtual.SCode != S_Code.sBIC) return;
|
|
VariaveisControleOperacao.EnviarComandoAtuador(_itemAtual.LabelModulo, angulo_abertura: BicoAnguloAbertura);
|
|
}
|
|
|
|
private void BombaLigar()
|
|
{
|
|
if (_itemAtual?.Modulo != T_Code.Atu || _itemAtual.SCode != S_Code.sBMB) return;
|
|
VariaveisControleOperacao.EnviarComandoAtuador(_itemAtual.LabelModulo, status: true);
|
|
}
|
|
|
|
private void BombaDesligar()
|
|
{
|
|
if (_itemAtual?.Modulo != T_Code.Atu || _itemAtual.SCode != S_Code.sBMB) return;
|
|
VariaveisControleOperacao.EnviarComandoAtuador(_itemAtual.LabelModulo, status: false);
|
|
}
|
|
|
|
private void DirReferenciar()
|
|
{
|
|
if (_itemAtual?.Modulo != T_Code.Dir) return;
|
|
if (MessageBox.Show("Tem certeza que deseja realizar o referenciamento?", "Referenciar", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
{
|
|
VariaveisControleOperacao.EnviarComandoReferenciamento(mod_id: _itemAtual.LabelModulo);
|
|
}
|
|
}
|
|
|
|
private void DirMovimentar()
|
|
{
|
|
if (_itemAtual?.Modulo != T_Code.Dir) return;
|
|
VariaveisControleOperacao.EnviarComandoDirecional(DirDirecaoSelecionada, DirAngulo, DirMovimentoSelecionado, mod_id: _itemAtual.LabelModulo);
|
|
}
|
|
|
|
private void GpsSalvar()
|
|
{
|
|
if (MessageBox.Show("Tem certeza que deseja redefinir o lever arm do GNSS?", "Lever Arm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
{
|
|
VariaveisControleOperacao.EnviarComandoLeverArm(lateral: GpsLeverArmLateral * 10.0, frontal: GpsLeverArmFrontal * 10.0);
|
|
}
|
|
}
|
|
|
|
private void TrajetoriaConfirmar()
|
|
{
|
|
if (_itemAtual?.Modulo != T_Code.Trj) return;
|
|
var trj = VariaveisControleOperacao.RoverEmFoco?.DadosLeitura?.Trajetoria;
|
|
int idxCorredor = trj?.PontoAtualIdxCorredor ?? 0;
|
|
if (MessageBox.Show($"Tem certeza que deseja liberar a operação no corredor {idxCorredor + 1}?", "Liberação", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
{
|
|
VariaveisControleOperacao.EnviarConfirmacaoHumanaTrajetoria(idxCorredor, TrajetoriaBatLiberada, TrajetoriaHerbLiberado);
|
|
}
|
|
}
|
|
|
|
private void ReleLigar()
|
|
{
|
|
if (_itemAtual?.Modulo != T_Code.Sen || _itemAtual.SCode != S_Code.sRLE) return;
|
|
VariaveisControleOperacao.EnviarComandoSensoriamento(_itemAtual.LabelModulo, status: Estado.Ligado);
|
|
}
|
|
|
|
private void ReleDesligar()
|
|
{
|
|
if (_itemAtual?.Modulo != T_Code.Sen || _itemAtual.SCode != S_Code.sRLE) return;
|
|
VariaveisControleOperacao.EnviarComandoSensoriamento(_itemAtual.LabelModulo, status: Estado.Desligado);
|
|
}
|
|
|
|
private void ServoEnviar()
|
|
{
|
|
if (_itemAtual == null || _itemAtual.SCode != S_Code.sSRV) return;
|
|
|
|
double angulo = Convert.ToInt32(ServoAngulo);
|
|
|
|
if (_itemAtual.Modulo == T_Code.Sen)
|
|
{
|
|
var servo = VariaveisControleOperacao.RoverEmFoco?.DadosLeitura?.Sensoriamento?.Servos?.FirstOrDefault(x => x.ID == _itemAtual.LabelModulo);
|
|
if (!(servo?.Incremental ?? false)) angulo = 180 - angulo;
|
|
VariaveisControleOperacao.EnviarComandoSensoriamento(_itemAtual.LabelModulo, status: angulo);
|
|
}
|
|
else if (_itemAtual.Modulo == T_Code.Atu)
|
|
{
|
|
var servo = VariaveisControleOperacao.RoverEmFoco?.DadosLeitura?.Atuador?.Servos?.FirstOrDefault(x => x.ID == _itemAtual.LabelModulo);
|
|
if (!(servo?.Incremental ?? false)) angulo = 180 - angulo;
|
|
VariaveisControleOperacao.EnviarComandoAtuador(_itemAtual.LabelModulo, angulo_controle: (int)angulo);
|
|
}
|
|
}
|
|
|
|
private void NpcCoolerEnviar()
|
|
{
|
|
if (_itemAtual?.Modulo != T_Code.Npc) return;
|
|
|
|
var modo = NpcCoolerModoSelecionado;
|
|
var entrada = NpcCoolerEntrada ? Estado.Ligado : Estado.Desligado;
|
|
var saida = NpcCoolerSaida ? Estado.Ligado : Estado.Desligado;
|
|
|
|
VariaveisControleOperacao.EnviarComandoCoolerControl(modo, entrada: entrada, saida: saida, temp_on: NpcCoolerTempOn, temp_turbo: NpcCoolerTempTurbo);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|