完善遥控权限、控制发送和急停反馈
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
import '../../../../core/error/failure.dart';
|
||||
|
||||
/// 后端明确返回业务失败,区别于断线/超时导致的结果未知。
|
||||
class EmergencyStopRejectedFailure extends ServerFailure {
|
||||
EmergencyStopRejectedFailure(super.message);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/// 请求目标,不代表设备已经执行;实际急停状态仍以设备反馈为准。
|
||||
enum EmergencyStopTarget {
|
||||
engage(1),
|
||||
release(0);
|
||||
|
||||
const EmergencyStopTarget(this.value);
|
||||
final int value;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
|
||||
import '../../../../core/error/failure.dart';
|
||||
import '../entities/emergency_stop_target.dart';
|
||||
|
||||
abstract class DeviceEmergencyStopRepository {
|
||||
/// 成功仅表示接口接受请求,不确认车辆实际急停或解除。
|
||||
Future<Either<Failure, Unit>> request(
|
||||
String deviceId,
|
||||
EmergencyStopTarget target,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
|
||||
import '../../../../core/error/failure.dart';
|
||||
import '../entities/emergency_stop_target.dart';
|
||||
import '../repositories/device_emergency_stop_repository.dart';
|
||||
|
||||
class RequestDeviceEmergencyStopUseCase {
|
||||
const RequestDeviceEmergencyStopUseCase(this.repository);
|
||||
final DeviceEmergencyStopRepository repository;
|
||||
|
||||
Future<Either<Failure, Unit>> call(
|
||||
String deviceId,
|
||||
EmergencyStopTarget target,
|
||||
) {
|
||||
final id = deviceId.trim();
|
||||
if (id.isEmpty) return Future.value(Left(Failure('设备标识不能为空')));
|
||||
return repository.request(id, target);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user