Bug Fix for decodeValveData / improvedNaming / CIRCUIT_VALUE_MAP (#33)
* initial code to interpret valveDataArray * Some additional comments on the valveDataArray decoding message * Adds decodeSensorData, decodeValveData, decodeDelayData, decodeMiscData * reverts unintended change to index.js * Refactor / rename variables - renamed variables to better describe their use - created a helper function 'isValvePresent' to simplify code - changed while loop to for loop * - Fixes bug in decodeValveData where only last valve's data was returned - renames some variables based on testing to more descriptive names - add CIRCUIT_NAME_VALUE_MAP for fixed values that the system uses (determined by testing on my system) * refactored decodeMiscData to simplify code * - Changed CIRCUIT_NAME_VALUE_MAP to array of objects - Refactored getCircuitByDeviceId - Added getCircuitsMap as helper to getCircuitByDeviceId and as a utility function to help in UI development
This commit is contained in:
@ -4,6 +4,14 @@ const SLMessage = require('./SLMessage.js').SLMessage;
|
||||
|
||||
const MSG_ID = 12532;
|
||||
|
||||
const CIRCUIT_NAME_VALUE_MAP = [
|
||||
{name: 'Unused', deviceId: 0},
|
||||
{name: 'Solar Active', deviceId: 128},
|
||||
{name: 'Pool or Spa Heater Active', deviceId: 129},
|
||||
{name: 'Pool Heater Active', deviceId: 130},
|
||||
{name: 'Spa Heater Active', deviceId: 131},
|
||||
];
|
||||
|
||||
exports.SLControllerConfigMessage = class SLControllerConfigMessage extends SLMessage {
|
||||
constructor(buf) {
|
||||
var size;
|
||||
@ -129,14 +137,28 @@ exports.SLControllerConfigMessage = class SLControllerConfigMessage extends SLMe
|
||||
}
|
||||
|
||||
getCircuitByDeviceId(deviceId) {
|
||||
if (this.bodyArray) {
|
||||
for (var i = 0; i < this.bodyArray.length; i++) {
|
||||
if (this.bodyArray[i].deviceId === deviceId) {
|
||||
return this.bodyArray[i];
|
||||
}
|
||||
var deviceArray = this.getCircuitsMap();
|
||||
|
||||
for (var i = 0; i < deviceArray.length; i++) {
|
||||
if (deviceArray[i].deviceId === deviceId) {
|
||||
return deviceArray[i];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
getCircuitsMap() {
|
||||
var deviceArray;
|
||||
|
||||
if (this.bodyArray) {
|
||||
deviceArray = this.bodyArray.concat(CIRCUIT_NAME_VALUE_MAP);
|
||||
} else {
|
||||
deviceArray = [].concat(CIRCUIT_NAME_VALUE_MAP);
|
||||
}
|
||||
|
||||
return deviceArray;
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -153,9 +153,10 @@ exports.SLEquipmentConfigurationMessage = class SLEquipmentConfigurationMessage
|
||||
|
||||
for (var loadCenterIndex = 0; loadCenterIndex <= secondaries; loadCenterIndex++) {
|
||||
var loadCenterValveData = this.valveDataArray[loadCenterIndex];
|
||||
var valveObject = {};
|
||||
|
||||
for (var valveIndex = 0; valveIndex < 5; valveIndex++) {
|
||||
var valveObject = {};
|
||||
|
||||
var isSolarValve = false;
|
||||
if (loadCenterIndex === 0) {
|
||||
if (valveIndex === 0 && isSolarValve0) {
|
||||
@ -198,23 +199,16 @@ exports.SLEquipmentConfigurationMessage = class SLEquipmentConfigurationMessage
|
||||
decodeDelayData() {
|
||||
this.delays = {};
|
||||
|
||||
this.delays.poolPumpCooldown = this.isBitSet(this.delayDataArray[0], 0);
|
||||
this.delays.spaPumpCooldown = this.isBitSet(this.delayDataArray[0], 1);
|
||||
this.delays.pumpOff = this.isBitSet(this.delayDataArray[0], 7);
|
||||
this.delays.poolPumpOnDuringHeaterCooldown = this.isBitSet(this.delayDataArray[0], 0);
|
||||
this.delays.spaPumpOnDuringHeaterCooldown = this.isBitSet(this.delayDataArray[0], 1);
|
||||
this.delays.pumpOffDuringValveAction = this.isBitSet(this.delayDataArray[0], 7);
|
||||
}
|
||||
|
||||
decodeMiscData() {
|
||||
this.misc = {};
|
||||
|
||||
if (this.isBitSet(this.miscDataArray[3], 0) === false) {
|
||||
this.misc.intelliChem = false;
|
||||
}
|
||||
|
||||
if (this.miscDataArray[4] !== 0) {
|
||||
this.misc.spaManual = true;
|
||||
} else {
|
||||
this.misc.spaManual = false;
|
||||
}
|
||||
this.misc.intelliChem = this.isBitSet(this.miscDataArray[3], 0);
|
||||
this.misc.spaManualHeat = this.miscDataArray[4] !== 0;
|
||||
}
|
||||
|
||||
isDualBody() {
|
||||
|
Reference in New Issue
Block a user