产品
产品流文件
- 流文件适用厂商
广州翊创智能科技有限公司
邮箱: easyctrlyc@foxmail.com
网址: http://www.easyctrl.net
- 流文件适用厂商产品
YC-MI.08A (8路干接点模块)
- 流文件
[
{
"id": "94ed0fe9200e82e5",
"type": "tab",
"label": "飞企继电器",
"disabled": false,
"info": ""
},
{
"id": "1d68366aedba0684",
"type": "modbus-response",
"z": "94ed0fe9200e82e5",
"name": "",
"registerShowMax": 20,
"x": 710,
"y": 280,
"wires": []
},
{
"id": "30aaf55c06b10c4b",
"type": "modbus-flex-write",
"z": "94ed0fe9200e82e5",
"name": "",
"showStatusActivities": true,
"showErrors": true,
"server": "d315b614063fabaf",
"emptyMsgOnFail": true,
"keepMsgProperties": true,
"x": 490,
"y": 280,
"wires": [
[
"1d68366aedba0684"
],
[
"1d68366aedba0684",
"75f83c233767ad06"
]
]
},
{
"id": "f74b89628e8201d6",
"type": "mqtt in",
"z": "94ed0fe9200e82e5",
"name": "设备控制",
"topic": "/edgebox/edgebox02/child/FE_electric_relay_08_02/function/invoke",
"qos": "0",
"datatype": "json",
"broker": "534d0e6087f67d4e",
"nl": false,
"rap": false,
"inputs": 0,
"x": 140,
"y": 280,
"wires": [
[
"2dedf6bd54303159"
]
]
},
{
"id": "f04b5d3df62bed92",
"type": "mqtt out",
"z": "94ed0fe9200e82e5",
"name": "消息发布",
"topic": "",
"qos": "0",
"retain": "false",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "534d0e6087f67d4e",
"x": 920,
"y": 200,
"wires": []
},
{
"id": "3dec78c9fc61044f",
"type": "function",
"z": "94ed0fe9200e82e5",
"name": "上报指令组装",
"func": "var data = msg.payload.data;\nvar payload = {\n deviceId:msg.deviceId,\n properties:{\n port01: data[0],\n port02: data[1],\n port03: data[2],\n port04: data[3],\n port05: data[4],\n port06: data[5],\n port07: data[6],\n port08: data[7]\n }\n};\n\n// 全局变量设置,用于避免重复上报\nvar flow_str = JSON.stringify(payload);\nif(flow.get(msg.deviceId) == flow_str){\n return null;\n}\nflow.set(msg.deviceId,flow_str);\n// 全局变量设置,用于设备数量、在线状态监测\nglobal.set(msg.deviceId,{device_state:true});\n\nmsg.payload = payload;\nmsg.topic = \"/edgebox/\"+msg.edgeboxId+\"/child/\"+msg.deviceId+\"/properties/report\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 720,
"y": 180,
"wires": [
[
"f04b5d3df62bed92"
]
]
},
{
"id": "032d6bc6d2ba3ef6",
"type": "inject",
"z": "94ed0fe9200e82e5",
"name": "采集任务",
"props": [
{
"p": "edgeboxId",
"v": "edgebox02",
"vt": "str"
},
{
"p": "deviceId",
"v": "FE_electric_relay_08_02",
"vt": "str"
},
{
"p": "unitid",
"v": "1",
"vt": "str"
}
],
"repeat": "5",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 170,
"y": 140,
"wires": [
[
"9d6e9a2f0d1ed76c"
]
]
},
{
"id": "2dedf6bd54303159",
"type": "function",
"z": "94ed0fe9200e82e5",
"name": "控制指令组装",
"func": "function getArrayValue(array, name) {\n for(var i=0 ;i< array.length;i++){\n if(array[i].name == name)return array[i].value;\n }\n return null;\n}\nmsg.msgId = msg.payload.messageId;\nvar functionId = msg.payload.functionId;\nif(\"on_off\"==functionId && msg.payload.inputs.length>1){\n var port = getArrayValue(msg.payload.inputs,\"port\");\n var value = getArrayValue(msg.payload.inputs,\"control\");\n var address = 0;\n if(\"port01\"==port){\n address = 0;\n }else if(\"port02\"==port){\n address = 1;\n }else if(\"port03\"==port){\n address = 2;\n }else if(\"port04\"==port){\n address = 3;\n }else if(\"port05\"==port){\n address = 4;\n }else if(\"port06\"==port){\n address = 5;\n }else if(\"port07\"==port){\n address = 6;\n }else if(\"port08\"==port){\n address = 7;\n }\n \n msg.payload = {\n 'value': value,\n 'fc': 5,\n 'unitid': 1,\n 'address': address,\n 'quantity': 1\n }; \n}else if(\"on_off_all\"==functionId && msg.payload.inputs.length>0){\n msg.payload = {\n 'value': msg.payload.inputs[0].value,\n 'fc': 5,\n 'unitid': 1,\n 'address': 255,\n 'quantity': 1\n }; \n}else{\n msg = null;\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 300,
"y": 280,
"wires": [
[
"30aaf55c06b10c4b"
]
]
},
{
"id": "75f83c233767ad06",
"type": "function",
"z": "94ed0fe9200e82e5",
"name": "回复指令组装",
"func": "// 控制是否成功\nvar isSuccess = msg.error!=null?false:true;\n// 控制返回指令组装\nvar payload = {\n timestamp:Date.now(),\n messageId:msg.msgId,\n success:true,\n output:{\n code: isSuccess?200:-1,\n msg: isSuccess?\"success\":\"fail\"\n }\n};\nmsg.payload = payload;\nmsg.topic = msg.topic + \"/reply\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 700,
"y": 340,
"wires": [
[
"f04b5d3df62bed92"
]
]
},
{
"id": "b4fccfc2ad3e1e76",
"type": "function",
"z": "94ed0fe9200e82e5",
"name": "离线指令组装",
"func": "var payload = {\n deviceId:msg.deviceId\n};\n\n// 全局变量设置,用于避免重复上报\nvar flow_str = JSON.stringify(payload);\nif(flow.get(msg.deviceId) == flow_str){\n return null;\n}\nflow.set(msg.deviceId,flow_str);\n// 全局变量设置,用于设备数量、在线状态监测\nglobal.set(msg.deviceId,{device_state:false});\n\nmsg.payload = payload;\nmsg.topic = \"/edgebox/\"+msg.edgeboxId+\"/child/\"+msg.deviceId+\"/offline\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 720,
"y": 220,
"wires": [
[
"f04b5d3df62bed92"
]
]
},
{
"id": "5490d1762ba95fa7",
"type": "function",
"z": "94ed0fe9200e82e5",
"name": "终端连接状态",
"func": "// 是否连接异常\nif(msg.error!=null){\n // 离线通知\n return [null,msg];\n}\n\n// 数据上报\nreturn [msg,null];",
"outputs": 2,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 480,
"y": 200,
"wires": [
[
"3dec78c9fc61044f"
],
[
"b4fccfc2ad3e1e76"
]
]
},
{
"id": "16087948a3ce5073",
"type": "modbus-response",
"z": "94ed0fe9200e82e5",
"name": "",
"registerShowMax": 20,
"x": 730,
"y": 140,
"wires": []
},
{
"id": "6440a52c067c53a2",
"type": "modbus-flex-getter",
"z": "94ed0fe9200e82e5",
"name": "信息采集",
"showStatusActivities": true,
"showErrors": true,
"logIOActivities": false,
"server": "d315b614063fabaf",
"useIOFile": false,
"ioFile": "",
"useIOForPayload": false,
"emptyMsgOnFail": true,
"keepMsgProperties": true,
"x": 500,
"y": 140,
"wires": [
[
"16087948a3ce5073"
],
[
"16087948a3ce5073",
"5490d1762ba95fa7"
]
]
},
{
"id": "9d6e9a2f0d1ed76c",
"type": "function",
"z": "94ed0fe9200e82e5",
"name": "采集指令组装",
"func": "msg.payload = {\n 'fc': 3,\n 'unitid': msg.unitid,\n 'address': 0,\n 'quantity': 8\n};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 340,
"y": 140,
"wires": [
[
"6440a52c067c53a2"
]
]
},
{
"id": "d315b614063fabaf",
"type": "modbus-client",
"name": "网关主机ModbusTCP",
"clienttype": "tcp",
"bufferCommands": true,
"stateLogEnabled": false,
"queueLogEnabled": false,
"tcpHost": "192.168.1.230",
"tcpPort": "502",
"tcpType": "DEFAULT",
"serialPort": "/dev/ttyUSB",
"serialType": "RTU-BUFFERD",
"serialBaudrate": "9600",
"serialDatabits": "8",
"serialStopbits": "1",
"serialParity": "none",
"serialConnectionDelay": "100",
"serialAsciiResponseStartDelimiter": "0x3A",
"unit_id": 1,
"commandDelay": 1,
"clientTimeout": 1000,
"reconnectOnTimeout": true,
"reconnectTimeout": 2000,
"parallelUnitIdsAllowed": true
},
{
"id": "534d0e6087f67d4e",
"type": "mqtt-broker",
"name": "飞企IOT-MQTT",
"broker": "10.62.16.222",
"port": "31884",
"clientid": "edgebox02",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"birthTopic": "/edgebox/edgebox02/online",
"birthQos": "0",
"birthPayload": "{\"deviceId\":\"edgebox02\" }",
"birthMsg": {},
"closeTopic": "/edgebox/edgebox02/offline",
"closeQos": "0",
"closePayload": "{\"deviceId\":\"edgebox02\" }",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"sessionExpiry": ""
}
]
- 导入编排引擎
产品设备上线
文档更新时间: 2022-09-09 17:59 作者:管理员