Difference between revisions of "NodeRed test code"
From ESS-WIKI
(Created page with "==Node-Red test code== <pre> [ { "id": "7c02f296.10d7bc", "type": "debug", "z": "12a0fcbd.7a1fab", "name": "", "active": true, "console": "false", "complete": "...") |
(→Node-Red test code) |
||
| Line 1: | Line 1: | ||
| − | == | + | ==Source code== |
<pre> | <pre> | ||
[ | [ | ||
Latest revision as of 10:12, 6 September 2016
Source code
[
{
"id": "7c02f296.10d7bc",
"type": "debug",
"z": "12a0fcbd.7a1fab",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 601.75,
"y": 268.75,
"wires": []
},
{
"id": "2f99eaee.6e0396",
"type": "file in",
"z": "12a0fcbd.7a1fab",
"name": "",
"filename": "/home/ivan/.node-red/nodes/FILE.INI",
"format": "utf8",
"x": 358.75,
"y": 372.75,
"wires": [
[
"7c02f296.10d7bc",
"5563ecf3.99b86c"
]
]
},
{
"id": "5563ecf3.99b86c",
"type": "my-PLA",
"z": "12a0fcbd.7a1fab",
"name": "",
"x": 371.75,
"y": 175.75,
"wires": [
[
"c3cfd28e.8b3ae8"
]
]
},
{
"id": "c3cfd28e.8b3ae8",
"type": "debug",
"z": "12a0fcbd.7a1fab",
"name": "Display status",
"active": true,
"console": "false",
"complete": "payload",
"x": 582.75,
"y": 92.75,
"wires": []
},
{
"id": "87bbfd3b.1edae8",
"type": "function",
"z": "12a0fcbd.7a1fab",
"name": "simulate device data",
"func": "\nif (msg.payload == \"input_data\"){\n // context.global.input_T=0;\n // context.global.input_H=0;\n \n if (typeof context.global.input_T == 'undefined'){\n context.global.input_T = 0;\n }\n \n if (typeof context.global.input_H == 'undefined'){\n context.global.input_H = 0;\n }\n \n //input_T\n if (context.global.input_T > 100){\n context.global.input_T = 0\n }\n else{\n context.global.input_T += 5;\n }\n //input_H \n if (context.global.input_H > 100){\n context.global.input_H = 0\n }\n else{\n context.global.input_H += 10;\n }\n \n msg.payload=context.global.input_T + \",\" + context.global.input_H\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 160.75,
"y": 176.75,
"wires": [
[
"5563ecf3.99b86c"
]
]
},
{
"id": "42d5b823.38b878",
"type": "inject",
"z": "12a0fcbd.7a1fab",
"name": "timer to trigger",
"topic": "",
"payload": "input_data",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"x": 146.75,
"y": 85.75,
"wires": [
[
"87bbfd3b.1edae8"
]
]
},
{
"id": "ef8ed13d.bbbdc",
"type": "inject",
"z": "12a0fcbd.7a1fab",
"name": "set ML param",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"x": 119.75,
"y": 372.75,
"wires": [
[
"2f99eaee.6e0396"
]
]
}
]
