modbus_rtu_device.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import axios from 'axios';
  2. export interface DeviceMonitorData {
  3. id: number;
  4. device_id: number;
  5. device_name: string;
  6. protocol: string;
  7. address: string;
  8. metric_type: string;
  9. metric_value: number;
  10. unit?: string;
  11. status: string;
  12. collect_time: Date;
  13. }
  14. export const ModbusRtuDeviceAPI = {
  15. // 获取Modbus RTU设备监控数据
  16. getMonitorData: async (params: {
  17. page?: number;
  18. pageSize?: number;
  19. device_id?: number;
  20. device_name?: string;
  21. protocol?: string;
  22. address?: string;
  23. metric_type?: string;
  24. status?: string;
  25. }) => {
  26. const response = await axios.get('/modbus-rtu-device/monitor-data', { params });
  27. return {
  28. data: response.data.data || [],
  29. total: response.data.total || 0,
  30. };
  31. },
  32. // 测试Modbus RTU设备连接
  33. testConnection: async (data: {
  34. protocol: string;
  35. address: string;
  36. baud_rate: number;
  37. data_bits: number;
  38. stop_bits: number;
  39. parity: string;
  40. }) => {
  41. const response = await axios.post('/modbus-rtu-device/test-connection', data);
  42. return response.data;
  43. },
  44. };