-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrealtime-plot.txt
More file actions
139 lines (137 loc) · 4.28 KB
/
realtime-plot.txt
File metadata and controls
139 lines (137 loc) · 4.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
Only one channel supported.
Paste code below into node-red import:
[
{
"id": "94c67c2b.5113a",
"type": "tab",
"label": "Flow 5",
"disabled": false,
"info": ""
},
{
"id": "c12c2dfb.950a5",
"type": "udp in",
"z": "94c67c2b.5113a",
"name": "",
"iface": "",
"port": "20001",
"ipv": "udp4",
"multicast": "false",
"group": "",
"datatype": "utf8",
"x": 120,
"y": 60,
"wires": [
[
"af514cea.ecd3c"
]
]
},
{
"id": "af514cea.ecd3c",
"type": "function",
"z": "94c67c2b.5113a",
"name": "udp2array",
"func": "var input = msg.payload;\ninput = input.replace(new RegExp(\"'\", 'g'), \"\\\"\")\n .replace(new RegExp(\"{\", 'g'), \"[\")\n .replace(new RegExp(\"}\", 'g'), \"]\");\n\nvar data = JSON.parse(input);\n\nmsg.payload = data;\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 290,
"y": 60,
"wires": [
[
"d7ffda25.df20b8"
]
]
},
{
"id": "d7ffda25.df20b8",
"type": "function",
"z": "94c67c2b.5113a",
"name": "format data packets",
"func": "var input = msg.payload;\nvar data = {};\n\nvar ts_last = flow.get(\"TSlast\");\nvar ts_now = input[1] * 1000;\nvar rate = 0;\n\nflow.set(\"TSlast\", ts_now);\nif(ts_last == undefined) {\n msg.payload = 0;\n return msg;\n}\n\ndata.ts_range = (ts_now - ts_last);\ndata.ts = ts_now;\ndata.packets = [];\n\nfor(var i=2; i < input.length; i++) {\n data.packets.push(input[i]);\n}\n\nmsg.payload = data;\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 500,
"y": 60,
"wires": [
[
"60917f30.b0a45"
]
]
},
{
"id": "920732c7.24398",
"type": "ui_chart",
"z": "94c67c2b.5113a",
"name": "",
"group": "8584d008.d0052",
"order": 1,
"width": "0",
"height": "0",
"label": "chart",
"chartType": "line",
"legend": "false",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": false,
"ymin": "",
"ymax": "",
"removeOlder": "120",
"removeOlderPoints": "",
"removeOlderUnit": "1",
"cutout": 0,
"useOneColor": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"useOldStyle": false,
"x": 910,
"y": 60,
"wires": [
[],
[]
]
},
{
"id": "60917f30.b0a45",
"type": "function",
"z": "94c67c2b.5113a",
"name": "format plot values",
"func": "var EVERY_N_PACKET = 20; // max = 24\nvar POINTS_PER_SECOND = 100 / EVERY_N_PACKET;\nvar KEEP_SECONDS = 60;\nvar KEY=\"f1_all_points\";\n\nvar MAX_POINTS = POINTS_PER_SECOND * KEEP_SECONDS;\n\nvar input = msg.payload;\n\nvar data = [{series:[\"P\"],\n data:[],\n labels:[\"Points\"]\n}];\n\nvar allPoints = flow.get(KEY);\nif(allPoints == undefined)\n allPoints = [];\n\n\nfor(var i=0, step=EVERY_N_PACKET; i + step < input.packets.length; i += step) {\n var o = {x: input.ts + i*10,\n y: input.packets[i]};\n allPoints.push(o);\n}\n\nif(allPoints.length > MAX_POINTS)\n allPoints = allPoints.slice(\n allPoints.length - MAX_POINTS, \n allPoints.length\n );\n\nflow.set(KEY, allPoints);\n\ndata[0].data.push(allPoints);\n\n\nmsg.payload = data;\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 730,
"y": 60,
"wires": [
[
"920732c7.24398"
]
]
},
{
"id": "8584d008.d0052",
"type": "ui_group",
"z": "",
"name": "test1",
"tab": "87d97be9.9ebb58",
"disp": true,
"width": "11",
"collapse": true
},
{
"id": "87d97be9.9ebb58",
"type": "ui_tab",
"z": "",
"name": "Home",
"icon": "dashboard"
}
]