This parameter is optional, so compatibility shouldn't be affected. Each SLMessage can set its own sender ID which is present on the returned message. This allows callers to fire multiple requests at once, even of the same type, while being able to identify which response went with which request. If not specified, the default value is 0. Also went ahead and documented some of the helper functions present on SLMessage (so, available on all message instances). Finally, since I was in and messing with each message anyway, I simplified and removed some repeated code from each derived message and had it call into the super to take advantage of shared decoding functionality. The lambdas ("arrow functions") in test functions were removed per advice from Mocha's documentation where the implicit `this` rebinding can apparently cause problems. This should probably have been its own commit, but, again, I was already in there messing with stuff, so...oh well. Closes #43
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
const SLMessage = require('./SLMessage.js').SLMessage;
|
|
|
|
const MSG_ID = 12584;
|
|
|
|
exports.SLGetPumpStatus = class SLGetPumpStatus extends SLMessage {
|
|
constructor(buf, pumpId, senderId) {
|
|
if (buf) {
|
|
var size = buf.readInt32LE(4) + 8;
|
|
super(buf, MSG_ID, size);
|
|
} else {
|
|
super(senderId, MSG_ID);
|
|
|
|
this.writeInt32LE(0);
|
|
this.writeInt32LE(pumpId);
|
|
}
|
|
}
|
|
|
|
decode() {
|
|
super.decode();
|
|
|
|
this.pumpSetting = new Array(8);
|
|
|
|
this.pumpType = this.readUInt32LE();
|
|
this.isRunning = this.readUInt32LE() !== 0; // 0, 1, or 4294967295 (FF FF FF FF)
|
|
this.pumpWatts = this.readUInt32LE();
|
|
this.pumpRPMs = this.readUInt32LE();
|
|
this.pumpUnknown1 = this.readUInt32LE(); // Always 0
|
|
this.pumpGPMs = this.readUInt32LE();
|
|
this.pumpUnknown2 = this.readUInt32LE(); // Always 255
|
|
|
|
for (var i = 0; i < 8; i++) {
|
|
this.pumpSetting[i] = {};
|
|
this.pumpSetting[i].circuitId = this.readUInt32LE();
|
|
this.pumpSetting[i].pumpSetPoint = this.readUInt32LE();
|
|
this.pumpSetting[i].isRPMs = this.readUInt32LE() !== 0; // 1 for RPMs; 0 for GPMs
|
|
}
|
|
}
|
|
|
|
static getResponseId() {
|
|
return MSG_ID + 1;
|
|
}
|
|
};
|