Files
feature-next-arch/lib/features/devices/data/models/route_plan_send_entity.dart
Songzex e416416e85 开始作业,
暂停作业,
停止作业,
回复作业,
---初步待使用
2026-03-02 14:11:04 +08:00

39 lines
988 B
Dart

// lib/features/devices/data/models/route_plan_send_entity.dart
import 'dart:typed_data'; // ✅ 必须添加
class RoutePlanSendEntity {
final int commandType;
final int pointCounts;
final double targetLatitude;
final double targetLongitude;
final int speed;
RoutePlanSendEntity({
required this.commandType,
required this.pointCounts,
required this.targetLatitude,
required this.targetLongitude,
required this.speed,
});
List<int> toBytes() {
final bytes = <int>[];
bytes.add(commandType);
bytes.addAll(_shortToBytes(pointCounts));
bytes.addAll(_doubleToBytes(targetLatitude));
bytes.addAll(_doubleToBytes(targetLongitude));
bytes.addAll(_shortToBytes(speed));
return bytes;
}
List<int> _shortToBytes(int value) {
return [(value >> 8) & 0xFF, value & 0xFF];
}
List<int> _doubleToBytes(double value) {
final byteData = ByteData(8)..setFloat64(0, value);
return byteData.buffer.asUint8List();
}
}