edgex modbus设备部署和测试
edgex modbus设备部署和测试中文
本帖最后由 keer_zu 于 2020-10-26 15:19 编辑
1. 首先登录控制台edgex-ui-go页面,导入device profile文件,和mqtt导入相同。文件名为modbus.device.profile.yml。内容如下:
name: "Network Power Meter"
manufacturer: "Dent Instruments"
model: "PS3037"
description: "Power Scout Meter"
labels:
- "modbus"
- "powerscout"
deviceResources:
-
name: "Current"
description: "Average current of all phases"
attributes:
{ primaryTable: "HOLDING_REGISTERS", startingAddress: "9" }
properties:
value:
{ type: "UINT16", scale: "1"}
units:
{ type: "String", readWrite: "R", defaultValue: "min"}
-
name: "Energy"
description: "System Total True Energy"
attributes:
{ primaryTable: "HOLDING_REGISTERS", startingAddress: "4001" }
properties:
value:
{ type: "FLOAT32", scale: "1"}
units:
{ type: "String", readWrite: "R", defaultValue: "min"}
-
name: "Power"
description: "System Total True Power "
attributes:
{ primaryTable: "HOLDING_REGISTERS", startingAddress: "4003" }
properties:
value:
{ type: "UINT16", scale: "1"}
units:
{ type: "String", readWrite: "R", defaultValue: "min"}
-
name: "Voltage"
description: "Voltage Line to line (Volts) Average"
attributes:
{ primaryTable: "HOLDING_REGISTERS", startingAddress: "4017" }
properties:
value:
{ type: "UINT16", scale: "1"}
units:
{ type: "String", readWrite: "R", defaultValue: "min"}
-
name: "DemandWindowSize"
description: "Demand window size in minutes; default is 15 min"
attributes:
{ primaryTable: "HOLDING_REGISTERS", startingAddress: "4603" }
properties:
value:
{ type: "UINT16", readWrite: "R", scale: "1"}
units:
{ type: "String", readWrite: "R", defaultValue: "min"}
-
name: "LineFrequency"
description: "Line frequency setting for metering: 50=50 Hz, 60=60Hz"
attributes:
{ primaryTable: "HOLDING_REGISTERS", startingAddress: "4609" }
properties:
value:
{ type: "UINT16", readWrite: "R", scale: "1"}
units:
{ type: "String", readWrite: "R", defaultValue: "Hz"}
deviceCommands:
-
name: "Current"
get:
- { index: "1", operation: "get", deviceResource: "Current" }
-
name: "Values"
get:
- { index: "1", operation: "get", deviceResource: "Energy" }
- { index: "2", operation: "get", deviceResource: "Power" }
- { index: "3", operation: "get", deviceResource: "Voltage" }
-
name: "Configuration"
set:
- { index: "1", operation: "set", deviceResource: "DemandWindowSize" }
- { index: "2", operation: "set", deviceResource: "LineFrequency" }
get:
- { index: "1", operation: "get", deviceResource: "DemandWindowSize" }
- { index: "2", operation: "get", deviceResource: "LineFrequency" }
coreCommands:
-
name: "Current"
get:
path: "/api/v1/device/{deviceId}/Current"
responses:
-
code: "200"
description: "Get the Current"
expectedValues: ["Current"]
-
code: "500"
description: "internal server error"
expectedValues: []
-
name: "Values"
get:
path: "/api/v1/device/{deviceId}/Values"
responses:
-
code: "200"
description: "Get the Values"
expectedValues: ["Energy","Power","Voltage"]
-
code: "500"
description: "internal server error"
expectedValues: []
-
name: "Configuration"
get:
path: "/api/v1/device/{deviceId}/Configuration"
responses:
-
code: "200"
description: "Get the Configuration"
expectedValues: ["DemandWindowSize","LineFrequency"]
-
code: "500"
description: "internal server error"
expectedValues: []
put:
path: "/api/v1/device/{deviceId}/Configuration"
parameterNames: ["DemandWindowSize","LineFrequency"]
responses:
-
code: "204"
description: "Set the Configuration"
expectedValues: []
-
code: "500"
description: "internal server error"
expectedValues: []
对要读取的modbus地址和存储的数据类型需要在profile中进行编辑。
2 修改modbus服务端的容器编排文件docker-compose.yml,将以下代码解注释:
然后重新启动:docker-compose up -d。
#device-modbus:
# image: edgexfoundry/docker-device-modbus-go:1.2.1
# ports:
# - "127.0.0.1:49991:49991"
# container_name: edgex-device-modbus
# hostname: edgex-device-modbus
# networks:
# - edgex-network
# environment:
# <<: *common-variables
# Service_Host: edgex-device-modbus
# depends_on:
# - data
# - command
一个视频:
https://haokan.baidu.com/v?pd=wisenatural&vid=12744066132837123040 https://www.hangge.com/blog/cache/detail_2341.html
页:
[1]