[小 迪 导读]:
本教程在掌握基础modbusRTU标准协议概念和业务流程之后,可以通过真实的ModbusRTU标准协议的设备和DTU来进行实战演练。
场景解析:在使用Modbus对设备进行采集时,我们会通过读取多个连续寄存器的数据块来保持多个数据的时间一致性,本文就来详细解读dgiot中的数据块配置
和读单个寄存器的区别在于要多配一个数据块的物模型,这个数据块的作用在于一次性把多个连续的寄存器数据读取上来,再通过解析这个数据块,把数据分配下去,所以下图中只有数据块是要采集的,温度湿度是通过计算得来的
数据块配置只读,不存储,不展示
数据类型建议配置text,长度9999,不过不存储情况下,此配置无关紧要
采集策略选择不采集(计算值),因为采集策略是计算值,采集公式里的变量要填自己的标识符
其他的同以往一样
物模型代码
{ "properties": [ { "accessMode": "r", "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": "20" }, "dataSource": { "": [], "_dlinkindex": "", "address": "0X0200", "operatetype": "readHregs", "originaltype": "bit", "registersnumber": "2", "slaveid": "0X01" }, "dataType": { "das": [], "size": 9999, "specs": {}, "type": "text" }, "devicetype": "数据块", "identifier": "block_data", "index": 0, "isaccumulate": false, "isshow": false, "isstorage": false, "moduleType": "properties", "name": "温湿度数据块", "required": true, "updateAt": "1695189804403" }, { "accessMode": "r", "dataForm": { "address": "0X10", "afn": "", "byteType": "", "bytelen": "", "collection": "%%{humd}/10", "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": "", "address": "1", "operatetype": "readHregs", "originaltype": "ushort16_AB", "registersnumber": "1", "slaveid": "block_data" }, "dataType": { "das": [], "specs": { "max": 100, "min": 0, "precision": 3, "step": 0, "unit": "%" }, "type": "float" }, "devicetype": "温湿度", "identifier": "humd", "isaccumulate": false, "isshow": true, "isstorage": true, "moduleType": "properties", "name": "湿度", "required": true, "updateAt": "1695196699923", "index": 1 }, { "accessMode": "r", "dataForm": { "address": "0X10", "afn": "", "byteType": "", "bytelen": "", "collection": "%%{wendu}/10", "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": "", "address": "0", "operatetype": "readHregs", "originaltype": "short16_AB", "registersnumber": "1", "slaveid": "block_data" }, "dataType": { "das": [], "specs": { "max": 100, "min": 0, "precision": 3, "step": 0, "unit": "℃" }, "type": "float" }, "devicetype": "温湿度", "identifier": "wendu", "isaccumulate": false, "isshow": true, "isstorage": true, "moduleType": "properties", "name": "温度", "required": true, "updateAt": "1695196712029", "index": 2 } ]}{
"properties": [
{
"accessMode": "r",
"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": "20"
},
"dataSource": {
"": [],
"_dlinkindex": "",
"address": "0X0200",
"operatetype": "readHregs",
"originaltype": "bit",
"registersnumber": "2",
"slaveid": "0X01"
},
"dataType": {
"das": [],
"size": 9999,
"specs": {},
"type": "text"
},
"devicetype": "数据块",
"identifier": "block_data",
"index": 0,
"isaccumulate": false,
"isshow": false,
"isstorage": false,
"moduleType": "properties",
"name": "温湿度数据块",
"required": true,
"updateAt": "1695189804403"
},
{
"accessMode": "r",
"dataForm": {
"address": "0X10",
"afn": "",
"byteType": "",
"bytelen": "",
"collection": "%%{humd}/10",
"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": "",
"address": "1",
"operatetype": "readHregs",
"originaltype": "ushort16_AB",
"registersnumber": "1",
"slaveid": "block_data"
},
"dataType": {
"das": [],
"specs": {
"max": 100,
"min": 0,
"precision": 3,
"step": 0,
"unit": "%"
},
"type": "float"
},
"devicetype": "温湿度",
"identifier": "humd",
"isaccumulate": false,
"isshow": true,
"isstorage": true,
"moduleType": "properties",
"name": "湿度",
"required": true,
"updateAt": "1695196699923",
"index": 1
},
{
"accessMode": "r",
"dataForm": {
"address": "0X10",
"afn": "",
"byteType": "",
"bytelen": "",
"collection": "%%{wendu}/10",
"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": "",
"address": "0",
"operatetype": "readHregs",
"originaltype": "short16_AB",
"registersnumber": "1",
"slaveid": "block_data"
},
"dataType": {
"das": [],
"specs": {
"max": 100,
"min": 0,
"precision": 3,
"step": 0,
"unit": "℃"
},
"type": "float"
},
"devicetype": "温湿度",
"identifier": "wendu",
"isaccumulate": false,
"isshow": true,
"isstorage": true,
"moduleType": "properties",
"name": "温度",
"required": true,
"updateAt": "1695196712029",
"index": 2
}
]
}
[小 迪 点 评]