import { type LoadedDriver } from '@ya-modbus/driver-loader'; import type { BaudRate, DataBits, DataPoint, DefaultSerialConfig, DeviceDriver, Parity, StopBits, Transport } from '@ya-modbus/driver-types'; /** * Default RTU transport configuration values */ export declare const DEFAULT_RTU_CONFIG: { readonly port: "/dev/ttyUSB0"; readonly baudRate: BaudRate; readonly dataBits: DataBits; readonly parity: Parity; readonly stopBits: StopBits; }; /** * Default TCP port for Modbus TCP */ export declare const DEFAULT_TCP_PORT = 502; /** * Check if a data point is readable */ export declare function isReadable(dataPoint: DataPoint): boolean; /** * Check if a data point is writable */ export declare function isWritable(dataPoint: DataPoint): boolean; /** * Find a data point by ID * * @param driver - Device driver instance * @param id - Data point ID * @returns Data point definition * @throws Error if data point not found */ export declare function findDataPoint(driver: DeviceDriver, id: string): DataPoint; /** * Find and validate a readable data point * * @param driver - Device driver instance * @param id - Data point ID * @returns Data point definition * @throws Error if data point not found or not readable */ export declare function findReadableDataPoint(driver: DeviceDriver, id: string): DataPoint; /** * Find and validate a writable data point * * @param driver - Device driver instance * @param id - Data point ID * @returns Data point definition * @throws Error if data point not found or not writable */ export declare function findWritableDataPoint(driver: DeviceDriver, id: string): DataPoint; /** * Compare two floating point numbers for approximate equality * * Uses relative error to handle both very small and very large values correctly. * Also checks absolute error to handle values near zero. * * @param a - First value * @param b - Second value * @param relativeEpsilon - Relative error tolerance (default: 1e-6, or 0.0001%) * @param absoluteEpsilon - Absolute error tolerance for values near zero (default: 1e-9) * @returns True if values are approximately equal */ export declare function floatsEqual(a: number, b: number, relativeEpsilon?: number, absoluteEpsilon?: number): boolean; /** * Parse value string based on data point type */ export declare function parseValue(valueStr: string, dataPoint: DataPoint): unknown; /** * Validate value against data point constraints */ export declare function validateValue(value: unknown, dataPoint: DataPoint): void; /** * Prompt user for confirmation */ export declare function confirm(message: string): Promise; /** * Options for creating a transport */ export interface TransportOptions { host?: string; port?: string | number; baudRate?: number; dataBits?: number; parity?: string; stopBits?: number; slaveId: number; timeout?: number; } /** * Options for loading a driver */ export interface DriverOptions { driver?: string; device?: string; slaveId: number; } /** * Execute a function with a transport, ensuring cleanup * * @param options - Transport configuration options * @param fn - Function to execute with the transport * @returns Result of the function */ export declare function withTransport(options: TransportOptions, fn: (transport: Transport) => Promise): Promise; /** * Load driver metadata without creating an instance * * When no driver name is provided, auto-detects from current working directory. * * @param driverName - Optional driver package name (auto-detects from cwd if not specified) * @returns Loaded driver metadata */ export declare function loadDriverMetadata(driverName?: string): Promise; /** * Get the effective default config for a device * * Returns device-specific config if available, otherwise driver-level config. * * @param driverMetadata - Loaded driver metadata * @param device - Optional device key * @returns Effective default config or undefined */ export declare function getEffectiveDefaultConfig(driverMetadata: LoadedDriver | undefined, device: string | undefined): DefaultSerialConfig | undefined; /** * Get the effective supported config for a device * * Returns device-specific constraints if available, otherwise driver-level constraints. * * @param driverMetadata - Loaded driver metadata * @param device - Optional device key * @returns Effective supported config or undefined */ export declare function getEffectiveSupportedConfig(driverMetadata: LoadedDriver | undefined, device: string | undefined): LoadedDriver['supportedConfig'] | undefined; /** * Create an effective driver metadata with device-specific configs resolved * * This creates a view of the driver metadata where defaultConfig and supportedConfig * are resolved based on the selected device. This allows validation and other * functions to work with device-specific settings transparently. * * @param driverMetadata - Loaded driver metadata * @param device - Optional device key * @returns Driver metadata with effective configs for the selected device */ export declare function getEffectiveDriverMetadata(driverMetadata: LoadedDriver, device: string | undefined): LoadedDriver; /** * Apply driver defaults to transport options * * Uses device-specific defaults if a device is selected, otherwise driver-level defaults. * * @param options - Transport options (may be incomplete) * @param driverMetadata - Loaded driver metadata with defaults * @param device - Optional device key for multi-device drivers * @returns Transport options with defaults applied */ export declare function applyDriverDefaults(options: TransportOptions, driverMetadata?: LoadedDriver, device?: string): TransportOptions; /** * Execute a function with a driver instance, ensuring cleanup * * @param transport - Transport to use for driver communication * @param driverMetadata - Loaded driver metadata * @param slaveId - Modbus slave ID * @param device - Optional device key for multi-device drivers * @param fn - Function to execute with the driver * @returns Result of the function */ export declare function withDriverInstance(transport: Transport, driverMetadata: LoadedDriver, slaveId: number, device: string | undefined, fn: (driver: DeviceDriver) => Promise): Promise; /** * Execute a function with a driver instance, handling the complete workflow * * This is a convenience function that: * 1. Loads driver metadata (DEFAULT_CONFIG, SUPPORTED_CONFIG) * 2. Validates user options against driver constraints (SUPPORTED_CONFIG) * 3. Applies driver defaults to user options * 4. Validates merged options (catches invalid third-party driver defaults) * 5. Creates transport with merged configuration * 6. Creates driver instance * 7. Executes callback with driver and merged options * 8. Ensures cleanup (closes transport) * * @param options - Combined transport and driver options * @param fn - Function to execute with the driver (and optionally merged config) * @returns Result of the function * @throws ValidationError if user options or driver defaults violate constraints */ export declare function withDriver(options: TransportOptions & { driver?: string; device?: string; }, fn: (driver: DeviceDriver, mergedOptions: TransportOptions) => Promise): Promise; //# sourceMappingURL=commands.d.ts.map