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
37 lines
869 B
JavaScript
37 lines
869 B
JavaScript
'use strict';
|
|
|
|
const SLMessage = require('./SLMessage.js').SLMessage;
|
|
|
|
const MSG_ID = 12586;
|
|
|
|
exports.SLSetPumpFlow = class SLSetPumpFlow extends SLMessage {
|
|
constructor(pumpId, circuitId, setPoint, isRPMs, senderId) {
|
|
super(senderId, MSG_ID);
|
|
|
|
this.pumpId = pumpId;
|
|
this.circuitId = circuitId;
|
|
this.setPoint = setPoint;
|
|
|
|
if (isRPMs === true) {
|
|
this.isRPMs = 1;
|
|
} else {
|
|
this.isRPMs = 0;
|
|
}
|
|
}
|
|
|
|
|
|
encode() {
|
|
this.writeInt32LE(0); // Always 0 in my case
|
|
this.writeInt32LE(this.pumpId); // presumably pumpId, always 0 in my case
|
|
this.writeInt32LE(this.circuitId); // This is indexed to the array of circuits returned in GetPumpStatus
|
|
this.writeInt32LE(this.setPoint);
|
|
this.writeInt32LE(this.isRPMs); // 0 for GPM, 1 for RPMs
|
|
|
|
super.encode();
|
|
}
|
|
|
|
static getResponseId() {
|
|
return MSG_ID + 1;
|
|
}
|
|
};
|