@enyo-energy/sunspec-sdk 0.0.31 → 0.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/sunspec-devices.cjs +26 -1
- package/dist/cjs/sunspec-devices.d.cts +10 -1
- package/dist/cjs/sunspec-interfaces.cjs +82 -1
- package/dist/cjs/sunspec-interfaces.d.cts +173 -0
- package/dist/cjs/sunspec-modbus-client.cjs +538 -199
- package/dist/cjs/sunspec-modbus-client.d.cts +18 -1
- package/dist/cjs/version.cjs +1 -1
- package/dist/cjs/version.d.cts +1 -1
- package/dist/sunspec-devices.d.ts +10 -1
- package/dist/sunspec-devices.js +26 -1
- package/dist/sunspec-interfaces.d.ts +173 -0
- package/dist/sunspec-interfaces.js +81 -0
- package/dist/sunspec-modbus-client.d.ts +18 -1
- package/dist/sunspec-modbus-client.js +539 -200
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -295,7 +295,7 @@ class SunspecModbusClient {
|
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
const addressesChecked = customBaseAddress !== undefined
|
|
298
|
-
? `${customBaseAddress}, ${customBaseAddress + 1}
|
|
298
|
+
? `${customBaseAddress}, ${customBaseAddress + 1}`
|
|
299
299
|
: '40000 or 40001';
|
|
300
300
|
throw new Error(`Device is not SunSpec compliant - "SunS" identifier not found at addresses ${addressesChecked}`);
|
|
301
301
|
}
|
|
@@ -525,64 +525,44 @@ class SunspecModbusClient {
|
|
|
525
525
|
const voltageANRaw = await this.readRegisterValue(baseAddr + 10, 1, 'uint16');
|
|
526
526
|
const voltageBNRaw = await this.readRegisterValue(baseAddr + 11, 1, 'uint16');
|
|
527
527
|
const voltageCNRaw = await this.readRegisterValue(baseAddr + 12, 1, 'uint16');
|
|
528
|
+
// Read raw values for fields that need IIFEs removed
|
|
529
|
+
const acCurrentRaw = await this.readRegisterValue(baseAddr + 2, 1, 'uint16');
|
|
530
|
+
const acPowerRaw = await this.readRegisterValue(baseAddr + 14, 1, 'int16');
|
|
531
|
+
const dcCurrentRaw = await this.readRegisterValue(baseAddr + 27, 1, 'uint16');
|
|
532
|
+
const dcVoltageRaw = await this.readRegisterValue(baseAddr + 28, 1, 'uint16');
|
|
533
|
+
const dcPowerRaw = await this.readRegisterValue(baseAddr + 30, 1, 'int16');
|
|
528
534
|
const data = {
|
|
529
535
|
blockNumber: 103,
|
|
530
536
|
blockAddress: model.address,
|
|
531
537
|
blockLength: model.length,
|
|
532
538
|
// AC Current values - Offsets 2-5
|
|
533
|
-
acCurrent: this.applyScaleFactor(
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
return raw;
|
|
538
|
-
})(), scaleFactors.A_SF, 'uint16', 'AC Current'),
|
|
539
|
-
phaseACurrent: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 3, 1, 'uint16'), scaleFactors.A_SF, 'uint16', 'Phase A Current'),
|
|
540
|
-
phaseBCurrent: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 4, 1, 'uint16'), scaleFactors.A_SF, 'uint16', 'Phase B Current'),
|
|
541
|
-
phaseCCurrent: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 5, 1, 'uint16'), scaleFactors.A_SF, 'uint16', 'Phase C Current'),
|
|
539
|
+
acCurrent: this.applyScaleFactor(acCurrentRaw, scaleFactors.A_SF, 'uint16', 'AC Current', 2, 103),
|
|
540
|
+
phaseACurrent: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 3, 1, 'uint16'), scaleFactors.A_SF, 'uint16', 'Phase A Current', 3, 103),
|
|
541
|
+
phaseBCurrent: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 4, 1, 'uint16'), scaleFactors.A_SF, 'uint16', 'Phase B Current', 4, 103),
|
|
542
|
+
phaseCCurrent: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 5, 1, 'uint16'), scaleFactors.A_SF, 'uint16', 'Phase C Current', 5, 103),
|
|
542
543
|
// Voltage values - Offsets 7-12
|
|
543
|
-
voltageAB: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 7, 1, 'uint16'), scaleFactors.V_SF, 'uint16', 'Voltage AB'),
|
|
544
|
-
voltageBC: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 8, 1, 'uint16'), scaleFactors.V_SF, 'uint16', 'Voltage BC'),
|
|
545
|
-
voltageCA: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 9, 1, 'uint16'), scaleFactors.V_SF, 'uint16', 'Voltage CA'),
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
voltageCN: this.applyScaleFactor(voltageCNRaw, scaleFactors.V_SF, 'uint16', 'Voltage CN'),
|
|
544
|
+
voltageAB: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 7, 1, 'uint16'), scaleFactors.V_SF, 'uint16', 'Voltage AB', 7, 103),
|
|
545
|
+
voltageBC: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 8, 1, 'uint16'), scaleFactors.V_SF, 'uint16', 'Voltage BC', 8, 103),
|
|
546
|
+
voltageCA: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 9, 1, 'uint16'), scaleFactors.V_SF, 'uint16', 'Voltage CA', 9, 103),
|
|
547
|
+
voltageAN: this.applyScaleFactor(voltageANRaw, scaleFactors.V_SF, 'uint16', 'Voltage AN', 10, 103),
|
|
548
|
+
voltageBN: this.applyScaleFactor(voltageBNRaw, scaleFactors.V_SF, 'uint16', 'Voltage BN', 11, 103),
|
|
549
|
+
voltageCN: this.applyScaleFactor(voltageCNRaw, scaleFactors.V_SF, 'uint16', 'Voltage CN', 12, 103),
|
|
550
550
|
// Power values - Offsets 14, 18, 20, 22
|
|
551
|
-
acPower: this.applyScaleFactor(
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
return raw;
|
|
556
|
-
})(), scaleFactors.W_SF, 'int16', 'AC Power'),
|
|
557
|
-
apparentPower: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 18, 1, 'uint16'), scaleFactors.VA_SF, 'uint16', 'Apparent Power'),
|
|
558
|
-
reactivePower: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 20, 1, 'int16'), scaleFactors.VAr_SF, 'int16', 'Reactive Power'),
|
|
559
|
-
powerFactor: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 22, 1, 'int16'), scaleFactors.PF_SF, 'int16', 'Power Factor'),
|
|
551
|
+
acPower: this.applyScaleFactor(acPowerRaw, scaleFactors.W_SF, 'int16', 'AC Power', 14, 103),
|
|
552
|
+
apparentPower: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 18, 1, 'uint16'), scaleFactors.VA_SF, 'uint16', 'Apparent Power', 18, 103),
|
|
553
|
+
reactivePower: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 20, 1, 'int16'), scaleFactors.VAr_SF, 'int16', 'Reactive Power', 20, 103),
|
|
554
|
+
powerFactor: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 22, 1, 'int16'), scaleFactors.PF_SF, 'int16', 'Power Factor', 22, 103),
|
|
560
555
|
// Frequency - Offset 16
|
|
561
|
-
frequency: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 16, 1, 'uint16'), scaleFactors.Hz_SF, 'uint16', 'Frequency'),
|
|
556
|
+
frequency: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 16, 1, 'uint16'), scaleFactors.Hz_SF, 'uint16', 'Frequency', 16, 103),
|
|
562
557
|
// DC values - Offsets 27, 28, 30
|
|
563
|
-
dcCurrent: this.applyScaleFactor(
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
console.log(`DC Current: address=${addr}, raw=0x${raw.toString(16).toUpperCase()} (${raw})`);
|
|
567
|
-
return raw;
|
|
568
|
-
})(), scaleFactors.DCA_SF, 'uint16', 'DC Current'),
|
|
569
|
-
dcVoltage: this.applyScaleFactor(await (async () => {
|
|
570
|
-
const addr = baseAddr + 28;
|
|
571
|
-
const raw = await this.readRegisterValue(addr, 1, 'uint16');
|
|
572
|
-
console.log(`DC Voltage: address=${addr}, raw=0x${raw.toString(16).toUpperCase()} (${raw})`);
|
|
573
|
-
return raw;
|
|
574
|
-
})(), scaleFactors.DCV_SF, 'uint16', 'DC Voltage'),
|
|
575
|
-
dcPower: this.applyScaleFactor(await (async () => {
|
|
576
|
-
const addr = baseAddr + 30;
|
|
577
|
-
const raw = await this.readRegisterValue(addr, 1, 'int16');
|
|
578
|
-
console.log(`DC Power: address=${addr}, raw=0x${raw.toString(16).toUpperCase()} (${raw}), SF=${scaleFactors.DCW_SF}`);
|
|
579
|
-
return raw;
|
|
580
|
-
})(), scaleFactors.DCW_SF, 'int16', 'DC Power'),
|
|
558
|
+
dcCurrent: this.applyScaleFactor(dcCurrentRaw, scaleFactors.DCA_SF, 'uint16', 'DC Current', 27, 103),
|
|
559
|
+
dcVoltage: this.applyScaleFactor(dcVoltageRaw, scaleFactors.DCV_SF, 'uint16', 'DC Voltage', 28, 103),
|
|
560
|
+
dcPower: this.applyScaleFactor(dcPowerRaw, scaleFactors.DCW_SF, 'int16', 'DC Power', 30, 103),
|
|
581
561
|
// Temperature values - Offsets 32, 34, 35, 36
|
|
582
|
-
cabinetTemperature: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 32, 1, 'int16'), scaleFactors.Tmp_SF, 'int16', 'Cabinet Temperature'),
|
|
583
|
-
heatSinkTemperature: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 34, 1, 'int16'), scaleFactors.Tmp_SF, 'int16', 'Heat Sink Temperature'),
|
|
584
|
-
transformerTemperature: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 35, 1, 'int16'), scaleFactors.Tmp_SF, 'int16', 'Transformer Temperature'),
|
|
585
|
-
otherTemperature: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 36, 1, 'int16'), scaleFactors.Tmp_SF, 'int16', 'Other Temperature'),
|
|
562
|
+
cabinetTemperature: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 32, 1, 'int16'), scaleFactors.Tmp_SF, 'int16', 'Cabinet Temperature', 32, 103),
|
|
563
|
+
heatSinkTemperature: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 34, 1, 'int16'), scaleFactors.Tmp_SF, 'int16', 'Heat Sink Temperature', 34, 103),
|
|
564
|
+
transformerTemperature: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 35, 1, 'int16'), scaleFactors.Tmp_SF, 'int16', 'Transformer Temperature', 35, 103),
|
|
565
|
+
otherTemperature: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 36, 1, 'int16'), scaleFactors.Tmp_SF, 'int16', 'Other Temperature', 36, 103),
|
|
586
566
|
// Status values - Offsets 38, 39
|
|
587
567
|
operatingState: await this.readRegisterValue(baseAddr + 38, 1, 'uint16'),
|
|
588
568
|
vendorState: await this.readRegisterValue(baseAddr + 39, 1, 'uint16'),
|
|
@@ -594,11 +574,20 @@ class SunspecModbusClient {
|
|
|
594
574
|
vendorEvents3: await this.readRegisterValue(baseAddr + 48, 2, 'uint32'),
|
|
595
575
|
vendorEvents4: await this.readRegisterValue(baseAddr + 50, 2, 'uint32')
|
|
596
576
|
};
|
|
577
|
+
// Log non-scaled fields
|
|
578
|
+
this.logRegisterRead(103, 38, 'Operating State', data.operatingState, 'enum16');
|
|
579
|
+
this.logRegisterRead(103, 39, 'Vendor State', data.vendorState, 'uint16');
|
|
580
|
+
this.logRegisterRead(103, 40, 'Events', data.events, 'bitfield32');
|
|
581
|
+
this.logRegisterRead(103, 42, 'Events2', data.events2, 'bitfield32');
|
|
582
|
+
this.logRegisterRead(103, 44, 'Vendor Events 1', data.vendorEvents1, 'bitfield32');
|
|
583
|
+
this.logRegisterRead(103, 46, 'Vendor Events 2', data.vendorEvents2, 'bitfield32');
|
|
584
|
+
this.logRegisterRead(103, 48, 'Vendor Events 3', data.vendorEvents3, 'bitfield32');
|
|
585
|
+
this.logRegisterRead(103, 50, 'Vendor Events 4', data.vendorEvents4, 'bitfield32');
|
|
597
586
|
// Read AC Energy (32-bit accumulator) - Offset 24-25
|
|
598
|
-
const
|
|
599
|
-
|
|
587
|
+
const acEnergy = await this.readRegisterValue(baseAddr + 24, 2, 'uint32');
|
|
588
|
+
this.logRegisterRead(103, 24, 'AC Energy', acEnergy, 'acc32');
|
|
600
589
|
data.acEnergy = !this.isUnimplementedValue(acEnergy, 'acc32')
|
|
601
|
-
? acEnergy * Math.pow(10, scaleFactors.WH_SF)
|
|
590
|
+
? acEnergy * Math.pow(10, scaleFactors.WH_SF)
|
|
602
591
|
: undefined;
|
|
603
592
|
return data;
|
|
604
593
|
}
|
|
@@ -626,41 +615,32 @@ class SunspecModbusClient {
|
|
|
626
615
|
DCV_SF: await this.readRegisterValue(baseAddr + 19, 1, 'int16'),
|
|
627
616
|
DCW_SF: await this.readRegisterValue(baseAddr + 21, 1, 'int16')
|
|
628
617
|
};
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
const
|
|
638
|
-
const
|
|
639
|
-
|
|
640
|
-
const
|
|
641
|
-
const
|
|
642
|
-
|
|
643
|
-
const
|
|
644
|
-
const
|
|
645
|
-
|
|
646
|
-
const dcVoltageAddr = baseAddr + 15;
|
|
647
|
-
const dcVoltageRaw = await this.readRegisterValue(dcVoltageAddr, 1, 'uint16');
|
|
648
|
-
console.log(`DC Voltage: address=${dcVoltageAddr}, raw=0x${dcVoltageRaw.toString(16).toUpperCase()} (${dcVoltageRaw})`);
|
|
649
|
-
const dcPowerAddr = baseAddr + 20;
|
|
650
|
-
const dcPowerRaw = await this.readRegisterValue(dcPowerAddr, 1, 'int16');
|
|
651
|
-
console.log(`DC Power: address=${dcPowerAddr}, raw=0x${dcPowerRaw.toString(16).toUpperCase()} (${dcPowerRaw}), SF=${scaleFactors.DCW_SF}`);
|
|
652
|
-
const stateAddr = baseAddr + 24;
|
|
653
|
-
const stateRaw = await this.readRegisterValue(stateAddr, 1, 'uint16');
|
|
654
|
-
console.log(`Operating State: address=${stateAddr}, raw=0x${stateRaw.toString(16).toUpperCase()} (${stateRaw})`);
|
|
618
|
+
this.logRegisterRead(101, 6, 'A_SF', scaleFactors.A_SF, 'int16');
|
|
619
|
+
this.logRegisterRead(101, 13, 'V_SF', scaleFactors.V_SF, 'int16');
|
|
620
|
+
this.logRegisterRead(101, 10, 'W_SF', scaleFactors.W_SF, 'int16');
|
|
621
|
+
this.logRegisterRead(101, 12, 'Hz_SF', scaleFactors.Hz_SF, 'int16');
|
|
622
|
+
this.logRegisterRead(101, 18, 'DCA_SF', scaleFactors.DCA_SF, 'int16');
|
|
623
|
+
this.logRegisterRead(101, 19, 'DCV_SF', scaleFactors.DCV_SF, 'int16');
|
|
624
|
+
this.logRegisterRead(101, 21, 'DCW_SF', scaleFactors.DCW_SF, 'int16');
|
|
625
|
+
// Read raw values
|
|
626
|
+
const acCurrentRaw = await this.readRegisterValue(baseAddr + 2, 1, 'uint16');
|
|
627
|
+
const voltageRaw = await this.readRegisterValue(baseAddr + 7, 1, 'uint16');
|
|
628
|
+
const acPowerRaw = await this.readRegisterValue(baseAddr + 9, 1, 'int16');
|
|
629
|
+
const freqRaw = await this.readRegisterValue(baseAddr + 11, 1, 'uint16');
|
|
630
|
+
const dcCurrentRaw = await this.readRegisterValue(baseAddr + 14, 1, 'uint16');
|
|
631
|
+
const dcVoltageRaw = await this.readRegisterValue(baseAddr + 15, 1, 'uint16');
|
|
632
|
+
const dcPowerRaw = await this.readRegisterValue(baseAddr + 20, 1, 'int16');
|
|
633
|
+
const stateRaw = await this.readRegisterValue(baseAddr + 24, 1, 'uint16');
|
|
634
|
+
this.logRegisterRead(101, 24, 'Operating State', stateRaw, 'enum16');
|
|
655
635
|
return {
|
|
656
636
|
blockNumber: 101,
|
|
657
|
-
voltageAN: this.applyScaleFactor(voltageRaw, scaleFactors.V_SF, 'uint16', '
|
|
658
|
-
acCurrent: this.applyScaleFactor(acCurrentRaw, scaleFactors.A_SF, 'uint16', '
|
|
659
|
-
acPower: this.applyScaleFactor(acPowerRaw, scaleFactors.W_SF, 'int16', '
|
|
660
|
-
frequency: this.applyScaleFactor(freqRaw, scaleFactors.Hz_SF, 'uint16', '
|
|
661
|
-
dcCurrent: this.applyScaleFactor(dcCurrentRaw, scaleFactors.DCA_SF, 'uint16', '
|
|
662
|
-
dcVoltage: this.applyScaleFactor(dcVoltageRaw, scaleFactors.DCV_SF, 'uint16', '
|
|
663
|
-
dcPower: this.applyScaleFactor(dcPowerRaw, scaleFactors.DCW_SF, 'int16', '
|
|
637
|
+
voltageAN: this.applyScaleFactor(voltageRaw, scaleFactors.V_SF, 'uint16', 'Voltage AN', 7, 101),
|
|
638
|
+
acCurrent: this.applyScaleFactor(acCurrentRaw, scaleFactors.A_SF, 'uint16', 'AC Current', 2, 101),
|
|
639
|
+
acPower: this.applyScaleFactor(acPowerRaw, scaleFactors.W_SF, 'int16', 'AC Power', 9, 101),
|
|
640
|
+
frequency: this.applyScaleFactor(freqRaw, scaleFactors.Hz_SF, 'uint16', 'Frequency', 11, 101),
|
|
641
|
+
dcCurrent: this.applyScaleFactor(dcCurrentRaw, scaleFactors.DCA_SF, 'uint16', 'DC Current', 14, 101),
|
|
642
|
+
dcVoltage: this.applyScaleFactor(dcVoltageRaw, scaleFactors.DCV_SF, 'uint16', 'DC Voltage', 15, 101),
|
|
643
|
+
dcPower: this.applyScaleFactor(dcPowerRaw, scaleFactors.DCW_SF, 'int16', 'DC Power', 20, 101),
|
|
664
644
|
operatingState: stateRaw
|
|
665
645
|
};
|
|
666
646
|
}
|
|
@@ -687,24 +667,55 @@ class SunspecModbusClient {
|
|
|
687
667
|
DCW_SF: await this.readRegisterValue(baseAddr + 31, 1, 'int16'), // Offset 31
|
|
688
668
|
Tmp_SF: await this.readRegisterValue(baseAddr + 36, 1, 'int16') // Offset 36
|
|
689
669
|
};
|
|
690
|
-
|
|
670
|
+
this.logRegisterRead(103, 6, 'A_SF', scaleFactors.A_SF, 'int16');
|
|
671
|
+
this.logRegisterRead(103, 13, 'V_SF', scaleFactors.V_SF, 'int16');
|
|
672
|
+
this.logRegisterRead(103, 15, 'W_SF', scaleFactors.W_SF, 'int16');
|
|
673
|
+
this.logRegisterRead(103, 17, 'Hz_SF', scaleFactors.Hz_SF, 'int16');
|
|
674
|
+
this.logRegisterRead(103, 19, 'VA_SF', scaleFactors.VA_SF, 'int16');
|
|
675
|
+
this.logRegisterRead(103, 21, 'VAr_SF', scaleFactors.VAr_SF, 'int16');
|
|
676
|
+
this.logRegisterRead(103, 23, 'PF_SF', scaleFactors.PF_SF, 'int16');
|
|
677
|
+
this.logRegisterRead(103, 26, 'WH_SF', scaleFactors.WH_SF, 'int16');
|
|
678
|
+
this.logRegisterRead(103, 28, 'DCA_SF', scaleFactors.DCA_SF, 'int16');
|
|
679
|
+
this.logRegisterRead(103, 29, 'DCV_SF', scaleFactors.DCV_SF, 'int16');
|
|
680
|
+
this.logRegisterRead(103, 31, 'DCW_SF', scaleFactors.DCW_SF, 'int16');
|
|
681
|
+
this.logRegisterRead(103, 36, 'Tmp_SF', scaleFactors.Tmp_SF, 'int16');
|
|
691
682
|
return scaleFactors;
|
|
692
683
|
}
|
|
693
684
|
/**
|
|
694
685
|
* Apply scale factor to a value
|
|
695
686
|
* Returns undefined if the value is unimplemented or scale factor is out of range
|
|
696
687
|
*/
|
|
697
|
-
applyScaleFactor(value, scaleFactor, dataType = 'uint16', fieldName) {
|
|
688
|
+
applyScaleFactor(value, scaleFactor, dataType = 'uint16', fieldName, offset, modelId) {
|
|
698
689
|
// Check for unimplemented values
|
|
699
690
|
if (this.isUnimplementedValue(value, dataType)) {
|
|
700
691
|
return undefined;
|
|
701
692
|
}
|
|
702
693
|
const scaledValue = value * Math.pow(10, scaleFactor);
|
|
703
|
-
// Log the raw and scaled values
|
|
704
|
-
|
|
705
|
-
|
|
694
|
+
// Log the raw and scaled values
|
|
695
|
+
if (offset !== undefined && modelId !== undefined && fieldName) {
|
|
696
|
+
const hex = value >= 0 ? value.toString(16).toUpperCase() : (value >>> 0).toString(16).toUpperCase();
|
|
697
|
+
console.log(`[Model ${modelId}] offset ${offset}: ${fieldName} raw=${value} (0x${hex}), SF=${scaleFactor}, scaled=${scaledValue}`);
|
|
698
|
+
}
|
|
699
|
+
else {
|
|
700
|
+
const fieldPrefix = fieldName ? `${fieldName}: ` : '';
|
|
701
|
+
console.log(`Scale Factor Applied - ${fieldPrefix}raw=${value} (decimal), SF=${scaleFactor}, scaled=${scaledValue}`);
|
|
702
|
+
}
|
|
706
703
|
return scaledValue;
|
|
707
704
|
}
|
|
705
|
+
logRegisterRead(modelId, offset, fieldName, rawValue, dataType) {
|
|
706
|
+
const typeInfo = dataType ? ` (${dataType})` : '';
|
|
707
|
+
if (rawValue === undefined) {
|
|
708
|
+
console.log(`[Model ${modelId}] offset ${offset}: ${fieldName} = -${typeInfo}`);
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
if (typeof rawValue === 'number') {
|
|
712
|
+
const hex = rawValue >= 0 ? rawValue.toString(16).toUpperCase() : (rawValue >>> 0).toString(16).toUpperCase();
|
|
713
|
+
console.log(`[Model ${modelId}] offset ${offset}: ${fieldName} = ${rawValue} (0x${hex})${typeInfo}`);
|
|
714
|
+
}
|
|
715
|
+
else {
|
|
716
|
+
console.log(`[Model ${modelId}] offset ${offset}: ${fieldName} = "${rawValue}"${typeInfo}`);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
708
719
|
/**
|
|
709
720
|
* Read MPPT Scale Factors for a specific module
|
|
710
721
|
* Returns the scale factors for DC Current, DC Voltage, DC Power, and DC Energy
|
|
@@ -738,10 +749,10 @@ class SunspecModbusClient {
|
|
|
738
749
|
DCW_SF, // Power Scale Factor
|
|
739
750
|
DCWH_SF, // Energy Scale Factor
|
|
740
751
|
};
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
752
|
+
this.logRegisterRead(160, 2, 'DCA_SF', DCA_SF, 'int16');
|
|
753
|
+
this.logRegisterRead(160, 3, 'DCV_SF', DCV_SF, 'int16');
|
|
754
|
+
this.logRegisterRead(160, 4, 'DCW_SF', DCW_SF, 'int16');
|
|
755
|
+
this.logRegisterRead(160, 5, 'DCWH_SF', DCWH_SF, 'int16');
|
|
745
756
|
return scaleFactors;
|
|
746
757
|
}
|
|
747
758
|
catch (error) {
|
|
@@ -771,7 +782,6 @@ class SunspecModbusClient {
|
|
|
771
782
|
console.error(`Failed to read scale factors for MPPT module ${moduleId}`);
|
|
772
783
|
return null;
|
|
773
784
|
}
|
|
774
|
-
console.log(`MPPT Module ${moduleId} Scale Factors:`, JSON.stringify(scaleFactors, null, 2));
|
|
775
785
|
const id = await this.readRegisterValue(moduleAddr, 1, 'uint16');
|
|
776
786
|
const idString = await this.readRegisterValue(moduleAddr + 1, 8, 'string');
|
|
777
787
|
const dcCurrentRaw = await this.readRegisterValue(moduleAddr + 9, 1, 'uint16');
|
|
@@ -780,6 +790,8 @@ class SunspecModbusClient {
|
|
|
780
790
|
const dcEnergyRaw = await this.readRegisterValue(moduleAddr + 12, 2, 'uint32');
|
|
781
791
|
const temperatureRaw = await this.readRegisterValue(moduleAddr + 16, 1, 'int16');
|
|
782
792
|
const dcst = await this.readRegisterValue(moduleAddr + 17, 1, 'uint16');
|
|
793
|
+
this.logRegisterRead(160, 0, `MPPT ${moduleId} ID`, id, 'uint16');
|
|
794
|
+
this.logRegisterRead(160, 1, `MPPT ${moduleId} String ID`, idString, 'string');
|
|
783
795
|
// Map the DC module state to human-readable name
|
|
784
796
|
// Check if this module is actually implemented/connected
|
|
785
797
|
// If all key values are unimplemented, this module doesn't exist
|
|
@@ -793,24 +805,28 @@ class SunspecModbusClient {
|
|
|
793
805
|
// Note: There appears to be a temperature scale factor in the original model,
|
|
794
806
|
// but it's not in the current register map. We'll apply a default scale factor.
|
|
795
807
|
const temperatureScaleFactor = -1; // Common default for temperature readings
|
|
808
|
+
this.logRegisterRead(160, 12, `MPPT ${moduleId} DC Energy`, dcEnergyRaw, 'acc32');
|
|
809
|
+
const timestampRaw = await this.readRegisterValue(moduleAddr + 14, 2, 'uint32');
|
|
810
|
+
this.logRegisterRead(160, 14, `MPPT ${moduleId} Timestamp`, timestampRaw, 'uint32');
|
|
811
|
+
this.logRegisterRead(160, 17, `MPPT ${moduleId} Operating State`, dcst, 'enum16');
|
|
796
812
|
const data = {
|
|
797
813
|
blockNumber: 160,
|
|
798
814
|
blockAddress: model.address,
|
|
799
815
|
blockLength: model.length,
|
|
800
816
|
id: id,
|
|
801
817
|
stringId: idString,
|
|
802
|
-
dcCurrent: this.applyScaleFactor(dcCurrentRaw, scaleFactors.DCA_SF, 'uint16', `MPPT ${moduleId} DC Current
|
|
818
|
+
dcCurrent: this.applyScaleFactor(dcCurrentRaw, scaleFactors.DCA_SF, 'uint16', `MPPT ${moduleId} DC Current`, 9, 160),
|
|
803
819
|
dcCurrentSF: scaleFactors.DCA_SF,
|
|
804
|
-
dcVoltage: this.applyScaleFactor(dcVoltageRaw, scaleFactors.DCV_SF, 'uint16', `MPPT ${moduleId} DC Voltage
|
|
820
|
+
dcVoltage: this.applyScaleFactor(dcVoltageRaw, scaleFactors.DCV_SF, 'uint16', `MPPT ${moduleId} DC Voltage`, 10, 160),
|
|
805
821
|
dcVoltageSF: scaleFactors.DCV_SF,
|
|
806
|
-
dcPower: this.applyScaleFactor(dcPowerRaw, scaleFactors.DCW_SF, 'uint16', `MPPT ${moduleId} DC Power
|
|
822
|
+
dcPower: this.applyScaleFactor(dcPowerRaw, scaleFactors.DCW_SF, 'uint16', `MPPT ${moduleId} DC Power`, 11, 160),
|
|
807
823
|
dcPowerSF: scaleFactors.DCW_SF,
|
|
808
824
|
dcEnergy: !this.isUnimplementedValue(dcEnergyRaw, 'acc32')
|
|
809
|
-
? dcEnergyRaw * Math.pow(10, scaleFactors.DCWH_SF)
|
|
825
|
+
? dcEnergyRaw * Math.pow(10, scaleFactors.DCWH_SF)
|
|
810
826
|
: undefined,
|
|
811
827
|
dcEnergySF: scaleFactors.DCWH_SF,
|
|
812
|
-
timestamp:
|
|
813
|
-
temperature: this.applyScaleFactor(temperatureRaw, temperatureScaleFactor, 'int16', `MPPT ${moduleId} Temperature
|
|
828
|
+
timestamp: timestampRaw,
|
|
829
|
+
temperature: this.applyScaleFactor(temperatureRaw, temperatureScaleFactor, 'int16', `MPPT ${moduleId} Temperature`, 16, 160),
|
|
814
830
|
temperatureSF: temperatureScaleFactor,
|
|
815
831
|
operatingState: dcst,
|
|
816
832
|
};
|
|
@@ -903,6 +919,238 @@ class SunspecModbusClient {
|
|
|
903
919
|
return `UNKNOWN(${state})`;
|
|
904
920
|
}
|
|
905
921
|
}
|
|
922
|
+
/**
|
|
923
|
+
* Map battery type to human-readable name (Model 802)
|
|
924
|
+
*/
|
|
925
|
+
mapBatteryType(typ) {
|
|
926
|
+
switch (typ) {
|
|
927
|
+
case sunspec_interfaces_js_1.SunspecBatteryType.NOT_APPLICABLE_UNKNOWN:
|
|
928
|
+
return "NOT_APPLICABLE_UNKNOWN";
|
|
929
|
+
case sunspec_interfaces_js_1.SunspecBatteryType.LEAD_ACID:
|
|
930
|
+
return "LEAD_ACID";
|
|
931
|
+
case sunspec_interfaces_js_1.SunspecBatteryType.NICKEL_METAL_HYDRIDE:
|
|
932
|
+
return "NICKEL_METAL_HYDRIDE";
|
|
933
|
+
case sunspec_interfaces_js_1.SunspecBatteryType.NICKEL_CADMIUM:
|
|
934
|
+
return "NICKEL_CADMIUM";
|
|
935
|
+
case sunspec_interfaces_js_1.SunspecBatteryType.LITHIUM_ION:
|
|
936
|
+
return "LITHIUM_ION";
|
|
937
|
+
case sunspec_interfaces_js_1.SunspecBatteryType.CARBON_ZINC:
|
|
938
|
+
return "CARBON_ZINC";
|
|
939
|
+
case sunspec_interfaces_js_1.SunspecBatteryType.ZINC_CHLORIDE:
|
|
940
|
+
return "ZINC_CHLORIDE";
|
|
941
|
+
case sunspec_interfaces_js_1.SunspecBatteryType.ALKALINE:
|
|
942
|
+
return "ALKALINE";
|
|
943
|
+
case sunspec_interfaces_js_1.SunspecBatteryType.RECHARGEABLE_ALKALINE:
|
|
944
|
+
return "RECHARGEABLE_ALKALINE";
|
|
945
|
+
case sunspec_interfaces_js_1.SunspecBatteryType.SODIUM_SULFUR:
|
|
946
|
+
return "SODIUM_SULFUR";
|
|
947
|
+
case sunspec_interfaces_js_1.SunspecBatteryType.FLOW:
|
|
948
|
+
return "FLOW";
|
|
949
|
+
case sunspec_interfaces_js_1.SunspecBatteryType.SUPER_CAPACITOR:
|
|
950
|
+
return "SUPER_CAPACITOR";
|
|
951
|
+
case sunspec_interfaces_js_1.SunspecBatteryType.OTHER:
|
|
952
|
+
return "OTHER";
|
|
953
|
+
default:
|
|
954
|
+
if (this.isUnimplementedValue(typ, 'enum16')) {
|
|
955
|
+
return "NOT_IMPLEMENTED";
|
|
956
|
+
}
|
|
957
|
+
return `UNKNOWN(${typ})`;
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Map battery bank state to human-readable name (Model 802)
|
|
962
|
+
*/
|
|
963
|
+
mapBatteryBankState(state) {
|
|
964
|
+
switch (state) {
|
|
965
|
+
case sunspec_interfaces_js_1.SunspecBatteryBankState.DISCONNECTED:
|
|
966
|
+
return "DISCONNECTED";
|
|
967
|
+
case sunspec_interfaces_js_1.SunspecBatteryBankState.INITIALIZING:
|
|
968
|
+
return "INITIALIZING";
|
|
969
|
+
case sunspec_interfaces_js_1.SunspecBatteryBankState.CONNECTED:
|
|
970
|
+
return "CONNECTED";
|
|
971
|
+
case sunspec_interfaces_js_1.SunspecBatteryBankState.STANDBY:
|
|
972
|
+
return "STANDBY";
|
|
973
|
+
case sunspec_interfaces_js_1.SunspecBatteryBankState.SOC_PROTECTION:
|
|
974
|
+
return "SOC_PROTECTION";
|
|
975
|
+
case sunspec_interfaces_js_1.SunspecBatteryBankState.SUSPENDING:
|
|
976
|
+
return "SUSPENDING";
|
|
977
|
+
case sunspec_interfaces_js_1.SunspecBatteryBankState.FAULT:
|
|
978
|
+
return "FAULT";
|
|
979
|
+
default:
|
|
980
|
+
if (this.isUnimplementedValue(state, 'enum16')) {
|
|
981
|
+
return "NOT_IMPLEMENTED";
|
|
982
|
+
}
|
|
983
|
+
return `UNKNOWN(${state})`;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* Read Model 802 scale factors (offsets 52-63)
|
|
988
|
+
*/
|
|
989
|
+
async readBatteryBaseScaleFactors(baseAddr) {
|
|
990
|
+
const scaleFactors = {
|
|
991
|
+
AHRtg_SF: await this.readRegisterValue(baseAddr + 52, 1, 'int16'),
|
|
992
|
+
WHRtg_SF: await this.readRegisterValue(baseAddr + 53, 1, 'int16'),
|
|
993
|
+
WChaDisChaMax_SF: await this.readRegisterValue(baseAddr + 54, 1, 'int16'),
|
|
994
|
+
DisChaRte_SF: await this.readRegisterValue(baseAddr + 55, 1, 'int16'),
|
|
995
|
+
SoC_SF: await this.readRegisterValue(baseAddr + 56, 1, 'int16'),
|
|
996
|
+
DoD_SF: await this.readRegisterValue(baseAddr + 57, 1, 'int16'),
|
|
997
|
+
SoH_SF: await this.readRegisterValue(baseAddr + 58, 1, 'int16'),
|
|
998
|
+
V_SF: await this.readRegisterValue(baseAddr + 59, 1, 'int16'),
|
|
999
|
+
CellV_SF: await this.readRegisterValue(baseAddr + 60, 1, 'int16'),
|
|
1000
|
+
A_SF: await this.readRegisterValue(baseAddr + 61, 1, 'int16'),
|
|
1001
|
+
AMax_SF: await this.readRegisterValue(baseAddr + 62, 1, 'int16'),
|
|
1002
|
+
W_SF: await this.readRegisterValue(baseAddr + 63, 1, 'int16'),
|
|
1003
|
+
};
|
|
1004
|
+
this.logRegisterRead(802, 52, 'AHRtg_SF', scaleFactors.AHRtg_SF, 'int16');
|
|
1005
|
+
this.logRegisterRead(802, 53, 'WHRtg_SF', scaleFactors.WHRtg_SF, 'int16');
|
|
1006
|
+
this.logRegisterRead(802, 54, 'WChaDisChaMax_SF', scaleFactors.WChaDisChaMax_SF, 'int16');
|
|
1007
|
+
this.logRegisterRead(802, 55, 'DisChaRte_SF', scaleFactors.DisChaRte_SF, 'int16');
|
|
1008
|
+
this.logRegisterRead(802, 56, 'SoC_SF', scaleFactors.SoC_SF, 'int16');
|
|
1009
|
+
this.logRegisterRead(802, 57, 'DoD_SF', scaleFactors.DoD_SF, 'int16');
|
|
1010
|
+
this.logRegisterRead(802, 58, 'SoH_SF', scaleFactors.SoH_SF, 'int16');
|
|
1011
|
+
this.logRegisterRead(802, 59, 'V_SF', scaleFactors.V_SF, 'int16');
|
|
1012
|
+
this.logRegisterRead(802, 60, 'CellV_SF', scaleFactors.CellV_SF, 'int16');
|
|
1013
|
+
this.logRegisterRead(802, 61, 'A_SF', scaleFactors.A_SF, 'int16');
|
|
1014
|
+
this.logRegisterRead(802, 62, 'AMax_SF', scaleFactors.AMax_SF, 'int16');
|
|
1015
|
+
this.logRegisterRead(802, 63, 'W_SF', scaleFactors.W_SF, 'int16');
|
|
1016
|
+
return scaleFactors;
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Read battery base data from Model 802 (Battery Base)
|
|
1020
|
+
*/
|
|
1021
|
+
async readBatteryBaseData() {
|
|
1022
|
+
const model = this.findModel(sunspec_interfaces_js_1.SunspecModelId.BatteryBase);
|
|
1023
|
+
if (!model) {
|
|
1024
|
+
console.log('Battery Base model 802 not found');
|
|
1025
|
+
return null;
|
|
1026
|
+
}
|
|
1027
|
+
const baseAddr = model.address;
|
|
1028
|
+
console.log(`Reading Battery Base Data from Model 802 at base address: ${baseAddr}`);
|
|
1029
|
+
try {
|
|
1030
|
+
// Read scale factors first (offsets 52-63)
|
|
1031
|
+
const sf = await this.readBatteryBaseScaleFactors(baseAddr);
|
|
1032
|
+
// Read raw values
|
|
1033
|
+
const ahRtgRaw = await this.readRegisterValue(baseAddr + 2, 1, 'uint16');
|
|
1034
|
+
const whRtgRaw = await this.readRegisterValue(baseAddr + 3, 1, 'uint16');
|
|
1035
|
+
const wChaRteMaxRaw = await this.readRegisterValue(baseAddr + 4, 1, 'uint16');
|
|
1036
|
+
const wDisChaRteMaxRaw = await this.readRegisterValue(baseAddr + 5, 1, 'uint16');
|
|
1037
|
+
const disChaRteRaw = await this.readRegisterValue(baseAddr + 6, 1, 'uint16');
|
|
1038
|
+
const soCMaxRaw = await this.readRegisterValue(baseAddr + 7, 1, 'uint16');
|
|
1039
|
+
const soCMinRaw = await this.readRegisterValue(baseAddr + 8, 1, 'uint16');
|
|
1040
|
+
const soCRsvMaxRaw = await this.readRegisterValue(baseAddr + 9, 1, 'uint16');
|
|
1041
|
+
const soCRsvMinRaw = await this.readRegisterValue(baseAddr + 10, 1, 'uint16');
|
|
1042
|
+
const soCRaw = await this.readRegisterValue(baseAddr + 11, 1, 'uint16');
|
|
1043
|
+
const doDRaw = await this.readRegisterValue(baseAddr + 12, 1, 'uint16');
|
|
1044
|
+
const soHRaw = await this.readRegisterValue(baseAddr + 13, 1, 'uint16');
|
|
1045
|
+
const nCycRaw = await this.readRegisterValue(baseAddr + 14, 2, 'uint32');
|
|
1046
|
+
const chaStRaw = await this.readRegisterValue(baseAddr + 16, 1, 'uint16');
|
|
1047
|
+
const locRemCtlRaw = await this.readRegisterValue(baseAddr + 17, 1, 'uint16');
|
|
1048
|
+
const typRaw = await this.readRegisterValue(baseAddr + 21, 1, 'uint16');
|
|
1049
|
+
const stateRaw = await this.readRegisterValue(baseAddr + 22, 1, 'uint16');
|
|
1050
|
+
const evt1Raw = await this.readRegisterValue(baseAddr + 26, 2, 'uint32');
|
|
1051
|
+
const evt2Raw = await this.readRegisterValue(baseAddr + 28, 2, 'uint32');
|
|
1052
|
+
const evtVnd1Raw = await this.readRegisterValue(baseAddr + 30, 2, 'uint32');
|
|
1053
|
+
const evtVnd2Raw = await this.readRegisterValue(baseAddr + 32, 2, 'uint32');
|
|
1054
|
+
const vRaw = await this.readRegisterValue(baseAddr + 34, 1, 'uint16');
|
|
1055
|
+
const vMaxRaw = await this.readRegisterValue(baseAddr + 35, 1, 'uint16');
|
|
1056
|
+
const vMinRaw = await this.readRegisterValue(baseAddr + 36, 1, 'uint16');
|
|
1057
|
+
const cellVMaxRaw = await this.readRegisterValue(baseAddr + 37, 1, 'uint16');
|
|
1058
|
+
const cellVMaxStrRaw = await this.readRegisterValue(baseAddr + 38, 1, 'uint16');
|
|
1059
|
+
const cellVMaxModRaw = await this.readRegisterValue(baseAddr + 39, 1, 'uint16');
|
|
1060
|
+
const cellVMinRaw = await this.readRegisterValue(baseAddr + 40, 1, 'uint16');
|
|
1061
|
+
const cellVMinStrRaw = await this.readRegisterValue(baseAddr + 41, 1, 'uint16');
|
|
1062
|
+
const cellVMinModRaw = await this.readRegisterValue(baseAddr + 42, 1, 'uint16');
|
|
1063
|
+
const cellVAvgRaw = await this.readRegisterValue(baseAddr + 43, 1, 'uint16');
|
|
1064
|
+
const aRaw = await this.readRegisterValue(baseAddr + 44, 1, 'int16');
|
|
1065
|
+
const aChaMaxRaw = await this.readRegisterValue(baseAddr + 45, 1, 'uint16');
|
|
1066
|
+
const aDisChaMaxRaw = await this.readRegisterValue(baseAddr + 46, 1, 'uint16');
|
|
1067
|
+
const wRaw = await this.readRegisterValue(baseAddr + 47, 1, 'int16');
|
|
1068
|
+
const reqInvStateRaw = await this.readRegisterValue(baseAddr + 48, 1, 'uint16');
|
|
1069
|
+
const reqWRaw = await this.readRegisterValue(baseAddr + 49, 1, 'int16');
|
|
1070
|
+
const setOpRaw = await this.readRegisterValue(baseAddr + 50, 1, 'uint16');
|
|
1071
|
+
const setInvStateRaw = await this.readRegisterValue(baseAddr + 51, 1, 'uint16');
|
|
1072
|
+
// Map enum fields
|
|
1073
|
+
const chaStName = this.mapBatteryChargeState(chaStRaw);
|
|
1074
|
+
const typName = this.mapBatteryType(typRaw);
|
|
1075
|
+
const stateName = this.mapBatteryBankState(stateRaw);
|
|
1076
|
+
// Log non-scaled fields
|
|
1077
|
+
this.logRegisterRead(802, 14, 'nCyc', nCycRaw, 'uint32');
|
|
1078
|
+
this.logRegisterRead(802, 16, 'chaSt', chaStRaw, 'enum16');
|
|
1079
|
+
this.logRegisterRead(802, 17, 'locRemCtl', locRemCtlRaw, 'enum16');
|
|
1080
|
+
this.logRegisterRead(802, 21, 'typ', typRaw, 'enum16');
|
|
1081
|
+
this.logRegisterRead(802, 22, 'state', stateRaw, 'enum16');
|
|
1082
|
+
this.logRegisterRead(802, 26, 'evt1', evt1Raw, 'bitfield32');
|
|
1083
|
+
this.logRegisterRead(802, 28, 'evt2', evt2Raw, 'bitfield32');
|
|
1084
|
+
this.logRegisterRead(802, 30, 'evtVnd1', evtVnd1Raw, 'bitfield32');
|
|
1085
|
+
this.logRegisterRead(802, 32, 'evtVnd2', evtVnd2Raw, 'bitfield32');
|
|
1086
|
+
this.logRegisterRead(802, 38, 'cellVMaxStr', cellVMaxStrRaw, 'uint16');
|
|
1087
|
+
this.logRegisterRead(802, 39, 'cellVMaxMod', cellVMaxModRaw, 'uint16');
|
|
1088
|
+
this.logRegisterRead(802, 41, 'cellVMinStr', cellVMinStrRaw, 'uint16');
|
|
1089
|
+
this.logRegisterRead(802, 42, 'cellVMinMod', cellVMinModRaw, 'uint16');
|
|
1090
|
+
this.logRegisterRead(802, 48, 'reqInvState', reqInvStateRaw, 'enum16');
|
|
1091
|
+
this.logRegisterRead(802, 50, 'setOp', setOpRaw, 'enum16');
|
|
1092
|
+
this.logRegisterRead(802, 51, 'setInvState', setInvStateRaw, 'enum16');
|
|
1093
|
+
const data = {
|
|
1094
|
+
blockNumber: 802,
|
|
1095
|
+
blockAddress: model.address,
|
|
1096
|
+
blockLength: model.length,
|
|
1097
|
+
// Nameplate
|
|
1098
|
+
ahRtg: this.applyScaleFactor(ahRtgRaw, sf.AHRtg_SF, 'uint16', 'AH Rating', 2, 802),
|
|
1099
|
+
whRtg: this.applyScaleFactor(whRtgRaw, sf.WHRtg_SF, 'uint16', 'WH Rating', 3, 802),
|
|
1100
|
+
wChaRteMax: this.applyScaleFactor(wChaRteMaxRaw, sf.WChaDisChaMax_SF, 'uint16', 'Max Charge Rate', 4, 802),
|
|
1101
|
+
wDisChaRteMax: this.applyScaleFactor(wDisChaRteMaxRaw, sf.WChaDisChaMax_SF, 'uint16', 'Max Discharge Rate', 5, 802),
|
|
1102
|
+
// SoC/Health
|
|
1103
|
+
disChaRte: this.applyScaleFactor(disChaRteRaw, sf.DisChaRte_SF, 'uint16', 'Self Discharge Rate', 6, 802),
|
|
1104
|
+
soCMax: this.applyScaleFactor(soCMaxRaw, sf.SoC_SF, 'uint16', 'SoC Max', 7, 802),
|
|
1105
|
+
soCMin: this.applyScaleFactor(soCMinRaw, sf.SoC_SF, 'uint16', 'SoC Min', 8, 802),
|
|
1106
|
+
soCRsvMax: this.applyScaleFactor(soCRsvMaxRaw, sf.SoC_SF, 'uint16', 'SoC Reserve Max', 9, 802),
|
|
1107
|
+
soCRsvMin: this.applyScaleFactor(soCRsvMinRaw, sf.SoC_SF, 'uint16', 'SoC Reserve Min', 10, 802),
|
|
1108
|
+
soC: this.applyScaleFactor(soCRaw, sf.SoC_SF, 'uint16', 'State of Charge', 11, 802),
|
|
1109
|
+
doD: this.applyScaleFactor(doDRaw, sf.DoD_SF, 'uint16', 'Depth of Discharge', 12, 802),
|
|
1110
|
+
soH: this.applyScaleFactor(soHRaw, sf.SoH_SF, 'uint16', 'State of Health', 13, 802),
|
|
1111
|
+
// Status
|
|
1112
|
+
nCyc: !this.isUnimplementedValue(nCycRaw, 'uint32') ? nCycRaw : undefined,
|
|
1113
|
+
chaSt: !this.isUnimplementedValue(chaStRaw, 'enum16') ? chaStRaw : undefined,
|
|
1114
|
+
chaStName,
|
|
1115
|
+
locRemCtl: !this.isUnimplementedValue(locRemCtlRaw, 'enum16') ? locRemCtlRaw : undefined,
|
|
1116
|
+
typ: !this.isUnimplementedValue(typRaw, 'enum16') ? typRaw : undefined,
|
|
1117
|
+
typName,
|
|
1118
|
+
state: !this.isUnimplementedValue(stateRaw, 'enum16') ? stateRaw : undefined,
|
|
1119
|
+
stateName,
|
|
1120
|
+
// Events
|
|
1121
|
+
evt1: !this.isUnimplementedValue(evt1Raw, 'bitfield32') ? evt1Raw : undefined,
|
|
1122
|
+
evt2: !this.isUnimplementedValue(evt2Raw, 'bitfield32') ? evt2Raw : undefined,
|
|
1123
|
+
evtVnd1: !this.isUnimplementedValue(evtVnd1Raw, 'bitfield32') ? evtVnd1Raw : undefined,
|
|
1124
|
+
evtVnd2: !this.isUnimplementedValue(evtVnd2Raw, 'bitfield32') ? evtVnd2Raw : undefined,
|
|
1125
|
+
// Voltage
|
|
1126
|
+
v: this.applyScaleFactor(vRaw, sf.V_SF, 'uint16', 'Battery Voltage', 34, 802),
|
|
1127
|
+
vMax: this.applyScaleFactor(vMaxRaw, sf.V_SF, 'uint16', 'Max Battery Voltage', 35, 802),
|
|
1128
|
+
vMin: this.applyScaleFactor(vMinRaw, sf.V_SF, 'uint16', 'Min Battery Voltage', 36, 802),
|
|
1129
|
+
cellVMax: this.applyScaleFactor(cellVMaxRaw, sf.CellV_SF, 'uint16', 'Max Cell Voltage', 37, 802),
|
|
1130
|
+
cellVMaxStr: !this.isUnimplementedValue(cellVMaxStrRaw, 'uint16') ? cellVMaxStrRaw : undefined,
|
|
1131
|
+
cellVMaxMod: !this.isUnimplementedValue(cellVMaxModRaw, 'uint16') ? cellVMaxModRaw : undefined,
|
|
1132
|
+
cellVMin: this.applyScaleFactor(cellVMinRaw, sf.CellV_SF, 'uint16', 'Min Cell Voltage', 40, 802),
|
|
1133
|
+
cellVMinStr: !this.isUnimplementedValue(cellVMinStrRaw, 'uint16') ? cellVMinStrRaw : undefined,
|
|
1134
|
+
cellVMinMod: !this.isUnimplementedValue(cellVMinModRaw, 'uint16') ? cellVMinModRaw : undefined,
|
|
1135
|
+
cellVAvg: this.applyScaleFactor(cellVAvgRaw, sf.CellV_SF, 'uint16', 'Avg Cell Voltage', 43, 802),
|
|
1136
|
+
// Current
|
|
1137
|
+
a: this.applyScaleFactor(aRaw, sf.A_SF, 'int16', 'Battery Current', 44, 802),
|
|
1138
|
+
aChaMax: this.applyScaleFactor(aChaMaxRaw, sf.AMax_SF, 'uint16', 'Max Charge Current', 45, 802),
|
|
1139
|
+
aDisChaMax: this.applyScaleFactor(aDisChaMaxRaw, sf.AMax_SF, 'uint16', 'Max Discharge Current', 46, 802),
|
|
1140
|
+
// Power
|
|
1141
|
+
w: this.applyScaleFactor(wRaw, sf.W_SF, 'int16', 'Battery Power', 47, 802),
|
|
1142
|
+
reqInvState: !this.isUnimplementedValue(reqInvStateRaw, 'enum16') ? reqInvStateRaw : undefined,
|
|
1143
|
+
reqW: this.applyScaleFactor(reqWRaw, sf.W_SF, 'int16', 'Requested Power', 49, 802),
|
|
1144
|
+
setOp: !this.isUnimplementedValue(setOpRaw, 'enum16') ? setOpRaw : undefined,
|
|
1145
|
+
setInvState: !this.isUnimplementedValue(setInvStateRaw, 'enum16') ? setInvStateRaw : undefined,
|
|
1146
|
+
};
|
|
1147
|
+
return data;
|
|
1148
|
+
}
|
|
1149
|
+
catch (error) {
|
|
1150
|
+
console.error(`Error reading battery base data: ${error}`);
|
|
1151
|
+
return null;
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
906
1154
|
/**
|
|
907
1155
|
* Read battery data from Model 124 (Basic Storage Controls)
|
|
908
1156
|
*/
|
|
@@ -937,7 +1185,14 @@ class SunspecModbusClient {
|
|
|
937
1185
|
InBatV_SF: await this.readRegisterValue(baseAddr + 24, 1, 'int16'),
|
|
938
1186
|
InOutWRte_SF: await this.readRegisterValue(baseAddr + 25, 1, 'int16')
|
|
939
1187
|
};
|
|
940
|
-
|
|
1188
|
+
this.logRegisterRead(124, 18, 'WChaMax_SF', scaleFactors.WChaMax_SF, 'int16');
|
|
1189
|
+
this.logRegisterRead(124, 19, 'WChaDisChaGra_SF', scaleFactors.WChaDisChaGra_SF, 'int16');
|
|
1190
|
+
this.logRegisterRead(124, 20, 'VAChaMax_SF', scaleFactors.VAChaMax_SF, 'int16');
|
|
1191
|
+
this.logRegisterRead(124, 21, 'MinRsvPct_SF', scaleFactors.MinRsvPct_SF, 'int16');
|
|
1192
|
+
this.logRegisterRead(124, 22, 'ChaState_SF', scaleFactors.ChaState_SF, 'int16');
|
|
1193
|
+
this.logRegisterRead(124, 23, 'StorAval_SF', scaleFactors.StorAval_SF, 'int16');
|
|
1194
|
+
this.logRegisterRead(124, 24, 'InBatV_SF', scaleFactors.InBatV_SF, 'int16');
|
|
1195
|
+
this.logRegisterRead(124, 25, 'InOutWRte_SF', scaleFactors.InOutWRte_SF, 'int16');
|
|
941
1196
|
// Read raw values
|
|
942
1197
|
const wChaMaxRaw = await this.readRegisterValue(baseAddr + 2, 1, 'uint16');
|
|
943
1198
|
const wChaGraRaw = await this.readRegisterValue(baseAddr + 3, 1, 'uint16');
|
|
@@ -955,43 +1210,42 @@ class SunspecModbusClient {
|
|
|
955
1210
|
const inOutWRteRvrtTmsRaw = await this.readRegisterValue(baseAddr + 15, 1, 'uint16');
|
|
956
1211
|
const inOutWRteRmpTmsRaw = await this.readRegisterValue(baseAddr + 16, 1, 'uint16');
|
|
957
1212
|
const chaGriSetRaw = await this.readRegisterValue(baseAddr + 17, 1, 'uint16');
|
|
958
|
-
// Map charge state
|
|
1213
|
+
// Map charge state and log non-scaled fields
|
|
959
1214
|
const chaStName = this.mapBatteryChargeState(chaStRaw);
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
}
|
|
1215
|
+
this.logRegisterRead(124, 5, 'storCtlMod', storCtlModRaw, 'bitfield16');
|
|
1216
|
+
this.logRegisterRead(124, 11, 'chaSt', chaStRaw, 'enum16');
|
|
1217
|
+
this.logRegisterRead(124, 14, 'inOutWRteWinTms', inOutWRteWinTmsRaw, 'uint16');
|
|
1218
|
+
this.logRegisterRead(124, 15, 'inOutWRteRvrtTms', inOutWRteRvrtTmsRaw, 'uint16');
|
|
1219
|
+
this.logRegisterRead(124, 16, 'inOutWRteRmpTms', inOutWRteRmpTmsRaw, 'uint16');
|
|
1220
|
+
this.logRegisterRead(124, 17, 'chaGriSet', chaGriSetRaw, 'enum16');
|
|
967
1221
|
// Calculate actual values with scale factors
|
|
968
1222
|
const data = {
|
|
969
1223
|
blockNumber: 124,
|
|
970
1224
|
blockAddress: model.address,
|
|
971
1225
|
blockLength: model.length,
|
|
972
1226
|
// Control settings
|
|
973
|
-
wChaMax: this.applyScaleFactor(wChaMaxRaw, scaleFactors.WChaMax_SF, 'uint16', 'Max Charge Power'),
|
|
1227
|
+
wChaMax: this.applyScaleFactor(wChaMaxRaw, scaleFactors.WChaMax_SF, 'uint16', 'Max Charge Power', 2, 124),
|
|
974
1228
|
wChaMaxSF: scaleFactors.WChaMax_SF,
|
|
975
|
-
wChaGra: this.applyScaleFactor(wChaGraRaw, scaleFactors.WChaDisChaGra_SF, 'uint16', 'Charge Rate Gradient'),
|
|
976
|
-
wDisChaGra: this.applyScaleFactor(wDisChaGraRaw, scaleFactors.WChaDisChaGra_SF, 'uint16', 'Discharge Rate Gradient'),
|
|
1229
|
+
wChaGra: this.applyScaleFactor(wChaGraRaw, scaleFactors.WChaDisChaGra_SF, 'uint16', 'Charge Rate Gradient', 3, 124),
|
|
1230
|
+
wDisChaGra: this.applyScaleFactor(wDisChaGraRaw, scaleFactors.WChaDisChaGra_SF, 'uint16', 'Discharge Rate Gradient', 4, 124),
|
|
977
1231
|
wChaDisChaGraSF: scaleFactors.WChaDisChaGra_SF,
|
|
978
1232
|
storCtlMod: !this.isUnimplementedValue(storCtlModRaw, 'bitfield16') ? storCtlModRaw : undefined,
|
|
979
|
-
vaChaMax: this.applyScaleFactor(vaChaMaxRaw, scaleFactors.VAChaMax_SF, 'uint16', 'Max Charging VA'),
|
|
1233
|
+
vaChaMax: this.applyScaleFactor(vaChaMaxRaw, scaleFactors.VAChaMax_SF, 'uint16', 'Max Charging VA', 6, 124),
|
|
980
1234
|
vaChaMaxSF: scaleFactors.VAChaMax_SF,
|
|
981
|
-
minRsvPct: this.applyScaleFactor(minRsvPctRaw, scaleFactors.MinRsvPct_SF, 'uint16', 'Min Reserve Percent'),
|
|
1235
|
+
minRsvPct: this.applyScaleFactor(minRsvPctRaw, scaleFactors.MinRsvPct_SF, 'uint16', 'Min Reserve Percent', 7, 124),
|
|
982
1236
|
minRsvPctSF: scaleFactors.MinRsvPct_SF,
|
|
983
1237
|
// Status values
|
|
984
|
-
chaState: this.applyScaleFactor(chaStateRaw, scaleFactors.ChaState_SF, 'uint16', 'State of Charge'),
|
|
1238
|
+
chaState: this.applyScaleFactor(chaStateRaw, scaleFactors.ChaState_SF, 'uint16', 'State of Charge', 8, 124),
|
|
985
1239
|
chaStateSF: scaleFactors.ChaState_SF,
|
|
986
|
-
storAval: this.applyScaleFactor(storAvalRaw, scaleFactors.StorAval_SF, 'uint16', 'Available Storage'),
|
|
1240
|
+
storAval: this.applyScaleFactor(storAvalRaw, scaleFactors.StorAval_SF, 'uint16', 'Available Storage', 9, 124),
|
|
987
1241
|
storAvalSF: scaleFactors.StorAval_SF,
|
|
988
|
-
inBatV: this.applyScaleFactor(inBatVRaw, scaleFactors.InBatV_SF, 'uint16', 'Battery Voltage'),
|
|
1242
|
+
inBatV: this.applyScaleFactor(inBatVRaw, scaleFactors.InBatV_SF, 'uint16', 'Battery Voltage', 10, 124),
|
|
989
1243
|
inBatVSF: scaleFactors.InBatV_SF,
|
|
990
1244
|
chaSt: !this.isUnimplementedValue(chaStRaw, 'enum16') ? chaStRaw : undefined,
|
|
991
1245
|
chaStName: chaStName,
|
|
992
1246
|
// Rate control
|
|
993
|
-
outWRte: this.applyScaleFactor(outWRteRaw, scaleFactors.InOutWRte_SF, 'int16', 'Discharge Rate'),
|
|
994
|
-
inWRte: this.applyScaleFactor(inWRteRaw, scaleFactors.InOutWRte_SF, 'int16', 'Charge Rate'),
|
|
1247
|
+
outWRte: this.applyScaleFactor(outWRteRaw, scaleFactors.InOutWRte_SF, 'int16', 'Discharge Rate', 12, 124),
|
|
1248
|
+
inWRte: this.applyScaleFactor(inWRteRaw, scaleFactors.InOutWRte_SF, 'int16', 'Charge Rate', 13, 124),
|
|
995
1249
|
inOutWRteSF: scaleFactors.InOutWRte_SF,
|
|
996
1250
|
// Timing parameters
|
|
997
1251
|
inOutWRteWinTms: !this.isUnimplementedValue(inOutWRteWinTmsRaw, 'uint16') ? inOutWRteWinTmsRaw : undefined,
|
|
@@ -1016,8 +1270,43 @@ class SunspecModbusClient {
|
|
|
1016
1270
|
}
|
|
1017
1271
|
return data;
|
|
1018
1272
|
}
|
|
1273
|
+
else if (model.id === 802) {
|
|
1274
|
+
// Model 802: Battery Base
|
|
1275
|
+
console.log('Using Model 802 (Battery Base)');
|
|
1276
|
+
const baseData = await this.readBatteryBaseData();
|
|
1277
|
+
if (!baseData) {
|
|
1278
|
+
return null;
|
|
1279
|
+
}
|
|
1280
|
+
// Derive charge/discharge power from w field
|
|
1281
|
+
let chargePower;
|
|
1282
|
+
let dischargePower;
|
|
1283
|
+
if (baseData.w !== undefined) {
|
|
1284
|
+
if (baseData.w >= 0) {
|
|
1285
|
+
chargePower = baseData.w;
|
|
1286
|
+
dischargePower = 0;
|
|
1287
|
+
}
|
|
1288
|
+
else {
|
|
1289
|
+
chargePower = 0;
|
|
1290
|
+
dischargePower = Math.abs(baseData.w);
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
return {
|
|
1294
|
+
blockNumber: 802,
|
|
1295
|
+
blockAddress: model.address,
|
|
1296
|
+
blockLength: model.length,
|
|
1297
|
+
soc: baseData.soC,
|
|
1298
|
+
soh: baseData.soH,
|
|
1299
|
+
voltage: baseData.v,
|
|
1300
|
+
current: baseData.a,
|
|
1301
|
+
chaSt: baseData.chaSt,
|
|
1302
|
+
chaStName: baseData.chaStName,
|
|
1303
|
+
status: baseData.state,
|
|
1304
|
+
chargePower,
|
|
1305
|
+
dischargePower,
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1019
1308
|
else {
|
|
1020
|
-
// Handle other battery models (
|
|
1309
|
+
// Handle other battery models (803) if needed
|
|
1021
1310
|
console.log(`Battery Model ${model.id} reading not yet implemented`);
|
|
1022
1311
|
return {
|
|
1023
1312
|
blockNumber: model.id,
|
|
@@ -1148,6 +1437,9 @@ class SunspecModbusClient {
|
|
|
1148
1437
|
MinRsvPct_SF: await this.readRegisterValue(baseAddr + 21, 1, 'int16'),
|
|
1149
1438
|
InOutWRte_SF: await this.readRegisterValue(baseAddr + 25, 1, 'int16')
|
|
1150
1439
|
};
|
|
1440
|
+
this.logRegisterRead(124, 18, 'WChaMax_SF', scaleFactors.WChaMax_SF, 'int16');
|
|
1441
|
+
this.logRegisterRead(124, 21, 'MinRsvPct_SF', scaleFactors.MinRsvPct_SF, 'int16');
|
|
1442
|
+
this.logRegisterRead(124, 25, 'InOutWRte_SF', scaleFactors.InOutWRte_SF, 'int16');
|
|
1151
1443
|
// Read raw values
|
|
1152
1444
|
const wChaMaxRaw = await this.readRegisterValue(baseAddr + 2, 1, 'uint16');
|
|
1153
1445
|
const storCtlModRaw = await this.readRegisterValue(baseAddr + 5, 1, 'uint16');
|
|
@@ -1155,14 +1447,16 @@ class SunspecModbusClient {
|
|
|
1155
1447
|
const outWRteRaw = await this.readRegisterValue(baseAddr + 12, 1, 'int16');
|
|
1156
1448
|
const inWRteRaw = await this.readRegisterValue(baseAddr + 13, 1, 'int16');
|
|
1157
1449
|
const chaGriSetRaw = await this.readRegisterValue(baseAddr + 17, 1, 'uint16');
|
|
1450
|
+
this.logRegisterRead(124, 5, 'storCtlMod', storCtlModRaw, 'bitfield16');
|
|
1451
|
+
this.logRegisterRead(124, 17, 'chaGriSet', chaGriSetRaw, 'enum16');
|
|
1158
1452
|
// Apply scale factors and return control settings
|
|
1159
1453
|
return {
|
|
1160
1454
|
storCtlMod: !this.isUnimplementedValue(storCtlModRaw, 'bitfield16') ? storCtlModRaw : undefined,
|
|
1161
1455
|
chaGriSet: !this.isUnimplementedValue(chaGriSetRaw, 'enum16') ? chaGriSetRaw : undefined,
|
|
1162
|
-
wChaMax: this.applyScaleFactor(wChaMaxRaw, scaleFactors.WChaMax_SF, 'uint16'),
|
|
1163
|
-
inWRte: this.applyScaleFactor(inWRteRaw, scaleFactors.InOutWRte_SF, 'int16'),
|
|
1164
|
-
outWRte: this.applyScaleFactor(outWRteRaw, scaleFactors.InOutWRte_SF, 'int16'),
|
|
1165
|
-
minRsvPct: this.applyScaleFactor(minRsvPctRaw, scaleFactors.MinRsvPct_SF, 'uint16')
|
|
1456
|
+
wChaMax: this.applyScaleFactor(wChaMaxRaw, scaleFactors.WChaMax_SF, 'uint16', 'Max Charge Power', 2, 124),
|
|
1457
|
+
inWRte: this.applyScaleFactor(inWRteRaw, scaleFactors.InOutWRte_SF, 'int16', 'Charge Rate', 13, 124),
|
|
1458
|
+
outWRte: this.applyScaleFactor(outWRteRaw, scaleFactors.InOutWRte_SF, 'int16', 'Discharge Rate', 12, 124),
|
|
1459
|
+
minRsvPct: this.applyScaleFactor(minRsvPctRaw, scaleFactors.MinRsvPct_SF, 'uint16', 'Min Reserve Percent', 7, 124)
|
|
1166
1460
|
};
|
|
1167
1461
|
}
|
|
1168
1462
|
catch (error) {
|
|
@@ -1233,25 +1527,21 @@ class SunspecModbusClient {
|
|
|
1233
1527
|
const powerSF = await this.readRegisterValue(baseAddr + powerSFOffset, 1, 'int16');
|
|
1234
1528
|
const freqSF = await this.readRegisterValue(baseAddr + freqSFOffset, 1, 'int16');
|
|
1235
1529
|
const energySF = await this.readRegisterValue(baseAddr + energySFOffset, 1, 'int16');
|
|
1236
|
-
|
|
1530
|
+
this.logRegisterRead(model.id, powerSFOffset, 'W_SF', powerSF, 'int16');
|
|
1531
|
+
this.logRegisterRead(model.id, freqSFOffset, 'Hz_SF', freqSF, 'int16');
|
|
1532
|
+
this.logRegisterRead(model.id, energySFOffset, 'TotWh_SF', energySF, 'int16');
|
|
1237
1533
|
// Read raw values
|
|
1238
|
-
const
|
|
1239
|
-
const
|
|
1240
|
-
|
|
1241
|
-
const
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
const exportAddr = baseAddr + exportOffset;
|
|
1245
|
-
const exportRaw = await this.readRegisterValue(exportAddr, 2, 'uint32');
|
|
1246
|
-
console.log(`Meter Export Energy: address=${exportAddr}, raw=0x${exportRaw.toString(16).toUpperCase()} (${exportRaw}), SF=${energySF}`);
|
|
1247
|
-
const importAddr = baseAddr + importOffset;
|
|
1248
|
-
const importRaw = await this.readRegisterValue(importAddr, 2, 'uint32');
|
|
1249
|
-
console.log(`Meter Import Energy: address=${importAddr}, raw=0x${importRaw.toString(16).toUpperCase()} (${importRaw}), SF=${energySF}`);
|
|
1534
|
+
const powerRaw = await this.readRegisterValue(baseAddr + powerOffset, 1, 'int16');
|
|
1535
|
+
const freqRaw = await this.readRegisterValue(baseAddr + freqOffset, 1, 'uint16');
|
|
1536
|
+
const exportRaw = await this.readRegisterValue(baseAddr + exportOffset, 2, 'uint32');
|
|
1537
|
+
const importRaw = await this.readRegisterValue(baseAddr + importOffset, 2, 'uint32');
|
|
1538
|
+
this.logRegisterRead(model.id, exportOffset, 'TotWhExp', exportRaw, 'acc32');
|
|
1539
|
+
this.logRegisterRead(model.id, importOffset, 'TotWhImp', importRaw, 'acc32');
|
|
1250
1540
|
// Calculate final values with scale factors
|
|
1251
|
-
const totalPower = this.applyScaleFactor(powerRaw, powerSF, 'int16', '
|
|
1252
|
-
const frequency = this.applyScaleFactor(freqRaw, freqSF, 'uint16', '
|
|
1253
|
-
const exportedEnergy = this.applyScaleFactor(exportRaw, energySF, "acc32");
|
|
1254
|
-
const importedEnergy = this.applyScaleFactor(importRaw, energySF, "acc32");
|
|
1541
|
+
const totalPower = this.applyScaleFactor(powerRaw, powerSF, 'int16', 'Total Power', powerOffset, model.id);
|
|
1542
|
+
const frequency = this.applyScaleFactor(freqRaw, freqSF, 'uint16', 'Frequency', freqOffset, model.id);
|
|
1543
|
+
const exportedEnergy = this.applyScaleFactor(exportRaw, energySF, "acc32", 'Exported Energy', exportOffset, model.id);
|
|
1544
|
+
const importedEnergy = this.applyScaleFactor(importRaw, energySF, "acc32", 'Imported Energy', importOffset, model.id);
|
|
1255
1545
|
return {
|
|
1256
1546
|
blockNumber: model.id,
|
|
1257
1547
|
totalPower,
|
|
@@ -1285,30 +1575,26 @@ class SunspecModbusClient {
|
|
|
1285
1575
|
const versionAddr = baseAddr + 40; // Offset 40-47 (8 registers) from data start
|
|
1286
1576
|
const serialAddr = baseAddr + 48; // Offset 48-63 (16 registers) from data start
|
|
1287
1577
|
const deviceAddrAddr = baseAddr + 64; // Offset 64 from data start
|
|
1288
|
-
console.log(`Reading manufacturer from address ${manufacturerAddr} (16 registers)`);
|
|
1289
1578
|
const manufacturer = await this.readRegisterValue(manufacturerAddr, 16, 'string');
|
|
1290
|
-
|
|
1291
|
-
console.log(`Reading model from address ${modelAddr} (16 registers)`);
|
|
1579
|
+
this.logRegisterRead(1, 0, 'Manufacturer', manufacturer, 'string');
|
|
1292
1580
|
const modelName = await this.readRegisterValue(modelAddr, 16, 'string');
|
|
1293
|
-
|
|
1294
|
-
console.log(`Reading options from address ${optionsAddr} (8 registers)`);
|
|
1581
|
+
this.logRegisterRead(1, 16, 'Model', modelName, 'string');
|
|
1295
1582
|
const options = await this.readRegisterValue(optionsAddr, 8, 'string');
|
|
1296
|
-
|
|
1583
|
+
this.logRegisterRead(1, 32, 'Options', options, 'string');
|
|
1297
1584
|
const version = await this.readRegisterValue(versionAddr, 8, 'string');
|
|
1298
|
-
|
|
1585
|
+
this.logRegisterRead(1, 40, 'Version', version, 'string');
|
|
1299
1586
|
const serialNumber = await this.readRegisterValue(serialAddr, 16, 'string');
|
|
1300
|
-
|
|
1587
|
+
this.logRegisterRead(1, 48, 'Serial Number', serialNumber, 'string');
|
|
1301
1588
|
const deviceAddress = await this.readRegisterValue(deviceAddrAddr, 1, 'uint16');
|
|
1302
|
-
|
|
1303
|
-
|
|
1589
|
+
this.logRegisterRead(1, 64, 'Device Address', deviceAddress, 'uint16');
|
|
1590
|
+
return {
|
|
1591
|
+
manufacturer,
|
|
1304
1592
|
model: modelName,
|
|
1305
|
-
options
|
|
1306
|
-
version
|
|
1307
|
-
serialNumber
|
|
1308
|
-
deviceAddress
|
|
1593
|
+
options,
|
|
1594
|
+
version,
|
|
1595
|
+
serialNumber,
|
|
1596
|
+
deviceAddress
|
|
1309
1597
|
};
|
|
1310
|
-
console.log('Common Block Data:', JSON.stringify(result, null, 2));
|
|
1311
|
-
return result;
|
|
1312
1598
|
}
|
|
1313
1599
|
catch (error) {
|
|
1314
1600
|
console.error(`Error reading common block: ${error}`);
|
|
@@ -1364,47 +1650,64 @@ class SunspecModbusClient {
|
|
|
1364
1650
|
MaxRmpRte_SF: await this.readRegisterValue(baseAddr + 30, 1, 'int16'),
|
|
1365
1651
|
ECPNomHz_SF: await this.readRegisterValue(baseAddr + 31, 1, 'int16')
|
|
1366
1652
|
};
|
|
1653
|
+
this.logRegisterRead(121, 22, 'WMax_SF', scaleFactors.WMax_SF, 'int16');
|
|
1654
|
+
this.logRegisterRead(121, 23, 'VRef_SF', scaleFactors.VRef_SF, 'int16');
|
|
1655
|
+
this.logRegisterRead(121, 24, 'VRefOfs_SF', scaleFactors.VRefOfs_SF, 'int16');
|
|
1656
|
+
this.logRegisterRead(121, 25, 'VMinMax_SF', scaleFactors.VMinMax_SF, 'int16');
|
|
1657
|
+
this.logRegisterRead(121, 26, 'VAMax_SF', scaleFactors.VAMax_SF, 'int16');
|
|
1658
|
+
this.logRegisterRead(121, 27, 'VArMax_SF', scaleFactors.VArMax_SF, 'int16');
|
|
1659
|
+
this.logRegisterRead(121, 28, 'WGra_SF', scaleFactors.WGra_SF, 'int16');
|
|
1660
|
+
this.logRegisterRead(121, 29, 'PFMin_SF', scaleFactors.PFMin_SF, 'int16');
|
|
1661
|
+
this.logRegisterRead(121, 30, 'MaxRmpRte_SF', scaleFactors.MaxRmpRte_SF, 'int16');
|
|
1662
|
+
this.logRegisterRead(121, 31, 'ECPNomHz_SF', scaleFactors.ECPNomHz_SF, 'int16');
|
|
1663
|
+
// Read non-scaled fields first for logging
|
|
1664
|
+
const vArActRaw = await this.readRegisterValue(baseAddr + 17, 1, 'uint16');
|
|
1665
|
+
const clcTotVARaw = await this.readRegisterValue(baseAddr + 18, 1, 'uint16');
|
|
1666
|
+
const connPhRaw = await this.readRegisterValue(baseAddr + 21, 1, 'uint16');
|
|
1667
|
+
this.logRegisterRead(121, 17, 'VArAct', vArActRaw, 'enum16');
|
|
1668
|
+
this.logRegisterRead(121, 18, 'ClcTotVA', clcTotVARaw, 'enum16');
|
|
1669
|
+
this.logRegisterRead(121, 21, 'ConnPh', connPhRaw, 'enum16');
|
|
1367
1670
|
return {
|
|
1368
1671
|
blockNumber: 121,
|
|
1369
1672
|
blockAddress: model.address,
|
|
1370
1673
|
blockLength: model.length,
|
|
1371
1674
|
// Power settings - Offset 2
|
|
1372
|
-
WMax: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 2, 1, 'uint16'), scaleFactors.WMax_SF, 'uint16', 'Max Power'),
|
|
1675
|
+
WMax: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 2, 1, 'uint16'), scaleFactors.WMax_SF, 'uint16', 'Max Power', 2, 121),
|
|
1373
1676
|
WMax_SF: scaleFactors.WMax_SF,
|
|
1374
1677
|
// Voltage settings - Offsets 3-6
|
|
1375
|
-
VRef: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 3, 1, 'uint16'), scaleFactors.VRef_SF, 'uint16', 'Voltage Reference'),
|
|
1678
|
+
VRef: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 3, 1, 'uint16'), scaleFactors.VRef_SF, 'uint16', 'Voltage Reference', 3, 121),
|
|
1376
1679
|
VRef_SF: scaleFactors.VRef_SF,
|
|
1377
|
-
VRefOfs: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 4, 1, 'int16'), scaleFactors.VRefOfs_SF, 'int16', 'Voltage Reference Offset'),
|
|
1680
|
+
VRefOfs: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 4, 1, 'int16'), scaleFactors.VRefOfs_SF, 'int16', 'Voltage Reference Offset', 4, 121),
|
|
1378
1681
|
VRefOfs_SF: scaleFactors.VRefOfs_SF,
|
|
1379
|
-
VMax: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 5, 1, 'uint16'), scaleFactors.VMinMax_SF, 'uint16', 'Max Voltage'),
|
|
1380
|
-
VMin: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 6, 1, 'uint16'), scaleFactors.VMinMax_SF, 'uint16', 'Min Voltage'),
|
|
1682
|
+
VMax: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 5, 1, 'uint16'), scaleFactors.VMinMax_SF, 'uint16', 'Max Voltage', 5, 121),
|
|
1683
|
+
VMin: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 6, 1, 'uint16'), scaleFactors.VMinMax_SF, 'uint16', 'Min Voltage', 6, 121),
|
|
1381
1684
|
VMinMax_SF: scaleFactors.VMinMax_SF,
|
|
1382
1685
|
// Apparent power settings - Offset 7
|
|
1383
|
-
VAMax: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 7, 1, 'uint16'), scaleFactors.VAMax_SF, 'uint16', 'Max Apparent Power'),
|
|
1686
|
+
VAMax: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 7, 1, 'uint16'), scaleFactors.VAMax_SF, 'uint16', 'Max Apparent Power', 7, 121),
|
|
1384
1687
|
VAMax_SF: scaleFactors.VAMax_SF,
|
|
1385
1688
|
// Reactive power settings - Offsets 8-11
|
|
1386
|
-
VArMaxQ1: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 8, 1, 'int16'), scaleFactors.VArMax_SF, 'int16', 'Max Reactive Power Q1'),
|
|
1387
|
-
VArMaxQ2: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 9, 1, 'int16'), scaleFactors.VArMax_SF, 'int16', 'Max Reactive Power Q2'),
|
|
1388
|
-
VArMaxQ3: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 10, 1, 'int16'), scaleFactors.VArMax_SF, 'int16', 'Max Reactive Power Q3'),
|
|
1389
|
-
VArMaxQ4: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 11, 1, 'int16'), scaleFactors.VArMax_SF, 'int16', 'Max Reactive Power Q4'),
|
|
1689
|
+
VArMaxQ1: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 8, 1, 'int16'), scaleFactors.VArMax_SF, 'int16', 'Max Reactive Power Q1', 8, 121),
|
|
1690
|
+
VArMaxQ2: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 9, 1, 'int16'), scaleFactors.VArMax_SF, 'int16', 'Max Reactive Power Q2', 9, 121),
|
|
1691
|
+
VArMaxQ3: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 10, 1, 'int16'), scaleFactors.VArMax_SF, 'int16', 'Max Reactive Power Q3', 10, 121),
|
|
1692
|
+
VArMaxQ4: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 11, 1, 'int16'), scaleFactors.VArMax_SF, 'int16', 'Max Reactive Power Q4', 11, 121),
|
|
1390
1693
|
VArMax_SF: scaleFactors.VArMax_SF,
|
|
1391
1694
|
// Ramp rate settings - Offset 12
|
|
1392
|
-
WGra: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 12, 1, 'uint16'), scaleFactors.WGra_SF, 'uint16', 'Power Ramp Rate'),
|
|
1695
|
+
WGra: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 12, 1, 'uint16'), scaleFactors.WGra_SF, 'uint16', 'Power Ramp Rate', 12, 121),
|
|
1393
1696
|
WGra_SF: scaleFactors.WGra_SF,
|
|
1394
1697
|
// Power factor settings - Offsets 13-16
|
|
1395
|
-
PFMinQ1: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 13, 1, 'int16'), scaleFactors.PFMin_SF, 'int16', 'Min Power Factor Q1'),
|
|
1396
|
-
PFMinQ2: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 14, 1, 'int16'), scaleFactors.PFMin_SF, 'int16', 'Min Power Factor Q2'),
|
|
1397
|
-
PFMinQ3: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 15, 1, 'int16'), scaleFactors.PFMin_SF, 'int16', 'Min Power Factor Q3'),
|
|
1398
|
-
PFMinQ4: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 16, 1, 'int16'), scaleFactors.PFMin_SF, 'int16', 'Min Power Factor Q4'),
|
|
1698
|
+
PFMinQ1: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 13, 1, 'int16'), scaleFactors.PFMin_SF, 'int16', 'Min Power Factor Q1', 13, 121),
|
|
1699
|
+
PFMinQ2: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 14, 1, 'int16'), scaleFactors.PFMin_SF, 'int16', 'Min Power Factor Q2', 14, 121),
|
|
1700
|
+
PFMinQ3: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 15, 1, 'int16'), scaleFactors.PFMin_SF, 'int16', 'Min Power Factor Q3', 15, 121),
|
|
1701
|
+
PFMinQ4: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 16, 1, 'int16'), scaleFactors.PFMin_SF, 'int16', 'Min Power Factor Q4', 16, 121),
|
|
1399
1702
|
PFMin_SF: scaleFactors.PFMin_SF,
|
|
1400
1703
|
// Other settings - Offsets 17-21
|
|
1401
|
-
VArAct:
|
|
1402
|
-
ClcTotVA:
|
|
1403
|
-
MaxRmpRte: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 19, 1, 'uint16'), scaleFactors.MaxRmpRte_SF, 'uint16', 'Max Ramp Rate'),
|
|
1704
|
+
VArAct: vArActRaw,
|
|
1705
|
+
ClcTotVA: clcTotVARaw,
|
|
1706
|
+
MaxRmpRte: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 19, 1, 'uint16'), scaleFactors.MaxRmpRte_SF, 'uint16', 'Max Ramp Rate', 19, 121),
|
|
1404
1707
|
MaxRmpRte_SF: scaleFactors.MaxRmpRte_SF,
|
|
1405
|
-
ECPNomHz: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 20, 1, 'uint16'), scaleFactors.ECPNomHz_SF, 'uint16', 'Nominal Frequency'),
|
|
1708
|
+
ECPNomHz: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 20, 1, 'uint16'), scaleFactors.ECPNomHz_SF, 'uint16', 'Nominal Frequency', 20, 121),
|
|
1406
1709
|
ECPNomHz_SF: scaleFactors.ECPNomHz_SF,
|
|
1407
|
-
ConnPh:
|
|
1710
|
+
ConnPh: connPhRaw
|
|
1408
1711
|
};
|
|
1409
1712
|
}
|
|
1410
1713
|
catch (error) {
|
|
@@ -1429,38 +1732,74 @@ class SunspecModbusClient {
|
|
|
1429
1732
|
OutPFSet_SF: await this.readRegisterValue(baseAddr + 22, 1, 'int16'),
|
|
1430
1733
|
VArPct_SF: await this.readRegisterValue(baseAddr + 23, 1, 'int16')
|
|
1431
1734
|
};
|
|
1735
|
+
this.logRegisterRead(123, 21, 'WMaxLimPct_SF', scaleFactors.WMaxLimPct_SF, 'int16');
|
|
1736
|
+
this.logRegisterRead(123, 22, 'OutPFSet_SF', scaleFactors.OutPFSet_SF, 'int16');
|
|
1737
|
+
this.logRegisterRead(123, 23, 'VArPct_SF', scaleFactors.VArPct_SF, 'int16');
|
|
1738
|
+
// Read non-scaled fields
|
|
1739
|
+
const connWinTmsRaw = await this.readRegisterValue(baseAddr, 1, 'uint16');
|
|
1740
|
+
const connRvrtTmsRaw = await this.readRegisterValue(baseAddr + 1, 1, 'uint16');
|
|
1741
|
+
const connRaw = await this.readRegisterValue(baseAddr + 2, 1, 'uint16');
|
|
1742
|
+
const wMaxLimPctWinTmsRaw = await this.readRegisterValue(baseAddr + 4, 1, 'uint16');
|
|
1743
|
+
const wMaxLimPctRvrtTmsRaw = await this.readRegisterValue(baseAddr + 5, 1, 'uint16');
|
|
1744
|
+
const wMaxLimPctRmpTmsRaw = await this.readRegisterValue(baseAddr + 6, 1, 'uint16');
|
|
1745
|
+
const wMaxLimEnaRaw = await this.readRegisterValue(baseAddr + 7, 1, 'uint16');
|
|
1746
|
+
const outPFSetWinTmsRaw = await this.readRegisterValue(baseAddr + 9, 1, 'uint16');
|
|
1747
|
+
const outPFSetRvrtTmsRaw = await this.readRegisterValue(baseAddr + 10, 1, 'uint16');
|
|
1748
|
+
const outPFSetRmpTmsRaw = await this.readRegisterValue(baseAddr + 11, 1, 'uint16');
|
|
1749
|
+
const outPFSetEnaRaw = await this.readRegisterValue(baseAddr + 12, 1, 'uint16');
|
|
1750
|
+
const vArPctWinTmsRaw = await this.readRegisterValue(baseAddr + 16, 1, 'uint16');
|
|
1751
|
+
const vArPctRvrtTmsRaw = await this.readRegisterValue(baseAddr + 17, 1, 'uint16');
|
|
1752
|
+
const vArPctRmpTmsRaw = await this.readRegisterValue(baseAddr + 18, 1, 'uint16');
|
|
1753
|
+
const vArPctModRaw = await this.readRegisterValue(baseAddr + 19, 1, 'uint16');
|
|
1754
|
+
const vArPctEnaRaw = await this.readRegisterValue(baseAddr + 20, 1, 'uint16');
|
|
1755
|
+
this.logRegisterRead(123, 0, 'Conn_WinTms', connWinTmsRaw, 'uint16');
|
|
1756
|
+
this.logRegisterRead(123, 1, 'Conn_RvrtTms', connRvrtTmsRaw, 'uint16');
|
|
1757
|
+
this.logRegisterRead(123, 2, 'Conn', connRaw, 'enum16');
|
|
1758
|
+
this.logRegisterRead(123, 4, 'WMaxLimPct_WinTms', wMaxLimPctWinTmsRaw, 'uint16');
|
|
1759
|
+
this.logRegisterRead(123, 5, 'WMaxLimPct_RvrtTms', wMaxLimPctRvrtTmsRaw, 'uint16');
|
|
1760
|
+
this.logRegisterRead(123, 6, 'WMaxLimPct_RmpTms', wMaxLimPctRmpTmsRaw, 'uint16');
|
|
1761
|
+
this.logRegisterRead(123, 7, 'WMaxLim_Ena', wMaxLimEnaRaw, 'enum16');
|
|
1762
|
+
this.logRegisterRead(123, 9, 'OutPFSet_WinTms', outPFSetWinTmsRaw, 'uint16');
|
|
1763
|
+
this.logRegisterRead(123, 10, 'OutPFSet_RvrtTms', outPFSetRvrtTmsRaw, 'uint16');
|
|
1764
|
+
this.logRegisterRead(123, 11, 'OutPFSet_RmpTms', outPFSetRmpTmsRaw, 'uint16');
|
|
1765
|
+
this.logRegisterRead(123, 12, 'OutPFSet_Ena', outPFSetEnaRaw, 'enum16');
|
|
1766
|
+
this.logRegisterRead(123, 16, 'VArPct_WinTms', vArPctWinTmsRaw, 'uint16');
|
|
1767
|
+
this.logRegisterRead(123, 17, 'VArPct_RvrtTms', vArPctRvrtTmsRaw, 'uint16');
|
|
1768
|
+
this.logRegisterRead(123, 18, 'VArPct_RmpTms', vArPctRmpTmsRaw, 'uint16');
|
|
1769
|
+
this.logRegisterRead(123, 19, 'VArPct_Mod', vArPctModRaw, 'enum16');
|
|
1770
|
+
this.logRegisterRead(123, 20, 'VArPct_Ena', vArPctEnaRaw, 'enum16');
|
|
1432
1771
|
const controls = {
|
|
1433
1772
|
blockNumber: 123,
|
|
1434
1773
|
blockAddress: model.address,
|
|
1435
1774
|
blockLength: model.length,
|
|
1436
1775
|
// Connection control - Offsets 0-2
|
|
1437
|
-
Conn_WinTms:
|
|
1438
|
-
Conn_RvrtTms:
|
|
1439
|
-
Conn:
|
|
1776
|
+
Conn_WinTms: connWinTmsRaw,
|
|
1777
|
+
Conn_RvrtTms: connRvrtTmsRaw,
|
|
1778
|
+
Conn: connRaw,
|
|
1440
1779
|
// Power limit control - Offsets 3-7
|
|
1441
|
-
WMaxLimPct: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 3, 1, 'uint16'), scaleFactors.WMaxLimPct_SF, 'uint16', 'Power Limit Percentage'),
|
|
1780
|
+
WMaxLimPct: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 3, 1, 'uint16'), scaleFactors.WMaxLimPct_SF, 'uint16', 'Power Limit Percentage', 3, 123),
|
|
1442
1781
|
WMaxLimPct_SF: scaleFactors.WMaxLimPct_SF,
|
|
1443
|
-
WMaxLimPct_WinTms:
|
|
1444
|
-
WMaxLimPct_RvrtTms:
|
|
1445
|
-
WMaxLimPct_RmpTms:
|
|
1446
|
-
WMaxLim_Ena:
|
|
1782
|
+
WMaxLimPct_WinTms: wMaxLimPctWinTmsRaw,
|
|
1783
|
+
WMaxLimPct_RvrtTms: wMaxLimPctRvrtTmsRaw,
|
|
1784
|
+
WMaxLimPct_RmpTms: wMaxLimPctRmpTmsRaw,
|
|
1785
|
+
WMaxLim_Ena: wMaxLimEnaRaw,
|
|
1447
1786
|
// Power factor control - Offsets 8-12
|
|
1448
|
-
OutPFSet: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 8, 1, 'int16'), scaleFactors.OutPFSet_SF, 'int16', 'Output Power Factor Set'),
|
|
1787
|
+
OutPFSet: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 8, 1, 'int16'), scaleFactors.OutPFSet_SF, 'int16', 'Output Power Factor Set', 8, 123),
|
|
1449
1788
|
OutPFSet_SF: scaleFactors.OutPFSet_SF,
|
|
1450
|
-
OutPFSet_WinTms:
|
|
1451
|
-
OutPFSet_RvrtTms:
|
|
1452
|
-
OutPFSet_RmpTms:
|
|
1453
|
-
OutPFSet_Ena:
|
|
1789
|
+
OutPFSet_WinTms: outPFSetWinTmsRaw,
|
|
1790
|
+
OutPFSet_RvrtTms: outPFSetRvrtTmsRaw,
|
|
1791
|
+
OutPFSet_RmpTms: outPFSetRmpTmsRaw,
|
|
1792
|
+
OutPFSet_Ena: outPFSetEnaRaw,
|
|
1454
1793
|
// Reactive power control - Offsets 13-20
|
|
1455
|
-
VArWMaxPct: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 13, 1, 'int16'), scaleFactors.VArPct_SF, 'int16', 'Reactive Power at Max Power %'),
|
|
1456
|
-
VArMaxPct: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 14, 1, 'int16'), scaleFactors.VArPct_SF, 'int16', 'Max Reactive Power %'),
|
|
1457
|
-
VArAvalPct: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 15, 1, 'int16'), scaleFactors.VArPct_SF, 'int16', 'Available Reactive Power %'),
|
|
1794
|
+
VArWMaxPct: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 13, 1, 'int16'), scaleFactors.VArPct_SF, 'int16', 'Reactive Power at Max Power %', 13, 123),
|
|
1795
|
+
VArMaxPct: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 14, 1, 'int16'), scaleFactors.VArPct_SF, 'int16', 'Max Reactive Power %', 14, 123),
|
|
1796
|
+
VArAvalPct: this.applyScaleFactor(await this.readRegisterValue(baseAddr + 15, 1, 'int16'), scaleFactors.VArPct_SF, 'int16', 'Available Reactive Power %', 15, 123),
|
|
1458
1797
|
VArPct_SF: scaleFactors.VArPct_SF,
|
|
1459
|
-
VArPct_WinTms:
|
|
1460
|
-
VArPct_RvrtTms:
|
|
1461
|
-
VArPct_RmpTms:
|
|
1462
|
-
VArPct_Mod:
|
|
1463
|
-
VArPct_Ena:
|
|
1798
|
+
VArPct_WinTms: vArPctWinTmsRaw,
|
|
1799
|
+
VArPct_RvrtTms: vArPctRvrtTmsRaw,
|
|
1800
|
+
VArPct_RmpTms: vArPctRmpTmsRaw,
|
|
1801
|
+
VArPct_Mod: vArPctModRaw,
|
|
1802
|
+
VArPct_Ena: vArPctEnaRaw
|
|
1464
1803
|
};
|
|
1465
1804
|
return controls;
|
|
1466
1805
|
}
|