I formatted the msg.payload as shown in the documentaqtion of influxdb node, but the opc node needs topic Id individually for each topic ID seperately (can't handle as a list of topic IDs all together ), So have to handle message after message!
After getting the payload from OPC node, I have to format the message acc. to Influxdb Out Node! I am not sure how to collect/assemble all the messages coming out of OPC node, eventhough they come out individually (one by one, at diff. timestamps)!
Here is my Function to format msg.payload acc.to Influxdb out Node (as in the Homepage of the node):
timestamp = new Date().getTime() *1e6;
msg = {payload:{}}
function append_array(topic_array, meas_array, timestamp){
var totalCount = topic_array.length;
const appended_array = [];
//append dicts to array
for (var i = 0; i < totalCount; i++){
appended_array.push([{topic: topic_array[i],measurement: meas_array[i], time:timestamp}]);
}
return appended_array;
}
const topic_array = [
'NodeID;ns=3;s="ExGrafanaDb"."MachineState1"."Data"."Mode"."TimeProduction"',
'NodeID;ns=3;s="ExGrafanaDb"."MachineState1"."Data"."Mode"."TimeProductionStart"',
'NodeID;ns=3;s="ExGrafanaDb"."MachineState1"."Data"."Mode"."TimeProductionEnd"',
];
const meas_array = [
'ExGrafanaDbMachineState1DataModeTimeProduction',
'ExGrafanaDbMachineState1DataModeTimeProductionStart',
'ExGrafanaDbMachineState1DataModeTimeProductionEnd',
];
msg.payload = append_array(topic_array, meas_array, timestamp);
console.log('msg.payload:', msg.payload);
Output:
[Running] node "d:\Thangz\Projekte\VC\Java\influxdb_set_ts"
msg.payload: [
[
{
topic: 'NodeID;ns=3;s="ExGrafanaDb"."MachineState1"."Data"."Mode"."TimeProduction"',
measurement: 'ExGrafanaDbMachineState1DataModeTimeProduction',
time: 1655716440354000000
}
],
[
{
topic: 'NodeID;ns=3;s="ExGrafanaDb"."MachineState1"."Data"."Mode"."TimeProductionStart"',
measurement: 'ExGrafanaDbMachineState1DataModeTimeProductionStart',
time: 1655716440354000000
}
],
[
{
topic: 'NodeID;ns=3;s="ExGrafanaDb"."MachineState1"."Data"."Mode"."TimeProductionEnd"',
measurement: 'ExGrafanaDbMachineState1DataModeTimeProductionEnd',
time: 1655716440354000000
}
]
]
[Done] exited with code=0 in 0.116 seconds
Currently I am working on it, any helps would be appreciated!