node-red 之 邊緣計算網(wǎng)關(guān)(EG8000mini)電表

1. 電表讀取數(shù)據(jù)

電表讀取數(shù)據(jù)

導出node-red節(jié)點

[
    {
        "id": "95dc0dd050ab3901",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "baadb31eff879fb1",
        "type": "inject",
        "z": "95dc0dd050ab3901",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 120,
        "y": 120,
        "wires": [
            [
                "ea4c7e63204009d0"
            ]
        ]
    },
    {
        "id": "799a16756d7dc6d8",
        "type": "debug",
        "z": "95dc0dd050ab3901",
        "name": "debug 13",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1160,
        "y": 400,
        "wires": []
    },
    {
        "id": "52c0fe628651a67b",
        "type": "serial port",
        "z": "95dc0dd050ab3901",
        "name": "",
        "serial": "87f78da6b6ce12e3",
        "x": 580,
        "y": 400,
        "wires": [
            [
                "d734a3d4055b7ca4"
            ]
        ]
    },
    {
        "id": "ea43aaa56da4c5fd",
        "type": "debug",
        "z": "95dc0dd050ab3901",
        "name": "調(diào)試 7",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 480,
        "y": 120,
        "wires": []
    },
    {
        "id": "d734a3d4055b7ca4",
        "type": "function",
        "z": "95dc0dd050ab3901",
        "name": "解析成json",
        "func": "var target = {\n    \"id\": \"1102363\",\n    \"com\": {\n        \"port\": \"1\",\n        \"baud\": \"2400\",\n        \"parity\": \"2\"\n    },\n    \"data\": {\n        \"type\": \"1\",\n        \"sch_no\": \"\",\n        \"frame\": \"01 06 00 00 00 00 89 CA\"\n    }\n}\nlet buffer = msg.payload;\nlet frame = JSON.parse(JSON.stringify(buffer)).data.map(p => p.toString(16).padStart(2,\"0\")).join(\" \");\ntarget.data.frame = frame;\nmsg.payload = target;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 790,
        "y": 400,
        "wires": [
            [
                "b65a484ed40e9aef"
            ]
        ]
    },
    {
        "id": "b65a484ed40e9aef",
        "type": "function",
        "z": "95dc0dd050ab3901",
        "name": "序列化成Buffer",
        "func": "msg.payload = Buffer.from(JSON.stringify(msg.payload));\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 980,
        "y": 400,
        "wires": [
            [
                "799a16756d7dc6d8",
                "0b58ebdacc5d2f31"
            ]
        ]
    },
    {
        "id": "2eef359efd2e5fbb",
        "type": "tcp in",
        "z": "95dc0dd050ab3901",
        "name": "TCP服務(wù)端9529",
        "server": "server",
        "host": "",
        "port": "9529",
        "datamode": "stream",
        "datatype": "buffer",
        "newline": "",
        "topic": "",
        "trim": false,
        "base64": false,
        "tls": "",
        "x": 120,
        "y": 520,
        "wires": [
            [
                "e815fcba1ef09e26",
                "a3c883d6c689f907",
                "d233df8f941cf211"
            ]
        ]
    },
    {
        "id": "0b58ebdacc5d2f31",
        "type": "tcp out",
        "z": "95dc0dd050ab3901",
        "name": "",
        "host": "",
        "port": "",
        "beserver": "reply",
        "base64": false,
        "end": false,
        "tls": "",
        "x": 1150,
        "y": 520,
        "wires": []
    },
    {
        "id": "e815fcba1ef09e26",
        "type": "function",
        "z": "95dc0dd050ab3901",
        "name": "僅回復心跳",
        "func": "var payload = msg.payload.toString(\"utf8\");\nif (payload.startsWith('3')) {\n    msg.payload = 1;\n    return msg;\n}",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 450,
        "y": 520,
        "wires": [
            [
                "0b58ebdacc5d2f31"
            ]
        ]
    },
    {
        "id": "a3c883d6c689f907",
        "type": "function",
        "z": "95dc0dd050ab3901",
        "name": "645數(shù)據(jù)序列化命令",
        "func": "var payload = msg.payload.toString(\"utf8\");\nif(payload.startsWith('3')){\n    return;\n}\nmsg.payload = Buffer.from(JSON.parse(payload).data.frame.trim().split(\" \").map(p=>parseInt(p,16)));\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 370,
        "y": 400,
        "wires": [
            [
                "52c0fe628651a67b"
            ]
        ]
    },
    {
        "id": "ea4c7e63204009d0",
        "type": "DLT645Read",
        "z": "95dc0dd050ab3901",
        "name": "",
        "serial": "4a19a59bebbc09ae",
        "columns": [
            {
                "Key": "ZDL",
                "Label": "總電量-1102363",
                "Address": "320302164358",
                "Tdata": "00000000"
            },
            {
                "Key": "L1-ZDL",
                "Label": "上1日總電量-1102363",
                "Address": "320302164358",
                "Tdata": "00000001"
            },
            {
                "Key": "L2-ZDL",
                "Label": "上2日總電量-1102363",
                "Address": "320302164358",
                "Tdata": "00000002"
            },
            {
                "Key": "L3-ZDL",
                "Label": "上3日總電流-1102363",
                "Address": "320302164358",
                "Tdata": "00000003"
            },
            {
                "Key": "A-V",
                "Label": "A相電壓-1102363",
                "Address": "320302164358",
                "Tdata": "02010100"
            },
            {
                "Key": "A-I",
                "Label": "A相電流-1102363",
                "Address": "320302164358",
                "Tdata": "02020100"
            },
            {
                "Key": "YGGL",
                "Label": "有功功率-1102363",
                "Address": "320302164358",
                "Tdata": "02030000"
            },
            {
                "Key": "GLYS",
                "Label": "功率因數(shù)-1102363",
                "Address": "320302164358",
                "Tdata": "02060000"
            }
        ],
        "x": 300,
        "y": 120,
        "wires": [
            [
                "ea43aaa56da4c5fd"
            ]
        ]
    },
    {
        "id": "d233df8f941cf211",
        "type": "debug",
        "z": "95dc0dd050ab3901",
        "name": "TCP接收到的原始消息",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 360,
        "y": 620,
        "wires": []
    },
    {
        "id": "87f78da6b6ce12e3",
        "type": "serial config",
        "name": "串口收發(fā)",
        "serialport": "/dev/ttyS3",
        "baudrate": "9600",
        "databits": "8",
        "stopbits": "1",
        "parity": "none",
        "timeout": "50",
        "reqtimeout": "1000"
    },
    {
        "id": "4a19a59bebbc09ae",
        "type": "serial config",
        "name": "溫控儀",
        "serialport": "/dev/ttyS2",
        "baudrate": "9600",
        "databits": "8",
        "stopbits": "1",
        "parity": "none",
        "timeout": "50",
        "reqtimeout": "5000"
    }
]
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容