EdgeX 1.2研究-2 读取Modbus协议设备

摘要:
1.使用基于以下链接的示例:https://docs.edgexfoundry.org/1.2/examples/Ch-ExamplesAddingModbusDevice/此示例运行不顺畅。这里的主要解释是配置文件与下载的版本不对应。经过两天的探索,它以以下方式实施。2.使用以下复合文件安装#/******************************************

1、使用的基于下面这个链接的示例:

https://docs.edgexfoundry.org/1.2/examples/Ch-ExamplesAddingModbusDevice/

这个示例没有跑通,主要卡在这里的讲解配置文件和下载的版本对应不上,经过两天的摸索,使用如下方式实现

2、使用下面compose文件安装

EdgeX 1.2研究-2 读取Modbus协议设备第1张EdgeX 1.2研究-2 读取Modbus协议设备第2张
# /*******************************************************************************
#  * Copyright 2020 Redis Labs Inc.
#  * Copyright 2020 Intel Corporation.
#  *
#  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
#  * in compliance with the License. You may obtain a copy of the License at
#  *
#  * http://www.apache.org/licenses/LICENSE-2.0
#  *
#  * Unless required by applicable law or agreed to in writing, software distributed under the License
#  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
#  * or implied. See the License for the specific language governing permissions and limitations under
#  * the License.
#  *
#  * @author: Jim White, Dell
#  * @author: Andre Srinivasan, Redis Labs
#  * @author: Leonard Goodell, Intel
#  * EdgeX Foundry, Geneva, version 1.2.0
#  * added: May 14, 2020
#  *******************************************************************************/

# NOTE:  this Docker Compose file does not contain the security services - namely the API Gateway
# and Secret Store

version: '3.4'

# all common shared environment variables defined here:
x-common-env-variables: &common-variables
  EDGEX_SECURITY_SECRET_STORE: "false"
  Registry_Host: edgex-core-consul
  Clients_CoreData_Host: edgex-core-data
  Clients_Data_Host: edgex-core-data # For device Services
  Clients_Notifications_Host: edgex-support-notifications
  Clients_Metadata_Host: edgex-core-metadata
  Clients_Command_Host: edgex-core-command
  Clients_Scheduler_Host: edgex-support-scheduler
  Clients_RulesEngine_Host: edgex-kuiper
  Clients_VirtualDevice_Host: edgex-device-virtual
  Databases_Primary_Host: edgex-redis
  # Required in case old configuration from previous release used.
  # Change to "true" if re-enabling logging service for remote logging
  Logging_EnableRemote: "false"
  #  Clients_Logging_Host: edgex-support-logging # un-comment if re-enabling logging service for remote logging

volumes:
  db-data:
  log-data:
  consul-config:
  consul-data:

services:
  consul:
    image: edgexfoundry/docker-edgex-consul:1.2.0
    ports:
      - "0.0.0.0:8400:8400"
      - "0.0.0.0:8500:8500"
    container_name: edgex-core-consul
    hostname: edgex-core-consul
    networks:
      - edgex-network
    volumes:
      - consul-config:/consul/config:z
      - consul-data:/consul/data:z
    environment: 
      - EDGEX_DB=redis
      - EDGEX_SECURE=false

  redis:
    image: redis:5.0.8-alpine
    ports:
      - "0.0.0.0:6379:6379"
    container_name: edgex-redis
    hostname: edgex-redis
    networks:
      - edgex-network
    environment:
      <<: *common-variables
    volumes:
      - db-data:/data:z

# The logging service has been deprecated in Geneva release and will be removed in the Hanoi release.
# All services are configure to send logging to STDOUT, i.e. not remote which requires this logging service
# If you still must use remote logging, un-comment the block below, all the related depends that have been commented out
# and the related global override that are commented out at the top.
#
#  logging:
#    image: edgexfoundry/docker-support-logging-go:1.2.1
#    ports:
#      - "0.0.0.0:48061:48061"
#    container_name: edgex-support-logging
#    hostname: edgex-support-logging
#    networks:
#      - edgex-network
#    environment:
#      <<: *common-variables
#      Service_Host: edgex-support-logging
#      Writable_Persistence: file
#      Databases_Primary_Type: file
#      Logging_EnableRemote: "false"
#    depends_on:
#      - consul

  system:
    image: edgexfoundry/docker-sys-mgmt-agent-go:1.2.1
    ports:
      - "0.0.0.0:48090:48090"
    container_name: edgex-sys-mgmt-agent
    hostname: edgex-sys-mgmt-agent
    networks:
      - edgex-network
    environment:
      <<: *common-variables
      Service_Host: edgex-sys-mgmt-agent
      ExecutorPath: /sys-mgmt-executor
      MetricsMechanism: executor
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:z
    depends_on:
      - consul
#      - logging  # uncomment if re-enabled remote logging
      - scheduler
      - notifications
      - metadata
      - data
      - command

  notifications:
    image: edgexfoundry/docker-support-notifications-go:1.2.1
    ports:
      - "0.0.0.0:48060:48060"
    container_name: edgex-support-notifications
    hostname: edgex-support-notifications
    networks:
      - edgex-network
    environment:
      <<: *common-variables
      Service_Host: edgex-support-notifications
    depends_on:
      - consul
