diff --git a/src/api/iot/device/modbus/config/index.ts b/src/api/iot/device/modbus/config/index.ts new file mode 100644 index 00000000..7db9e69f --- /dev/null +++ b/src/api/iot/device/modbus/config/index.ts @@ -0,0 +1,31 @@ +import request from '@/config/axios' + +/** Modbus 连接配置 VO */ +export interface DeviceModbusConfigVO { + id?: number // 主键 + deviceId: number // 设备编号 + ip: string // Modbus 服务器 IP 地址 + port: number // Modbus 服务器端口 + slaveId: number // 从站地址 + timeout: number // 连接超时时间,单位:毫秒 + retryInterval: number // 重试间隔,单位:毫秒 + mode: number // 模式 + frameFormat: number // 帧格式 + status: number // 状态 +} + +/** Modbus 连接配置 API */ +export const DeviceModbusConfigApi = { + /** 获取设备的 Modbus 连接配置 */ + getModbusConfig: async (deviceId: number) => { + return await request.get({ + url: `/iot/device-modbus-config/get`, + params: { deviceId } + }) + }, + + /** 保存 Modbus 连接配置 */ + saveModbusConfig: async (data: DeviceModbusConfigVO) => { + return await request.post({ url: `/iot/device-modbus-config/save`, data }) + } +} diff --git a/src/api/iot/device/modbus/point/index.ts b/src/api/iot/device/modbus/point/index.ts new file mode 100644 index 00000000..0ae51bb9 --- /dev/null +++ b/src/api/iot/device/modbus/point/index.ts @@ -0,0 +1,48 @@ +import request from '@/config/axios' + +/** Modbus 点位配置 VO */ +export interface DeviceModbusPointVO { + id?: number // 主键 + deviceId: number // 设备编号 + thingModelId?: number // 物模型属性编号 + identifier: string // 属性标识符 + name: string // 属性名称 + functionCode?: number // Modbus 功能码 + registerAddress?: number // 寄存器起始地址 + registerCount?: number // 寄存器数量 + byteOrder?: string // 字节序 + rawDataType?: string // 原始数据类型 + scale: number // 缩放因子 + pollInterval: number // 轮询间隔,单位:毫秒 + status: number // 状态 +} + +/** Modbus 点位配置 API */ +export const DeviceModbusPointApi = { + /** 获取设备的 Modbus 点位分页 */ + getModbusPointPage: async (params: any) => { + return await request.get({ url: `/iot/device-modbus-point/page`, params }) + }, + + /** 获取 Modbus 点位详情 */ + getModbusPoint: async (id: number) => { + return await request.get({ + url: `/iot/device-modbus-point/get?id=${id}` + }) + }, + + /** 创建 Modbus 点位配置 */ + createModbusPoint: async (data: DeviceModbusPointVO) => { + return await request.post({ url: `/iot/device-modbus-point/create`, data }) + }, + + /** 更新 Modbus 点位配置 */ + updateModbusPoint: async (data: DeviceModbusPointVO) => { + return await request.put({ url: `/iot/device-modbus-point/update`, data }) + }, + + /** 删除 Modbus 点位配置 */ + deleteModbusPoint: async (id: number) => { + return await request.delete({ url: `/iot/device-modbus-point/delete?id=${id}` }) + } +} diff --git a/src/api/iot/product/product/index.ts b/src/api/iot/product/product/index.ts index ba465efd..73eb0f99 100644 --- a/src/api/iot/product/product/index.ts +++ b/src/api/iot/product/product/index.ts @@ -16,7 +16,8 @@ export interface ProductVO { status: number // 产品状态 deviceType: number // 设备类型 netType: number // 联网方式 - codecType: string // 数据格式(编解码器类型) + protocolType: string // 协议类型 + serializeType: string // 序列化类型 deviceCount: number // 设备数量 createTime: Date // 创建时间 } @@ -27,9 +28,23 @@ export enum DeviceTypeEnum { GATEWAY_SUB = 1, // 网关子设备 GATEWAY = 2 // 网关设备 } -// IOT 数据格式(编解码器类型)枚举类 -export enum CodecTypeEnum { - ALINK = 'Alink' // 阿里云 Alink 协议 +// IoT 协议类型枚举 +export enum ProtocolTypeEnum { + TCP = 'tcp', + UDP = 'udp', + WEBSOCKET = 'websocket', + HTTP = 'http', + MQTT = 'mqtt', + EMQX = 'emqx', + COAP = 'coap', + MODBUS_TCP_CLIENT = 'modbus_tcp_client', + MODBUS_TCP_SERVER = 'modbus_tcp_server' +} + +// IoT 序列化类型枚举 +export enum SerializeTypeEnum { + JSON = 'json', + BINARY = 'binary' } // IoT 产品 API diff --git a/src/utils/dict.ts b/src/utils/dict.ts index b4f0c587..ec54b408 100644 --- a/src/utils/dict.ts +++ b/src/utils/dict.ts @@ -233,7 +233,8 @@ export enum DICT_TYPE { IOT_NET_TYPE = 'iot_net_type', // IOT 联网方式 IOT_PRODUCT_STATUS = 'iot_product_status', // IOT 产品状态 IOT_PRODUCT_DEVICE_TYPE = 'iot_product_device_type', // IOT 产品设备类型 - IOT_CODEC_TYPE = 'iot_codec_type', // IOT 数据格式(编解码器类型) + IOT_PROTOCOL_TYPE = 'iot_protocol_type', // IOT 协议类型 + IOT_SERIALIZE_TYPE = 'iot_serialize_type', // IOT 序列化类型 IOT_LOCATION_TYPE = 'iot_location_type', // IOT 定位类型 IOT_DEVICE_STATE = 'iot_device_state', // IOT 设备状态 IOT_THING_MODEL_TYPE = 'iot_thing_model_type', // IOT 产品功能类型 @@ -247,5 +248,7 @@ export enum DICT_TYPE { IOT_ALERT_RECEIVE_TYPE = 'iot_alert_receive_type', // IoT 告警接收类型 IOT_OTA_TASK_DEVICE_SCOPE = 'iot_ota_task_device_scope', // IoT OTA任务设备范围 IOT_OTA_TASK_STATUS = 'iot_ota_task_status', // IoT OTA 任务状态 - IOT_OTA_TASK_RECORD_STATUS = 'iot_ota_task_record_status' // IoT OTA 记录状态 + IOT_OTA_TASK_RECORD_STATUS = 'iot_ota_task_record_status', // IoT OTA 记录状态 + IOT_MODBUS_MODE = 'iot_modbus_mode', // IoT Modbus 工作模式 + IOT_MODBUS_FRAME_FORMAT = 'iot_modbus_frame_format' // IoT Modbus 帧格式 } diff --git a/src/views/iot/device/device/detail/DeviceModbusConfig.vue b/src/views/iot/device/device/detail/DeviceModbusConfig.vue new file mode 100644 index 00000000..7e3719e3 --- /dev/null +++ b/src/views/iot/device/device/detail/DeviceModbusConfig.vue @@ -0,0 +1,292 @@ + + + + diff --git a/src/views/iot/device/device/detail/DeviceModbusConfigForm.vue b/src/views/iot/device/device/detail/DeviceModbusConfigForm.vue new file mode 100644 index 00000000..4a2493ee --- /dev/null +++ b/src/views/iot/device/device/detail/DeviceModbusConfigForm.vue @@ -0,0 +1,205 @@ + + + + diff --git a/src/views/iot/device/device/detail/DeviceModbusPointForm.vue b/src/views/iot/device/device/detail/DeviceModbusPointForm.vue new file mode 100644 index 00000000..9934cf0d --- /dev/null +++ b/src/views/iot/device/device/detail/DeviceModbusPointForm.vue @@ -0,0 +1,286 @@ + + + + diff --git a/src/views/iot/device/device/detail/index.vue b/src/views/iot/device/device/detail/index.vue index f8949ecd..8682b5aa 100644 --- a/src/views/iot/device/device/detail/index.vue +++ b/src/views/iot/device/device/detail/index.vue @@ -42,13 +42,29 @@ @success="getDeviceData" /> + + + diff --git a/src/views/iot/rule/scene/form/sections/TriggerSection.vue b/src/views/iot/rule/scene/form/sections/TriggerSection.vue index 144d53c6..e3a4ecfa 100644 --- a/src/views/iot/rule/scene/form/sections/TriggerSection.vue +++ b/src/views/iot/rule/scene/form/sections/TriggerSection.vue @@ -90,6 +90,12 @@ /> + + + @@ -115,8 +121,9 @@