fix:地图仪表盘功能模块实现
This commit is contained in:
@@ -194,6 +194,11 @@
|
||||
name: '设备管理',
|
||||
component: './device-ops/device',
|
||||
},
|
||||
{
|
||||
path: '/device-ops/map-dashboard.html',
|
||||
name: '地图仪表板',
|
||||
component: './device-ops/map-dashboard',
|
||||
},
|
||||
{
|
||||
path: '/device-ops/device/:id',
|
||||
name: '设备详情',
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+217
@@ -0,0 +1,217 @@
|
||||
import moment from 'moment';
|
||||
|
||||
// 设备状态枚举
|
||||
export enum DeviceStatus {
|
||||
TASK = 'task', // 任务中 - 绿色
|
||||
STANDBY = 'standby', // 待机 - 蓝色
|
||||
MAINTENANCE = 'maintenance', // 维护 - 橙色
|
||||
ERROR = 'error', // 异常 - 红色
|
||||
OFFLINE = 'offline' // 离线 - 灰色
|
||||
}
|
||||
|
||||
// 设备状态配置
|
||||
export const DEVICE_STATUS_CONFIG = {
|
||||
[DeviceStatus.TASK]: {
|
||||
color: '#52c41a',
|
||||
icon: '▶️',
|
||||
text: '任务中',
|
||||
bgColor: '#f6ffed'
|
||||
},
|
||||
[DeviceStatus.STANDBY]: {
|
||||
color: '#1890ff',
|
||||
icon: '⏰',
|
||||
text: '待机',
|
||||
bgColor: '#f0f8ff'
|
||||
},
|
||||
[DeviceStatus.MAINTENANCE]: {
|
||||
color: '#fa8c16',
|
||||
icon: '🔧',
|
||||
text: '维护',
|
||||
bgColor: '#fff7e6'
|
||||
},
|
||||
[DeviceStatus.ERROR]: {
|
||||
color: '#ff4d4f',
|
||||
icon: '⚠️',
|
||||
text: '异常',
|
||||
bgColor: '#fff2f0'
|
||||
},
|
||||
[DeviceStatus.OFFLINE]: {
|
||||
color: '#8c8c8c',
|
||||
icon: '❌',
|
||||
text: '离线',
|
||||
bgColor: '#f5f5f5'
|
||||
}
|
||||
};
|
||||
|
||||
// 设备类型
|
||||
export interface Device {
|
||||
id: string;
|
||||
name: string;
|
||||
sn: string;
|
||||
type: string;
|
||||
status: DeviceStatus;
|
||||
location: {
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
altitude?: number;
|
||||
};
|
||||
battery: number;
|
||||
signal: number;
|
||||
temperature: number;
|
||||
humidity: number;
|
||||
lastUpdate: string;
|
||||
group?: string;
|
||||
description?: string;
|
||||
// 新增字段
|
||||
batteryCycles?: number; // 电池循环次数
|
||||
flightHours?: number; // 飞行时长
|
||||
lastMaintenance?: string; // 最后维护时间
|
||||
nextMaintenance?: string; // 下次维护时间
|
||||
operator?: string; // 操作员
|
||||
ipAddress?: string; // IP地址
|
||||
firmwareVersion?: string; // 固件版本
|
||||
}
|
||||
|
||||
// 景区位置数据(北京周边景区)
|
||||
const SCENIC_SPOTS = [
|
||||
{ name: '颐和园', lat: 39.9999, lng: 116.2755, group: '颐和园景区' },
|
||||
{ name: '天坛公园', lat: 39.8822, lng: 116.4066, group: '天坛景区' },
|
||||
{ name: '故宫博物院', lat: 39.9163, lng: 116.3972, group: '故宫景区' },
|
||||
{ name: '八达岭长城', lat: 40.3569, lng: 116.0200, group: '长城景区' },
|
||||
{ name: '圆明园', lat: 40.0084, lng: 116.2995, group: '圆明园景区' },
|
||||
{ name: '香山公园', lat: 39.9944, lng: 116.1955, group: '香山景区' },
|
||||
{ name: '北海公园', lat: 39.9254, lng: 116.3897, group: '北海景区' },
|
||||
{ name: '景山公园', lat: 39.9244, lng: 116.3974, group: '景山景区' },
|
||||
{ name: '天安门广场', lat: 39.9054, lng: 116.3976, group: '天安门景区' },
|
||||
{ name: '奥林匹克公园', lat: 40.0024, lng: 116.3974, group: '奥体景区' },
|
||||
];
|
||||
|
||||
// 设备类型配置
|
||||
const DEVICE_TYPES = [
|
||||
{ type: '无人机', prefix: 'UAV', description: '航拍无人机设备' },
|
||||
{ type: '摄像头', prefix: 'CAM', description: '监控摄像头设备' },
|
||||
{ type: '传感器', prefix: 'SEN', description: '环境监测传感器' },
|
||||
{ type: '控制器', prefix: 'CTL', description: '智能控制器设备' },
|
||||
{ type: '基站', prefix: 'BS', description: '通信基站设备' },
|
||||
];
|
||||
|
||||
// 生成随机位置(在指定景区附近)
|
||||
const generateLocation = (scenicSpot: any) => {
|
||||
// 在景区周围500米范围内随机生成位置
|
||||
const radius = 0.005; // 约500米
|
||||
const angle = Math.random() * 2 * Math.PI;
|
||||
const distance = Math.random() * radius;
|
||||
|
||||
const lat = scenicSpot.lat + distance * Math.cos(angle);
|
||||
const lng = scenicSpot.lng + distance * Math.sin(angle);
|
||||
|
||||
return {
|
||||
latitude: lat,
|
||||
longitude: lng,
|
||||
altitude: Math.floor(Math.random() * 100) + 50
|
||||
};
|
||||
};
|
||||
|
||||
// 生成模拟设备数据
|
||||
export const generateMockDevices = (): Device[] => {
|
||||
const mockDevices: Device[] = [];
|
||||
|
||||
// 为每个景区生成2-4个设备
|
||||
SCENIC_SPOTS.forEach((spot, spotIndex) => {
|
||||
const deviceCount = Math.floor(Math.random() * 3) + 2; // 2-4个设备
|
||||
|
||||
for (let i = 1; i <= deviceCount; i++) {
|
||||
const deviceType = DEVICE_TYPES[Math.floor(Math.random() * DEVICE_TYPES.length)];
|
||||
const status = Object.values(DeviceStatus)[Math.floor(Math.random() * Object.values(DeviceStatus).length)];
|
||||
const deviceId = `${spotIndex + 1}_${i}`;
|
||||
|
||||
// 生成设备编号
|
||||
const sn = `${deviceType.prefix}${(spotIndex + 1).toString().padStart(2, '0')}${i.toString().padStart(2, '0')}`;
|
||||
|
||||
// 生成位置
|
||||
const location = generateLocation(spot);
|
||||
|
||||
// 生成电池循环次数(仅无人机)
|
||||
const batteryCycles = deviceType.type === '无人机' ? Math.floor(Math.random() * 200) + 1 : undefined;
|
||||
|
||||
// 生成飞行时长(仅无人机)
|
||||
const flightHours = deviceType.type === '无人机' ? Math.floor(Math.random() * 1000) + 10 : undefined;
|
||||
|
||||
// 生成维护时间
|
||||
const lastMaintenance = moment().subtract(Math.floor(Math.random() * 30), 'days').format('YYYY-MM-DD');
|
||||
const nextMaintenance = moment().add(Math.floor(Math.random() * 30) + 7, 'days').format('YYYY-MM-DD');
|
||||
|
||||
mockDevices.push({
|
||||
id: `device_${deviceId}`,
|
||||
name: `${deviceType.type}${deviceId}`,
|
||||
sn,
|
||||
type: deviceType.type,
|
||||
status,
|
||||
location,
|
||||
battery: Math.floor(Math.random() * 100) + 1,
|
||||
signal: Math.floor(Math.random() * 100) + 1,
|
||||
temperature: Math.floor(Math.random() * 40) + 10,
|
||||
humidity: Math.floor(Math.random() * 60) + 20,
|
||||
lastUpdate: moment().subtract(Math.floor(Math.random() * 60), 'minutes').format('YYYY-MM-DD HH:mm:ss'),
|
||||
group: spot.group,
|
||||
description: `${deviceType.description},位于${spot.name}`,
|
||||
batteryCycles,
|
||||
flightHours,
|
||||
lastMaintenance,
|
||||
nextMaintenance,
|
||||
operator: `操作员${Math.floor(Math.random() * 10) + 1}`,
|
||||
ipAddress: `192.168.${Math.floor(Math.random() * 255) + 1}.${Math.floor(Math.random() * 255) + 1}`,
|
||||
firmwareVersion: `v${Math.floor(Math.random() * 5) + 1}.${Math.floor(Math.random() * 10)}.${Math.floor(Math.random() * 10)}`
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return mockDevices;
|
||||
};
|
||||
|
||||
// 设备统计接口
|
||||
export interface DeviceStats {
|
||||
total: number;
|
||||
online: number;
|
||||
offline: number;
|
||||
task: number;
|
||||
standby: number;
|
||||
maintenance: number;
|
||||
error: number;
|
||||
byGroup: Record<string, number>;
|
||||
byType: Record<string, number>;
|
||||
}
|
||||
|
||||
// 计算设备统计
|
||||
export const calculateDeviceStats = (devices: Device[]): DeviceStats => {
|
||||
const stats: DeviceStats = {
|
||||
total: devices.length,
|
||||
online: devices.filter(d => d.status !== DeviceStatus.OFFLINE).length,
|
||||
offline: devices.filter(d => d.status === DeviceStatus.OFFLINE).length,
|
||||
task: devices.filter(d => d.status === DeviceStatus.TASK).length,
|
||||
standby: devices.filter(d => d.status === DeviceStatus.STANDBY).length,
|
||||
maintenance: devices.filter(d => d.status === DeviceStatus.MAINTENANCE).length,
|
||||
error: devices.filter(d => d.status === DeviceStatus.ERROR).length,
|
||||
byGroup: {},
|
||||
byType: {}
|
||||
};
|
||||
|
||||
// 按分组统计
|
||||
devices.forEach(device => {
|
||||
if (device.group) {
|
||||
stats.byGroup[device.group] = (stats.byGroup[device.group] || 0) + 1;
|
||||
}
|
||||
stats.byType[device.type] = (stats.byType[device.type] || 0) + 1;
|
||||
});
|
||||
|
||||
return stats;
|
||||
};
|
||||
|
||||
// 获取景区列表
|
||||
export const getScenicSpots = () => {
|
||||
return SCENIC_SPOTS.map(spot => ({
|
||||
name: spot.name,
|
||||
group: spot.group,
|
||||
location: { latitude: spot.lat, longitude: spot.lng }
|
||||
}));
|
||||
};
|
||||
@@ -13,7 +13,9 @@ import {
|
||||
DashboardOutlined, BarChartOutlined, SettingOutlined, BellOutlined,
|
||||
EyeOutlined, ReloadOutlined, DownloadOutlined, FilterOutlined,
|
||||
PlayCircleOutlined, PauseCircleOutlined, StopOutlined, CameraOutlined,
|
||||
VideoCameraOutlined, SoundOutlined, BulbOutlined, ToolOutlined
|
||||
VideoCameraOutlined, SoundOutlined, BulbOutlined, ToolOutlined,
|
||||
ControlOutlined, HomeOutlined, PauseOutlined, PlayOutlined,
|
||||
CameraOutlined as CameraIcon, VideoCameraOutlined as VideoIcon
|
||||
} from '@ant-design/icons';
|
||||
import { device, getStreamUrls } from '@/services/device/api';
|
||||
import { request } from 'umi';
|
||||
@@ -434,6 +436,30 @@ const DeviceMonitor: React.FC = () => {
|
||||
const [useReactPlayer, setUseReactPlayer] = useState(true);
|
||||
const [videoStreamStatus, setVideoStreamStatus] = useState<'loading' | 'playing' | 'error' | 'ended' | 'stalled'>('loading');
|
||||
|
||||
// 设备控制相关状态
|
||||
const [controlVisible, setControlVisible] = useState(false);
|
||||
const [currentControlDevice, setCurrentControlDevice] = useState<Device | null>(null);
|
||||
const [controlLoading, setControlLoading] = useState(false);
|
||||
const [controlError, setControlError] = useState('');
|
||||
const [controlSuccess, setControlSuccess] = useState('');
|
||||
|
||||
// 摇杆控制状态
|
||||
const [stickControl, setStickControl] = useState({
|
||||
roll: 1024, // 右手左右控制
|
||||
pitch: 1024, // 右手上下控制
|
||||
throttle: 1024, // 左手上下控制
|
||||
yaw: 1024, // 左手左右控制
|
||||
gimbal_pitch: 1024 // 云台画面上下划
|
||||
});
|
||||
|
||||
// 相机控制状态
|
||||
const [cameraMode, setCameraMode] = useState(0); // 0=拍照,1=录像,2=智能低光,3=全景拍照
|
||||
const [isRecording, setIsRecording] = useState(false);
|
||||
|
||||
// 飞行控制状态
|
||||
const [flightMode, setFlightMode] = useState<'idle' | 'manual' | 'task' | 'return'>('idle');
|
||||
const [isInDRCMode, setIsInDRCMode] = useState(false);
|
||||
|
||||
const tokenCache = {
|
||||
value: '',
|
||||
expire: 0,
|
||||
@@ -1487,6 +1513,9 @@ const DeviceMonitor: React.FC = () => {
|
||||
<a onClick={() => handlePlayVideo(record)}>
|
||||
<VideoCameraOutlined /> 视频流
|
||||
</a>
|
||||
<a onClick={() => handleOpenControl(record)}>
|
||||
<SettingOutlined /> 设备控制
|
||||
</a>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
@@ -2069,11 +2098,20 @@ const DeviceMonitor: React.FC = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 录制功能
|
||||
const handleToggleRecording = () => {
|
||||
setVideoRecording(!videoRecording);
|
||||
// 这里可以添加实际的录制逻辑
|
||||
console.log('录制状态:', !videoRecording);
|
||||
// 开始/停止录像
|
||||
const handleToggleVideoRecording = async () => {
|
||||
if (!currentControlDevice) return;
|
||||
|
||||
const method = isRecording ? 'camera_recording_stop' : 'camera_recording_start';
|
||||
const success = await sendControlCommand(
|
||||
currentControlDevice.deviceSn,
|
||||
method
|
||||
);
|
||||
|
||||
if (success) {
|
||||
setIsRecording(!isRecording);
|
||||
setControlSuccess(isRecording ? '停止录像指令已发送' : '开始录像指令已发送');
|
||||
}
|
||||
};
|
||||
|
||||
// 全屏功能
|
||||
@@ -2481,6 +2519,218 @@ const DeviceMonitor: React.FC = () => {
|
||||
);
|
||||
};
|
||||
|
||||
// 发送设备控制指令
|
||||
const sendControlCommand = async (deviceSn: string, method: string, data: any = {}) => {
|
||||
if (!wsRef.current || wsRef.current.readyState !== WebSocket.OPEN) {
|
||||
setControlError('WebSocket连接未建立,无法发送控制指令');
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
setControlLoading(true);
|
||||
setControlError('');
|
||||
setControlSuccess('');
|
||||
|
||||
const messageId = `control-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
||||
|
||||
const controlMessage = {
|
||||
type: "sub",
|
||||
topic: `/device-message-sender/D-Dock2/${deviceSn}`,
|
||||
parameter: {
|
||||
messageType: "WRITE_PROPERTY",
|
||||
properties: {
|
||||
method: method,
|
||||
data: data
|
||||
},
|
||||
headers: {
|
||||
async: false
|
||||
}
|
||||
},
|
||||
id: messageId
|
||||
};
|
||||
|
||||
console.log('发送控制指令:', JSON.stringify(controlMessage, null, 2));
|
||||
|
||||
wsRef.current.send(JSON.stringify(controlMessage));
|
||||
|
||||
// 等待响应
|
||||
return new Promise<boolean>((resolve) => {
|
||||
const timeout = setTimeout(() => {
|
||||
setControlError('控制指令超时,请检查设备状态');
|
||||
setControlLoading(false);
|
||||
resolve(false);
|
||||
}, 10000); // 10秒超时
|
||||
|
||||
const originalOnMessage = wsRef.current!.onmessage;
|
||||
wsRef.current!.onmessage = (event) => {
|
||||
try {
|
||||
const data = JSON.parse(event.data);
|
||||
if (data.type === 'result' && data.id === messageId) {
|
||||
clearTimeout(timeout);
|
||||
setControlLoading(false);
|
||||
|
||||
if (data.payload && data.payload.success !== false) {
|
||||
setControlSuccess('控制指令执行成功');
|
||||
resolve(true);
|
||||
} else {
|
||||
setControlError(data.payload?.message || '控制指令执行失败');
|
||||
resolve(false);
|
||||
}
|
||||
|
||||
// 恢复原始消息处理
|
||||
if (originalOnMessage) {
|
||||
wsRef.current!.onmessage = originalOnMessage;
|
||||
}
|
||||
} else {
|
||||
// 继续处理其他消息
|
||||
if (originalOnMessage) {
|
||||
originalOnMessage.call(wsRef.current!, event);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('解析控制响应失败:', error);
|
||||
}
|
||||
};
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('发送控制指令失败:', error);
|
||||
setControlError('发送控制指令失败');
|
||||
setControlLoading(false);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// 摇杆控制
|
||||
const handleStickControl = async (axis: string, value: number) => {
|
||||
if (!currentControlDevice) return;
|
||||
|
||||
const newStickControl = { ...stickControl, [axis]: value };
|
||||
setStickControl(newStickControl);
|
||||
|
||||
const success = await sendControlCommand(
|
||||
currentControlDevice.deviceSn,
|
||||
'stick_control',
|
||||
newStickControl
|
||||
);
|
||||
|
||||
if (success) {
|
||||
console.log('摇杆控制成功:', axis, value);
|
||||
}
|
||||
};
|
||||
|
||||
// 相机模式切换
|
||||
const handleCameraModeSwitch = async (mode: number) => {
|
||||
if (!currentControlDevice) return;
|
||||
|
||||
const success = await sendControlCommand(
|
||||
currentControlDevice.deviceSn,
|
||||
'camera_mode_switch',
|
||||
{ camera_mode: mode }
|
||||
);
|
||||
|
||||
if (success) {
|
||||
setCameraMode(mode);
|
||||
setControlSuccess(`相机模式切换为: ${getCameraModeText(mode)}`);
|
||||
}
|
||||
};
|
||||
|
||||
// 拍照
|
||||
const handleTakePhoto = async () => {
|
||||
if (!currentControlDevice) return;
|
||||
|
||||
const success = await sendControlCommand(
|
||||
currentControlDevice.deviceSn,
|
||||
'camera_photo_take'
|
||||
);
|
||||
|
||||
if (success) {
|
||||
setControlSuccess('拍照指令已发送');
|
||||
}
|
||||
};
|
||||
|
||||
// 暂停航线任务
|
||||
const handlePauseTask = async () => {
|
||||
if (!currentControlDevice) return;
|
||||
|
||||
const success = await sendControlCommand(
|
||||
currentControlDevice.deviceSn,
|
||||
'flighttask_pause'
|
||||
);
|
||||
|
||||
if (success) {
|
||||
setFlightMode('idle');
|
||||
setControlSuccess('航线任务已暂停');
|
||||
}
|
||||
};
|
||||
|
||||
// 返航
|
||||
const handleReturnHome = async () => {
|
||||
if (!currentControlDevice) return;
|
||||
|
||||
const success = await sendControlCommand(
|
||||
currentControlDevice.deviceSn,
|
||||
'return_home'
|
||||
);
|
||||
|
||||
if (success) {
|
||||
setFlightMode('return');
|
||||
setControlSuccess('返航指令已发送');
|
||||
}
|
||||
};
|
||||
|
||||
// 进入DRC模式
|
||||
const handleEnterDRCMode = async () => {
|
||||
if (!currentControlDevice) return;
|
||||
|
||||
const success = await sendControlCommand(
|
||||
currentControlDevice.deviceSn,
|
||||
'drc_mode_enter'
|
||||
);
|
||||
|
||||
if (success) {
|
||||
setIsInDRCMode(true);
|
||||
setFlightMode('manual');
|
||||
setControlSuccess('已进入指令飞行模式');
|
||||
}
|
||||
};
|
||||
|
||||
// 获取相机模式文本
|
||||
const getCameraModeText = (mode: number) => {
|
||||
const modeMap: Record<number, string> = {
|
||||
0: '拍照',
|
||||
1: '录像',
|
||||
2: '智能低光',
|
||||
3: '全景拍照'
|
||||
};
|
||||
return modeMap[mode] || '未知模式';
|
||||
};
|
||||
|
||||
// 打开设备控制面板
|
||||
const handleOpenControl = (device: Device) => {
|
||||
setCurrentControlDevice(device);
|
||||
setControlVisible(true);
|
||||
setControlError('');
|
||||
setControlSuccess('');
|
||||
setControlLoading(false);
|
||||
};
|
||||
|
||||
// 关闭设备控制面板
|
||||
const handleCloseControl = () => {
|
||||
setControlVisible(false);
|
||||
setCurrentControlDevice(null);
|
||||
setControlError('');
|
||||
setControlSuccess('');
|
||||
setControlLoading(false);
|
||||
// 重置摇杆到中立位
|
||||
setStickControl({
|
||||
roll: 1024,
|
||||
pitch: 1024,
|
||||
throttle: 1024,
|
||||
yaw: 1024,
|
||||
gimbal_pitch: 1024
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<PageContainer>
|
||||
{/* 顶部控制栏 */}
|
||||
@@ -3208,7 +3458,7 @@ const DeviceMonitor: React.FC = () => {
|
||||
</Button>,
|
||||
<Button
|
||||
key="record"
|
||||
onClick={handleToggleRecording}
|
||||
onClick={handleToggleVideoRecording}
|
||||
disabled={!videoStreamUrl}
|
||||
type={videoRecording ? 'primary' : 'default'}
|
||||
>
|
||||
@@ -3401,6 +3651,283 @@ const DeviceMonitor: React.FC = () => {
|
||||
)}
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
{/* 设备控制弹窗 */}
|
||||
<Modal
|
||||
title={
|
||||
<Space>
|
||||
<SettingOutlined />
|
||||
{currentControlDevice ? `${currentControlDevice.deviceName} 设备控制` : '设备控制'}
|
||||
</Space>
|
||||
}
|
||||
open={controlVisible}
|
||||
onCancel={handleCloseControl}
|
||||
footer={[
|
||||
<Button key="close" onClick={handleCloseControl}>
|
||||
关闭
|
||||
</Button>,
|
||||
]}
|
||||
width={1000}
|
||||
destroyOnClose
|
||||
>
|
||||
<div>
|
||||
{/* 状态提示 */}
|
||||
{controlError && (
|
||||
<Alert
|
||||
message="控制错误"
|
||||
description={controlError}
|
||||
type="error"
|
||||
showIcon
|
||||
style={{ marginBottom: 16 }}
|
||||
/>
|
||||
)}
|
||||
|
||||
{controlSuccess && (
|
||||
<Alert
|
||||
message="控制成功"
|
||||
description={controlSuccess}
|
||||
type="success"
|
||||
showIcon
|
||||
style={{ marginBottom: 16 }}
|
||||
/>
|
||||
)}
|
||||
|
||||
{controlLoading && (
|
||||
<Alert
|
||||
message="正在执行控制指令"
|
||||
description="请稍候..."
|
||||
type="info"
|
||||
showIcon
|
||||
style={{ marginBottom: 16 }}
|
||||
/>
|
||||
)}
|
||||
|
||||
<Tabs defaultActiveKey="flight" type="card">
|
||||
{/* 飞行控制标签页 */}
|
||||
<TabPane tab="飞行控制" key="flight">
|
||||
<Row gutter={[16, 16]}>
|
||||
<Col span={12}>
|
||||
<Card title="飞行模式控制" size="small">
|
||||
<Space direction="vertical" style={{ width: '100%' }}>
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<PlayCircleOutlined />}
|
||||
onClick={handleEnterDRCMode}
|
||||
loading={controlLoading}
|
||||
disabled={isInDRCMode}
|
||||
block
|
||||
>
|
||||
进入指令飞行模式
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
type="default"
|
||||
icon={<PauseCircleOutlined />}
|
||||
onClick={handlePauseTask}
|
||||
loading={controlLoading}
|
||||
block
|
||||
>
|
||||
暂停航线任务
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
type="default"
|
||||
icon={<HomeOutlined />}
|
||||
onClick={handleReturnHome}
|
||||
loading={controlLoading}
|
||||
block
|
||||
>
|
||||
返航
|
||||
</Button>
|
||||
</Space>
|
||||
</Card>
|
||||
</Col>
|
||||
|
||||
<Col span={12}>
|
||||
<Card title="当前状态" size="small">
|
||||
<Descriptions size="small" column={1}>
|
||||
<Descriptions.Item label="飞行模式">
|
||||
<Tag color={
|
||||
flightMode === 'idle' ? 'default' :
|
||||
flightMode === 'manual' ? 'blue' :
|
||||
flightMode === 'task' ? 'green' :
|
||||
flightMode === 'return' ? 'orange' : 'default'
|
||||
}>
|
||||
{flightMode === 'idle' ? '空闲' :
|
||||
flightMode === 'manual' ? '手动控制' :
|
||||
flightMode === 'task' ? '任务执行' :
|
||||
flightMode === 'return' ? '返航中' : '未知'}
|
||||
</Tag>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="DRC模式">
|
||||
<Tag color={isInDRCMode ? 'green' : 'default'}>
|
||||
{isInDRCMode ? '已启用' : '未启用'}
|
||||
</Tag>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="设备状态">
|
||||
<Tag color={currentControlDevice?.boundStatus === 1 ? 'green' : 'red'}>
|
||||
{currentControlDevice?.boundStatus === 1 ? '在线' : '离线'}
|
||||
</Tag>
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
</TabPane>
|
||||
|
||||
{/* 摇杆控制标签页 */}
|
||||
<TabPane tab="摇杆控制" key="stick">
|
||||
<Row gutter={[16, 16]}>
|
||||
<Col span={12}>
|
||||
<Card title="右手控制" size="small">
|
||||
<Space direction="vertical" style={{ width: '100%' }}>
|
||||
<div>
|
||||
<Text>左右控制 (Roll): {stickControl.roll}</Text>
|
||||
<Slider
|
||||
min={0}
|
||||
max={2048}
|
||||
value={stickControl.roll}
|
||||
onChange={(value) => handleStickControl('roll', value)}
|
||||
disabled={controlLoading || !isInDRCMode}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Text>上下控制 (Pitch): {stickControl.pitch}</Text>
|
||||
<Slider
|
||||
min={0}
|
||||
max={2048}
|
||||
value={stickControl.pitch}
|
||||
onChange={(value) => handleStickControl('pitch', value)}
|
||||
disabled={controlLoading || !isInDRCMode}
|
||||
/>
|
||||
</div>
|
||||
</Space>
|
||||
</Card>
|
||||
</Col>
|
||||
|
||||
<Col span={12}>
|
||||
<Card title="左手控制" size="small">
|
||||
<Space direction="vertical" style={{ width: '100%' }}>
|
||||
<div>
|
||||
<Text>上下控制 (Throttle): {stickControl.throttle}</Text>
|
||||
<Slider
|
||||
min={0}
|
||||
max={2048}
|
||||
value={stickControl.throttle}
|
||||
onChange={(value) => handleStickControl('throttle', value)}
|
||||
disabled={controlLoading || !isInDRCMode}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Text>左右控制 (Yaw): {stickControl.yaw}</Text>
|
||||
<Slider
|
||||
min={924}
|
||||
max={1124}
|
||||
value={stickControl.yaw}
|
||||
onChange={(value) => handleStickControl('yaw', value)}
|
||||
disabled={controlLoading || !isInDRCMode}
|
||||
/>
|
||||
</div>
|
||||
</Space>
|
||||
</Card>
|
||||
</Col>
|
||||
|
||||
<Col span={24}>
|
||||
<Card title="云台控制" size="small">
|
||||
<div>
|
||||
<Text>云台上下 (Gimbal Pitch): {stickControl.gimbal_pitch}</Text>
|
||||
<Slider
|
||||
min={0}
|
||||
max={2048}
|
||||
value={stickControl.gimbal_pitch}
|
||||
onChange={(value) => handleStickControl('gimbal_pitch', value)}
|
||||
disabled={controlLoading || !isInDRCMode}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
</TabPane>
|
||||
|
||||
{/* 相机控制标签页 */}
|
||||
<TabPane tab="相机控制" key="camera">
|
||||
<Row gutter={[16, 16]}>
|
||||
<Col span={12}>
|
||||
<Card title="相机模式" size="small">
|
||||
<Space direction="vertical" style={{ width: '100%' }}>
|
||||
<div>
|
||||
<Text>当前模式: {getCameraModeText(cameraMode)}</Text>
|
||||
</div>
|
||||
<Button
|
||||
type={cameraMode === 0 ? 'primary' : 'default'}
|
||||
icon={<CameraOutlined />}
|
||||
onClick={() => handleCameraModeSwitch(0)}
|
||||
loading={controlLoading}
|
||||
block
|
||||
>
|
||||
拍照模式
|
||||
</Button>
|
||||
<Button
|
||||
type={cameraMode === 1 ? 'primary' : 'default'}
|
||||
icon={<VideoCameraOutlined />}
|
||||
onClick={() => handleCameraModeSwitch(1)}
|
||||
loading={controlLoading}
|
||||
block
|
||||
>
|
||||
录像模式
|
||||
</Button>
|
||||
<Button
|
||||
type={cameraMode === 2 ? 'primary' : 'default'}
|
||||
icon={<BulbOutlined />}
|
||||
onClick={() => handleCameraModeSwitch(2)}
|
||||
loading={controlLoading}
|
||||
block
|
||||
>
|
||||
智能低光
|
||||
</Button>
|
||||
<Button
|
||||
type={cameraMode === 3 ? 'primary' : 'default'}
|
||||
icon={<CameraOutlined />}
|
||||
onClick={() => handleCameraModeSwitch(3)}
|
||||
loading={controlLoading}
|
||||
block
|
||||
>
|
||||
全景拍照
|
||||
</Button>
|
||||
</Space>
|
||||
</Card>
|
||||
</Col>
|
||||
|
||||
<Col span={12}>
|
||||
<Card title="相机操作" size="small">
|
||||
<Space direction="vertical" style={{ width: '100%' }}>
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<CameraOutlined />}
|
||||
onClick={handleTakePhoto}
|
||||
loading={controlLoading}
|
||||
block
|
||||
>
|
||||
拍照
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
type={isRecording ? 'primary' : 'default'}
|
||||
icon={isRecording ? <StopOutlined /> : <VideoCameraOutlined />}
|
||||
onClick={handleToggleVideoRecording}
|
||||
loading={controlLoading}
|
||||
block
|
||||
>
|
||||
{isRecording ? '停止录像' : '开始录像'}
|
||||
</Button>
|
||||
</Space>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
</div>
|
||||
</Modal>
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user