Added chem data

Added salt cell config
Added system version
Tweaked pool status to pre-adjust values

Chem data uses big endian encoding for most of its values (but not all) while everything else (so far) has used little endian. Chem data also encodes bits like whether there's a system error or not inside other pieces of data like salt levels. There are also bytes in the returned data that I don't know the significance of just yet.
Pool status was tweaked such that asking for pH is corrected down to its proper float representation (e.g. 7.60) instead of the integer representation that is sent by the system (760). Same for water balance/saturation. Salt now returns the proper value (scaled up by 50) instead of the value sent over by the system, which I guess is the maximum precision the system can provide.
This commit is contained in:
Parnic
2018-03-30 19:59:17 -05:00
parent b6ee816fb3
commit 3262ac428b
7 changed files with 140 additions and 5 deletions

View File

@ -104,6 +104,21 @@ class UnitConnection extends EventEmitter {
this.client.write(new messages.SLControllerConfigMessage().toBuffer());
}
getChemicalData() {
console.log('sending chemical data query...');
this.client.write(new messages.SLChemDataMessage().toBuffer());
}
getSaltCellConfig() {
console.log('sending salt cell config query...');
this.client.write(new messages.SLSaltCellConfigMessage().toBuffer());
}
getVersion() {
console.log('sending version query...');
this.client.write(new messages.SLVersionMessage().toBuffer());
}
onClientMessage(msg) {
console.log('received message of length ' + msg.length);
var msgType = msg.readInt16LE(2);
@ -119,6 +134,17 @@ class UnitConnection extends EventEmitter {
} else if (msgType === 12533) {
console.log(" it's controller configuration");
this.emit('controllerConfig', new messages.SLControllerConfigMessage(msg));
} else if (msgType === 12593) {
console.log(" it's chem data");
this.emit('chemicalData', new messages.SLChemDataMessage(msg));
} else if (msgType === 12573) {
console.log(" it's salt cell config");
this.emit('saltCellConfig', new messages.SLSaltCellConfigMessage(msg));
} else if (msgType === 8121) {
console.log(" it's version");
this.emit('version', new messages.SLVersionMessage(msg));
} else {
console.log(" it's unknown. type: " + msgType);
}
}
}