From 8d908aad5d08aecb8f8a972784b88542750195b2 Mon Sep 17 00:00:00 2001 From: Parnic Date: Mon, 8 Jun 2020 19:05:45 -0500 Subject: [PATCH] WIP interpretation of equipment configuration properties --- index.js | 3 ++ messages/SLEquipmentConfigurationMessage.js | 54 +++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/index.js b/index.js index 6edd5b5..7033928 100644 --- a/index.js +++ b/index.js @@ -371,4 +371,7 @@ module.exports = { LIGHT_CMD_COLOR_RED: 15, LIGHT_CMD_COLOR_WHITE: 16, LIGHT_CMD_COLOR_PURPLE: 17, + PUMP_TYPE_INTELLIFLOVF: 1, + PUMP_TYPE_INTELLIFLOVS: 2, + PUMP_TYPE_INTELLIFLOVSF: 3, }; diff --git a/messages/SLEquipmentConfigurationMessage.js b/messages/SLEquipmentConfigurationMessage.js index 4d300ce..798bfb1 100644 --- a/messages/SLEquipmentConfigurationMessage.js +++ b/messages/SLEquipmentConfigurationMessage.js @@ -45,6 +45,60 @@ exports.SLEquipmentConfigurationMessage = class SLEquipmentConfigurationMessage this.spaFlowDataArray = this.readSLArray(); } + getVersion() { + if (this.versionDataArray === null || this.versionDataArray.length < 2) { + return 0; + } + + return (this.versionDataArray[0] * 1000) + (this.versionDataArray[1]); + } + + getSecondariesCount() { + return (this.controllerData & 0x11000000) >> 6; + } + + getPumpType(pumpIndex) { + if (typeof (pumpIndex) !== 'number') { + return 0; + } + + if (this.flowDataArray === null || this.flowDataArray.length < (pumpIndex + 1) * 45) { + return 0; + } + + let pumpType = this.flowDataArray[(45 * pumpIndex) + 2]; + if (pumpType <= 3) { + return pumpType; + } + + return 0; + } + + getCircuitRPMs(pumpIndex, circuitDeviceId) { + if (typeof (pumpIndex) !== 'number' || typeof (circuitDeviceId) !== 'number') { + return 0; + } + + if (pumpIndex < 0 || pumpIndex >= 8) { + return 0; + } + + if (this.flowDataArray === null || this.flowDataArray.length < (pumpIndex + 1) * 45) { + return 0; + } + + for (var i = 0; i < 8; i++) { + let offset = (45 * pumpIndex) + 4 + (i * 2); + if (this.flowDataArray[offset] === circuitDeviceId) { + let upperBits = this.flowDataArray[offset + 1]; + let lowerBits = this.flowDataArray[offset + (16 - (i * 2)) + 1 + i]; + return (upperBits << 8) + lowerBits; + } + } + + return 0; + } + static getResponseId() { return MSG_ID + 1; }