From 66ad55aeb3bfc1a8a3b392d3f7a6c637c3eb4c14 Mon Sep 17 00:00:00 2001 From: Diego Freitas Date: Fri, 3 Jul 2026 16:25:38 -0300 Subject: [PATCH] ajustes lever arm --- .../Models/Operacoes/OperacaoModel.cs | 36 ++++++++++++++++--- .../Diagnostico/DiagnosticoOpcoesViewModel.cs | 29 ++++++++++----- 2 files changed, 51 insertions(+), 14 deletions(-) diff --git a/AgroBase/AgroBase/Models/Operacoes/OperacaoModel.cs b/AgroBase/AgroBase/Models/Operacoes/OperacaoModel.cs index 672c0661a..34cd99f00 100644 --- a/AgroBase/AgroBase/Models/Operacoes/OperacaoModel.cs +++ b/AgroBase/AgroBase/Models/Operacoes/OperacaoModel.cs @@ -2478,17 +2478,43 @@ namespace AgroBase.Models return; } - double? laLateral = lever.Item1; - double? laFrontal = lever.Item2; + double? totalLateralCm = lever.Item1; + double? totalFrontalCm = lever.Item2; - if (laLateral == null && laFrontal == null) + if (totalLateralCm == null && totalFrontalCm == null) return; + double totalAtualLateralCm = + GPSService.LeverArm?.LateralTotalCm ?? + VariaveisEquipamento.LeverArmLateralCm; + + double totalAtualFrontalCm = + GPSService.LeverArm?.FrontalTotalCm ?? + VariaveisEquipamento.LeverArmFrontalCm; + + double novoTotalLateralCm = + totalLateralCm ?? totalAtualLateralCm; + + double novoTotalFrontalCm = + totalFrontalCm ?? totalAtualFrontalCm; + + double campoLateralCm = + novoTotalLateralCm - VariaveisEquipamento.LeverArmLateralCm; + + double campoFrontalCm = + novoTotalFrontalCm - VariaveisEquipamento.LeverArmFrontalCm; + + Variaveis.MostrarLog( + $"[ComandoBase][LeverArm] Total RX: frontal={novoTotalFrontalCm:0.##}cm, lateral={novoTotalLateralCm:0.##}cm | " + + $"Fisico: frontal={VariaveisEquipamento.LeverArmFrontalCm:0.##}cm, lateral={VariaveisEquipamento.LeverArmLateralCm:0.##}cm | " + + $"Campo: frontal={campoFrontalCm:0.##}cm, lateral={campoLateralCm:0.##}cm" + ); + GPSService.LeverArm = new GeoLeverArm( offsetFisicoFrontalCm: VariaveisEquipamento.LeverArmFrontalCm, offsetFisicoLateralCm: VariaveisEquipamento.LeverArmLateralCm, - offsetCampoFrontalCm: laFrontal ?? 0, - offsetCampoLateralCm: laLateral ?? 0 + offsetCampoFrontalCm: campoFrontalCm, + offsetCampoLateralCm: campoLateralCm ); } diff --git a/AgroBase/OperationControl/ViewModels/Views/Operacao/Monitoramento/Diagnostico/DiagnosticoOpcoesViewModel.cs b/AgroBase/OperationControl/ViewModels/Views/Operacao/Monitoramento/Diagnostico/DiagnosticoOpcoesViewModel.cs index 4de85486e..24c25987f 100644 --- a/AgroBase/OperationControl/ViewModels/Views/Operacao/Monitoramento/Diagnostico/DiagnosticoOpcoesViewModel.cs +++ b/AgroBase/OperationControl/ViewModels/Views/Operacao/Monitoramento/Diagnostico/DiagnosticoOpcoesViewModel.cs @@ -201,12 +201,16 @@ namespace OperationControl.ViewModels.Views.Operacao.Monitoramento.Diagnostico set { if (SetProperty(ref _gpsLeverArmLateral, value)) - GpsLeverArmLateralTexto = $"{value * 10.0:00} cm"; + GpsLeverArmLateralTexto = $"{value:0.##} cm"; } } - private string _gpsLeverArmLateralTexto = "00 cm"; - public string GpsLeverArmLateralTexto { get => _gpsLeverArmLateralTexto; set => SetProperty(ref _gpsLeverArmLateralTexto, value); } + private string _gpsLeverArmLateralTexto = "0 cm"; + public string GpsLeverArmLateralTexto + { + get => _gpsLeverArmLateralTexto; + set => SetProperty(ref _gpsLeverArmLateralTexto, value); + } private double _gpsLeverArmFrontal; public double GpsLeverArmFrontal @@ -215,12 +219,16 @@ namespace OperationControl.ViewModels.Views.Operacao.Monitoramento.Diagnostico set { if (SetProperty(ref _gpsLeverArmFrontal, value)) - GpsLeverArmFrontalTexto = $"{value * 10.0:00} cm"; + GpsLeverArmFrontalTexto = $"{value:0.##} cm"; } } - private string _gpsLeverArmFrontalTexto = "00 cm"; - public string GpsLeverArmFrontalTexto { get => _gpsLeverArmFrontalTexto; set => SetProperty(ref _gpsLeverArmFrontalTexto, value); } + private string _gpsLeverArmFrontalTexto = "0 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); } @@ -617,8 +625,8 @@ namespace OperationControl.ViewModels.Views.Operacao.Monitoramento.Diagnostico TxtGpsOrientacao = $"{dados?.OrientacaoReal ?? 0}"; if (clicado) { - GpsLeverArmLateral = (dados?.LeverArmLateral ?? 0) / 10.0; - GpsLeverArmFrontal = (dados?.LeverArmFrontal ?? 0) / 10.0; + GpsLeverArmLateral = (dados?.LeverArmLateral ?? 0); + GpsLeverArmFrontal = (dados?.LeverArmFrontal ?? 0); } } @@ -810,7 +818,10 @@ namespace OperationControl.ViewModels.Views.Operacao.Monitoramento.Diagnostico { 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); + VariaveisControleOperacao.EnviarComandoLeverArm( + lateral: GpsLeverArmLateral, + frontal: GpsLeverArmFrontal + ); } }