diff --git a/AgroBase/OperationControl/Controls/MapViewControl.xaml.cs b/AgroBase/OperationControl/Controls/MapViewControl.xaml.cs index 7f2e4c181..8e13654b2 100644 --- a/AgroBase/OperationControl/Controls/MapViewControl.xaml.cs +++ b/AgroBase/OperationControl/Controls/MapViewControl.xaml.cs @@ -1208,7 +1208,8 @@ namespace OperationControl.Controls public bool TryGetIdFromFeature(MIFeature feature, out string id) { - var f = _features.FirstOrDefault(x => x.Features.Contains(feature)); + //var f = _features.FirstOrDefault(x => x.Features.Contains(feature)); + var f = _features.FirstOrDefault(x => x.Features.Contains(feature) || x.MarkerShapes.Contains(feature)); if (f != null) { id = f.Id; @@ -1221,13 +1222,29 @@ namespace OperationControl.Controls public void SetMarkerFocused(string id, bool focused) { ClearMarkerFocused(); + var f = _features.FirstOrDefault(x => x.Id == id); - if (f != null) f.Focused = focused; + if (f != null) + { + f.Focused = focused; + f.UpdateData(); + } + + UpdateFeatures(); } public void ClearMarkerFocused() { - _features.ForEach(f => f.Focused = false); + foreach (var f in _features) + { + if (f.Focused) + { + f.Focused = false; + f.UpdateData(); + } + } + + UpdateFeatures(); } private void UpdateFeatures() @@ -1273,7 +1290,8 @@ namespace OperationControl.Controls Lat = lat ?? 0, Lon = lon ?? 0, Label = lbl, - Seta = new List(), + MarkerShapes = new List(), + IsBase = isBase, Status = status ?? StatusOperacao.NaoIniciado, Pulverizando = pulv ?? false, Focused = false @@ -1339,6 +1357,7 @@ namespace OperationControl.Controls { public void CreateTrajectory(MapControl _map) { + _mapParent = _map; _trajProvider = new MemoryProvider(_trajFeatures); _trajLayer = new Layer { @@ -1346,7 +1365,7 @@ namespace OperationControl.Controls DataSource = _trajProvider, Style = null }; - _map.Map!.Layers.Add(_trajLayer); + _mapParent.Map!.Layers.Add(_trajLayer); _predProvider = new MemoryProvider(_predFeatures); _predLayer = new Layer { @@ -1354,9 +1373,10 @@ namespace OperationControl.Controls DataSource = _predProvider, Style = null }; - _map.Map!.Layers.Add(_predLayer); + _mapParent.Map!.Layers.Add(_predLayer); } + MapControl _mapParent; public string Id { get; set; } public bool Focused { get; set; } public bool Pulverizando { get; set; } @@ -1368,7 +1388,8 @@ namespace OperationControl.Controls public string Label { get; set; } public System.Windows.Media.Color Color { get; set; } public StatusOperacao Status { get; set; } - public List Seta { get; set; } + public List MarkerShapes { get; set; } + public bool IsBase { get; set; } public Coordinate Position { get; set; } public List Predict { get; set; } @@ -1388,13 +1409,20 @@ namespace OperationControl.Controls var (x, y) = Mapsui.Projections.SphericalMercator.FromLonLat(Lon, Lat); var newPoint = new MPoint(x, y); - UpsertHeadingFeature(newPoint, withArrowHead: true); + MarkerShapes.Clear(); + if (IsBase) + CreateBaseMarker(newPoint); + else + CreateRoverTriangleMarker(newPoint); + + foreach (var shape in MarkerShapes) + Features.Add(shape); + + // ponto invisível/pequeno para hit-test e precisão Point = new PointFeature(newPoint); SetStyles(); - Features.Add(Point); - Seta.ForEach(f => Features.Add(f)); if (lat != null || lon != null) UpdateRoverPosition(); @@ -1402,68 +1430,178 @@ namespace OperationControl.Controls UpdatePredictTrajectory(); } - private void UpsertHeadingFeature(MPoint centerWorld, bool withArrowHead = true) + private (double lengthWorld, double widthWorld, bool realScale) GetRoverSizeWorld() { - Seta.Clear(); + double resolution = 1.0; - // 1) Comprimento constante em tela: px -> metros - //var resolution = _map.Map?.Navigator?.Resolutions?.LastOrDefault() ?? 1.0; // m/px no WebMercator - var resolution = 1.0; - var lenPx = 9; // corpo da seta (ajuste fino: 12~20 px) - var headPx = 6; // “asas” da seta (se withArrowHead = true) - var len = lenPx * resolution; // metros - var headLen = headPx * resolution; // metros - - // 2) 0° = Norte (↑). Se o seu 0° for Leste (→), troque sin/cos conforme comentário abaixo. - var rad = Heading * Math.PI / 180.0; - var dx = len * Math.Sin(rad); // se 0° = Leste → use cos(rad) - var dy = len * Math.Cos(rad); // se 0° = Leste → use sin(rad) - - var p0 = centerWorld; - var p1 = new MPoint(centerWorld.X + dx, centerWorld.Y + dy); - - // 3) Corpo da seta (linha principal) - var mainLine = new LineString(new Coordinate[] { new Coordinate(p0.X, p0.Y), new Coordinate(p1.X, p1.Y) }); - - var mainFeat = new GeometryFeature { Geometry = mainLine }; - SetHeadingStyle(mainFeat, Color); - Seta.Add(mainFeat); - - // 5) (Opcional) cabeça da seta em “V”: duas linhas com ±θ a partir da ponta - if (withArrowHead) + try { - var theta = 25 * Math.PI / 180.0; // abertura do V (~25°) - // perna esquerda - var dxL = headLen * Math.Sin(rad + Math.PI - theta); - var dyL = headLen * Math.Cos(rad + Math.PI - theta); - var pL = new MPoint(p1.X + dxL, p1.Y + dyL); - var leftLine = new LineString(new Coordinate[] { new Coordinate(p1.X, p1.Y), new Coordinate(pL.X, pL.Y) }); + resolution = _mapParent.Map.Navigator.Viewport.Resolution; + } + catch + { + resolution = 1.0; + } - // perna direita - var dxR = headLen * Math.Sin(rad + Math.PI + theta); - var dyR = headLen * Math.Cos(rad + Math.PI + theta); - var pR = new MPoint(p1.X + dxR, p1.Y + dyR); - var rightLine = new LineString(new Coordinate[] { new Coordinate(p1.X, p1.Y), new Coordinate(pR.X, pR.Y) }); + // Dimensões reais do robô em metros + double robotLengthM = 1.20; + double robotWidthM = 1.00; - var fL = new GeometryFeature { Geometry = leftLine }; - var fR = new GeometryFeature { Geometry = rightLine }; - SetHeadingStyle(fL, Color); - SetHeadingStyle(fR, Color); + // Acima disso: ícone fixo em px + // Abaixo disso: tamanho real em metros + double realScaleResolutionThreshold = 0.14; - Seta.Add(fL); - Seta.Add(fR); + if (resolution < realScaleResolutionThreshold) + { + return (robotLengthM, robotWidthM, true); + } + + double normalPx = 24; + double minPx = 16; + double maxPx = 32; + + double sizePx = Math.Clamp(normalPx, minPx, maxPx); + double lengthWorld = sizePx * resolution; + double widthWorld = lengthWorld * 0.75; + + return (lengthWorld, widthWorld, false); + } + + private void CreateRoverTriangleMarker(MPoint centerWorld) + { + var (baseColor, _, _) = GetStatusVisual(); + + var (lengthWorld, widthWorld, realScale) = GetRoverSizeWorld(); + + double frontLength = lengthWorld * 0.55; + double backLength = lengthWorld * 0.45; + double halfWidth = widthWorld * 0.5; + + // Heading: 0° = Norte + double rad = Heading * Math.PI / 180.0; + + double ux = Math.Sin(rad); + double uy = Math.Cos(rad); + + // perpendicular + double px = Math.Cos(rad); + double py = -Math.Sin(rad); + + var front = new Coordinate( + centerWorld.X + ux * frontLength, + centerWorld.Y + uy * frontLength + ); + + var left = new Coordinate( + centerWorld.X - ux * backLength + px * halfWidth, + centerWorld.Y - uy * backLength + py * halfWidth + ); + + var right = new Coordinate( + centerWorld.X - ux * backLength - px * halfWidth, + centerWorld.Y - uy * backLength - py * halfWidth + ); + + var ring = new LinearRing(new[] + { + front, + left, + right, + front + }); + + var polygon = new Polygon(ring); + + var triangle = new GeometryFeature + { + Geometry = polygon + }; + + triangle.Styles.Add(new VectorStyle + { + Fill = new Brush(baseColor), + Outline = new Pen(Mapsui.Styles.Color.White, Focused ? 3 : 2) + }); + + MarkerShapes.Add(triangle); + + if (Focused) + { + var focusRing = new PointFeature(centerWorld); + focusRing.Styles.Add(new SymbolStyle + { + SymbolType = SymbolType.Ellipse, + SymbolScale = 1.35, + Fill = new Brush(new Mapsui.Styles.Color(baseColor.R, baseColor.G, baseColor.B, 45)), + Outline = new Pen(new Mapsui.Styles.Color(baseColor.R, baseColor.G, baseColor.B, 180), 2) + }); + + MarkerShapes.Add(focusRing); } } - private static void SetHeadingStyle(GeometryFeature f, System.Windows.Media.Color wpfColor) + private double GetMarkerSizeWorld(double normalPx = 22, double minPx = 16, double maxPx = 30) { - if (f.Styles == null) f.Styles = new List(); else f.Styles.Clear(); - var c = new Mapsui.Styles.Color(wpfColor.R, wpfColor.G, wpfColor.B, 230); - f.Styles.Add(new VectorStyle + double resolution = 1.0; + + try { - Line = new Pen(c, 2), // espessura em px na tela - Outline = null, + // metros por pixel no zoom atual + resolution = _mapParent.Map.Navigator.Viewport.Resolution; + } + catch + { + resolution = 1.0; + } + + double sizePx = Math.Clamp(normalPx, minPx, maxPx); + return sizePx * resolution; + } + + private void CreateBaseMarker(MPoint centerWorld) + { + var baseColor = new Mapsui.Styles.Color(220, 45, 45, 255); + + double radius = GetMarkerSizeWorld(22, 16, 30); + + var coords = new List(); + + // hexágono + for (int i = 0; i < 6; i++) + { + double ang = Math.PI / 6.0 + i * Math.PI / 3.0; + + coords.Add(new Coordinate( + centerWorld.X + Math.Cos(ang) * radius, + centerWorld.Y + Math.Sin(ang) * radius + )); + } + + coords.Add(coords[0]); + + var hex = new GeometryFeature + { + Geometry = new Polygon(new LinearRing(coords.ToArray())) + }; + + hex.Styles.Add(new VectorStyle + { + Fill = new Brush(baseColor), + Outline = new Pen(Mapsui.Styles.Color.White, Focused ? 3 : 2) }); + + MarkerShapes.Add(hex); + + var center = new PointFeature(centerWorld); + center.Styles.Add(new SymbolStyle + { + SymbolType = SymbolType.Ellipse, + SymbolScale = 0.45, + Fill = new Brush(Mapsui.Styles.Color.White), + Outline = null + }); + + MarkerShapes.Add(center); } private void SetStyles(double _pulseFactor = 1.0) @@ -1471,54 +1609,41 @@ namespace OperationControl.Controls if (Point.Styles == null) Point.Styles = new List(); else Point.Styles.Clear(); - // Pega o “visual” conforme o Status var (baseColor, statusGlyph, labelBackColor) = GetStatusVisual(); - // 1) Ponto central minúsculo (precisão) + // ponto central pequeno para referência/hit-test Point.Styles.Add(new SymbolStyle { - SymbolScale = 0.22, - Fill = new Brush(baseColor), + SymbolScale = 0.10, + Fill = new Brush(Mapsui.Styles.Color.White), Outline = null }); - // 2) “Aura” simulando gradiente (3 círculos com alpha/escala crescentes) - Point.Styles.Add(new SymbolStyle - { - SymbolScale = _pulseFactor * 0.55, - Fill = new Brush(new Color(baseColor.R, baseColor.G, baseColor.B, 120)), - Outline = null - }); - Point.Styles.Add(new SymbolStyle - { - SymbolScale = _pulseFactor * 0.95, - Fill = new Brush(new Color(baseColor.R, baseColor.G, baseColor.B, 70)), - Outline = null - }); - Point.Styles.Add(new SymbolStyle - { - SymbolScale = _pulseFactor * 1.4, - Fill = new Brush(new Color(baseColor.R, baseColor.G, baseColor.B, 30)), - Outline = null - }); + bool showLabel = + Focused || + true || + Status == StatusOperacao.Erro || + Status == StatusOperacao.Parado; - // 3) Rótulo do id (pequeno, acima do ponto) - if (!string.IsNullOrWhiteSpace(Label)) + if (showLabel && !string.IsNullOrWhiteSpace(Label)) { - // texto: se tiver glyph, coloca na frente var texto = string.IsNullOrEmpty(statusGlyph) ? Label : $"{Label} {statusGlyph}"; - var backColor = labelBackColor ?? new Color(0, 0, 0, 140); + var backColor = labelBackColor ?? new Mapsui.Styles.Color(0, 0, 0, 150); Point.Styles.Add(new LabelStyle { Text = texto, ForeColor = Mapsui.Styles.Color.White, BackColor = new Brush(backColor), - Offset = new Offset(0, -30), - Font = new Font { FontFamily = "Segoe UI Emoji", Size = 18 } + Offset = new Offset(0, -34), + Font = new Font + { + FontFamily = "Segoe UI Emoji", + Size = 15 + } }); } } diff --git a/AgroBase/OperationControl/Controls/Pulverizador/PulverizadorIndicator.xaml b/AgroBase/OperationControl/Controls/Pulverizador/PulverizadorIndicator.xaml index 13bb51dd3..f2c056399 100644 --- a/AgroBase/OperationControl/Controls/Pulverizador/PulverizadorIndicator.xaml +++ b/AgroBase/OperationControl/Controls/Pulverizador/PulverizadorIndicator.xaml @@ -145,7 +145,8 @@ Vazao="{Binding Vazao}" TempoAtuado="{Binding TempoAtuado}" Atuacoes="{Binding Atuacoes}" - Loaded="BicoLequeIndicator_Loaded" /> + Loaded="BicoLequeIndicator_Loaded" + Height="200" /> diff --git a/AgroBase/OperationControl/OperationControl.csproj.lscache b/AgroBase/OperationControl/OperationControl.csproj.lscache new file mode 100644 index 000000000..0e981b87b --- /dev/null +++ b/AgroBase/OperationControl/OperationControl.csproj.lscache @@ -0,0 +1,441 @@ +version=1 + +# This file caches language service data to improve the performance of C# Dev Kit. +# It is not intended for manual editing. It can safely be deleted and will be +# regenerated automatically. For more information, see https://aka.ms/lscache +# +# To control where cache files are stored, use the following VS Code setting: +# "dotnet.projectsystem.cacheInProjectFolder": true + +[project] +language=C# +primary +lastDtbSucceeded + +[properties] +AssemblyName=OperationControl +CommandLineArgsForDesignTimeEvaluation=-langversion:12.0 -define:TRACE +CompilerGeneratedFilesOutputPath= +MaxSupportedLangVersion=12.0 +ProjectAssetsFile=obj/project.assets.json +RootNamespace=OperationControl +RunAnalyzers= +RunAnalyzersDuringLiveAnalysis= +SolutionPath=*Undefined* +TargetFrameworkIdentifier=.NETCoreApp +TargetPath=bin/Debug/net8.0-windows7.0/OperationControl.dll +TargetRefPath=obj/Debug/net8.0-windows7.0/ref/OperationControl.dll +TemporaryDependencyNodeTargetIdentifier=net8.0-windows7.0 + +[commandLineArguments] +/noconfig +/unsafe- +/checked- +/nowarn:1701,1702,1701,1702 +/fullpaths +/nostdlib+ +/errorreport:prompt +/warn:8 +/define:TRACE;DEBUG;NET;NET8_0;NETCOREAPP;WINDOWS;WINDOWS7_0;NET5_0_OR_GREATER;NET6_0_OR_GREATER;NET7_0_OR_GREATER;NET8_0_OR_GREATER;NETCOREAPP3_0_OR_GREATER;NETCOREAPP3_1_OR_GREATER;WINDOWS7_0_OR_GREATER +/highentropyva+ +/nullable:enable +/debug+ +/debug:portable +/filealign:512 +/optimize- +/out:obj\Debug\net8.0-windows7.0\OperationControl.dll +/refout:obj\Debug\net8.0-windows7.0\refint\OperationControl.dll +/target:winexe +/warnaserror- +/utf8output +/deterministic+ +/langversion:12.0 +/warnaserror+:NU1605,SYSLIB0011 + +[sourceFiles] +App.xaml.cs +AssemblyInfo.cs +Controls/ + AttitudeIndicator.xaml.cs + AutoFitTextBlock.cs + Bbox3DViewer.xaml.cs + GstVideoView.xaml.cs + HeadingIndicator.xaml.cs + LabeledBar.xaml.cs + ManualControlPad.xaml.cs + MapViewControl.xaml.cs + ProgressBarText.xaml.cs + Pulverizador/ + BicoLequeIndicator.xaml.cs + Converters.cs + PulverizadorIndicator.xaml.cs + RiskMeter.xaml.cs + TemperatureIndicator.xaml.cs +Converters/ + BoolToVisibility.cs + MainWindow.cs + MultiplyConverter.cs + NegateAngleConverter.cs +Helpers/RelayCommand.cs +Models/ + AlertaModel.cs + AppShell.cs + Enums.cs + GraficoModel.cs + Operacao/ResumoOperacionalModel.cs + TcpVideoReceiver.cs + Variaveis.cs +obj/Debug/net8.0-windows7.0/ + .NETCoreApp,Version=v8.0.AssemblyAttributes.cs + OperationControl.AssemblyInfo.cs + OperationControl.GlobalUsings.g.cs +Services/ + GpsService.cs + ManualControlSender.cs +ViewModels/ + Base/NotifyBase.cs + Views/ConfigConexao/ + ConfigConexaoViewModel.cs + NetworkConfigViewModel.cs + Views/Operacao/Monitoramento/ + ControleManualViewModel.cs + Diagnostico/ + DiagnosticoGraficoSerieViewModel.cs + DiagnosticoModuloItemViewModel.cs + DiagnosticoOpcoesViewModel.cs + DiagnosticoViewModel.cs + HistoricoViewModel.cs + MonitoramentoViewModel.cs + ParametrizacaoViewModel.cs + PulverizadorViewModel.cs + ResumoViewModel.cs + Views/Operacao/ + OperacaoBottomViewModel.cs + OperacaoCenterViewModel.cs + OperacaoLeftViewModel.cs + OperacaoRightViewModel.cs + OperacaoTopViewModel.cs + Views/PreparacaoMapa/ + PreparacaoMapaBottomViewModel.cs + PreparacaoMapaTopViewModel.cs + Windows/DockWindowViewModel.cs +Views/ + ConfigConexao/ConfigConexaoView.xaml.cs + Operacao/Monitoramento/ + ControleManualView.xaml.cs + DiagnosticoView.xaml.cs + HistoricoView.xaml.cs + MonitoramentoView.xaml.cs + ParametrizacaoView.xaml.cs + PulverizadorView.xaml.cs + ResumoView.xaml.cs + Operacao/ + OperacaoBottomView.xaml.cs + OperacaoCenterView.xaml.cs + OperacaoLeftView.xaml.cs + OperacaoRightView.xaml.cs + OperacaoTopView.xaml.cs + PreparacaoMapa/ + PreparacaoMapaBottomView.xaml.cs + PreparacaoMapaTopView.xaml.cs + PreparacaoMapaView.xaml.cs +Windows/ + DockWindow.xaml.cs + MainWindow.xaml.cs + NetworkConfigWindow.xaml.cs + SelecaoTipoMapa.xaml.cs + +[metadataReferences] +../AgroBase/bin/Debug/AgroBase.exe +/packs/Microsoft.NETCore.App.Ref/8.0.0/ref/net8.0/ + Microsoft.CSharp.dll + Microsoft.VisualBasic.Core.dll + Microsoft.Win32.Primitives.dll + Microsoft.Win32.Registry.dll + mscorlib.dll + netstandard.dll + System.AppContext.dll + System.Buffers.dll + System.Collections.Concurrent.dll + System.Collections.dll + System.Collections.Immutable.dll + System.Collections.NonGeneric.dll + System.Collections.Specialized.dll + System.ComponentModel.Annotations.dll + System.ComponentModel.DataAnnotations.dll + System.ComponentModel.dll + System.ComponentModel.EventBasedAsync.dll + System.ComponentModel.Primitives.dll + System.ComponentModel.TypeConverter.dll + System.Configuration.dll + System.Console.dll + System.Core.dll + System.Data.Common.dll + System.Data.DataSetExtensions.dll + System.Data.dll + System.Diagnostics.Contracts.dll + System.Diagnostics.Debug.dll + System.Diagnostics.DiagnosticSource.dll + System.Diagnostics.FileVersionInfo.dll + System.Diagnostics.Process.dll + System.Diagnostics.StackTrace.dll + System.Diagnostics.TextWriterTraceListener.dll + System.Diagnostics.Tools.dll + System.Diagnostics.TraceSource.dll + System.Diagnostics.Tracing.dll + System.dll + System.Drawing.Primitives.dll + System.Dynamic.Runtime.dll + System.Formats.Asn1.dll + System.Formats.Tar.dll + System.Globalization.Calendars.dll + System.Globalization.dll + System.Globalization.Extensions.dll + System.IO.Compression.Brotli.dll + System.IO.Compression.dll + System.IO.Compression.FileSystem.dll + System.IO.Compression.ZipFile.dll + System.IO.dll + System.IO.FileSystem.AccessControl.dll + System.IO.FileSystem.dll + System.IO.FileSystem.DriveInfo.dll + System.IO.FileSystem.Primitives.dll + System.IO.FileSystem.Watcher.dll + System.IO.IsolatedStorage.dll + System.IO.MemoryMappedFiles.dll + System.IO.Pipes.AccessControl.dll + System.IO.Pipes.dll + System.IO.UnmanagedMemoryStream.dll + System.Linq.dll + System.Linq.Expressions.dll + System.Linq.Parallel.dll + System.Linq.Queryable.dll + System.Memory.dll + System.Net.dll + System.Net.Http.dll + System.Net.Http.Json.dll + System.Net.HttpListener.dll + System.Net.Mail.dll + System.Net.NameResolution.dll + System.Net.NetworkInformation.dll + System.Net.Ping.dll + System.Net.Primitives.dll + System.Net.Quic.dll + System.Net.Requests.dll + System.Net.Security.dll + System.Net.ServicePoint.dll + System.Net.Sockets.dll + System.Net.WebClient.dll + System.Net.WebHeaderCollection.dll + System.Net.WebProxy.dll + System.Net.WebSockets.Client.dll + System.Net.WebSockets.dll + System.Numerics.dll + System.Numerics.Vectors.dll + System.ObjectModel.dll + System.Reflection.DispatchProxy.dll + System.Reflection.dll + System.Reflection.Emit.dll + System.Reflection.Emit.ILGeneration.dll + System.Reflection.Emit.Lightweight.dll + System.Reflection.Extensions.dll + System.Reflection.Metadata.dll + System.Reflection.Primitives.dll + System.Reflection.TypeExtensions.dll + System.Resources.Reader.dll + System.Resources.ResourceManager.dll + System.Resources.Writer.dll + System.Runtime.CompilerServices.Unsafe.dll + System.Runtime.CompilerServices.VisualC.dll + System.Runtime.dll + System.Runtime.Extensions.dll + System.Runtime.Handles.dll + System.Runtime.InteropServices.dll + System.Runtime.InteropServices.JavaScript.dll + System.Runtime.InteropServices.RuntimeInformation.dll + System.Runtime.Intrinsics.dll + System.Runtime.Loader.dll + System.Runtime.Numerics.dll + System.Runtime.Serialization.dll + System.Runtime.Serialization.Formatters.dll + System.Runtime.Serialization.Json.dll + System.Runtime.Serialization.Primitives.dll + System.Runtime.Serialization.Xml.dll + System.Security.AccessControl.dll + System.Security.Claims.dll + System.Security.Cryptography.Algorithms.dll + System.Security.Cryptography.Cng.dll + System.Security.Cryptography.Csp.dll + System.Security.Cryptography.dll + System.Security.Cryptography.Encoding.dll + System.Security.Cryptography.OpenSsl.dll + System.Security.Cryptography.Primitives.dll + System.Security.Cryptography.X509Certificates.dll + System.Security.dll + System.Security.Principal.dll + System.Security.Principal.Windows.dll + System.Security.SecureString.dll + System.ServiceModel.Web.dll + System.ServiceProcess.dll + System.Text.Encoding.CodePages.dll + System.Text.Encoding.dll + System.Text.Encoding.Extensions.dll + System.Text.RegularExpressions.dll + System.Threading.Channels.dll + System.Threading.dll + System.Threading.Overlapped.dll + System.Threading.Tasks.Dataflow.dll + System.Threading.Tasks.dll + System.Threading.Tasks.Extensions.dll + System.Threading.Tasks.Parallel.dll + System.Threading.Thread.dll + System.Threading.ThreadPool.dll + System.Threading.Timer.dll + System.Transactions.dll + System.Transactions.Local.dll + System.ValueTuple.dll + System.Web.dll + System.Web.HttpUtility.dll + System.Windows.dll + System.Xml.dll + System.Xml.Linq.dll + System.Xml.ReaderWriter.dll + System.Xml.Serialization.dll + System.Xml.XDocument.dll + System.Xml.XmlDocument.dll + System.Xml.XmlSerializer.dll + System.Xml.XPath.dll + System.Xml.XPath.XDocument.dll +/packs/Microsoft.WindowsDesktop.App.Ref/8.0.0/ref/net8.0/ + Accessibility.dll + Microsoft.VisualBasic.dll + Microsoft.VisualBasic.Forms.dll + Microsoft.Win32.Registry.AccessControl.dll + Microsoft.Win32.SystemEvents.dll + PresentationCore.dll + PresentationFramework.Aero.dll + PresentationFramework.Aero2.dll + PresentationFramework.AeroLite.dll + PresentationFramework.Classic.dll + PresentationFramework.dll + PresentationFramework.Luna.dll + PresentationFramework.Royale.dll + PresentationUI.dll + ReachFramework.dll + System.CodeDom.dll + System.Configuration.ConfigurationManager.dll + System.Design.dll + System.Diagnostics.EventLog.dll + System.Diagnostics.PerformanceCounter.dll + System.DirectoryServices.dll + System.Drawing.Common.dll + System.Drawing.Design.dll + System.Drawing.dll + System.IO.Packaging.dll + System.Printing.dll + System.Resources.Extensions.dll + System.Security.Cryptography.Pkcs.dll + System.Security.Cryptography.ProtectedData.dll + System.Security.Cryptography.Xml.dll + System.Security.Permissions.dll + System.Threading.AccessControl.dll + System.Windows.Controls.Ribbon.dll + System.Windows.Extensions.dll + System.Windows.Forms.Design.dll + System.Windows.Forms.Design.Editors.dll + System.Windows.Forms.dll + System.Windows.Forms.Primitives.dll + System.Windows.Input.Manipulations.dll + System.Windows.Presentation.dll + System.Xaml.dll + UIAutomationClient.dll + UIAutomationClientSideProviders.dll + UIAutomationProvider.dll + UIAutomationTypes.dll + WindowsBase.dll + WindowsFormsIntegration.dll +/ + bitmiracle.libtiff.net/2.4.660/lib/netstandard2.0/BitMiracle.LibTiff.NET.dll + brutile.mbtiles/6.0.0/lib/net8.0/BruTile.MbTiles.dll + brutile/6.0.0/lib/net8.0/ + BruTile.dll + BruTile.XmlSerializers.dll + dotspatial.projections/4.0.656/lib/net6.0/DotSpatial.Projections.dll + excss/4.3.1/lib/net8.0/ExCSS.dll + extended.wpf.toolkit/5.0.0/lib/net5.0/ + Xceed.Wpf.AvalonDock.dll + Xceed.Wpf.AvalonDock.Themes.Aero.dll + Xceed.Wpf.AvalonDock.Themes.Metro.dll + Xceed.Wpf.AvalonDock.Themes.VS2010.dll + Xceed.Wpf.Toolkit.dll + ffme.windows/7.0.361-beta.1/lib/net8.0-windows7.0/ffme.win.dll + ffmpeg.autogen/7.0.0/lib/netstandard2.1/FFmpeg.AutoGen.dll + gircore.glib-2.0/0.7.0-preview.3/lib/net8.0/GLib-2.0.dll + gircore.gobject-2.0/0.7.0-preview.3/lib/net8.0/GObject-2.0.dll + gircore.gst-1.0/0.7.0-preview.3/lib/net8.0/Gst-1.0.dll + gircore.gstbase-1.0/0.7.0-preview.3/lib/net8.0/GstBase-1.0.dll + gircore.gstvideo-1.0/0.7.0-preview.3/lib/net8.0/GstVideo-1.0.dll + harfbuzzsharp/8.3.1.2/lib/net8.0/HarfBuzzSharp.dll + libvlcsharp.wpf/3.9.4/lib/net6.0-windows7.0/LibVLCSharp.WPF.dll + libvlcsharp/3.9.4/lib/net8.0/LibVLCSharp.dll + mapsui.extensions/5.0.0/lib/net8.0/Mapsui.Extensions.dll + mapsui.nts/5.0.0/lib/net8.0/Mapsui.Nts.dll + mapsui.rendering.skia/5.0.0/lib/net8.0/Mapsui.Rendering.Skia.dll + mapsui.tiling/5.0.0/lib/net8.0/Mapsui.Tiling.dll + mapsui.wpf/5.0.0/lib/net8.0-windows7.0/Mapsui.UI.Wpf.dll + mapsui/5.0.0/lib/net8.0/Mapsui.dll + mapsui3.geometries/3.0.0-alpha.3/lib/netstandard2.0/Mapsui.Geometries.dll + nettopologysuite.features/2.1.0/lib/netstandard2.0/NetTopologySuite.Features.dll + nettopologysuite.io.geojson/4.0.0/lib/netstandard2.0/NetTopologySuite.IO.GeoJSON.dll + nettopologysuite.io.geojson4stj/4.0.0/lib/netstandard2.0/NetTopologySuite.IO.GeoJSON4STJ.dll + nettopologysuite.io.shapefile/2.1.0/lib/netstandard2.0/NetTopologySuite.IO.ShapeFile.dll + nettopologysuite/2.6.0/lib/netstandard2.1/NetTopologySuite.dll + newtonsoft.json/13.0.1/lib/netstandard2.0/Newtonsoft.Json.dll + opentk.audio.openal/4.9.4/lib/netcoreapp3.1/OpenTK.Audio.OpenAL.dll + opentk.compute/4.9.4/lib/netcoreapp3.1/OpenTK.Compute.dll + opentk.core/4.9.4/lib/netstandard2.1/OpenTK.Core.dll + opentk.glwpfcontrol/4.3.3/lib/netcoreapp3.1/GLWpfControl.dll + opentk.graphics/4.9.4/lib/netcoreapp3.1/OpenTK.Graphics.dll + opentk.input/4.9.4/lib/netstandard2.0/OpenTK.Input.dll + opentk.mathematics/4.9.4/lib/netcoreapp3.1/OpenTK.Mathematics.dll + opentk.windowing.common/4.9.4/lib/netcoreapp3.1/OpenTK.Windowing.Common.dll + opentk.windowing.desktop/4.9.4/lib/netcoreapp3.1/OpenTK.Windowing.Desktop.dll + opentk.windowing.graphicslibraryframework/4.9.4/lib/netcoreapp3.1/OpenTK.Windowing.GraphicsLibraryFramework.dll + scottplot.wpf/5.1.57/lib/net8.0-windows7.0/ScottPlot.WPF.dll + scottplot/5.1.57/lib/net8.0/ScottPlot.dll + shimskiasharp/3.2.1/lib/net8.0/ShimSkiaSharp.dll + skiasharp.harfbuzz/3.119.1/lib/net8.0/SkiaSharp.HarfBuzz.dll + skiasharp.views.desktop.common/3.119.1/lib/net8.0/SkiaSharp.Views.Desktop.Common.dll + skiasharp.views.wpf/3.119.1/lib/net462/SkiaSharp.Views.WPF.dll + skiasharp/3.119.1/ref/net8.0/SkiaSharp.dll + sqlite-net-base/1.10.196-beta/lib/net8.0/SQLite-net.dll + sqlitepclraw.config.e_sqlite3/3.0.2/lib/net8.0/SQLitePCLRaw.batteries_v2.dll + sqlitepclraw.core/3.0.2/lib/netstandard2.0/SQLitePCLRaw.core.dll + sqlitepclraw.provider.e_sqlite3/3.0.2/lib/net8.0-windows7.0/SQLitePCLRaw.provider.e_sqlite3.dll + svg.custom/3.2.1/lib/net8.0/Svg.Custom.dll + svg.model/3.2.1/lib/net8.0/Svg.Model.dll + svg.skia/3.2.1/lib/net8.0/Svg.Skia.dll + system.io.pipelines/9.0.0/lib/net8.0/System.IO.Pipelines.dll + system.io.ports/10.0.0/lib/net8.0/System.IO.Ports.dll + system.text.encodings.web/9.0.0/lib/net8.0/System.Text.Encodings.Web.dll + system.text.json/9.0.0/lib/net8.0/System.Text.Json.dll + topten.richtextkit/0.4.167/lib/net5.0/Topten.RichTextKit.dll + +[analyzerReferences] +/packs/Microsoft.NETCore.App.Ref/8.0.0/analyzers/dotnet/cs/ + Microsoft.Interop.ComInterfaceGenerator.dll + Microsoft.Interop.JavaScript.JSImportGenerator.dll + Microsoft.Interop.LibraryImportGenerator.dll + Microsoft.Interop.SourceGeneration.dll + System.Text.RegularExpressions.Generator.dll +/packs/Microsoft.WindowsDesktop.App.Ref/8.0.0/analyzers/dotnet/ + cs/System.Windows.Forms.Analyzers.CSharp.dll + System.Windows.Forms.Analyzers.dll +/sdk/8.0.100/Sdks/Microsoft.NET.Sdk/analyzers/ + Microsoft.CodeAnalysis.CSharp.NetAnalyzers.dll + Microsoft.CodeAnalysis.NetAnalyzers.dll +/system.text.json/9.0.0/analyzers/dotnet/roslyn4.4/cs/System.Text.Json.SourceGeneration.dll + +[analyzerConfigFiles] +/sdk/8.0.100/Sdks/Microsoft.NET.Sdk/analyzers/build/config/analysislevel_8_default.globalconfig +obj/Debug/net8.0-windows7.0/OperationControl.GeneratedMSBuildEditorConfig.editorconfig diff --git a/AgroBase/OperationControl/Services/GpsService.cs b/AgroBase/OperationControl/Services/GpsService.cs index daaed5893..e707d3f31 100644 --- a/AgroBase/OperationControl/Services/GpsService.cs +++ b/AgroBase/OperationControl/Services/GpsService.cs @@ -103,18 +103,26 @@ namespace OperationControl.Services porta.Open(); - var nmea = $"gngga com3 1\r\n"; + // 🔹 1. Tenta identificar via VERSION + if (await EhUm982PorVersionAsync(porta, timeoutMs, ct)) + { + PortaGps = porta; + PortaGps.DataReceived -= PortaGPS_DataReceived; + PortaGps.DataReceived += PortaGPS_DataReceived; + return true; + } + + // 🔹 2. Fallback: ativa NMEA + var nmea = $"gngga com2 1\r\n"; porta.Write(Encoding.ASCII.GetBytes(nmea), 0, nmea.Length); - // Dá um tempinho pro módulo começar a cuspir NMEA await Task.Delay(200, ct); string recebido = await LerAmostraAsync(porta, timeoutMs, ct); if (EhGpsUm982OuNmea(recebido)) { - // Mantém essa porta como porta oficial do GPS - PortaGps = porta; // não fecha + PortaGps = porta; PortaGps.DataReceived -= PortaGPS_DataReceived; PortaGps.DataReceived += PortaGPS_DataReceived; return true; @@ -196,6 +204,29 @@ namespace OperationControl.Services recebido.Contains("$GNTHS"); } + private async Task EhUm982PorVersionAsync(SerialPort porta, int timeoutMs, CancellationToken ct) + { + try + { + var cmd = "version\r\n"; + porta.DiscardInBuffer(); + porta.Write(cmd); + + await Task.Delay(100, ct); + + string resposta = await LerAmostraAsync(porta, timeoutMs, ct); + + if (!string.IsNullOrEmpty(resposta) && + resposta.Contains("UM982")) + { + return true; + } + } + catch { } + + return false; + } + /// /// Fecha a porta do GPS (se estiver aberta). /// @@ -251,9 +282,9 @@ namespace OperationControl.Services } BaseFix.FixLiberado = fixar; - string portaUsb = "com3"; - string portaSaida = "com3"; - string portaEntrada = "com3"; + string portaUsb = "com2"; + string portaSaida = "com2"; + string portaEntrada = "com2"; string baseId = "957"; if (!fixar) @@ -370,8 +401,9 @@ namespace OperationControl.Services string distancia_min = "0"; string[] comandos = { // Bauds - $"config {porta_usb} 115200\r\n", - $"config {porta_saida} 115200\r\n", + $"config com1 115200\r\n", + $"config com2 115200\r\n", + $"config com3 115200\r\n", // limpa logs das portas $"unlog com1\r\n", diff --git a/AgroBase/OperationControl/Views/Operacao/OperacaoLeftView.xaml b/AgroBase/OperationControl/Views/Operacao/OperacaoLeftView.xaml index f40fe3e99..457065ccf 100644 --- a/AgroBase/OperationControl/Views/Operacao/OperacaoLeftView.xaml +++ b/AgroBase/OperationControl/Views/Operacao/OperacaoLeftView.xaml @@ -187,7 +187,7 @@ -