@ya-modbus/driver-types 0.4.1-refactor-scope-driver-packages.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 ADDED
@@ -0,0 +1,167 @@
1
+ # @ya-modbus/driver-types
2
+
3
+ TypeScript type definitions for ya-modbus device drivers.
4
+
5
+ ## Overview
6
+
7
+ This package provides TypeScript interfaces and types for developing Modbus device drivers. It contains no runtime code - only type definitions designed to be a lightweight dependency.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @ya-modbus/driver-types
13
+ ```
14
+
15
+ ## Core Types
16
+
17
+ ### DeviceDriver
18
+
19
+ The main interface that all device drivers must implement:
20
+
21
+ ```typescript
22
+ import type { DeviceDriver } from '@ya-modbus/driver-types'
23
+
24
+ const driver: DeviceDriver = {
25
+ name: 'my-device',
26
+ manufacturer: 'Acme Corp',
27
+ model: 'MD-100',
28
+ dataPoints: [...],
29
+
30
+ async readDataPoint(id: string) { ... },
31
+ async writeDataPoint(id: string, value: unknown) { ... },
32
+ async readDataPoints(ids: string[]) { ... },
33
+ }
34
+ ```
35
+
36
+ ### Transport
37
+
38
+ Abstraction over Modbus RTU/TCP communication:
39
+
40
+ ```typescript
41
+ import type { Transport } from '@ya-modbus/driver-types'
42
+
43
+ // Read holding registers
44
+ const buffer = await transport.readHoldingRegisters(0x0000, 2)
45
+
46
+ // Write single register
47
+ await transport.writeSingleRegister(0x0100, 1234)
48
+ ```
49
+
50
+ **Transport methods:**
51
+
52
+ - `readHoldingRegisters(address, count)` - Read holding registers (FC 03)
53
+ - `readInputRegisters(address, count)` - Read input registers (FC 04)
54
+ - `readCoils(address, count)` - Read coils (FC 01)
55
+ - `readDiscreteInputs(address, count)` - Read discrete inputs (FC 02)
56
+ - `writeSingleRegister(address, value)` - Write single register (FC 06)
57
+ - `writeMultipleRegisters(address, values)` - Write multiple registers (FC 16)
58
+ - `writeSingleCoil(address, value)` - Write single coil (FC 05)
59
+ - `writeMultipleCoils(address, values)` - Write multiple coils (FC 15)
60
+ - `close()` - Close the transport connection
61
+
62
+ ### DataPoint
63
+
64
+ Defines semantic data points exposed by drivers:
65
+
66
+ ```typescript
67
+ import type { DataPoint } from '@ya-modbus/driver-types'
68
+
69
+ const temperaturePoint: DataPoint = {
70
+ id: 'temperature',
71
+ name: 'Temperature',
72
+ description: 'Current temperature reading',
73
+ unit: '°C',
74
+ dataType: 'float',
75
+ access: 'read',
76
+ }
77
+ ```
78
+
79
+ ### Configuration Types
80
+
81
+ Types for driver configuration and device defaults:
82
+
83
+ ```typescript
84
+ import type {
85
+ DriverConfig,
86
+ DefaultSerialConfig,
87
+ DefaultTCPConfig,
88
+ SupportedSerialConfig,
89
+ } from '@ya-modbus/driver-types'
90
+
91
+ // Factory function configuration
92
+ const config: DriverConfig = {
93
+ transport,
94
+ slaveId: 1,
95
+ device: 'or-we-514', // For multi-device drivers
96
+ }
97
+
98
+ // Default serial port configuration
99
+ export const DEFAULT_CONFIG = {
100
+ baudRate: 9600,
101
+ parity: 'even',
102
+ dataBits: 8,
103
+ stopBits: 1,
104
+ defaultAddress: 1,
105
+ } as const satisfies DefaultSerialConfig
106
+
107
+ // Supported configuration constraints
108
+ export const SUPPORTED_CONFIG = {
109
+ validBaudRates: [9600, 14400, 19200],
110
+ validParity: ['even', 'none'],
111
+ } as const satisfies SupportedSerialConfig
112
+ ```
113
+
114
+ ### Multi-Device Support
115
+
116
+ Types for drivers that support multiple device models:
117
+
118
+ ```typescript
119
+ import type { DeviceRegistry, DeviceInfo } from '@ya-modbus/driver-types'
120
+
121
+ export const DEVICES = {
122
+ 'or-we-514': {
123
+ manufacturer: 'ORNO',
124
+ model: 'OR-WE-514',
125
+ description: 'Single-phase energy meter',
126
+ },
127
+ 'or-we-516': {
128
+ manufacturer: 'ORNO',
129
+ model: 'OR-WE-516',
130
+ description: 'Three-phase energy meter',
131
+ },
132
+ } as const satisfies DeviceRegistry
133
+ ```
134
+
135
+ ## Exported Types
136
+
137
+ | Type | Description |
138
+ | ----------------------- | -------------------------------- |
139
+ | `DeviceDriver` | Main driver interface |
140
+ | `CreateDriverFunction` | Factory function signature |
141
+ | `DriverConfig` | Factory function configuration |
142
+ | `Transport` | Modbus transport interface |
143
+ | `DataPoint` | Semantic data point definition |
144
+ | `DataType` | Supported data types |
145
+ | `AccessMode` | Read/write access modes |
146
+ | `Unit` | Standard measurement units |
147
+ | `SlaveId` | Modbus slave ID (1-247) |
148
+ | `Parity` | Serial parity settings |
149
+ | `DataBits` | Serial data bits (7/8) |
150
+ | `StopBits` | Serial stop bits (1/2) |
151
+ | `BaudRate` | Serial baud rate |
152
+ | `DefaultSerialConfig` | Default RTU configuration |
153
+ | `DefaultTCPConfig` | Default TCP configuration |
154
+ | `SupportedSerialConfig` | Serial configuration constraints |
155
+ | `SupportedTCPConfig` | TCP configuration constraints |
156
+ | `DeviceInfo` | Device metadata |
157
+ | `DeviceRegistry` | Multi-device registry |
158
+
159
+ ## See Also
160
+
161
+ - [Driver SDK](../driver-sdk/) - Runtime utilities for driver development
162
+ - [Driver Development Guide](../../docs/DRIVER-DEVELOPMENT.md)
163
+ - [Example Drivers](../driver-ex9em/)
164
+
165
+ ## License
166
+
167
+ GPL-3.0-or-later
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Standard data types and data point definitions
3
+ */
4
+ import type { Unit } from './units.js';
5
+ /**
6
+ * Standard data types for data points
7
+ */
8
+ export type DataType = 'float' | 'integer' | 'boolean' | 'string' | 'timestamp' | 'enum';
9
+ /**
10
+ * Polling type for data points
11
+ */
12
+ export type PollType = 'dynamic' | 'static' | 'on-demand';
13
+ /**
14
+ * Access permissions for data points
15
+ */
16
+ export type AccessMode = 'r' | 'w' | 'rw';
17
+ /**
18
+ * Data point definition (semantic interface)
19
+ */
20
+ export interface DataPoint {
21
+ /** Unique identifier for this data point */
22
+ id: string;
23
+ /** Human-readable name */
24
+ name?: string;
25
+ /** Data type */
26
+ type: DataType;
27
+ /** Unit of measurement */
28
+ unit?: Unit;
29
+ /** Polling behavior */
30
+ pollType?: PollType;
31
+ /** Access permissions */
32
+ access?: AccessMode;
33
+ /** Optional description */
34
+ description?: string;
35
+ /** For enum type: valid values */
36
+ enumValues?: Record<string | number, string>;
37
+ /** Minimum valid value (for numeric types) */
38
+ min?: number;
39
+ /** Maximum valid value (for numeric types) */
40
+ max?: number;
41
+ /** Number of decimal places for display */
42
+ decimals?: number;
43
+ }
44
+ //# sourceMappingURL=data-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-types.d.ts","sourceRoot":"","sources":["../src/data-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEtC;;GAEG;AACH,MAAM,MAAM,QAAQ,GAChB,OAAO,GACP,SAAS,GACT,SAAS,GACT,QAAQ,GACR,WAAW,GACX,MAAM,CAAA;AAEV;;GAEG;AACH,MAAM,MAAM,QAAQ,GAChB,SAAS,GACT,QAAQ,GACR,WAAW,CAAA;AAEf;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,CAAA;AAEzC;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,4CAA4C;IAC5C,EAAE,EAAE,MAAM,CAAA;IAEV,0BAA0B;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb,gBAAgB;IAChB,IAAI,EAAE,QAAQ,CAAA;IAEd,0BAA0B;IAC1B,IAAI,CAAC,EAAE,IAAI,CAAA;IAEX,uBAAuB;IACvB,QAAQ,CAAC,EAAE,QAAQ,CAAA;IAEnB,yBAAyB;IACzB,MAAM,CAAC,EAAE,UAAU,CAAA;IAEnB,2BAA2B;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB,kCAAkC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,CAAA;IAE5C,8CAA8C;IAC9C,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ,8CAA8C;IAC9C,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Standard data types and data point definitions
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=data-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-types.js","sourceRoot":"","sources":["../src/data-types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,283 @@
1
+ /**
2
+ * Core device driver interface
3
+ */
4
+ import type { DataPoint } from './data-types.js';
5
+ import type { Transport } from './transport.js';
6
+ /**
7
+ * Modbus slave/device ID
8
+ *
9
+ * Valid range: 1-247 (0 is broadcast, 248-255 reserved)
10
+ */
11
+ export type SlaveId = number;
12
+ /**
13
+ * Device driver factory function configuration
14
+ */
15
+ export interface DriverConfig {
16
+ /** Device key from driver's DEVICES registry (for multi-device drivers) */
17
+ device?: string;
18
+ /** Modbus transport layer */
19
+ transport: Transport;
20
+ /** Modbus slave ID (1-247) */
21
+ slaveId: SlaveId;
22
+ /** Optional custom poll interval in milliseconds */
23
+ pollInterval?: number;
24
+ }
25
+ /**
26
+ * Device driver interface
27
+ *
28
+ * Drivers are created using factory functions that return objects
29
+ * implementing this interface.
30
+ */
31
+ export interface DeviceDriver {
32
+ /** Unique device name/identifier */
33
+ readonly name: string;
34
+ /** Device manufacturer */
35
+ readonly manufacturer: string;
36
+ /** Device model identifier */
37
+ readonly model: string;
38
+ /** Available data points (semantic interface) */
39
+ readonly dataPoints: ReadonlyArray<DataPoint>;
40
+ /**
41
+ * Read data point value from device
42
+ *
43
+ * @param id - Data point identifier
44
+ * @returns Current value
45
+ */
46
+ readDataPoint(id: string): Promise<unknown>;
47
+ /**
48
+ * Write data point value to device
49
+ *
50
+ * @param id - Data point identifier
51
+ * @param value - Value to write
52
+ */
53
+ writeDataPoint(id: string, value: unknown): Promise<void>;
54
+ /**
55
+ * Read multiple data points atomically
56
+ *
57
+ * @param ids - Data point identifiers
58
+ * @returns Map of data point values
59
+ */
60
+ readDataPoints(ids: string[]): Promise<Record<string, unknown>>;
61
+ /**
62
+ * Optional device initialization
63
+ * Called once after driver creation
64
+ */
65
+ initialize?(): Promise<void>;
66
+ /**
67
+ * Optional cleanup
68
+ * Called when driver is being destroyed
69
+ */
70
+ destroy?(): Promise<void>;
71
+ }
72
+ /**
73
+ * Factory function signature for creating device drivers
74
+ */
75
+ export type CreateDriverFunction = (config: DriverConfig) => Promise<DeviceDriver>;
76
+ /**
77
+ * Serial port parity setting
78
+ */
79
+ export type Parity = 'none' | 'even' | 'odd';
80
+ /**
81
+ * Serial port data bits
82
+ */
83
+ export type DataBits = 7 | 8;
84
+ /**
85
+ * Serial port stop bits
86
+ */
87
+ export type StopBits = 1 | 2;
88
+ /**
89
+ * Serial port baud rate
90
+ *
91
+ * Common values: 2400, 4800, 9600, 14400, 19200, 38400, 57600, 115200
92
+ */
93
+ export type BaudRate = number;
94
+ /**
95
+ * Factory-default serial port configuration for RTU devices
96
+ *
97
+ * Driver packages should export a DEFAULT_CONFIG constant implementing this interface
98
+ * to provide sensible defaults for connecting to factory-default devices.
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * export const DEFAULT_CONFIG = {
103
+ * baudRate: 9600,
104
+ * parity: 'even',
105
+ * dataBits: 8,
106
+ * stopBits: 1,
107
+ * defaultAddress: 1,
108
+ * } as const satisfies DefaultSerialConfig
109
+ * ```
110
+ */
111
+ export interface DefaultSerialConfig {
112
+ /** Default baud rate (e.g., 9600, 19200) */
113
+ readonly baudRate: BaudRate;
114
+ /** Default parity setting */
115
+ readonly parity: Parity;
116
+ /** Default data bits (7 or 8) */
117
+ readonly dataBits: DataBits;
118
+ /** Default stop bits (1 or 2) */
119
+ readonly stopBits: StopBits;
120
+ /** Default Modbus slave address (1-247) */
121
+ readonly defaultAddress: SlaveId;
122
+ }
123
+ /**
124
+ * Factory-default TCP configuration for Modbus TCP devices
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * export const DEFAULT_CONFIG = {
129
+ * defaultAddress: 1,
130
+ * defaultPort: 502,
131
+ * } as const satisfies DefaultTCPConfig
132
+ * ```
133
+ */
134
+ export interface DefaultTCPConfig {
135
+ /** Default Modbus unit ID (1-247) */
136
+ readonly defaultAddress: SlaveId;
137
+ /** Default TCP port (typically 502) */
138
+ readonly defaultPort: number;
139
+ }
140
+ /**
141
+ * Union type for default device configuration
142
+ *
143
+ * Drivers should export DEFAULT_CONFIG matching one of these types
144
+ */
145
+ export type DefaultConfig = DefaultSerialConfig | DefaultTCPConfig;
146
+ /**
147
+ * Supported serial port configuration values
148
+ *
149
+ * Serial driver packages should export a SUPPORTED_CONFIG constant implementing this interface
150
+ * to define device-specific serial configuration constraints.
151
+ *
152
+ * All properties are optional - only specify values that are device-specific.
153
+ * Omit properties if your device supports all standard Modbus values for that setting.
154
+ * For example, omit `validParity` if your device supports all parity options (none/even/odd).
155
+ *
156
+ * @example
157
+ * ```typescript
158
+ * import type { SupportedSerialConfig } from '@ya-modbus/driver-types'
159
+ *
160
+ * export const SUPPORTED_CONFIG = {
161
+ * validBaudRates: [9600, 14400, 19200],
162
+ * validParity: ['even', 'none'],
163
+ * validDataBits: [8],
164
+ * validStopBits: [1],
165
+ * validAddressRange: [1, 247],
166
+ * } as const satisfies SupportedSerialConfig
167
+ * ```
168
+ */
169
+ export interface SupportedSerialConfig {
170
+ /**
171
+ * Supported baud rates
172
+ * Common values: 2400, 4800, 9600, 14400, 19200, 38400, 57600, 115200
173
+ */
174
+ readonly validBaudRates?: readonly BaudRate[];
175
+ /**
176
+ * Supported parity settings
177
+ * Values: 'none', 'even', 'odd'
178
+ */
179
+ readonly validParity?: readonly Parity[];
180
+ /**
181
+ * Supported data bits
182
+ * Common values: 7, 8
183
+ */
184
+ readonly validDataBits?: readonly DataBits[];
185
+ /**
186
+ * Supported stop bits
187
+ * Common values: 1, 2
188
+ */
189
+ readonly validStopBits?: readonly StopBits[];
190
+ /**
191
+ * Supported slave address range
192
+ * Typically 1-247 for Modbus
193
+ */
194
+ readonly validAddressRange?: readonly [min: number, max: number];
195
+ }
196
+ /**
197
+ * Supported TCP configuration values
198
+ *
199
+ * TCP driver packages should export a SUPPORTED_CONFIG constant implementing this interface
200
+ * to define device-specific TCP configuration constraints.
201
+ *
202
+ * @example
203
+ * ```typescript
204
+ * import type { SupportedTCPConfig } from '@ya-modbus/driver-types'
205
+ *
206
+ * export const SUPPORTED_CONFIG = {
207
+ * validPorts: [502, 503],
208
+ * validAddressRange: [1, 247],
209
+ * } as const satisfies SupportedTCPConfig
210
+ * ```
211
+ */
212
+ export interface SupportedTCPConfig {
213
+ /**
214
+ * Supported TCP ports
215
+ * Typically [502] for standard Modbus TCP
216
+ */
217
+ readonly validPorts?: readonly number[];
218
+ /**
219
+ * Supported device address range
220
+ * For Modbus TCP, this is the unit ID (typically 1-247)
221
+ */
222
+ readonly validAddressRange?: readonly [min: number, max: number];
223
+ }
224
+ /**
225
+ * Union type for supported device configuration
226
+ *
227
+ * Drivers should export SUPPORTED_CONFIG matching one of these types
228
+ */
229
+ export type SupportedConfig = SupportedSerialConfig | SupportedTCPConfig;
230
+ /**
231
+ * Device metadata for multi-device drivers
232
+ *
233
+ * Contains user-facing information about a supported device.
234
+ * Internal details like register mappings are not exposed here.
235
+ *
236
+ * @example
237
+ * ```typescript
238
+ * const deviceInfo: DeviceInfo = {
239
+ * manufacturer: 'ORNO',
240
+ * model: 'OR-WE-514',
241
+ * description: 'Single-phase energy meter',
242
+ * defaultConfig: { baudRate: 9600, parity: 'even', ... },
243
+ * }
244
+ * ```
245
+ */
246
+ export interface DeviceInfo {
247
+ /** Device manufacturer */
248
+ readonly manufacturer: string;
249
+ /** Device model identifier */
250
+ readonly model: string;
251
+ /** Human-readable device description */
252
+ readonly description?: string;
253
+ /** Device-specific default configuration */
254
+ readonly defaultConfig?: DefaultConfig;
255
+ /** Device-specific supported configuration constraints */
256
+ readonly supportedConfig?: SupportedConfig;
257
+ }
258
+ /**
259
+ * Registry of supported devices for multi-device drivers
260
+ *
261
+ * Maps device keys to their metadata. Device keys are used with the
262
+ * `device` parameter in DriverConfig to select which device to use.
263
+ *
264
+ * **Must contain at least one device.** Empty registries are rejected at runtime.
265
+ *
266
+ * @example
267
+ * ```typescript
268
+ * export const DEVICES = {
269
+ * 'or-we-514': {
270
+ * manufacturer: 'ORNO',
271
+ * model: 'OR-WE-514',
272
+ * description: 'Single-phase energy meter',
273
+ * },
274
+ * 'or-we-516': {
275
+ * manufacturer: 'ORNO',
276
+ * model: 'OR-WE-516',
277
+ * description: 'Three-phase energy meter',
278
+ * },
279
+ * } as const satisfies DeviceRegistry
280
+ * ```
281
+ */
282
+ export type DeviceRegistry = Readonly<Record<string, DeviceInfo>>;
283
+ //# sourceMappingURL=device-driver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device-driver.d.ts","sourceRoot":"","sources":["../src/device-driver.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAA;AAE5B;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf,6BAA6B;IAC7B,SAAS,EAAE,SAAS,CAAA;IAEpB,8BAA8B;IAC9B,OAAO,EAAE,OAAO,CAAA;IAEhB,oDAAoD;IACpD,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAErB,0BAA0B;IAC1B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAE7B,8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ACzB,0BAA0B;IAC1B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAE7B,8BAA8B;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IAEtB,wCAAwC;IACxC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAE7B,4CAA4C;IAC5C,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAA;IAEtC,0DAA0D;IAC1D,QAAQ,CAAC,eAAe,CAAC,EAAE,eAAe,CAAA;CAC3C;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Core device driver interface
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=device-driver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device-driver.js","sourceRoot":"","sources":["../src/device-driver.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Type definitions for ya-modbus device drivers
3
+ *
4
+ * This package contains TypeScript type definitions with no runtime code.
5
+ * It's designed to be a lightweight dependency for driver packages.
6
+ */
7
+ export * from './device-driver.js';
8
+ export * from './data-types.js';
9
+ export * from './units.js';
10
+ export * from './transport.js';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Type definitions for ya-modbus device drivers
3
+ *
4
+ * This package contains TypeScript type definitions with no runtime code.
5
+ * It's designed to be a lightweight dependency for driver packages.
6
+ */
7
+ // Re-export all types
8
+ export * from './device-driver.js';
9
+ export * from './data-types.js';
10
+ export * from './units.js';
11
+ export * from './transport.js';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,sBAAsB;AACtB,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Transport layer interface
3
+ *
4
+ * Abstraction over Modbus RTU/TCP transports.
5
+ * Drivers use this interface to communicate with devices.
6
+ */
7
+ /**
8
+ * Modbus transport interface
9
+ */
10
+ export interface Transport {
11
+ /**
12
+ * Read holding registers
13
+ *
14
+ * @param address - Starting register address
15
+ * @param count - Number of registers to read
16
+ * @returns Register values as Buffer
17
+ */
18
+ readHoldingRegisters(address: number, count: number): Promise<Buffer>;
19
+ /**
20
+ * Read input registers
21
+ *
22
+ * @param address - Starting register address
23
+ * @param count - Number of registers to read
24
+ * @returns Register values as Buffer
25
+ */
26
+ readInputRegisters(address: number, count: number): Promise<Buffer>;
27
+ /**
28
+ * Read coils
29
+ *
30
+ * @param address - Starting coil address
31
+ * @param count - Number of coils to read
32
+ * @returns Coil values as Buffer
33
+ */
34
+ readCoils(address: number, count: number): Promise<Buffer>;
35
+ /**
36
+ * Read discrete inputs
37
+ *
38
+ * @param address - Starting input address
39
+ * @param count - Number of inputs to read
40
+ * @returns Input values as Buffer
41
+ */
42
+ readDiscreteInputs(address: number, count: number): Promise<Buffer>;
43
+ /**
44
+ * Write single holding register
45
+ *
46
+ * @param address - Register address
47
+ * @param value - Value to write (16-bit)
48
+ */
49
+ writeSingleRegister(address: number, value: number): Promise<void>;
50
+ /**
51
+ * Write multiple holding registers
52
+ *
53
+ * @param address - Starting register address
54
+ * @param values - Register values as Buffer
55
+ */
56
+ writeMultipleRegisters(address: number, values: Buffer): Promise<void>;
57
+ /**
58
+ * Write single coil
59
+ *
60
+ * @param address - Coil address
61
+ * @param value - Value to write (boolean)
62
+ */
63
+ writeSingleCoil(address: number, value: boolean): Promise<void>;
64
+ /**
65
+ * Write multiple coils
66
+ *
67
+ * @param address - Starting coil address
68
+ * @param values - Coil values as Buffer
69
+ */
70
+ writeMultipleCoils(address: number, values: Buffer): Promise<void>;
71
+ /**
72
+ * Close the transport connection
73
+ *
74
+ * Releases resources and allows the process to exit.
75
+ * Should be called when done using the transport.
76
+ */
77
+ close(): Promise<void>;
78
+ }
79
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;;;;;OAMG;IACH,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAErE;;;;;;OAMG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAEnE;;;;;;OAMG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAE1D;;;;;;OAMG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAEnE;;;;;OAKG;IACH,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAElE;;;;;OAKG;IACH,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEtE;;;;;OAKG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE/D;;;;;OAKG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAElE;;;;;OAKG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACvB"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Transport layer interface
3
+ *
4
+ * Abstraction over Modbus RTU/TCP transports.
5
+ * Drivers use this interface to communicate with devices.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Standard units of measurement
3
+ *
4
+ * Canonical unit definitions for device data points.
5
+ * Drivers should use these standard units for interoperability.
6
+ */
7
+ /**
8
+ * Standard unit types
9
+ */
10
+ export type Unit = 'V' | 'A' | 'W' | 'kW' | 'VA' | 'kVA' | 'VAr' | 'kVAr' | 'Wh' | 'kWh' | 'MWh' | 'VArh' | 'kVArh' | 'Ah' | 'Hz' | 'Ω' | '°C' | '°F' | 'K' | 'Pa' | 'kPa' | 'bar' | 'psi' | 'L/s' | 'L/min' | 'm³/h' | 'm/s' | 'km/h' | 'rpm' | '%' | 's' | 'min' | 'h' | 'ppm' | 'dB';
11
+ //# sourceMappingURL=units.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../src/units.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,MAAM,IAAI,GAEZ,GAAG,GACH,GAAG,GACH,GAAG,GACH,IAAI,GACJ,IAAI,GACJ,KAAK,GACL,KAAK,GACL,MAAM,GACN,IAAI,GACJ,KAAK,GACL,KAAK,GACL,MAAM,GACN,OAAO,GACP,IAAI,GACJ,IAAI,GACJ,GAAG,GAGH,IAAI,GACJ,IAAI,GACJ,GAAG,GAGH,IAAI,GACJ,KAAK,GACL,KAAK,GACL,KAAK,GAGL,KAAK,GACL,OAAO,GACP,MAAM,GAGN,KAAK,GACL,MAAM,GACN,KAAK,GAGL,GAAG,GAGH,GAAG,GACH,KAAK,GACL,GAAG,GAGH,KAAK,GACL,IAAI,CAAA"}
package/dist/units.js ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Standard units of measurement
3
+ *
4
+ * Canonical unit definitions for device data points.
5
+ * Drivers should use these standard units for interoperability.
6
+ */
7
+ export {};
8
+ // Note: For custom units not in this list, use the closest standard unit
9
+ // or request addition to this type definition
10
+ //# sourceMappingURL=units.js.map