产品
产品流文件
- 流文件适用厂商
广州翊创智能科技有限公司
邮箱: easyctrlyc@foxmail.com
网址: http://www.easyctrl.net
- 流文件适用厂商产品
面板开关(8路)
- 流文件
[
{
"id": "7971b53809e291bf",
"type": "tab",
"label": "飞企控制面板",
"disabled": false,
"info": ""
},
{
"id": "f4a5a8123193969a",
"type": "modbus-response",
"z": "7971b53809e291bf",
"name": "",
"registerShowMax": 20,
"x": 690,
"y": 220,
"wires": []
},
{
"id": "de5ee744e84c41a9",
"type": "modbus-flex-write",
"z": "7971b53809e291bf",
"name": "",
"showStatusActivities": true,
"showErrors": true,
"server": "d315b614063fabaf",
"emptyMsgOnFail": true,
"keepMsgProperties": true,
"x": 490,
"y": 220,
"wires": [
[
"f4a5a8123193969a"
],
[
"f4a5a8123193969a",
"8a7836f0e9412b5b"
]
]
},
{
"id": "188cdda7bade929f",
"type": "mqtt in",
"z": "7971b53809e291bf",
"name": "设备控制",
"topic": "/edgebox/edgebox02/child/FE_switch_08_02/function/invoke",
"qos": "0",
"datatype": "json",
"broker": "534d0e6087f67d4e",
"nl": false,
"rap": false,
"inputs": 0,
"x": 160,
"y": 220,
"wires": [
[
"67e5e5027a836fb1"
]
]
},
{
"id": "67e5e5027a836fb1",
"type": "function",
"z": "7971b53809e291bf",
"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": 220,
"wires": [
[
"de5ee744e84c41a9"
]
]
},
{
"id": "8a7836f0e9412b5b",
"type": "function",
"z": "7971b53809e291bf",
"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": 680,
"y": 260,
"wires": [
[
"7f016a0b465581ba"
]
]
},
{
"id": "7f016a0b465581ba",
"type": "mqtt out",
"z": "7971b53809e291bf",
"name": "消息发布",
"topic": "",
"qos": "0",
"retain": "false",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "534d0e6087f67d4e",
"x": 960,
"y": 160,
"wires": []
},
{
"id": "37e65569467385ab",
"type": "function",
"z": "7971b53809e291bf",
"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+\"/online\";\n// \"/edgebox/\"+msg.edgeboxId+\"/child/\"+msg.deviceId+\"/properties/report\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 740,
"y": 140,
"wires": [
[
"7f016a0b465581ba"
]
]
},
{
"id": "2a5a7fb184515473",
"type": "inject",
"z": "7971b53809e291bf",
"name": "采集任务",
"props": [
{
"p": "payload"
},
{
"p": "edgeboxId",
"v": "edgebox02",
"vt": "str"
},
{
"p": "deviceId",
"v": "FE_switch_08_02",
"vt": "str"
},
{
"p": "unitid",
"v": "7",
"vt": "str"
}
],
"repeat": "5",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payloadType": "date",
"x": 190,
"y": 100,
"wires": [
[
"c9626b7a33e56079"
]
]
},
{
"id": "dd70ec6046d15e05",
"type": "function",
"z": "7971b53809e291bf",
"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": 740,
"y": 180,
"wires": [
[
"7f016a0b465581ba"
]
]
},
{
"id": "2dec11fa9e6fb71a",
"type": "function",
"z": "7971b53809e291bf",
"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": 540,
"y": 160,
"wires": [
[
"37e65569467385ab"
],
[
"dd70ec6046d15e05"
]
]
},
{
"id": "f1cce61d0afb12ab",
"type": "modbus-response",
"z": "7971b53809e291bf",
"name": "",
"registerShowMax": 20,
"x": 750,
"y": 100,
"wires": []
},
{
"id": "2591ac48415d842c",
"type": "modbus-flex-getter",
"z": "7971b53809e291bf",
"name": "信息采集",
"showStatusActivities": true,
"showErrors": true,
"logIOActivities": false,
"server": "d315b614063fabaf",
"useIOFile": false,
"ioFile": "",
"useIOForPayload": false,
"emptyMsgOnFail": true,
"keepMsgProperties": true,
"x": 520,
"y": 100,
"wires": [
[
"f1cce61d0afb12ab"
],
[
"f1cce61d0afb12ab",
"2dec11fa9e6fb71a"
]
]
},
{
"id": "c9626b7a33e56079",
"type": "function",
"z": "7971b53809e291bf",
"name": "采集指令组装",
"func": "msg.payload = {\n 'fc': 1,\n 'unitid': msg.unitid,\n 'address': 0,\n 'quantity': 8\n};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 360,
"y": 100,
"wires": [
[
"2591ac48415d842c"
]
]
},
{
"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 18:00 作者:管理员