UNPKG

node-red-contrib-victron-ble

Version:

node-red node to parse Instant Readout advertisement data from Victron BLE devices

58 lines (57 loc) 2.99 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.AcCharger = void 0; const base_1 = require("./base"); class AcCharger extends base_1.Device { chargeState; chargerError; outputVoltage1; outputVoltage2; outputVoltage3; outputCurrent1; outputCurrent2; outputCurrent3; temperature; acCurrent; parseDecrypted(decrypted) { const reader = new base_1.BitReader(decrypted); const charge_state = reader.readUnsignedInt(8); const charger_error = reader.readUnsignedInt(8); const output_voltage1 = reader.readUnsignedInt(13); const output_current1 = reader.readUnsignedInt(11); const output_voltage2 = reader.readUnsignedInt(13); const output_current2 = reader.readUnsignedInt(11); const output_voltage3 = reader.readUnsignedInt(13); const output_current3 = reader.readUnsignedInt(11); const temperature = reader.readUnsignedInt(7); const ac_current = reader.readUnsignedInt(9); this.chargeState = charge_state !== 0xFF ? charge_state : undefined; this.chargerError = charger_error !== 0xFF ? charger_error : undefined; this.outputVoltage1 = output_voltage1 !== 0x1FFF ? output_voltage1 / 100 : undefined; this.outputVoltage2 = output_voltage2 !== 0x1FFF ? output_voltage2 / 100 : undefined; this.outputVoltage3 = output_voltage3 !== 0x1FFF ? output_voltage3 / 100 : undefined; this.outputCurrent1 = output_current1 !== 0x7FF ? output_current1 / 10 : undefined; this.outputCurrent2 = output_current2 !== 0x7FF ? output_current2 / 10 : undefined; this.outputCurrent3 = output_current3 !== 0x7FF ? output_current3 / 10 : undefined; this.temperature = temperature !== 0x7F ? (temperature - 40) : undefined; this.acCurrent = ac_current !== 0x1FF ? ac_current / 10 : undefined; } } exports.AcCharger = AcCharger; __decorate([ (0, base_1.EnumField)(base_1.OperationMode), __metadata("design:type", Number) ], AcCharger.prototype, "chargeState", void 0); __decorate([ (0, base_1.EnumField)(base_1.ChargerError), __metadata("design:type", Number) ], AcCharger.prototype, "chargerError", void 0);