v1: 231.4223175048828 265067.167 QTot: 0 F: 49.99128723144531 PFTot: NaN Ptot: 0 P3: 0 P2: 0 P1: 0 U31: 400.7892761230469 U23: 402.8990783691406 U12: 401.9129333496094 I3: 0 I2: 0 I1: 0 V3: 232.07000732421875 V2: 233.63577270507812
v1:  231.6444854736328
265067.167
QTot:  0
F:  50.00823211669922
PFTot:  -1
Ptot:  -0.00000842034842207795
P3:  0
P2:  -0.00000842034842207795
P1:  0
U31:  401.17315673828125
U23:  402.95745849609375
U12:  402.1151428222656
I3:  0
I2:  0
I1:  0
V3:  232.2249298095703
V2:  233.64129638671875
Set an unique msg.topic string value in each function node, the join manually as Key/Value object, using msg.topic as the key.
the function:
let intValue;
if (typeof msg.payload === "number") {
intValue = msg.payload;
} else if (typeof msg.payload === "string") {
intValue = Number(msg.payload);
} else if (msg.payload.length == 4) {
// four byte array or buffer
intValue = (((((msg.payload[0] << 8) + msg.payload[1]) << 8) + msg.payload[2]) << 8) + msg.payload[3];
} else {
node.warn("Unrecognised payload type or length");
}
msg.payload1 = String("v1:  "+Int2Float32(intValue));
return msg;
function Int2Float32(bytes) {
var sign = (bytes & 0x80000000) ? -1 : 1;
var exponent = ((bytes >> 23) & 0xFF) - 127;
var significand = (bytes & ~(-1 << 23));
if (exponent == 128) 
    return sign * ((significand) ? Number.NaN : Number.POSITIVE_INFINITY);
if (exponent == -127) {
    if (significand === 0) return sign * 0.0;
    exponent = -126;
    significand /= (1 << 22);
} else significand = (significand | (1 << 23)) / (1 << 23);
return sign * significand * Math.pow(2, exponent);
}
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
