8. Adding Data to Template Node
Next, we will populate the template node with data from two different motors. We will insert an inject node and a function node and connect them to each other.
Double-click on the function node and copy the following code
1
min = Math.round(Math.random()*1000);
2
max = Math.round((Math.random()*10000)+1000);
3
4
msg.payload = {
5
factory: {
6
machine00: {
7
min: min,
8
max: max,
9
failProb: 20,
10
name: "Motor 1"
11
},
12
machine01: {
13
min: min*5,
14
max: max*2,
15
failProb: 10,
16
name: "Motor 2"
17
}
18
}
19
}
20
21
return msg;
Copied!
and change the name to Generate Data.
Click Done once the function is complete.
We will use the inject node to trigger this function every 3 seconds. To do this, double-click on each inject node and change the following parameters.
Click Done after parameters are set.
Drag and drop a comment node and name it Water Filtration. Click Deploy and go to your dashboard page to see your progress.
Last modified 1yr ago
Copy link