import type { BaudRate, DataBits, DefaultSerialConfig, Parity, StopBits, SupportedSerialConfig } from '@ya-modbus/driver-types'; /** * Parameter combination for discovery testing * Represents a complete set of Modbus RTU serial parameters */ export interface ParameterCombination { slaveId: number; baudRate: BaudRate; parity: Parity; dataBits: DataBits; stopBits: StopBits; } /** * Discovery strategy type * * - quick: Tests only driver-supported parameters (5-10 minutes) * - thorough: Tests all standard Modbus parameters (30-60 minutes) */ export type DiscoveryStrategy = 'quick' | 'thorough'; /** * Options for parameter combination generation */ export interface GeneratorOptions { /** Discovery strategy to use */ strategy: DiscoveryStrategy; /** Driver-provided default configuration (prioritized first) */ defaultConfig?: DefaultSerialConfig; /** Driver-provided supported configuration constraints */ supportedConfig?: SupportedSerialConfig; /** Optional list of specific slave IDs to test (overrides addressRange) */ slaveIds?: number[]; /** Optional list of specific baud rates to test (overrides strategy defaults) */ baudRates?: BaudRate[]; /** Optional list of specific parities to test (overrides strategy defaults) */ parities?: Parity[]; } /** * Group of parameter combinations that share the same serial configuration */ export interface ParameterGroup { /** Serial parameters shared by all combinations in this group */ serialParams: { baudRate: BaudRate; parity: Parity; dataBits: DataBits; stopBits: StopBits; }; /** All parameter combinations for this serial configuration (different slave IDs) */ combinations: ParameterCombination[]; } /** * Generate parameter combinations grouped by serial configuration * * This is a memory-efficient alternative to materializing all combinations. * Instead of creating all ~1500+ combinations at once, this generator yields * groups of ~247 combinations at a time (one per serial config). * * Each group shares the same serial parameters (baud, parity, data bits, stop bits) * but has different slave IDs. This matches how the scanner works - it creates * one connection per serial config and tests all slave IDs with that connection. * * @param options - Generation options * @yields Parameter groups to test * * @example Iterate over groups without materializing all combinations * ```typescript * for (const group of generateParameterGroups(options)) { * // Only this group's ~247 combinations are in memory * const { serialParams, combinations } = group * // ... use combinations ... * } * ``` */ export declare function generateParameterGroups(options: GeneratorOptions): Generator; /** * Generate all parameter combinations for Modbus device discovery * * Produces combinations in priority order: * 1. Default configuration (if provided) tested first * 2. Common slave addresses (1, 2) before others * 3. Common baud rates before exotic ones * * @param options - Generation options * @yields Parameter combinations to test * * @example Quick discovery with driver config * ```typescript * const combinations = generateParameterCombinations({ * strategy: 'quick', * defaultConfig: { baudRate: 9600, parity: 'even', ... }, * supportedConfig: { validBaudRates: [9600, 19200], ... } * }) * ``` * * @example Thorough discovery without driver * ```typescript * const combinations = generateParameterCombinations({ * strategy: 'thorough' * }) * ``` */ export declare function generateParameterCombinations(options: GeneratorOptions): Generator; //# sourceMappingURL=parameter-generator.d.ts.map