#      - logging  # uncomment if re-enabled remote logging
      - redis

  metadata:
    image: edgexfoundry/docker-core-metadata-go:1.2.1
    ports:
      - "0.0.0.0:48081:48081"
    container_name: edgex-core-metadata
    hostname: edgex-core-metadata
    networks:
      - edgex-network
    environment:
      <<: *common-variables
      Service_Host: edgex-core-metadata
      Service_Timeout: "20000"
      Notifications_Sender: edgex-core-metadata
    depends_on:
      - consul
#      - logging  # uncomment if re-enabled remote logging
      - redis
      - notifications

  data:
    image: edgexfoundry/docker-core-data-go:1.2.1
    ports:
      - "0.0.0.0:48080:48080"
      - "0.0.0.0:5563:5563"
    container_name: edgex-core-data
    hostname: edgex-core-data
    networks:
      - edgex-network
    environment:
      <<: *common-variables
      Service_Host: edgex-core-data
    depends_on:
      - consul
#      - logging  # uncomment if re-enabled remote logging
      - redis
      - metadata

  command:
    image: edgexfoundry/docker-core-command-go:1.2.1
    ports:
      - "0.0.0.0:48082:48082"
    container_name: edgex-core-command
    hostname: edgex-core-command
    networks:
      - edgex-network
    environment:
      <<: *common-variables
      Service_Host: edgex-core-command
    depends_on:
      - consul
#      - logging  # uncomment if re-enabled remote logging
      - redis
      - metadata

  scheduler:
    image: edgexfoundry/docker-support-scheduler-go:1.2.1
    ports:
      - "0.0.0.0:48085:48085"
    container_name: edgex-support-scheduler
    hostname: edgex-support-scheduler
    networks:
      - edgex-network
    environment:
      <<: *common-variables
      Service_Host: edgex-support-scheduler
      IntervalActions_ScrubPushed_Host: edgex-core-data
      IntervalActions_ScrubAged_Host: edgex-core-data
    depends_on:
      - consul
#      - logging  # uncomment if re-enabled remote logging
      - redis

  app-service-rules:
    image: edgexfoundry/docker-app-service-configurable:1.2.0
    ports:
      - "0.0.0.0:48100:48100"
    container_name: edgex-app-service-configurable-rules
    hostname: edgex-app-service-configurable-rules
    networks:
      - edgex-network
    environment:
      <<: *common-variables
      edgex_profile: rules-engine
      Service_Host: edgex-app-service-configurable-rules
      Service_Port: 48100
      MessageBus_SubscribeHost_Host: edgex-core-data
      Binding_PublishTopic: events
    depends_on:
      - consul
#      - logging  # uncomment if re-enabled remote logging
      - data

  rulesengine:
    image: emqx/kuiper:0.4.2-alpine
    ports:
      - "0.0.0.0:48075:48075"
      - "0.0.0.0:20498:20498"
    container_name: edgex-kuiper
    hostname: edgex-kuiper
    networks:
      - edgex-network
    environment:
      # KUIPER_DEBUG: "true"
      KUIPER_CONSOLE_LOG: "true"
      KUIPER_REST_PORT: 48075
      EDGEX_SERVER: edgex-app-service-configurable-rules
      EDGEX_SERVICE_SERVER: http://edgex-core-data:48080
      EDGEX_TOPIC: events
      EDGEX_PROTOCOL: tcp
      EDGEX_PORT: 5566
    depends_on:
      - app-service-rules

  # Support RulesEngine has been deprecated in the Geneva (1.2.0) release
  # If still required, simply uncomment the block below and comment out the block above.
  #
  # rulesengine:
  #   image: edgexfoundry/docker-support-rulesengine:1.2.1
  #   ports:
  #     - "0.0.0.0:48075:48075"
  #   container_name: edgex-support-rulesengine
  #   hostname: edgex-support-rulesengine
  #   networks:
  #     - edgex-network
  #   depends_on:
  #     - app-service-rules

#################################################################
# Device Services
#################################################################

  device-virtual:
    image: edgexfoundry/docker-device-virtual-go:1.2.2
    ports:
    - "0.0.0.0:49990:49990"
    container_name: edgex-device-virtual
    hostname: edgex-device-virtual
    networks:
      - edgex-network
    environment:
      <<: *common-variables
      Service_Host: edgex-device-virtual
    depends_on:
      - consul
