关于前端:DGIOT玩转Modbus实战教程05功能码控制下发

32次阅读

共计 1798 个字符,预计需要花费 5 分钟才能阅读完成。

[小 迪 导读]
本教程在把握根底 modbusRTU 标准协议 概念和业务流程之后,通过实在的反对 ModbusRTU 标准协议的设施和 DTU 来进行实战演练。

零碎须要应用一个测试软件:

  • 网络调试助手

零碎架构逻辑图如下,包含设施模仿,通道通信,模型设置,利用显示局部

操作步骤:

1. 创立产品

产品信息

产品增加通道后需对通道进行重启

2. 创立物模型

物模型代码

{
    "properties": [
        {
            "accessMode": "rw",
            "dataForm": {
                "address": "0X10",
                "afn": "","byteType":"",
                "bytelen": "","collection":"%s","control":"%d","countcollection":"%s","countround":"all","countstrategy": 20,"da":"",
                "data": "null",
                "dt": "","iscount":"0","offset": 0,"operatetype":"readCoils","order": 0,"originaltype":"short16_AB","protocol":"MODBUSRTU","rate": 1,"round":"all","slaveid":"0X10","strategy":" 被动上报 "},"dataSource": {"": [],
                "_dlinkindex": 1,
                "address": "0X00",
                "operatetype": "writeCoil",
                "originaltype": "bit",
                "registersnumber": "1",
                "slaveid": "0X01"
            },
            "dataType": {"das": [],
                "specs": {
                    "1": "开",
                    "10": "关"
                },
                "type": "enum"
            },
            "devicetype": "开关控制器",
            "identifier": "switch",
            "isaccumulate": false,
            "isshow": false,
            "isstorage": false,
            "moduleType": "properties",
            "name": "开关",
            "required": true,
            "updateAt": "1664250089119",
            "index": 0
        }
    ]
}

3. 增加低代码

低代码模板:

{
  "type": "form",
  "body": [
    {
      "id": "u:52fbc3355570",
      "mode": "inline",
      "name": "switch",
      "type": "switch",
      "label": "开关机",
      "onText": "开",
      "option": "","offText":" 关 ","trueValue": 1,"falseValue": 10,"validateApi": {"url":"iotapi/classes/Device/parse_objectid","method":"put","headers": {"store":"localStorage","dgiotReplace":"parse_objectid"},"requestAdaptor":"return {\r\n  ...api,\r\n  data:{\r\n    profile:{\r\n      switch:api.data.switch    \r\n}\r\n  }\r\n}"},"optionAtLeft": false,"submitOnChange": true
    }
  ],
  "title": "开关机控制器",
  "trueValue": true,
  "falseValue": false,
  "submitText": "","optionAtLeft": false
}

4. 依据通道的登录报文帧头个数自定义设施名

关上网络调试助手
依据登录报文帧头个数填写 15 位(通道登录报文帧头测试可自定义,理论状况参考物理设施的登录报文编码个数),点击发送

5. 查看登录的设施

点击管制

找到之前产品内创立的低代码表单

选择开关,能够在网络调试助手上看到平台发送的报文,此报文也会是 modbus 设施收到的报文,理论状况参考物理设施应用阐明

[小 迪 点评]

  • dgiot 反对 ModbusRTU 协定的设施接入,有实在设施的用户尝试进行设施接入演练,同时提供 05 性能码反对对设施管制。

想理解更多 dgiot 的具体细节,欢送大家在 GitHub 上查看相干源代码。

正文完
 0