{
"Min_bit": true,
"PLC_TIME.SEC": 53,
"PLC_TIME.MSEC_REAL": 674.6240234375
}
{
"measurement": "Tag_value",
"fields": {
"value": xxx
}
}
var tagnames = Object.keys(msg.payload);
let allTags = msg.payload;
msg.payload = [];
tagnames.forEach((tagname) => {
let newTag = {};
newTag.measurement = tagname;
let fields = {};
if (allTags[tagname] == true) fields.value = 1;
else if (allTags[tagname] == false) fields.value = 0;
else fields.value = allTags[tagname];
newTag.fields = fields;
msg.payload.push(newTag);
});
msg.topic = "PLC_Name";
return msg;
[{
"measurement": "Min_bit",
"fields": {
"value": 0
}
}, {
"measurement": "PLC_TIME.SEC",
"fields": {
"value": 6
}
}, {
"measurement": "PLC_TIME.MSEC_REAL",
"fields": {
"value": 825.2969970703125
}
}]