#      - logging  # uncomment if re-enabled remote logging
      - data
      - metadata

  device-rest:
    image: edgexfoundry/docker-device-rest-go:1.1.1
    ports:
      - "0.0.0.0:49986:49986"
    container_name: edgex-device-rest
    hostname: edgex-device-rest
    networks:
      - edgex-network
    environment:
      <<: *common-variables
      Service_Host: edgex-device-rest
    depends_on:
      - data
      - command
  #      - logging  # uncomment if re-enabled remote logging

  device-random:
    image: edgexfoundry/docker-device-random-go:1.2.1
    ports:
      - "0.0.0.0:49988:49988"
    container_name: edgex-device-random
    hostname: edgex-device-random
    networks:
      - edgex-network
    environment:
      <<: *common-variables
      Service_Host: edgex-device-random
    depends_on:
      - data
      - command

#  device-mqtt:
#    image: edgexfoundry/docker-device-mqtt-go:1.2.1
#    ports:
#      - "0.0.0.0:49982:49982"
#    container_name: edgex-device-mqtt
#    hostname: edgex-device-mqtt
#    networks:
#      - edgex-network
#    environment:
#      <<: *common-variables
#      Service_Host: edgex-device-mqtt
#    depends_on:
#      - data
#      - command
#
  device-modbus:
     image: edgexfoundry/docker-device-modbus-go:1.2.1
     ports:
       - "0.0.0.0: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
 
#  device-snmp:
#    image: edgexfoundry/docker-device-snmp-go:1.2.1
#    ports:
#      - "0.0.0.0:49993:49993"
#    container_name: edgex-device-snmp
#    hostname: edgex-device-snmp
#    networks:
#      - edgex-network
#    environment:
#      <<: *common-variables
#      Service_Host: edgex-device-snmp
#    depends_on:
#      - data
#      - command
  ui:
    image: edgexfoundry/docker-edgex-ui-go:1.3.0
    ports:
      - "4000:4000"
    container_name: edgex-ui-go
    hostname: edgex-ui-go
    networks:
      - edgex-network
    volumes:
      - db-data:/data/db
      - log-data:/edgex/logs
      - consul-config:/consul/config
      - consul-data:/consul/data
    depends_on:
      - data
      - command
networks:
  edgex-network:
    driver: "bridge"
View Code

3、打开4000端口go-ui,界面如下、

EdgeX 1.2研究-2 读取Modbus协议设备第3张

 如果DeviceService列表为空说明安装有问题,请从新安装。

EdgeX 1.2研究-2 读取Modbus协议设备第4张

 上传配置文件

EdgeX 1.2研究-2 读取Modbus协议设备第5张EdgeX 1.2研究-2 读取Modbus协议设备第6张
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: []
View Code

EdgeX 1.2研究-2 读取Modbus协议设备第7张

 4、添加设备

EdgeX 1.2研究-2 读取Modbus协议设备第8张

 EdgeX 1.2研究-2 读取Modbus协议设备第9张

 5、如果无法读取数据,重启下下docker即可。

免责声明:文章转载自《EdgeX 1.2研究-2 读取Modbus协议设备》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇WPF下的右键菜单隐藏Django(一):从socket到MVC下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Redis配置不当致使root被提权漏洞

Redis配置不当致使root被提权漏洞 Dear all~ 最近Redis服务被曝出因配置不当,可能造成数据库被恶意清空,或被黑客利用写入后门文件造成进一步入侵,请关注! 一、漏洞发布日期 2015年11月10日 二、已确认被成功利用的软件及系统 对公网开放,且未启用认证的redis服务器。 三、漏洞描述 最近Redis服务被曝出因配置不当,被攻击者进行...

生产环境项目问题记录系列(二):Docker打包镜像Nuget包因权限问题还原失败

docker打包镜像遇到一个因为nuget权限验证问题导致镜像打包失败的问题,公司Nuget包用的是tfs管理的,tfs有权限验证,结果导致nuget还原失败,原有的NuGet.config文件如下: <?xml version="1.0" encoding="utf-8"?> <configuration> <sol...

k8s命令

编辑pod版本号等信息kubectl edit deployment ams-metric -n manage导出容器内容到文件docker export 1ceefea8d9ff > calc.tar加载tar到本地仓库docker load -i ams-access-1.0.PC5.tar 快速从容器push到镜像仓库docker commit...

ubuntu安装redis

1、下载安装 root@21ebdf03a086:/# apt-cache search redisroot@21ebdf03a086:/# apt-get install redis-server a、redis配置文件:/etc/redis/redis.confb、redis服务路径:/etc/init.d/redis-server 2、启动redis...

将redis作为windows系统的系统服务

在windows系统,每次打开redis服务都是一个dos窗口一直开着,很不爽,这里我用winsw工具把redis作为系统服务启动 我把自动启动的所有内容都整理好了,请自行下载 下载地址:http://files.cnblogs.com/files/modou/redis%E5%81%9A%E4%B8%BAwindows%E6%9C%8D%E5%8A%A1...

【Redis】Redis5.0的一些新特性

redis5.0总共增加了12项新特性,如下:    1.新增加的Stream(流)数据类型,这样redis就有了6大数据类型,另外五种是String(字符串),Hash(哈希),List(列表),Set(集合)及Zset(sorted set有序集合)。它弥补了其它5种数据类型不能实现的功能,比如List数据类型只能先进先出,或者后进先出,不能从中间去数...