diff --git a/AgroBase/OperationControl/Controls/Pulverizador/BicoLequeIndicator.xaml b/AgroBase/OperationControl/Controls/Pulverizador/BicoLequeIndicator.xaml index ab31986e4..4044e0f8c 100644 --- a/AgroBase/OperationControl/Controls/Pulverizador/BicoLequeIndicator.xaml +++ b/AgroBase/OperationControl/Controls/Pulverizador/BicoLequeIndicator.xaml @@ -45,7 +45,7 @@ - + diff --git a/AgroBase/OperationControl/Controls/Pulverizador/BicoLequeIndicator.xaml.cs b/AgroBase/OperationControl/Controls/Pulverizador/BicoLequeIndicator.xaml.cs index c473bf7c1..c0e9d734c 100644 --- a/AgroBase/OperationControl/Controls/Pulverizador/BicoLequeIndicator.xaml.cs +++ b/AgroBase/OperationControl/Controls/Pulverizador/BicoLequeIndicator.xaml.cs @@ -20,6 +20,8 @@ namespace OperationControl.Controls.Pulverizador SizeChanged += (_, __) => UpdateGeometry(); } + public event Action OnBicoClicked; + public bool IsCommandOn { get => (bool)GetValue(IsCommandOnProperty); @@ -162,6 +164,16 @@ namespace OperationControl.Controls.Pulverizador UpdateVisualState(); } + + + private void SolenoidRect_Click(object sender, System.Windows.Input.MouseButtonEventArgs e) + { + if (DataContext is BicoModel bico) + { + OnBicoClicked?.Invoke(bico.Index); + } + } + } public class BicoModel : INotifyPropertyChanged diff --git a/AgroBase/OperationControl/Controls/Pulverizador/PulverizadorIndicator.xaml b/AgroBase/OperationControl/Controls/Pulverizador/PulverizadorIndicator.xaml index fdfacb669..13bb51dd3 100644 --- a/AgroBase/OperationControl/Controls/Pulverizador/PulverizadorIndicator.xaml +++ b/AgroBase/OperationControl/Controls/Pulverizador/PulverizadorIndicator.xaml @@ -144,7 +144,8 @@ IsSpraying="{Binding IsSpraying}" Vazao="{Binding Vazao}" TempoAtuado="{Binding TempoAtuado}" - Atuacoes="{Binding Atuacoes}" /> + Atuacoes="{Binding Atuacoes}" + Loaded="BicoLequeIndicator_Loaded" /> diff --git a/AgroBase/OperationControl/Controls/Pulverizador/PulverizadorIndicator.xaml.cs b/AgroBase/OperationControl/Controls/Pulverizador/PulverizadorIndicator.xaml.cs index b7fbad8f8..91f3236b8 100644 --- a/AgroBase/OperationControl/Controls/Pulverizador/PulverizadorIndicator.xaml.cs +++ b/AgroBase/OperationControl/Controls/Pulverizador/PulverizadorIndicator.xaml.cs @@ -1,5 +1,6 @@ using AgroBase.Models; using OperationControl.Controls.Pulverizador; +using OperationControl.Models; using System.Collections.ObjectModel; using System.Windows; @@ -15,6 +16,29 @@ namespace OperationControl.Controls RebuildBicos(); } + private void BicoLequeIndicator_Loaded(object sender, RoutedEventArgs e) + { + if (sender is BicoLequeIndicator bicoCtrl) + { + bicoCtrl.OnBicoClicked -= BicoCtrl_OnBicoClicked; + bicoCtrl.OnBicoClicked += BicoCtrl_OnBicoClicked; + } + } + + private void BicoCtrl_OnBicoClicked(int index) + { + if (!(VariaveisControleOperacao.RoverEmFoco?.Controle?.PulverizadorAutomatico ?? false)) + { + System.Windows.MessageBox.Show("Para acionar os bicos manualmente, é necessário que o Pulverizador Automático esteja desligado", "Pulverizador automático", MessageBoxButton.OK, MessageBoxImage.Information); + return; + } + var bico = VariaveisControleOperacao.RoverEmFoco?.DadosLeitura?.Atuador?.Bicos?.FirstOrDefault(x => x.Posicao == (index + 1)); + if (bico != null) + { + VariaveisControleOperacao.EnviarComandoAtuador(bico.ID, !bico.ComandoEstado); + } + } + public double DistanciaEntreBicosCm { get => (double)GetValue(DistanciaEntreBicosCmProperty); diff --git a/AgroBase/OperationControl/Models/AppShell.cs b/AgroBase/OperationControl/Models/AppShell.cs index 8e69aca17..44e848c6b 100644 --- a/AgroBase/OperationControl/Models/AppShell.cs +++ b/AgroBase/OperationControl/Models/AppShell.cs @@ -60,11 +60,25 @@ namespace OperationControl.Models { ComandoEstado = true, LeituraEstado = true, - ID = "BOMBA", + ID = "BMBLN", ID_Num = 10, Inicializado = true, - Potencia = 50, - TempoAtuado = 3000 + ComandoPotencia = 50, + LeituraPotencia = 50, + TempoAtuado = 3000, + ComandoPressao = 85, + LeituraPressao = 80, + }, + new AgroBase.Models.Operacoes.OperacaoParametrosDadosBombaModel() + { + ID = "BMBAGT", + ID_Num = 11, + ComandoEstado = true, + LeituraEstado = false, + Inicializado = true, + ComandoPotencia = 80, + LeituraPotencia = 0, + TempoAtuado = 100, } }, Bicos = new List() @@ -96,7 +110,7 @@ namespace OperationControl.Models Inicializado = true, LeituraAngulo = 0, LeituraEstado = false, - Posicao = 1, + Posicao = 2, QtdAtuacoes = 5, TempoAtuado = 300, VazaoInstantaneaMLs = 15, @@ -113,21 +127,40 @@ namespace OperationControl.Models Inicializado = true, LeituraAngulo = 0, LeituraEstado = true, - Posicao = 2, + Posicao = 3, QtdAtuacoes = 5, TempoAtuado = 300, VazaoInstantaneaMLs = 15, VazaoMediaMLs = 30, VolumeVazadoML = 325 }, - } + }, + CapacidadeReservatorio = 60, + DistanciaEstimadaRestanteMetros = 254.5, + ErvasNoRadar = true, + HerbicidaConsumidoMl = 1541.32, + HerbicidaPorAtuacaoMl = 235.1, + Iniciado = true, + LPorMetro = 0.36, + LPorMinuto = 1.2, + MassaReservatorioKg = 25, + PercentualErvasNoRadar = 3.4, + PercentualErvasTerreno = 36.7, + PercentualReservatorio = 47, + PressaoLinhaPsi = 84.3, + QtdCamerasSolo = 1, + TempoEstimadoRestanteMinutos = 60, + VazaoInstantaneaMLs = 19.3, + VazaoMediaMLs = 15.8, + VolumeReservatorioL = 26, + VolumeVazaoMl = 1.39, }, Controle = new AgroBase.Models.Operacoes.OperacaoParametrosDadosControleModel() { AlturaBarra = 50, Angulo = 0, PercentualVelocidadeSPKmh = 0, - TipoMovimento = TipoMovimentoDirecional.RodasDianteiras + TipoMovimento = TipoMovimentoDirecional.RodasDianteiras, }, Gnss = new AgroBase.Models.Operacoes.OperacaoParametrosDadosGNSSModel() { @@ -153,6 +186,7 @@ namespace OperationControl.Models }; r.Controle = new AgroBase.Models.Operacoes.OperacaoParametrosControleModel() { + AtuAgitadorModo = ModoAgitadorCalda.Continuo, AtuAlturaAreaPulverizacao = 10, AtuDuracaoAtuacao = 200, AtuPercentualErvasBicoOff = 1, @@ -192,6 +226,14 @@ namespace OperationControl.Models } VariaveisControleOperacao.EnviarDadosHeartbeat(); VariaveisControleOperacao.AtualizarListaRoversNaRede(); + + if (Mock && AddRover) + { + System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => + { + Variaveis.Dock?._vm?.AtualizarDadosTela(VariaveisControleOperacao.RoverEmFoco); + })); + } } finally { diff --git a/AgroBase/OperationControl/Models/TcpVideoReceiver.cs b/AgroBase/OperationControl/Models/TcpVideoReceiver.cs index 73b9fd590..0e7b74bdd 100644 --- a/AgroBase/OperationControl/Models/TcpVideoReceiver.cs +++ b/AgroBase/OperationControl/Models/TcpVideoReceiver.cs @@ -5,10 +5,11 @@ using System.Windows.Media.Imaging; namespace OperationControl.Models { - internal class TcpVideoReceiver + public class TcpVideoReceiver { private readonly int _port; private readonly System.Windows.Controls.Image _imageControl; + public readonly string imageName; private volatile bool _rodando; private Thread _thread; @@ -18,6 +19,7 @@ namespace OperationControl.Models { _port = port; _imageControl = imageControl; + imageName = imageControl.Name; } public void Iniciar() diff --git a/AgroBase/OperationControl/Models/Variaveis.cs b/AgroBase/OperationControl/Models/Variaveis.cs index b46a586f9..ba900ae7e 100644 --- a/AgroBase/OperationControl/Models/Variaveis.cs +++ b/AgroBase/OperationControl/Models/Variaveis.cs @@ -340,6 +340,8 @@ namespace OperationControl.Models public static void EnviarComandoTransmissaoVideo(AgroBase.Models.Enums.T_Code disp, bool ligar, AgroBase.Models.Enums.TipoFrameCamera tipoFrame) { + if (string.IsNullOrEmpty(SelectedRoverId) || SelectedRoverId == BaseMarkerID) return; + EnviarDadosControle(SelectedRoverId, new OperacaoComandoBaseModel() { Momento = DateTime.Now, diff --git a/AgroBase/OperationControl/OperationControl.csproj.user b/AgroBase/OperationControl/OperationControl.csproj.user index 8950f6d80..b3d6a1091 100644 --- a/AgroBase/OperationControl/OperationControl.csproj.user +++ b/AgroBase/OperationControl/OperationControl.csproj.user @@ -58,6 +58,9 @@ Code + + Code + Code diff --git a/AgroBase/OperationControl/ViewModels/Views/Operacao/Monitoramento/PulverizadorViewModel.cs b/AgroBase/OperationControl/ViewModels/Views/Operacao/Monitoramento/PulverizadorViewModel.cs new file mode 100644 index 000000000..4f5bbee1d --- /dev/null +++ b/AgroBase/OperationControl/ViewModels/Views/Operacao/Monitoramento/PulverizadorViewModel.cs @@ -0,0 +1,351 @@ +using OperationControl.Models; +using ScottPlot.Colormaps; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using static AgroBase.Models.Enums; + +namespace OperationControl.ViewModels.Views.Operacao.Monitoramento +{ + public class PulverizadorViewModel : INotifyPropertyChanged + { + public ObservableCollection CameraErvasFrameTipos { get; set; } + private FrameTipoItem _cameraErvasFrameTipoSelecionado; + public FrameTipoItem CameraErvasFrameTipoSelecionado + { + get => _cameraErvasFrameTipoSelecionado; + set + { + if (_cameraErvasFrameTipoSelecionado != value) + { + _cameraErvasFrameTipoSelecionado = value; + OnPropertyChanged(); + VariaveisControleOperacao.EnviarComandoTransmissaoVideo(AgroBase.Models.Enums.T_Code.Cam, true, value.Valor); + } + } + } + + public PulverizadorViewModel() + { + var itens = Enum.GetValues(typeof(TipoFrameCamera)) + .Cast() + .Select(x => new FrameTipoItem + { + Valor = x, + Nome = x.ToString() + }) + .ToList(); + + CameraErvasFrameTipos = new ObservableCollection(itens); + CameraErvasFrameTipoSelecionado = CameraErvasFrameTipos.FirstOrDefault(); + } + + public ObservableCollection EventosPulverizador { get; set; } = new(); + + private string _statusGeralPulverizador = "Operando"; + public string StatusGeralPulverizador + { + get => _statusGeralPulverizador; + set => SetProperty(ref _statusGeralPulverizador, value); + } + + private string _cameraErvasTitulo = "Câmera de Ervas"; + public string CameraErvasTitulo + { + get => _cameraErvasTitulo; + set => SetProperty(ref _cameraErvasTitulo, value); + } + + private string _cameraErvasStatus = "Streaming OK"; + public string CameraErvasStatus + { + get => _cameraErvasStatus; + set => SetProperty(ref _cameraErvasStatus, value); + } + + private string _modoPulverizacaoTexto = "Automático"; + public string ModoPulverizacaoTexto + { + get => _modoPulverizacaoTexto; + set => SetProperty(ref _modoPulverizacaoTexto, value); + } + + private string _pulverizacaoLiberadaTexto = "Liberada"; + public string PulverizacaoLiberadaTexto + { + get => _pulverizacaoLiberadaTexto; + set => SetProperty(ref _pulverizacaoLiberadaTexto, value); + } + + private string _statusBombaTexto = "Ligado"; + public string StatusBombaTexto + { + get => _statusBombaTexto; + set + { + if (SetProperty(ref _statusBombaTexto, value)) + OnPropertyChanged(nameof(StatusBombaTextoGeral)); + } + } + + private string _statusBombaTextoLido = "Desligado"; + public string StatusBombaTextoLido + { + get => _statusBombaTextoLido; + set + { + if (SetProperty(ref _statusBombaTextoLido, value)) + OnPropertyChanged(nameof(StatusBombaTextoGeral)); + } + } + + private string _potenciaBombaValor = "78 %"; + public string PotenciaBombaValor + { + get => _potenciaBombaValor; + set => SetProperty(ref _potenciaBombaValor, value); + } + + private string _potenciaBombaValorLido = "78 %"; + public string PotenciaBombaValorLido + { + get => _potenciaBombaValorLido; + set + { + if (SetProperty(ref _potenciaBombaValorLido, value)) + OnPropertyChanged(nameof(StatusBombaTextoGeral)); + } + } + + public string StatusBombaTextoGeral => $"{StatusBombaTexto} ({StatusBombaTextoLido} {PotenciaBombaValorLido})"; + + private string _potenciaAgitadorValor = "60 %"; + public string PotenciaAgitadorValor + { + get => _potenciaAgitadorValor; + set => SetProperty(ref _potenciaAgitadorValor, value); + } + + private string _potenciaAgitadorValorLido = "55 %"; + public string PotenciaAgitadorValorLido + { + get => _potenciaAgitadorValorLido; + set + { + if (SetProperty(ref _potenciaAgitadorValorLido, value)) + OnPropertyChanged(nameof(ModoAgitadorTextoGeral)); + } + } + + private string _modoAgitadorTexto = "Contínuo"; + public string ModoAgitadorTexto + { + get => _modoAgitadorTexto; + set + { + if (SetProperty(ref _modoAgitadorTexto, value)) + OnPropertyChanged(nameof(ModoAgitadorTextoGeral)); + } + } + + public string ModoAgitadorTextoGeral => $"{ModoAgitadorTexto} ({PotenciaAgitadorValorLido})"; + + private string _nivelTanqueValor = "63 %"; + public string NivelTanqueValor + { + get => _nivelTanqueValor; + set => SetProperty(ref _nivelTanqueValor, value); + } + + private string _nivelTanqueLitrosValor = "34,3 L"; + public string NivelTanqueLitrosValor + { + get => _nivelTanqueLitrosValor; + set => SetProperty(ref _nivelTanqueLitrosValor, value); + } + + private string _pressaoLinhaValor = "2,8 bar"; + public string PressaoLinhaValor + { + get => _pressaoLinhaValor; + set => SetProperty(ref _pressaoLinhaValor, value); + } + + private string _pressaoLinhaPsiValor = "84,8 psi"; + public string PressaoLinhaPsiValor + { + get => _pressaoLinhaPsiValor; + set => SetProperty(ref _pressaoLinhaPsiValor, value); + } + + private string _vazaoInstantaneaValor = "0,23 L/min"; + public string VazaoInstantaneaValor + { + get => _vazaoInstantaneaValor; + set => SetProperty(ref _vazaoInstantaneaValor, value); + } + + private string _vazaoMediaValor = "média: 0,19 L/min"; + public string VazaoMediaValor + { + get => _vazaoMediaValor; + set => SetProperty(ref _vazaoMediaValor, value); + } + + private string _autonomiaDistanciaValor = "721,2 m"; + public string AutonomiaDistanciaValor + { + get => _autonomiaDistanciaValor; + set => SetProperty(ref _autonomiaDistanciaValor, value); + } + + private string _autonomiaTempoValor = "02:14:10"; + public string AutonomiaTempoValor + { + get => _autonomiaTempoValor; + set => SetProperty(ref _autonomiaTempoValor, value); + } + + private string _volumeVazadoValor = "1,36 L"; + public string VolumeVazadoValor + { + get => _volumeVazadoValor; + set => SetProperty(ref _volumeVazadoValor, value); + } + + private string _tempoLigadoPulverizacaoValor = "00:02:32 ligado"; + public string TempoLigadoPulverizacaoValor + { + get => _tempoLigadoPulverizacaoValor; + set => SetProperty(ref _tempoLigadoPulverizacaoValor, value); + } + + private string _bicosAtivosValor = "7 / 12"; + public string BicosAtivosValor + { + get => _bicosAtivosValor; + set => SetProperty(ref _bicosAtivosValor, value); + } + + private string _infoComplementarBicosValor = "Vazão média: 0,2 mL/s"; + public string InfoComplementarBicosValor + { + get => _infoComplementarBicosValor; + set => SetProperty(ref _infoComplementarBicosValor, value); + } + + private string _percentualErvasRadar = "Radar: 2,5 %"; + public string PercentualErvasRadar + { + get => _percentualErvasRadar; + set => SetProperty(ref _percentualErvasRadar, value); + } + + private string _percentualErvasTerreno = "Terreno: 25,4 %"; + public string PercentualErvasTerreno + { + get => _percentualErvasTerreno; + set => SetProperty(ref _percentualErvasTerreno, value); + } + + public void AtualizarParametrosTela(PulverizadorSnapshot dados) + { + if (dados == null) return; + + if (dados.StatusGeralPulverizador != null) StatusGeralPulverizador = dados.StatusGeralPulverizador; + + if (dados.CameraErvasStatus != null) CameraErvasStatus = dados.CameraErvasStatus; + + if (dados.ModoPulverizacaoTexto != null) ModoPulverizacaoTexto = dados.ModoPulverizacaoTexto; + if (dados.PulverizacaoLiberadaTexto != null) PulverizacaoLiberadaTexto = dados.PulverizacaoLiberadaTexto; + + if (dados.StatusBombaTexto != null) StatusBombaTexto = dados.StatusBombaTexto; + if (dados.StatusBombaTextoLido != null) StatusBombaTextoLido = dados.StatusBombaTextoLido; + if (dados.PotenciaBombaValor != null) PotenciaBombaValor = dados.PotenciaBombaValor; + if (dados.PotenciaBombaValorLido != null) PotenciaBombaValorLido = dados.PotenciaBombaValorLido; + + if (dados.PotenciaAgitadorValor != null) PotenciaAgitadorValor = dados.PotenciaAgitadorValor; + if (dados.PotenciaAgitadorValorLido != null) PotenciaAgitadorValorLido = dados.PotenciaAgitadorValorLido; + if (dados.ModoAgitadorTexto != null) ModoAgitadorTexto = dados.ModoAgitadorTexto; + + if (dados.NivelTanqueValor != null) NivelTanqueValor = dados.NivelTanqueValor; + if (dados.NivelTanqueLitrosValor != null) NivelTanqueLitrosValor = dados.NivelTanqueLitrosValor; + + if (dados.PressaoLinhaValor != null) PressaoLinhaValor = dados.PressaoLinhaValor; + if (dados.PressaoLinhaPsiValor != null) PressaoLinhaPsiValor = dados.PressaoLinhaPsiValor; + + if (dados.VazaoInstantaneaValor != null) VazaoInstantaneaValor = dados.VazaoInstantaneaValor; + if (dados.VazaoMediaValor != null) VazaoMediaValor = dados.VazaoMediaValor; + + if (dados.AutonomiaDistanciaValor != null) AutonomiaDistanciaValor = dados.AutonomiaDistanciaValor; + if (dados.AutonomiaTempoValor != null) AutonomiaTempoValor = dados.AutonomiaTempoValor; + + if (dados.VolumeVazadoValor != null) VolumeVazadoValor = dados.VolumeVazadoValor; + if (dados.TempoLigadoPulverizacaoValor != null) TempoLigadoPulverizacaoValor = dados.TempoLigadoPulverizacaoValor; + + if (dados.BicosAtivosValor != null) BicosAtivosValor = dados.BicosAtivosValor; + if (dados.InfoComplementarBicosValor != null) InfoComplementarBicosValor = dados.InfoComplementarBicosValor; + + if (dados.PercentualErvasRadar != null) PercentualErvasRadar = dados.PercentualErvasRadar; + if (dados.PercentualErvasTerreno != null) PercentualErvasTerreno = dados.PercentualErvasTerreno; + } + + public event PropertyChangedEventHandler? PropertyChanged; + + protected void OnPropertyChanged([CallerMemberName] string? propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + protected bool SetProperty(ref T field, T value, [CallerMemberName] string? propertyName = null) + { + if (EqualityComparer.Default.Equals(field, value)) + return false; + + field = value; + OnPropertyChanged(propertyName); + return true; + } + } + + public class PulverizadorSnapshot + { + public string? StatusGeralPulverizador { get; set; } + + public string? CameraErvasStatus { get; set; } + + public string? ModoPulverizacaoTexto { get; set; } + public string? PulverizacaoLiberadaTexto { get; set; } + + public string? StatusBombaTexto { get; set; } + public string? StatusBombaTextoLido { get; set; } + public string? PotenciaBombaValor { get; set; } + public string? PotenciaBombaValorLido { get; set; } + + public string? PotenciaAgitadorValor { get; set; } + public string? PotenciaAgitadorValorLido { get; set; } + public string? ModoAgitadorTexto { get; set; } + + public string? NivelTanqueValor { get; set; } + public string? NivelTanqueLitrosValor { get; set; } + + public string? PressaoLinhaValor { get; set; } + public string? PressaoLinhaPsiValor { get; set; } + + public string? VazaoInstantaneaValor { get; set; } + public string? VazaoMediaValor { get; set; } + + public string? AutonomiaDistanciaValor { get; set; } + public string? AutonomiaTempoValor { get; set; } + + public string? VolumeVazadoValor { get; set; } + public string? TempoLigadoPulverizacaoValor { get; set; } + + public string? BicosAtivosValor { get; set; } + public string? InfoComplementarBicosValor { get; set; } + + public string? PercentualErvasRadar { get; set; } + public string? PercentualErvasTerreno { get; set; } + } +} \ No newline at end of file diff --git a/AgroBase/OperationControl/ViewModels/Views/Operacao/OperacaoCenterViewModel.cs b/AgroBase/OperationControl/ViewModels/Views/Operacao/OperacaoCenterViewModel.cs index e7e82c049..1f4e99478 100644 --- a/AgroBase/OperationControl/ViewModels/Views/Operacao/OperacaoCenterViewModel.cs +++ b/AgroBase/OperationControl/ViewModels/Views/Operacao/OperacaoCenterViewModel.cs @@ -42,6 +42,7 @@ namespace OperationControl.ViewModels.Views.Operacao OnPropertyChanged(nameof(ExibirDiagnostico)); OnPropertyChanged(nameof(ExibirMonitoramento)); OnPropertyChanged(nameof(ExibirHistorico)); + OnPropertyChanged(nameof(ExibirPulverizador)); OnPropertyChanged(nameof(TituloCentro)); OnPropertyChanged(nameof(SubtituloCentro)); } @@ -51,6 +52,7 @@ namespace OperationControl.ViewModels.Views.Operacao public bool ExibirDiagnostico => ConteudoAtual == OperacaoCenterConteudo.Diagnostico; public bool ExibirMonitoramento => ConteudoAtual == OperacaoCenterConteudo.Monitoramento; public bool ExibirHistorico => ConteudoAtual == OperacaoCenterConteudo.Historico; + public bool ExibirPulverizador => ConteudoAtual == OperacaoCenterConteudo.Pulverizador; public string TituloCentro { @@ -104,6 +106,7 @@ namespace OperationControl.ViewModels.Views.Operacao SecaoRightBar.Parametrizacao => OperacaoCenterConteudo.Mapa, SecaoRightBar.Menu => OperacaoCenterConteudo.Monitoramento, SecaoRightBar.Historico => OperacaoCenterConteudo.Historico, + SecaoRightBar.Pulverizador => OperacaoCenterConteudo.Pulverizador, _ => OperacaoCenterConteudo.Mapa }; @@ -147,5 +150,6 @@ namespace OperationControl.ViewModels.Views.Operacao Diagnostico = 2, Monitoramento = 3, Historico = 4, + Pulverizador = 5, } } diff --git a/AgroBase/OperationControl/ViewModels/Views/Operacao/OperacaoRightViewModel.cs b/AgroBase/OperationControl/ViewModels/Views/Operacao/OperacaoRightViewModel.cs index 30ca201e4..4ca64bb71 100644 --- a/AgroBase/OperationControl/ViewModels/Views/Operacao/OperacaoRightViewModel.cs +++ b/AgroBase/OperationControl/ViewModels/Views/Operacao/OperacaoRightViewModel.cs @@ -99,10 +99,10 @@ namespace OperationControl.ViewModels.Views.Operacao } } - public bool EmMenu => new List() { SecaoRightBar.Menu, SecaoRightBar.Diagnostico, SecaoRightBar.Historico }.Contains(SecaoAtual); public bool EmResumo => SecaoAtual == SecaoRightBar.Resumo; public bool EmParametrizacao => SecaoAtual == SecaoRightBar.Parametrizacao; public bool EmControle => SecaoAtual == SecaoRightBar.Controle; + public bool EmMenu => !EmResumo && !EmControle && !EmParametrizacao; public bool BotaoTopoEhVoltar => EmResumo || EmControle || EmParametrizacao; @@ -266,6 +266,7 @@ namespace OperationControl.ViewModels.Views.Operacao Parametrizacao = 4, Controle = 5, Historico = 6, + Pulverizador = 7, } } diff --git a/AgroBase/OperationControl/ViewModels/Windows/DockWindowViewModel.cs b/AgroBase/OperationControl/ViewModels/Windows/DockWindowViewModel.cs index c5a68df68..885c6a85c 100644 --- a/AgroBase/OperationControl/ViewModels/Windows/DockWindowViewModel.cs +++ b/AgroBase/OperationControl/ViewModels/Windows/DockWindowViewModel.cs @@ -958,9 +958,59 @@ namespace OperationControl.ViewModels // DIAGNOSTICO AtualizarDadosDiagnostico(rover); + // CAMERAS + var snr = obj?.Cameras?.FirstOrDefault(x => x.dispositivo == AgroBase.Models.Enums.T_Code.Snr); + var cam = obj?.Cameras?.FirstOrDefault(x => x.dispositivo == AgroBase.Models.Enums.T_Code.Cam); + + _viewOperacaoCenter?.Monitoramento?._vm?.AtualizarDadosCameras(snr, cam, obj?.OperadorVisual?.StatusCarro, obj?.Atuador?.PercentualErvasNoRadar); + // PULVERIZADOR - var bomba = obj.Atuador?.Bombas?.FirstOrDefault(); - var ATU = _viewOperacaoCenter.Monitoramento.Pulverizador; + bool telaPulverizador = _viewOperacaoCenter?._vm?.ConteudoAtual == OperacaoCenterConteudo.Pulverizador; + var bomba = obj.Atuador?.Bombas?.FirstOrDefault(x => x.ID == "BMBLN"); + var agitador = obj.Atuador?.Bombas?.FirstOrDefault(x => x.ID == "BMBAGT"); + if (telaPulverizador) + { + _viewOperacaoCenter?.Pulverizador?._vm?.AtualizarParametrosTela(new Views.Operacao.Monitoramento.PulverizadorSnapshot() + { + StatusGeralPulverizador = (obj?.ModulosSaude?.FirstOrDefault(x => x.modulo == T_Code.Atu)?.status ?? StatusModulo.Desconectado).ToString(), + + CameraErvasStatus = _viewOperacaoCenter?.Monitoramento?._vm?.CameraErvasStatus ?? "", + + ModoPulverizacaoTexto = (rover?.Controle?.PulverizadorAutomatico ?? false) ? "Automático" : "Manual", + PulverizacaoLiberadaTexto = (obj?.ModulosSaude?.FirstOrDefault(x => x.modulo == T_Code.Atu)?.motivos?.Any() ?? false) ? "Liberado" : "Bloqueado", + + StatusBombaTexto = (bomba?.ComandoEstado ?? false) ? "Ligado": "Desligado", + StatusBombaTextoLido = (bomba?.LeituraEstado ?? false) ? "Ligado": "Desligado", + PotenciaBombaValor = $"{(bomba?.ComandoPotencia ?? 0):F2} %", + PotenciaBombaValorLido = $"{(bomba?.ComandoPotencia ?? 0):F2} %", + + ModoAgitadorTexto = (rover?.Controle?.AtuAgitadorModo ?? ModoAgitadorCalda.SemAgitacao).ToString(), + PotenciaAgitadorValor = $"{agitador?.ComandoPotencia ?? 0} %", + PotenciaAgitadorValorLido = $"{agitador?.LeituraPotencia ?? 0} %", + + NivelTanqueValor = $"{(obj?.Atuador?.PercentualReservatorio ?? 0):F2} %", + NivelTanqueLitrosValor = $"{(obj?.Atuador?.VolumeReservatorioL ?? 0):F2} L", + + PressaoLinhaValor = $"{(rover?.Controle?.AtuPressaoLinha ?? 0):F2} psi", + PressaoLinhaPsiValor = $"{(obj?.Atuador?.PressaoLinhaPsi ?? 0):F2} psi", + + VazaoInstantaneaValor = $"{(obj?.Atuador?.VazaoInstantaneaMLs ?? 0):F2} mL/s", + VazaoMediaValor = $"média {(obj?.Atuador?.VazaoMediaMLs ?? 0):F2} mL/s", + + AutonomiaDistanciaValor = $"{(obj?.Atuador?.DistanciaEstimadaRestanteMetros ?? 0):F2} m", + AutonomiaTempoValor = $"{FuncoesGlobais.ConverterSegundosParaHHmmss((int)(obj?.Atuador?.TempoEstimadoRestanteMinutos ?? 0) * 60)}", + + VolumeVazadoValor = $"{(obj?.Atuador?.VolumeVazaoMl ?? 0):F2} mL", + TempoLigadoPulverizacaoValor = $"{FuncoesGlobais.ConverterSegundosParaHHmmss((int)(bomba?.TempoAtuado ?? 0) / 1000)}", + + BicosAtivosValor = $"{(obj?.Atuador?.Bicos?.Count(x => x.ComandoEstado == true) ?? 0)} / {obj?.Atuador?.Bicos?.Count ?? 0}", + InfoComplementarBicosValor = $"vazão média: {(obj?.Atuador?.Bicos?.Where(x => x.ComandoEstado == true)?.Average(x => x.VazaoInstantaneaMLs) ?? 0)} mL/s", + + PercentualErvasRadar = $"radar: {(obj?.Atuador?.PercentualErvasNoRadar ?? 0)} %", + PercentualErvasTerreno = $"terreno: {(obj?.Atuador?.PercentualErvasTerreno ?? 0)} %", + }); + } + var ATU = telaPulverizador ? _viewOperacaoCenter.Pulverizador.areaPulverizador : _viewOperacaoCenter.Monitoramento.Pulverizador; ATU.ComprimentoBarraCm = AgroBase.Models.VariaveisEquipamento.ComprimentoBarraPulverizadoraCm; ATU.DistanciaEntreBicosCm = AgroBase.Models.VariaveisEquipamento.DistanciaEntreBicosCm; //ATU.AlturaBarra = obj?.Controle?.AlturaBarra ?? AgroBase.Models.VariaveisEquipamento.AlturaBarraPulverizadoraCm; @@ -968,16 +1018,13 @@ namespace OperationControl.ViewModels ATU.PressaoLinha = obj?.Atuador?.PressaoLinhaPsi ?? 0; ATU.VazaoInstantanea = obj?.Atuador?.VazaoInstantaneaMLs ?? 0; ATU.TempoAtuado = (bomba?.TempoAtuado ?? 0) / 1000.0; - double erroLateral = ((obj?.Trajetoria?.DistanciaEsquerda ?? 0) - (obj?.Trajetoria?.DistanciaDireita ?? 0)) / 2.0 * 100.0; ATU.LarguraRuaCm = 100.0; ATU.ErroLateralCm = erroLateral; - if (ATU.QtdBicos != obj?.Atuador?.Bicos?.Count) { ATU.QtdBicos = obj?.Atuador?.Bicos?.Count ?? AgroBase.Models.VariaveisEquipamento.QuantidadeBicosPulverizadores; } - foreach (var bico in ATU.Bicos) { var _bc = obj?.Atuador?.Bicos?.FirstOrDefault(x => (x.Posicao - 1) == bico.Index); @@ -1003,11 +1050,7 @@ namespace OperationControl.ViewModels if (obj?.Imu?.InclinacaoLateral != null) IMU.RollDeg = (double)obj.Imu.InclinacaoLateral; IMU.LateralError = erroLateral; - // CAMERAS - var snr = obj?.Cameras?.FirstOrDefault(x => x.dispositivo == AgroBase.Models.Enums.T_Code.Snr); - var cam = obj?.Cameras?.FirstOrDefault(x => x.dispositivo == AgroBase.Models.Enums.T_Code.Cam); - _viewOperacaoCenter?.Monitoramento?._vm?.AtualizarDadosCameras(snr, cam, obj?.OperadorVisual?.StatusCarro, obj?.Atuador?.PercentualErvasNoRadar); } @@ -1085,8 +1128,29 @@ namespace OperationControl.ViewModels } private void OnSecaoSelecionadaChanged(SecaoRightBar secao) { - if (secao == SecaoRightBar.Parametrizacao) - VariaveisControleOperacao.RequisitarParametrosOperacao(); + switch (secao) + { + case SecaoRightBar.Parametrizacao: + VariaveisControleOperacao.RequisitarParametrosOperacao(); + break; + case SecaoRightBar.Pulverizador: + if (_viewOperacaoCenter.Monitoramento.videoWeed.imageName != _viewOperacaoCenter.Pulverizador.imgVideo.Name) + { + _viewOperacaoCenter.Monitoramento.videoWeed.Parar(); + _viewOperacaoCenter.Monitoramento.videoWeed = new TcpVideoReceiver(5002, _viewOperacaoCenter.Pulverizador.imgVideo); + _viewOperacaoCenter.Monitoramento.videoWeed.Iniciar(); + } + break; + default: + if (_viewOperacaoCenter.Monitoramento.videoWeed.imageName != _viewOperacaoCenter.Monitoramento.imgVideoWeed.Name) + { + _viewOperacaoCenter.Monitoramento.videoWeed.Parar(); + _viewOperacaoCenter.Monitoramento.videoWeed = new TcpVideoReceiver(5002, _viewOperacaoCenter.Monitoramento.imgVideoWeed); + _viewOperacaoCenter.Monitoramento.videoWeed.Iniciar(); + } + break; + } + _viewOperacaoCenter?._vm?.DefinirSecao(secao); AtualizarDadosMapa(VariaveisControleOperacao.RoverEmFoco); } diff --git a/AgroBase/OperationControl/Views/Operacao/Monitoramento/MonitoramentoView.xaml.cs b/AgroBase/OperationControl/Views/Operacao/Monitoramento/MonitoramentoView.xaml.cs index 90c9382d3..f89dcc66c 100644 --- a/AgroBase/OperationControl/Views/Operacao/Monitoramento/MonitoramentoView.xaml.cs +++ b/AgroBase/OperationControl/Views/Operacao/Monitoramento/MonitoramentoView.xaml.cs @@ -12,7 +12,7 @@ namespace OperationControl.Views.Operacao.Monitoramento public MonitoramentoViewModel _vm; private TcpVideoReceiver videoFront; - private TcpVideoReceiver videoWeed; + public TcpVideoReceiver videoWeed; public PulverizadorIndicator Pulverizador => areaPulverizador; public HeadingIndicator Heading => areaHeading; public AttitudeIndicator Attitude => areaAttitude; diff --git a/AgroBase/OperationControl/Views/Operacao/Monitoramento/PulverizadorView.xaml b/AgroBase/OperationControl/Views/Operacao/Monitoramento/PulverizadorView.xaml new file mode 100644 index 000000000..08cd2e778 --- /dev/null +++ b/AgroBase/OperationControl/Views/Operacao/Monitoramento/PulverizadorView.xaml @@ -0,0 +1,345 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/AgroBase/OperationControl/Views/Operacao/Monitoramento/PulverizadorView.xaml.cs b/AgroBase/OperationControl/Views/Operacao/Monitoramento/PulverizadorView.xaml.cs new file mode 100644 index 000000000..20aeeeb1b --- /dev/null +++ b/AgroBase/OperationControl/Views/Operacao/Monitoramento/PulverizadorView.xaml.cs @@ -0,0 +1,25 @@ +using OperationControl.Models; +using OperationControl.ViewModels.Views.Operacao.Monitoramento; + +namespace OperationControl.Views.Operacao.Monitoramento +{ + /// + /// Interação lógica para PulverizadorView.xam + /// + public partial class PulverizadorView : System.Windows.Controls. UserControl + { + public PulverizadorViewModel _vm; + + private TcpVideoReceiver video; + + public PulverizadorView() + { + InitializeComponent(); + + _vm = new PulverizadorViewModel(); + DataContext = _vm; + + video = new TcpVideoReceiver(5002, imgVideo); + } + } +} diff --git a/AgroBase/OperationControl/Views/Operacao/OperacaoCenterView.xaml b/AgroBase/OperationControl/Views/Operacao/OperacaoCenterView.xaml index c5901f7e2..69abbc145 100644 --- a/AgroBase/OperationControl/Views/Operacao/OperacaoCenterView.xaml +++ b/AgroBase/OperationControl/Views/Operacao/OperacaoCenterView.xaml @@ -38,5 +38,10 @@ + + + + + \ No newline at end of file diff --git a/AgroBase/OperationControl/Views/Operacao/OperacaoCenterView.xaml.cs b/AgroBase/OperationControl/Views/Operacao/OperacaoCenterView.xaml.cs index 76038954b..4cbeaaedd 100644 --- a/AgroBase/OperationControl/Views/Operacao/OperacaoCenterView.xaml.cs +++ b/AgroBase/OperationControl/Views/Operacao/OperacaoCenterView.xaml.cs @@ -14,6 +14,7 @@ namespace OperationControl.Views.Operacao public MonitoramentoView Monitoramento => areaMonitor; public DiagnosticoView Diagnostico => areaDiagnostico; public HistoricoView Historico => areaHistorico; + public PulverizadorView Pulverizador => areaPulverizador; public OperacaoCenterView() { diff --git a/AgroBase/OperationControl/Views/Operacao/OperacaoRightView.xaml b/AgroBase/OperationControl/Views/Operacao/OperacaoRightView.xaml index dc631d517..08edf91a9 100644 --- a/AgroBase/OperationControl/Views/Operacao/OperacaoRightView.xaml +++ b/AgroBase/OperationControl/Views/Operacao/OperacaoRightView.xaml @@ -22,13 +22,8 @@ - - + + @@ -54,8 +49,7 @@ - + @@ -211,6 +205,8 @@