完善自主作业下发、暂停恢复和轨迹保留

This commit is contained in:
2026-11-21 14:51:37 +08:00
parent a37c448391
commit 4a1ce4199d
18 changed files with 556 additions and 127 deletions

View File

@@ -63,6 +63,9 @@ class PvWorkMap extends StatefulWidget {
this.recordLocationTrace = true,
this.workTrace,
this.taskTrace,
this.savedRoute = const <LatLng>[],
this.onTaskTraceChanged,
this.onTaskRouteChanged,
this.expectedTaskId,
this.traceDiagnosticsEnabled = false,
this.showDevice = true,
@@ -164,6 +167,9 @@ class PvWorkMap extends StatefulWidget {
final bool recordLocationTrace;
final List<LatLng>? workTrace;
final WorkTraceInput? taskTrace;
final List<LatLng> savedRoute;
final ValueChanged<List<LatLng>>? onTaskTraceChanged;
final ValueChanged<List<LatLng>>? onTaskRouteChanged;
final String? expectedTaskId;
final bool traceDiagnosticsEnabled;
final bool showDevice;
@@ -196,7 +202,13 @@ class _PvWorkMapState extends State<PvWorkMap> {
return;
}
_taskTraceRecorder.synchronize(deviceId: widget.deviceSn, input: input);
if (_pos != null) _taskTraceRecorder.addPosition(_pos!);
if (_route.isEmpty && widget.savedRoute.isNotEmpty && input.visible) {
_route = List.of(widget.savedRoute);
_routeTaskId = int.tryParse(widget.expectedTaskId ?? '') ?? -1;
}
if (_pos != null && _taskTraceRecorder.addPosition(_pos!)) {
widget.onTaskTraceChanged?.call(_taskTraceRecorder.points);
}
}
void _logTraceRender(List<LatLng> points) {
@@ -405,6 +417,7 @@ class _PvWorkMapState extends State<PvWorkMap> {
}
_route = [for (final p in msg.data) LatLng(p.lat, p.lng)];
});
widget.onTaskRouteChanged?.call(List.of(_route));
}
/// 定位推送来了:攒轨迹 + 按需把机器移到正中间
@@ -446,7 +459,9 @@ class _PvWorkMapState extends State<PvWorkMap> {
_pos = p;
widget.onDevicePosition?.call(p);
if (widget.taskTrace != null) {
_taskTraceRecorder.addPosition(p);
if (_taskTraceRecorder.addPosition(p)) {
widget.onTaskTraceChanged?.call(_taskTraceRecorder.points);
}
} else if (widget.recordLocationTrace) {
_appendTrace(p);
}