| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import axios from 'axios';
- export interface DeviceMonitorData {
- id: number;
- device_id: number;
- device_name: string;
- protocol: string;
- address: string;
- metric_type: string;
- metric_value: number;
- unit?: string;
- status: string;
- collect_time: Date;
- }
- export const ModbusRtuDeviceAPI = {
- // 获取Modbus RTU设备监控数据
- getMonitorData: async (params: {
- page?: number;
- pageSize?: number;
- device_id?: number;
- device_name?: string;
- protocol?: string;
- address?: string;
- metric_type?: string;
- status?: string;
- }) => {
- const response = await axios.get('/modbus-rtu-device/monitor-data', { params });
- return {
- data: response.data.data || [],
- total: response.data.total || 0,
- };
- },
- // 测试Modbus RTU设备连接
- testConnection: async (data: {
- protocol: string;
- address: string;
- baud_rate: number;
- data_bits: number;
- stop_bits: number;
- parity: string;
- }) => {
- const response = await axios.post('/modbus-rtu-device/test-connection', data);
- return response.data;
- },
- };
|