开始作业,
暂停作业, 停止作业, 回复作业, ---初步待使用
This commit is contained in:
38
lib/features/devices/data/models/route_plan_send_entity.dart
Normal file
38
lib/features/devices/data/models/route_plan_send_entity.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user