累计作业面积 时长实现 急停全局数据接入 局部内联样式 换为 外联 优化控制模式和系统模式的切换 功能控制面板加入急停 任务界面 加入急停
This commit is contained in:
@@ -705,7 +705,8 @@ export default function DeviceStatusPage() {
|
||||
return;
|
||||
}
|
||||
//console.log(runningStatus,controlMode, "现在的控制controlmode")
|
||||
if (controlMode == 3 && runningStatus?.control_mode == 3) {
|
||||
if ((controlMode == 3 && runningStatus?.control_mode == 3) || runningStatus?.systemMode == 3) {
|
||||
messageApi.warning(t('devices.onRemoteControl'));
|
||||
return;
|
||||
}
|
||||
const data = {
|
||||
@@ -716,7 +717,7 @@ export default function DeviceStatusPage() {
|
||||
if (res.code == 200 && res?.data) {
|
||||
messageApi.success(t('devices.controlModeSuccess'));
|
||||
} else {
|
||||
messageApi.error(res.msg || t('devices.controlModeFail'));
|
||||
messageApi.error(t('devices.controlModeFail'));
|
||||
}
|
||||
}).catch(err => {
|
||||
messageApi.success(t('devices.controlModeFail'));
|
||||
@@ -731,29 +732,44 @@ export default function DeviceStatusPage() {
|
||||
...currentDroneData, // 持久化数据最后覆盖,确保优先显示
|
||||
};
|
||||
}, [device, uavState, currentDroneData]);
|
||||
// 模式/权限提示节流:仅在用户真实操作(有按键或摇杆输入)时提示,2 秒内只提示一次
|
||||
// 避免点击页面其他区域、手柄轮询中性帧、失焦复位等无输入帧误触发提示
|
||||
const controlWarnRef = useRef(0);
|
||||
const handleGamepadUpdate = useCallback((state) => {
|
||||
// 无控制权限时:不发送消息,且只发起一次权限申请(避免手柄/方向盘高频更新刷屏)
|
||||
if (!isControlled) {
|
||||
messageApi.warning("请获取控制权限");
|
||||
//if (!hasRequestedControlRef.current && !connecting) {
|
||||
// hasRequestedControlRef.current = true;
|
||||
// handleControlModal();
|
||||
//}
|
||||
//return;
|
||||
}
|
||||
console.log(realtimePosition?.controlMode, "现在的控制controlmode")
|
||||
if (
|
||||
realtimePosition?.controlMode != 3 &&
|
||||
realtimePosition?.controlMode != 0 &&
|
||||
realtimePosition?.controlMode != null
|
||||
) {
|
||||
messageApi.warning(t('devices.noRemoteControl'));
|
||||
const hasInput =
|
||||
//(Array.isArray(state?.buttons) && state.buttons.some((v: any) => v == true || v == 1)) ||
|
||||
(Array.isArray(state?.axes) && state.axes.some((v: any) => Math.abs(Number(v) || 0) > 0.05));
|
||||
// 只有真实操作才做模式与权限校验,中性帧(无按键、轴为 0)不提示
|
||||
if (hasInput) {
|
||||
const now = Date.now();
|
||||
if (now - controlWarnRef.current > 2000) {
|
||||
let warned = false;
|
||||
// 无控制权限时:提示(避免手柄/方向盘高频更新刷屏)
|
||||
if (!isControlled) {
|
||||
messageApi.warning("请获取控制权限");
|
||||
warned = true;
|
||||
}
|
||||
console.log(runningStatus, "realtimePosition1111")
|
||||
if (!(runningStatus?.control_mode == 3 || runningStatus?.systemMode == 3)) {
|
||||
messageApi.warning(t('devices.switchControl'));
|
||||
warned = true;
|
||||
} else if (
|
||||
runningStatus?.controlMode != 3 &&
|
||||
runningStatus?.controlMode != 0 &&
|
||||
runningStatus?.controlMode != null
|
||||
) {
|
||||
messageApi.warning(t('devices.noRemoteControl'));
|
||||
warned = true;
|
||||
}
|
||||
if (warned) controlWarnRef.current = now;
|
||||
}
|
||||
}
|
||||
console.log('Gamepad state updated:', state);
|
||||
// 记录方向盘 xy 坐标,用于倒车影像叠加层
|
||||
if (state?.axes) {
|
||||
setSteerXY({ x: state.axes[2] || 0, y: state.axes[1] || 0 });
|
||||
}
|
||||
// 无论是否有输入(含 false/中性帧)都必须下发,保证设备侧能收到释放/停止状态
|
||||
controllerRef.current?.sendGamepad(state);
|
||||
}, [isControlled, connecting]);
|
||||
// 手柄已连接时拦截面板操作并提示(2 秒内只提示一次,避免高频刷屏)
|
||||
@@ -1324,23 +1340,30 @@ export default function DeviceStatusPage() {
|
||||
<ConsoleRow
|
||||
icon={<DashboardOutlined />}
|
||||
label={t('devices.systemMode')}
|
||||
value={
|
||||
(runningStatus?.system_mode ?? runningStatus?.systemMode) !== undefined
|
||||
? (() => {
|
||||
const mode = runningStatus?.system_mode ?? runningStatus?.systemMode;
|
||||
switch (mode) {
|
||||
case '2':
|
||||
case 2:
|
||||
return t('devices.autoTask');
|
||||
case '3':
|
||||
case 3:
|
||||
return t('devices.remoteControl');
|
||||
default:
|
||||
return "-";
|
||||
}
|
||||
})()
|
||||
: '-'
|
||||
}
|
||||
value={(() => {
|
||||
const mode =
|
||||
runningStatus?.system_mode ??
|
||||
runningStatus?.systemMode ??
|
||||
runningStatus?.control_mode ??
|
||||
runningStatus?.controlMode;
|
||||
|
||||
switch (mode) {
|
||||
case '2':
|
||||
case 2:
|
||||
return t('devices.autoTask');
|
||||
case '3':
|
||||
case 3:
|
||||
return t('devices.remoteControl');
|
||||
case '0':
|
||||
case 0:
|
||||
return t('devices.controlOff');
|
||||
case '1':
|
||||
case 1:
|
||||
return t('devices.localCpntrol');
|
||||
default:
|
||||
return '-';
|
||||
}
|
||||
})()}
|
||||
/>
|
||||
<ConsoleRow icon={<DashboardOutlined />} label={t('devices.forwardSpeed')} value={(runningStatus?.linear_speed ?? runningStatus?.linearSpeed) !== undefined ? Number(runningStatus?.linear_speed ?? runningStatus?.linearSpeed).toFixed(2) + ' m/s' : '-'} />
|
||||
<ConsoleRow icon={<DashboardOutlined />} label={t('devices.turnSpeed')} value={(runningStatus?.angular_speed ?? runningStatus?.angularSpeed) !== undefined ? Number(runningStatus?.angular_speed ?? runningStatus?.angularSpeed).toFixed(2) + ' rad/s' : '-'} />
|
||||
@@ -1397,7 +1420,7 @@ export default function DeviceStatusPage() {
|
||||
</div>
|
||||
) : mowerView === 'front' ? (
|
||||
<div style={{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0 }}>
|
||||
<AgrtcRoomRobot CHANNEL={"41-thream03"} />
|
||||
<AgrtcRoomRobot CHANNEL={"cam2-17"} />
|
||||
<CarReverseGuideLine
|
||||
direction="forward"
|
||||
steer={steerXY.x * 45}
|
||||
@@ -1553,7 +1576,7 @@ export default function DeviceStatusPage() {
|
||||
bodyStyle={{ padding: 10, display: 'flex', flex: "auto" }}
|
||||
>
|
||||
<RobotFeatureButtons
|
||||
showEmergencyStop={false}
|
||||
showEmergencyStop
|
||||
deviceId={selectedSn}
|
||||
activeFeatures={['response', 'obstacleAvoidance', 'lowBatteryReturn', 'tiltProtection', "findCar"]}
|
||||
onToggle={(feature, enabled) => { console.log('[DeviceStatusPage] Feature toggled: ' + feature + ' = ' + enabled); }}
|
||||
|
||||
Reference in New Issue
Block a user