@enyo-energy/sunspec-sdk 0.0.8 → 0.0.9
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-modbus-client.cjs +53 -13
- package/dist/cjs/version.cjs +1 -1
- package/dist/cjs/version.d.cts +1 -1
- package/dist/sunspec-modbus-client.js +53 -13
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -286,7 +286,7 @@ class SunspecModbusClient {
|
|
|
286
286
|
const baseAddr = model.address + 2; // Skip ID and Length
|
|
287
287
|
try {
|
|
288
288
|
// Read all scale factors first using fault-tolerant reader
|
|
289
|
-
console.log(`Reading Inverter Data from Model
|
|
289
|
+
console.log(`Reading Inverter Data from Model ${model.id} at base address: ${baseAddr}`);
|
|
290
290
|
const scaleFactors = await this.readInverterScaleFactors(baseAddr);
|
|
291
291
|
// Read values using fault-tolerant reader with proper data types
|
|
292
292
|
// Read raw voltage values to check for unimplemented phases
|
|
@@ -611,17 +611,57 @@ class SunspecModbusClient {
|
|
|
611
611
|
const baseAddr = model.address + 2;
|
|
612
612
|
console.log(`Reading Meter Data from Model ${model.id} at base address: ${baseAddr}`);
|
|
613
613
|
try {
|
|
614
|
-
//
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
614
|
+
// Different meter models have different register offsets
|
|
615
|
+
console.log(`Meter is Model ${model.id}`);
|
|
616
|
+
let powerOffset;
|
|
617
|
+
let powerSFOffset;
|
|
618
|
+
let freqOffset;
|
|
619
|
+
let freqSFOffset;
|
|
620
|
+
let exportOffset;
|
|
621
|
+
let importOffset;
|
|
622
|
+
let energySFOffset;
|
|
623
|
+
switch (model.id) {
|
|
624
|
+
case 201: // Single-phase meter
|
|
625
|
+
console.log('Using Model 201 (Single-Phase Meter) offsets');
|
|
626
|
+
powerOffset = 18; // W - Total Real Power (int16)
|
|
627
|
+
powerSFOffset = 21; // W_SF - Power scale factor
|
|
628
|
+
freqOffset = 32; // Hz - Frequency (uint16)
|
|
629
|
+
freqSFOffset = 35; // Hz_SF - Frequency scale factor
|
|
630
|
+
exportOffset = 38; // TotWhExp - Total Wh Exported (acc32)
|
|
631
|
+
importOffset = 46; // TotWhImp - Total Wh Imported (acc32)
|
|
632
|
+
energySFOffset = 4; // TotWh_SF - Total Energy scale factor
|
|
633
|
+
break;
|
|
634
|
+
case 203: // 3-phase meter (Delta)
|
|
635
|
+
console.log('Using Model 203 (3-Phase Meter Delta) offsets');
|
|
636
|
+
powerOffset = 14; // W - Total Real Power (int16)
|
|
637
|
+
powerSFOffset = 17; // W_SF - Power scale factor
|
|
638
|
+
freqOffset = 24; // Hz - Frequency (uint16)
|
|
639
|
+
freqSFOffset = 27; // Hz_SF - Frequency scale factor
|
|
640
|
+
exportOffset = 38; // TotWhExp - Total Wh Exported (acc32)
|
|
641
|
+
importOffset = 46; // TotWhImp - Total Wh Imported (acc32)
|
|
642
|
+
energySFOffset = 4; // TotWh_SF - Total Energy scale factor
|
|
643
|
+
break;
|
|
644
|
+
case 204: // 3-phase meter (Wye)
|
|
645
|
+
console.log('Using Model 204 (3-Phase Meter Wye) offsets');
|
|
646
|
+
powerOffset = 14; // W - Total Real Power (int16)
|
|
647
|
+
powerSFOffset = 17; // W_SF - Power scale factor
|
|
648
|
+
freqOffset = 28; // Hz - Frequency (uint16)
|
|
649
|
+
freqSFOffset = 31; // Hz_SF - Frequency scale factor
|
|
650
|
+
exportOffset = 42; // TotWhExp - Total Wh Exported (acc32)
|
|
651
|
+
importOffset = 50; // TotWhImp - Total Wh Imported (acc32)
|
|
652
|
+
energySFOffset = 4; // TotWh_SF - Total Energy scale factor
|
|
653
|
+
break;
|
|
654
|
+
default:
|
|
655
|
+
console.error(`Unknown meter model ${model.id}, using Model 201 defaults`);
|
|
656
|
+
powerOffset = 18;
|
|
657
|
+
powerSFOffset = 21;
|
|
658
|
+
freqOffset = 32;
|
|
659
|
+
freqSFOffset = 35;
|
|
660
|
+
exportOffset = 38;
|
|
661
|
+
importOffset = 46;
|
|
662
|
+
energySFOffset = 4;
|
|
663
|
+
break;
|
|
664
|
+
}
|
|
625
665
|
// Read scale factors
|
|
626
666
|
const powerSF = await this.readRegisterValue(baseAddr + powerSFOffset, 1, 'int16');
|
|
627
667
|
const freqSF = await this.readRegisterValue(baseAddr + freqSFOffset, 1, 'int16');
|
|
@@ -838,7 +878,7 @@ class SunspecModbusClient {
|
|
|
838
878
|
blockAddress: model.address,
|
|
839
879
|
blockLength: model.length,
|
|
840
880
|
// Connection control - Offsets 0-2
|
|
841
|
-
Conn_WinTms: await this.readRegisterValue(baseAddr
|
|
881
|
+
Conn_WinTms: await this.readRegisterValue(baseAddr, 1, 'uint16'),
|
|
842
882
|
Conn_RvrtTms: await this.readRegisterValue(baseAddr + 1, 1, 'uint16'),
|
|
843
883
|
Conn: await this.readRegisterValue(baseAddr + 2, 1, 'uint16'),
|
|
844
884
|
// Power limit control - Offsets 3-7
|
package/dist/cjs/version.cjs
CHANGED
package/dist/cjs/version.d.cts
CHANGED
|
@@ -283,7 +283,7 @@ export class SunspecModbusClient {
|
|
|
283
283
|
const baseAddr = model.address + 2; // Skip ID and Length
|
|
284
284
|
try {
|
|
285
285
|
// Read all scale factors first using fault-tolerant reader
|
|
286
|
-
console.log(`Reading Inverter Data from Model
|
|
286
|
+
console.log(`Reading Inverter Data from Model ${model.id} at base address: ${baseAddr}`);
|
|
287
287
|
const scaleFactors = await this.readInverterScaleFactors(baseAddr);
|
|
288
288
|
// Read values using fault-tolerant reader with proper data types
|
|
289
289
|
// Read raw voltage values to check for unimplemented phases
|
|
@@ -608,17 +608,57 @@ export class SunspecModbusClient {
|
|
|
608
608
|
const baseAddr = model.address + 2;
|
|
609
609
|
console.log(`Reading Meter Data from Model ${model.id} at base address: ${baseAddr}`);
|
|
610
610
|
try {
|
|
611
|
-
//
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
611
|
+
// Different meter models have different register offsets
|
|
612
|
+
console.log(`Meter is Model ${model.id}`);
|
|
613
|
+
let powerOffset;
|
|
614
|
+
let powerSFOffset;
|
|
615
|
+
let freqOffset;
|
|
616
|
+
let freqSFOffset;
|
|
617
|
+
let exportOffset;
|
|
618
|
+
let importOffset;
|
|
619
|
+
let energySFOffset;
|
|
620
|
+
switch (model.id) {
|
|
621
|
+
case 201: // Single-phase meter
|
|
622
|
+
console.log('Using Model 201 (Single-Phase Meter) offsets');
|
|
623
|
+
powerOffset = 18; // W - Total Real Power (int16)
|
|
624
|
+
powerSFOffset = 21; // W_SF - Power scale factor
|
|
625
|
+
freqOffset = 32; // Hz - Frequency (uint16)
|
|
626
|
+
freqSFOffset = 35; // Hz_SF - Frequency scale factor
|
|
627
|
+
exportOffset = 38; // TotWhExp - Total Wh Exported (acc32)
|
|
628
|
+
importOffset = 46; // TotWhImp - Total Wh Imported (acc32)
|
|
629
|
+
energySFOffset = 4; // TotWh_SF - Total Energy scale factor
|
|
630
|
+
break;
|
|
631
|
+
case 203: // 3-phase meter (Delta)
|
|
632
|
+
console.log('Using Model 203 (3-Phase Meter Delta) offsets');
|
|
633
|
+
powerOffset = 14; // W - Total Real Power (int16)
|
|
634
|
+
powerSFOffset = 17; // W_SF - Power scale factor
|
|
635
|
+
freqOffset = 24; // Hz - Frequency (uint16)
|
|
636
|
+
freqSFOffset = 27; // Hz_SF - Frequency scale factor
|
|
637
|
+
exportOffset = 38; // TotWhExp - Total Wh Exported (acc32)
|
|
638
|
+
importOffset = 46; // TotWhImp - Total Wh Imported (acc32)
|
|
639
|
+
energySFOffset = 4; // TotWh_SF - Total Energy scale factor
|
|
640
|
+
break;
|
|
641
|
+
case 204: // 3-phase meter (Wye)
|
|
642
|
+
console.log('Using Model 204 (3-Phase Meter Wye) offsets');
|
|
643
|
+
powerOffset = 14; // W - Total Real Power (int16)
|
|
644
|
+
powerSFOffset = 17; // W_SF - Power scale factor
|
|
645
|
+
freqOffset = 28; // Hz - Frequency (uint16)
|
|
646
|
+
freqSFOffset = 31; // Hz_SF - Frequency scale factor
|
|
647
|
+
exportOffset = 42; // TotWhExp - Total Wh Exported (acc32)
|
|
648
|
+
importOffset = 50; // TotWhImp - Total Wh Imported (acc32)
|
|
649
|
+
energySFOffset = 4; // TotWh_SF - Total Energy scale factor
|
|
650
|
+
break;
|
|
651
|
+
default:
|
|
652
|
+
console.error(`Unknown meter model ${model.id}, using Model 201 defaults`);
|
|
653
|
+
powerOffset = 18;
|
|
654
|
+
powerSFOffset = 21;
|
|
655
|
+
freqOffset = 32;
|
|
656
|
+
freqSFOffset = 35;
|
|
657
|
+
exportOffset = 38;
|
|
658
|
+
importOffset = 46;
|
|
659
|
+
energySFOffset = 4;
|
|
660
|
+
break;
|
|
661
|
+
}
|
|
622
662
|
// Read scale factors
|
|
623
663
|
const powerSF = await this.readRegisterValue(baseAddr + powerSFOffset, 1, 'int16');
|
|
624
664
|
const freqSF = await this.readRegisterValue(baseAddr + freqSFOffset, 1, 'int16');
|
|
@@ -835,7 +875,7 @@ export class SunspecModbusClient {
|
|
|
835
875
|
blockAddress: model.address,
|
|
836
876
|
blockLength: model.length,
|
|
837
877
|
// Connection control - Offsets 0-2
|
|
838
|
-
Conn_WinTms: await this.readRegisterValue(baseAddr
|
|
878
|
+
Conn_WinTms: await this.readRegisterValue(baseAddr, 1, 'uint16'),
|
|
839
879
|
Conn_RvrtTms: await this.readRegisterValue(baseAddr + 1, 1, 'uint16'),
|
|
840
880
|
Conn: await this.readRegisterValue(baseAddr + 2, 1, 'uint16'),
|
|
841
881
|
// Power limit control - Offsets 3-7
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED