edgex modbus设备部署和测试

[复制链接]
 楼主| keer_zu 发表于 2020-10-26 14:38 | 显示全部楼层 |阅读模式
 楼主| keer_zu 发表于 2020-10-26 15:18 | 显示全部楼层
本帖最后由 keer_zu 于 2020-10-26 15:19 编辑

1. 首先登录控制台edgex-ui-go页面,导入device profile文件,和mqtt导入相同。文件名为modbus.device.profile.yml。内容如下:
  1. name: "Network Power Meter"
  2. manufacturer: "Dent Instruments"
  3. model: "PS3037"
  4. description: "Power Scout Meter"
  5. labels:
  6.   - "modbus"
  7.   - "powerscout"
  8. deviceResources:
  9.   -
  10.     name: "Current"
  11.     description: "Average current of all phases"
  12.     attributes:
  13.       { primaryTable: "HOLDING_REGISTERS", startingAddress: "9" }
  14.     properties:
  15.       value:
  16.         { type: "UINT16", scale: "1"}
  17.       units:
  18.         { type: "String", readWrite: "R", defaultValue: "min"}
  19.   -
  20.     name: "Energy"
  21.     description: "System Total True Energy"
  22.     attributes:
  23.       { primaryTable: "HOLDING_REGISTERS", startingAddress: "4001" }
  24.     properties:
  25.       value:
  26.         { type: "FLOAT32", scale: "1"}
  27.       units:
  28.         { type: "String", readWrite: "R", defaultValue: "min"}
  29.   -
  30.     name: "Power"
  31.     description: "System Total True Power "
  32.     attributes:
  33.       { primaryTable: "HOLDING_REGISTERS", startingAddress: "4003" }
  34.     properties:
  35.       value:
  36.         { type: "UINT16", scale: "1"}
  37.       units:
  38.         { type: "String", readWrite: "R", defaultValue: "min"}
  39.   -
  40.     name: "Voltage"
  41.     description: "Voltage Line to line (Volts) Average"
  42.     attributes:
  43.       { primaryTable: "HOLDING_REGISTERS", startingAddress: "4017" }
  44.     properties:
  45.       value:
  46.         { type: "UINT16", scale: "1"}
  47.       units:
  48.         { type: "String", readWrite: "R", defaultValue: "min"}
  49.   -
  50.     name: "DemandWindowSize"
  51.     description: "Demand window size in minutes; default is 15 min"
  52.     attributes:
  53.       { primaryTable: "HOLDING_REGISTERS", startingAddress: "4603" }
  54.     properties:
  55.       value:
  56.         { type: "UINT16", readWrite: "R", scale: "1"}
  57.       units:
  58.         { type: "String", readWrite: "R", defaultValue: "min"}
  59.   -
  60.     name: "LineFrequency"
  61.     description: "Line frequency setting for metering: 50=50 Hz, 60=60Hz"
  62.     attributes:
  63.       { primaryTable: "HOLDING_REGISTERS", startingAddress: "4609" }
  64.     properties:
  65.       value:
  66.         { type: "UINT16", readWrite: "R", scale: "1"}
  67.       units:
  68.         { type: "String", readWrite: "R", defaultValue: "Hz"}
  69. deviceCommands:
  70.   -
  71.     name: "Current"
  72.     get:
  73.       - { index: "1", operation: "get", deviceResource: "Current" }
  74.   -
  75.     name: "Values"
  76.     get:
  77.       - { index: "1", operation: "get", deviceResource: "Energy" }
  78.       - { index: "2", operation: "get", deviceResource: "Power" }
  79.       - { index: "3", operation: "get", deviceResource: "Voltage" }
  80.   -
  81.     name: "Configuration"
  82.     set:
  83.       - { index: "1", operation: "set", deviceResource: "DemandWindowSize" }
  84.       - { index: "2", operation: "set", deviceResource: "LineFrequency" }
  85.     get:
  86.       - { index: "1", operation: "get", deviceResource: "DemandWindowSize" }
  87.       - { index: "2", operation: "get", deviceResource: "LineFrequency" }
  88. coreCommands:
  89.   -
  90.     name: "Current"
  91.     get:
  92.       path: "/api/v1/device/{deviceId}/Current"
  93.       responses:
  94.         -
  95.           code: "200"
  96.           description: "Get the Current"
  97.           expectedValues: ["Current"]
  98.         -
  99.           code: "500"
  100.           description: "internal server error"
  101.           expectedValues: []
  102.   -
  103.     name: "Values"
  104.     get:
  105.       path: "/api/v1/device/{deviceId}/Values"
  106.       responses:
  107.         -
  108.           code: "200"
  109.           description: "Get the Values"
  110.           expectedValues: ["Energy","Power","Voltage"]
  111.         -
  112.           code: "500"
  113.           description: "internal server error"
  114.           expectedValues: []
  115.   -
  116.     name: "Configuration"
  117.     get:
  118.       path: "/api/v1/device/{deviceId}/Configuration"
  119.       responses:
  120.         -
  121.           code: "200"
  122.           description: "Get the Configuration"
  123.           expectedValues: ["DemandWindowSize","LineFrequency"]
  124.         -
  125.           code: "500"
  126.           description: "internal server error"
  127.           expectedValues: []
  128.     put:
  129.       path: "/api/v1/device/{deviceId}/Configuration"
  130.       parameterNames: ["DemandWindowSize","LineFrequency"]
  131.       responses:
  132.         -
  133.           code: "204"
  134.           description: "Set the Configuration"
  135.           expectedValues: []
  136.         -
  137.           code: "500"
  138.           description: "internal server error"
  139.           expectedValues: []

对要读取的modbus地址和存储的数据类型需要在profile中进行编辑。

2 修改modbus服务端的容器编排文件docker-compose.yml,将以下代码解注释:
然后重新启动:docker-compose up -d。
  1. #  device-modbus:
  2. #    image: edgexfoundry/docker-device-modbus-go:1.2.1
  3. #    ports:
  4. #      - "127.0.0.1:49991:49991"
  5. #    container_name: edgex-device-modbus
  6. #    hostname: edgex-device-modbus
  7. #    networks:
  8. #      - edgex-network
  9. #    environment:
  10. #      <<: *common-variables
  11. #      Service_Host: edgex-device-modbus
  12. #    depends_on:
  13. #      - data
  14. #      - command






 楼主| keer_zu 发表于 2020-10-26 15:29 | 显示全部楼层
 楼主| keer_zu 发表于 2020-10-28 09:42 | 显示全部楼层
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:qq群:49734243 Email:zukeqiang@gmail.com

1477

主题

12909

帖子

55

粉丝
快速回复 在线客服 返回列表 返回顶部