@ya-modbus/driver-sdm630 0.0.0-stage → 0.0.0

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/README.md CHANGED
@@ -1,3 +1,153 @@
1
- # Temporary Holding Version
1
+ # @ya-modbus/driver-sdm630
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Eastron SDM630 3-phase energy meter driver for ya-modbus.
4
+
5
+ ## Device Information
6
+
7
+ - **Manufacturer**: Eastron
8
+ - **Model**: SDM630 (3 phases + N, DIN rail, RS-485)
9
+ - **Communication**: Modbus RTU, input registers (function code 04), float32 big-endian, 2 registers per value
10
+ - **Default Settings**:
11
+ - Address: 1
12
+ - Baud rate: 9600
13
+ - Parity: None
14
+ - Stop bits: 1
15
+ - Data bits: 8
16
+ - **Supported Settings**: baud rate 2400, 4800, 9600, 19200 or 38400; no parity with 1 or 2 stop bits, or even/odd parity with 1 stop bit; address 1 to 247
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install @ya-modbus/driver-sdm630
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ```typescript
27
+ import { createDriver, DEFAULT_CONFIG } from '@ya-modbus/driver-sdm630'
28
+ import { createRTUTransport } from '@ya-modbus/transport'
29
+
30
+ const transport = await createRTUTransport({
31
+ port: '/dev/ttyUSB0',
32
+ baudRate: DEFAULT_CONFIG.baudRate,
33
+ parity: DEFAULT_CONFIG.parity,
34
+ dataBits: DEFAULT_CONFIG.dataBits,
35
+ stopBits: DEFAULT_CONFIG.stopBits,
36
+ slaveId: DEFAULT_CONFIG.defaultAddress,
37
+ })
38
+
39
+ const driver = await createDriver({ transport, slaveId: DEFAULT_CONFIG.defaultAddress })
40
+
41
+ const values = await driver.readDataPoints(['voltage_l1', 'active_power_total', 'frequency'])
42
+ console.log(values)
43
+ ```
44
+
45
+ ## Data Points
46
+
47
+ All data points are read-only and are read on every poll. Where the unit column has `-`, the value has no unit or `driver-types` has no unit for it: phase angles are in degrees and total apparent energy is in kVAh.
48
+
49
+ | ID | Register | Unit | Description |
50
+ | ---------------------------- | -------- | ----- | ------------------------------------------------------------------------------ |
51
+ | `voltage_l1` | 0x00 | V | L1 voltage |
52
+ | `voltage_l2` | 0x02 | V | L2 voltage |
53
+ | `voltage_l3` | 0x04 | V | L3 voltage |
54
+ | `current_l1` | 0x06 | A | L1 current |
55
+ | `current_l2` | 0x08 | A | L2 current |
56
+ | `current_l3` | 0x0A | A | L3 current |
57
+ | `active_power_l1` | 0x0C | W | L1 active power |
58
+ | `active_power_l2` | 0x0E | W | L2 active power |
59
+ | `active_power_l3` | 0x10 | W | L3 active power |
60
+ | `apparent_power_l1` | 0x12 | VA | L1 apparent power |
61
+ | `apparent_power_l2` | 0x14 | VA | L2 apparent power |
62
+ | `apparent_power_l3` | 0x16 | VA | L3 apparent power |
63
+ | `reactive_power_l1` | 0x18 | VAr | L1 reactive power |
64
+ | `reactive_power_l2` | 0x1A | VAr | L2 reactive power |
65
+ | `reactive_power_l3` | 0x1C | VAr | L3 reactive power |
66
+ | `power_factor_l1` | 0x1E | - | L1 power factor |
67
+ | `power_factor_l2` | 0x20 | - | L2 power factor |
68
+ | `power_factor_l3` | 0x22 | - | L3 power factor |
69
+ | `phase_angle_l1` | 0x24 | - | L1 phase angle (degrees) |
70
+ | `phase_angle_l2` | 0x26 | - | L2 phase angle (degrees) |
71
+ | `phase_angle_l3` | 0x28 | - | L3 phase angle (degrees) |
72
+ | `voltage_ln_average` | 0x2A | V | Average L-N Voltage |
73
+ | `current_average` | 0x2E | A | Average Line Current |
74
+ | `current_sum` | 0x30 | A | Sum of Line Currents |
75
+ | `active_power_total` | 0x34 | W | Total Active Power |
76
+ | `apparent_power_total` | 0x38 | VA | Total Apparent Power |
77
+ | `reactive_power_total` | 0x3C | VAr | Total Reactive Power |
78
+ | `power_factor_total` | 0x3E | - | Total Power Factor |
79
+ | `phase_angle_total` | 0x42 | - | Total phase angle (degrees) |
80
+ | `frequency` | 0x46 | Hz | Grid Frequency |
81
+ | `active_energy_forward` | 0x48 | kWh | Import Active Energy |
82
+ | `active_energy_reverse` | 0x4A | kWh | Export Active Energy |
83
+ | `reactive_energy_forward` | 0x4C | kVArh | Import Reactive Energy |
84
+ | `reactive_energy_reverse` | 0x4E | kVArh | Export Reactive Energy |
85
+ | `apparent_energy_total` | 0x50 | - | Total apparent energy (kVAh) |
86
+ | `charge_total` | 0x52 | Ah | Total Charge |
87
+ | `active_power_demand` | 0x54 | W | Total Active Power Demand |
88
+ | `active_power_demand_max` | 0x56 | W | Maximum total active power demand (the manual says VA, the real meter gives W) |
89
+ | `apparent_power_demand` | 0x64 | VA | Total Apparent Power Demand |
90
+ | `apparent_power_demand_max` | 0x66 | VA | Maximum Apparent Power Demand |
91
+ | `voltage_l1_l2` | 0xC8 | V | L1-L2 voltage |
92
+ | `voltage_l2_l3` | 0xCA | V | L2-L3 voltage |
93
+ | `voltage_l3_l1` | 0xCC | V | L3-L1 voltage |
94
+ | `voltage_ll_average` | 0xCE | V | Average L-L Voltage |
95
+ | `current_neutral` | 0xE0 | A | Neutral Current |
96
+ | `voltage_thd_l1` | 0xEA | % | L1 voltage thd |
97
+ | `voltage_thd_l2` | 0xEC | % | L2 voltage thd |
98
+ | `voltage_thd_l3` | 0xEE | % | L3 voltage thd |
99
+ | `current_thd_l1` | 0xF0 | % | L1 current thd |
100
+ | `current_thd_l2` | 0xF2 | % | L2 current thd |
101
+ | `current_thd_l3` | 0xF4 | % | L3 current thd |
102
+ | `voltage_thd_ln_average` | 0xF8 | % | Average L-N Voltage THD |
103
+ | `current_thd_average` | 0xFA | % | Average Current THD |
104
+ | `current_demand_l1` | 0x102 | A | L1 current demand |
105
+ | `current_demand_l2` | 0x104 | A | L2 current demand |
106
+ | `current_demand_l3` | 0x106 | A | L3 current demand |
107
+ | `current_demand_max_l1` | 0x108 | A | L1 maximum current demand |
108
+ | `current_demand_max_l2` | 0x10A | A | L2 maximum current demand |
109
+ | `current_demand_max_l3` | 0x10C | A | L3 maximum current demand |
110
+ | `voltage_thd_l1_l2` | 0x14E | % | L1-L2 voltage thd |
111
+ | `voltage_thd_l2_l3` | 0x150 | % | L2-L3 voltage thd |
112
+ | `voltage_thd_l3_l1` | 0x152 | % | L3-L1 voltage thd |
113
+ | `voltage_thd_ll_average` | 0x154 | % | Average L-L Voltage THD |
114
+ | `active_energy_total` | 0x156 | kWh | Total Active Energy |
115
+ | `reactive_energy_total` | 0x158 | kVArh | Total Reactive Energy |
116
+ | `active_energy_forward_l1` | 0x15A | kWh | L1 import active energy |
117
+ | `active_energy_forward_l2` | 0x15C | kWh | L2 import active energy |
118
+ | `active_energy_forward_l3` | 0x15E | kWh | L3 import active energy |
119
+ | `active_energy_reverse_l1` | 0x160 | kWh | L1 export active energy |
120
+ | `active_energy_reverse_l2` | 0x162 | kWh | L2 export active energy |
121
+ | `active_energy_reverse_l3` | 0x164 | kWh | L3 export active energy |
122
+ | `active_energy_l1` | 0x166 | kWh | L1 total active energy |
123
+ | `active_energy_l2` | 0x168 | kWh | L2 total active energy |
124
+ | `active_energy_l3` | 0x16A | kWh | L3 total active energy |
125
+ | `reactive_energy_forward_l1` | 0x16C | kVArh | L1 import reactive energy |
126
+ | `reactive_energy_forward_l2` | 0x16E | kVArh | L2 import reactive energy |
127
+ | `reactive_energy_forward_l3` | 0x170 | kVArh | L3 import reactive energy |
128
+ | `reactive_energy_reverse_l1` | 0x172 | kVArh | L1 export reactive energy |
129
+ | `reactive_energy_reverse_l2` | 0x174 | kVArh | L2 export reactive energy |
130
+ | `reactive_energy_reverse_l3` | 0x176 | kVArh | L3 export reactive energy |
131
+ | `reactive_energy_l1` | 0x178 | kVArh | L1 total reactive energy |
132
+ | `reactive_energy_l2` | 0x17A | kVArh | L2 total reactive energy |
133
+ | `reactive_energy_l3` | 0x17C | kVArh | L3 total reactive energy |
134
+
135
+ "Import" is the `forward` energy and "export" is the `reverse` energy. Ids follow `driver-or-we-516` where the meaning is the same.
136
+
137
+ The driver reads the registers in at most 6 requests per poll: 0x00 (80 registers), 0x50 (8), 0x64 (4), 0xC8 (8), 0xE0 (46) and 0x14E (48). The homy Modbus reader reads these same blocks from a real meter; the gaps inside them read without errors. The meter allows at most 80 registers per request. A block is read only when one of its data points is requested.
138
+
139
+ Not included: neutral current demand and its maximum (0x68, 0x6A) and the settings (holding registers: demand period, system type, baud rate, parity and stop bits, address).
140
+
141
+ ## Notes
142
+
143
+ - **Average line current is at 0x2E.** Register 0x2C is not in the manual and returns 0 on a real meter.
144
+ - **Line-to-line voltage THD (0x14E to 0x154) returns 0** on the meter of the owner. The data points are kept so every value the homy Modbus reader publishes is also published here.
145
+ - **0x56 is the maximum of the power demand in W.** The manual table says VA, which is probably a mistake in the manual (checked on a real meter on 2026-10-14).
146
+
147
+ ## Sources
148
+
149
+ - "SDM630 Modbus Protocol" V1.8: https://www.eastroneurope.com/images/uploads/products/protocol/SDM630_MODBUS_Protocol.pdf
150
+
151
+ ## License
152
+
153
+ GPL-3.0-or-later
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Eastron SDM630 3-Phase Energy Meter Driver
3
+ *
4
+ * 3-phase + N energy meter, DIN rail, RS-485, Modbus RTU.
5
+ *
6
+ * Factory default specifications are exported via the DEFAULT_CONFIG constant.
7
+ * See DEFAULT_CONFIG for baud rate, parity, data bits, stop bits, and default address.
8
+ *
9
+ * Register mapping (input registers, FC 04, float32 big-endian, 2 registers each),
10
+ * from "SDM630 Modbus Protocol" V1.8. A full poll reads 6 blocks:
11
+ * - 0x00 x 80: phase values, totals, frequency, energy
12
+ * - 0x50 x 8: kVAh, Ah, power demand
13
+ * - 0x64 x 4: VA demand
14
+ * - 0xC8 x 8: line-to-line voltage
15
+ * - 0xE0 x 46: neutral current, THD, current demand
16
+ * - 0x14E x 48: line-to-line THD, total and per-phase energy
17
+ */
18
+ import type { CreateDriverFunction } from '@ya-modbus/driver-types';
19
+ /**
20
+ * Supported configuration values for SDM630
21
+ *
22
+ * From the manual: "User Option Of Parity And Stop Bits: No Parity and 2 Stop Bits /
23
+ * No Parity and 1 Stop Bit / Even Parity and 1 Stop Bit / Odd Parity and 1 Stop Bit"
24
+ * and "User Option of Baud 2400; 4800 ; 9600 ; 19200 ; 38400".
25
+ * The address range is "1 to 247".
26
+ */
27
+ export declare const SUPPORTED_CONFIG: {
28
+ readonly validBaudRates: readonly [2400, 4800, 9600, 19200, 38400];
29
+ readonly validParity: readonly ["none", "even", "odd"];
30
+ readonly validDataBits: readonly [8];
31
+ readonly validStopBits: readonly [1, 2];
32
+ readonly validAddressRange: readonly [1, 247];
33
+ };
34
+ /**
35
+ * Default SDM630 device configuration
36
+ *
37
+ * Use these values when connecting to a factory-default SDM630 device.
38
+ */
39
+ export declare const DEFAULT_CONFIG: {
40
+ readonly baudRate: 9600;
41
+ readonly parity: "none";
42
+ readonly dataBits: 8;
43
+ readonly stopBits: 1;
44
+ readonly defaultAddress: 1;
45
+ };
46
+ /**
47
+ * Create SDM630 device driver
48
+ */
49
+ export declare const createDriver: CreateDriverFunction;
50
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EACV,oBAAoB,EAMrB,MAAM,yBAAyB,CAAA;AAEhC;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB;;;;;;CAMa,CAAA;AAE1C;;;;GAIG;AACH,eAAO,MAAM,cAAc;;;;;;CAMa,CAAA;AAqJxC;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,oBA6C1B,CAAA"}
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ /**
3
+ * Eastron SDM630 3-Phase Energy Meter Driver
4
+ *
5
+ * 3-phase + N energy meter, DIN rail, RS-485, Modbus RTU.
6
+ *
7
+ * Factory default specifications are exported via the DEFAULT_CONFIG constant.
8
+ * See DEFAULT_CONFIG for baud rate, parity, data bits, stop bits, and default address.
9
+ *
10
+ * Register mapping (input registers, FC 04, float32 big-endian, 2 registers each),
11
+ * from "SDM630 Modbus Protocol" V1.8. A full poll reads 6 blocks:
12
+ * - 0x00 x 80: phase values, totals, frequency, energy
13
+ * - 0x50 x 8: kVAh, Ah, power demand
14
+ * - 0x64 x 4: VA demand
15
+ * - 0xC8 x 8: line-to-line voltage
16
+ * - 0xE0 x 46: neutral current, THD, current demand
17
+ * - 0x14E x 48: line-to-line THD, total and per-phase energy
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.createDriver = exports.DEFAULT_CONFIG = exports.SUPPORTED_CONFIG = void 0;
21
+ const driver_sdk_1 = require("@ya-modbus/driver-sdk");
22
+ /**
23
+ * Supported configuration values for SDM630
24
+ *
25
+ * From the manual: "User Option Of Parity And Stop Bits: No Parity and 2 Stop Bits /
26
+ * No Parity and 1 Stop Bit / Even Parity and 1 Stop Bit / Odd Parity and 1 Stop Bit"
27
+ * and "User Option of Baud 2400; 4800 ; 9600 ; 19200 ; 38400".
28
+ * The address range is "1 to 247".
29
+ */
30
+ exports.SUPPORTED_CONFIG = {
31
+ validBaudRates: [2400, 4800, 9600, 19200, 38400],
32
+ validParity: ['none', 'even', 'odd'],
33
+ validDataBits: [8],
34
+ validStopBits: [1, 2],
35
+ validAddressRange: [1, 247],
36
+ };
37
+ /**
38
+ * Default SDM630 device configuration
39
+ *
40
+ * Use these values when connecting to a factory-default SDM630 device.
41
+ */
42
+ exports.DEFAULT_CONFIG = {
43
+ baudRate: 9600,
44
+ parity: 'none',
45
+ dataBits: 8,
46
+ stopBits: 1,
47
+ defaultAddress: 1,
48
+ };
49
+ const MAIN = { address: 0x00, count: 80 };
50
+ const DEMAND = { address: 0x50, count: 8 };
51
+ const VA_DEMAND = { address: 0x64, count: 4 };
52
+ const LINE_VOLTAGE = { address: 0xc8, count: 8 };
53
+ const NEUTRAL_THD = { address: 0xe0, count: 46 };
54
+ const ENERGY = { address: 0x14e, count: 48 };
55
+ const PHASES = ['l1', 'l2', 'l3'];
56
+ const LINES = ['l1_l2', 'l2_l3', 'l3_l1'];
57
+ /** A data point for one float32 register pair */
58
+ function single(block, register, id, name, unit, decimals, description = name) {
59
+ return {
60
+ block,
61
+ register,
62
+ point: { id, name, type: 'float', ...(unit && { unit }), access: 'r', description, decimals },
63
+ };
64
+ }
65
+ /** Three data points, 2 registers apart, one per phase (or per line pair) */
66
+ function triple(block, first, idPrefix, namePrefix, unit, decimals, suffixes = PHASES, description = '') {
67
+ return suffixes.map((suffix, i) => {
68
+ const label = suffix.toUpperCase().replace('_', '-');
69
+ return single(block, first + i * 2, `${idPrefix}_${suffix}`, `${label} ${namePrefix}`, unit, decimals, `${label} ${namePrefix.toLowerCase()}${description}`);
70
+ });
71
+ }
72
+ const DEGREES = ' (degrees)';
73
+ const REGISTERS = [
74
+ ...triple(MAIN, 0x00, 'voltage', 'Voltage', 'V', 1),
75
+ ...triple(MAIN, 0x06, 'current', 'Current', 'A', 3),
76
+ ...triple(MAIN, 0x0c, 'active_power', 'Active Power', 'W', 1),
77
+ ...triple(MAIN, 0x12, 'apparent_power', 'Apparent Power', 'VA', 1),
78
+ ...triple(MAIN, 0x18, 'reactive_power', 'Reactive Power', 'VAr', 1),
79
+ ...triple(MAIN, 0x1e, 'power_factor', 'Power Factor', undefined, 3),
80
+ ...triple(MAIN, 0x24, 'phase_angle', 'Phase Angle', undefined, 1, PHASES, DEGREES),
81
+ single(MAIN, 0x2a, 'voltage_ln_average', 'Average L-N Voltage', 'V', 1),
82
+ single(MAIN, 0x2e, 'current_average', 'Average Line Current', 'A', 3),
83
+ single(MAIN, 0x30, 'current_sum', 'Sum of Line Currents', 'A', 3),
84
+ single(MAIN, 0x34, 'active_power_total', 'Total Active Power', 'W', 1),
85
+ single(MAIN, 0x38, 'apparent_power_total', 'Total Apparent Power', 'VA', 1),
86
+ single(MAIN, 0x3c, 'reactive_power_total', 'Total Reactive Power', 'VAr', 1),
87
+ single(MAIN, 0x3e, 'power_factor_total', 'Total Power Factor', undefined, 3),
88
+ single(MAIN, 0x42, 'phase_angle_total', 'Total Phase Angle', undefined, 1, 'Total phase angle (degrees)'),
89
+ single(MAIN, 0x46, 'frequency', 'Grid Frequency', 'Hz', 2),
90
+ single(MAIN, 0x48, 'active_energy_forward', 'Import Active Energy', 'kWh', 2),
91
+ single(MAIN, 0x4a, 'active_energy_reverse', 'Export Active Energy', 'kWh', 2),
92
+ single(MAIN, 0x4c, 'reactive_energy_forward', 'Import Reactive Energy', 'kVArh', 2),
93
+ single(MAIN, 0x4e, 'reactive_energy_reverse', 'Export Reactive Energy', 'kVArh', 2),
94
+ single(DEMAND, 0x50, 'apparent_energy_total', 'Total Apparent Energy', undefined, 2, 'Total apparent energy (kVAh)'),
95
+ single(DEMAND, 0x52, 'charge_total', 'Total Charge', 'Ah', 2),
96
+ single(DEMAND, 0x54, 'active_power_demand', 'Total Active Power Demand', 'W', 1),
97
+ single(DEMAND, 0x56, 'active_power_demand_max', 'Maximum Total Active Power Demand', 'W', 1, 'Maximum total active power demand (the manual says VA, the real meter gives W)'),
98
+ single(VA_DEMAND, 0x64, 'apparent_power_demand', 'Total Apparent Power Demand', 'VA', 1),
99
+ single(VA_DEMAND, 0x66, 'apparent_power_demand_max', 'Maximum Apparent Power Demand', 'VA', 1),
100
+ ...triple(LINE_VOLTAGE, 0xc8, 'voltage', 'Voltage', 'V', 1, LINES),
101
+ single(LINE_VOLTAGE, 0xce, 'voltage_ll_average', 'Average L-L Voltage', 'V', 1),
102
+ single(NEUTRAL_THD, 0xe0, 'current_neutral', 'Neutral Current', 'A', 3),
103
+ ...triple(NEUTRAL_THD, 0xea, 'voltage_thd', 'Voltage THD', '%', 2),
104
+ ...triple(NEUTRAL_THD, 0xf0, 'current_thd', 'Current THD', '%', 2),
105
+ single(NEUTRAL_THD, 0xf8, 'voltage_thd_ln_average', 'Average L-N Voltage THD', '%', 2),
106
+ single(NEUTRAL_THD, 0xfa, 'current_thd_average', 'Average Current THD', '%', 2),
107
+ ...triple(NEUTRAL_THD, 0x102, 'current_demand', 'Current Demand', 'A', 3),
108
+ ...triple(NEUTRAL_THD, 0x108, 'current_demand_max', 'Maximum Current Demand', 'A', 3),
109
+ ...triple(ENERGY, 0x14e, 'voltage_thd', 'Voltage THD', '%', 2, LINES),
110
+ single(ENERGY, 0x154, 'voltage_thd_ll_average', 'Average L-L Voltage THD', '%', 2),
111
+ single(ENERGY, 0x156, 'active_energy_total', 'Total Active Energy', 'kWh', 2),
112
+ single(ENERGY, 0x158, 'reactive_energy_total', 'Total Reactive Energy', 'kVArh', 2),
113
+ ...triple(ENERGY, 0x15a, 'active_energy_forward', 'Import Active Energy', 'kWh', 2),
114
+ ...triple(ENERGY, 0x160, 'active_energy_reverse', 'Export Active Energy', 'kWh', 2),
115
+ ...triple(ENERGY, 0x166, 'active_energy', 'Total Active Energy', 'kWh', 2),
116
+ ...triple(ENERGY, 0x16c, 'reactive_energy_forward', 'Import Reactive Energy', 'kVArh', 2),
117
+ ...triple(ENERGY, 0x172, 'reactive_energy_reverse', 'Export Reactive Energy', 'kVArh', 2),
118
+ ...triple(ENERGY, 0x178, 'reactive_energy', 'Total Reactive Energy', 'kVArh', 2),
119
+ ];
120
+ const DATA_POINTS = REGISTERS.map((r) => r.point);
121
+ const REGISTER_BY_ID = new Map(REGISTERS.map((r) => [r.point.id, r]));
122
+ /**
123
+ * Create SDM630 device driver
124
+ */
125
+ const createDriver = (config) => {
126
+ const { transport } = config;
127
+ /** Read each needed block once and decode the requested ids */
128
+ async function read(ids) {
129
+ const unknown = ids.filter((id) => !REGISTER_BY_ID.has(id));
130
+ if (unknown.length > 0) {
131
+ throw new Error(`Unknown data points: ${unknown.join(', ')}`);
132
+ }
133
+ const wanted = ids.map((id) => REGISTER_BY_ID.get(id));
134
+ const blocks = new Set(wanted.map((r) => r.block));
135
+ const buffers = new Map();
136
+ for (const block of blocks) {
137
+ buffers.set(block, await transport.readInputRegisters(block.address, block.count));
138
+ }
139
+ const result = {};
140
+ for (const { block, register, point } of wanted) {
141
+ result[point.id] = (0, driver_sdk_1.readFloatBE)(buffers.get(block), (register - block.address) * 2);
142
+ }
143
+ return result;
144
+ }
145
+ const driver = {
146
+ name: 'SDM630',
147
+ manufacturer: 'Eastron',
148
+ model: 'SDM630',
149
+ dataPoints: DATA_POINTS,
150
+ async readDataPoint(id) {
151
+ if (!REGISTER_BY_ID.has(id)) {
152
+ throw new Error(`Unknown data point: ${id}`);
153
+ }
154
+ return (await read([id]))[id];
155
+ },
156
+ writeDataPoint(id) {
157
+ return Promise.reject(new Error(`Data point ${id} is read-only`));
158
+ },
159
+ readDataPoints: read,
160
+ };
161
+ return Promise.resolve(driver);
162
+ };
163
+ exports.createDriver = createDriver;
164
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAEH,sDAAmD;AAUnD;;;;;;;GAOG;AACU,QAAA,gBAAgB,GAAG;IAC9B,cAAc,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC;IAChD,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC;IACpC,aAAa,EAAE,CAAC,CAAC,CAAC;IAClB,aAAa,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACrB,iBAAiB,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC;CACa,CAAA;AAE1C;;;;GAIG;AACU,QAAA,cAAc,GAAG;IAC5B,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,CAAC;IACX,QAAQ,EAAE,CAAC;IACX,cAAc,EAAE,CAAC;CACqB,CAAA;AAYxC,MAAM,IAAI,GAAU,EAAE,OAAO,EAAE,I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