import { MotionMasterMessage, ParameterAddressValue, ParameterTypeValue, ParameterTypeValueKey, ParameterValueType, ValueType } from './types'; import { UnitConverterId } from './units'; /** * Defines visualization settings for a parameter when displayed on plots or charts. */ export type ParameterPlot = { /** * Axis association for plotting. * * - `'y1'` — Primary Y-axis * - `'y2'` — Secondary Y-axis */ axis: 'y1' | 'y2'; /** * Color code (typically in HEX or RGB) used to render this parameter on the plot. */ color: string; /** * Determines whether the parameter should be visible on the plot. */ visible: boolean; }; export declare const parameterIdToPlotColor: { [k: string]: string; }; export declare const parameterIdToPlotAxis: { [k: string]: 'y1' | 'y2'; }; export declare const parameterIdToRadix: { [key: string]: 2 | 16 | 10; }; export declare const betaParameterIds: string[]; /** * Represents the recommended types for a parameter input. */ export type ParameterInputType = 'number' | 'text' | 'range' | 'select' | 'ipv4'; /** * Extended information for a device parameter derived from the EtherCAT * Slave Information (ESI) file. * * This interface represents additional metadata and constraints * extracted from the ESI file, which enhances the base device parameter * description with validation, description, unit, mapping capabilities, and UI hints. */ export interface ParameterEsiExtension { /** Indicates if the parameter is mandatory (true) or optional (false/undefined). */ mandatory?: boolean; /** Minimum allowed numeric value for the parameter, if applicable. */ min?: number | null; /** Maximum allowed numeric value for the parameter, if applicable. */ max?: number | null; /** Default numeric value for the parameter, if defined. */ defaultData?: number; /** Unit symbol associated with the parameter (empty string if none). */ unit?: string | null; /** Size of the parameter in bits. */ bitSize?: number; /** * Maximum length allowed for STRING type parameters, * adjusted to accommodate firmware-specific constraints. */ strlen?: number; /** Raw ESI data type string (e.g., "UINT16", "STRING(50)"). */ esiType?: string; /** Human-readable description of the parameter or subitem. */ description?: string; /** Description specifically for record data types, if applicable. */ recordDescription?: string; /** Parsed options for enumerated parameter values, if available. */ options?: Record; /** Indicates if the parameter can be mapped as an RxPDO. */ canBeMappedAsRxPdo?: boolean; /** Indicates if the parameter can be mapped as a TxPDO. */ canBeMappedAsTxPdo?: boolean; /** Flag indicating if the parameter belongs to an SMM module. */ isSmm?: boolean; /** Group or category name for the parameter. */ group?: string | null; /** Optional type value key string, prioritizing typeValueKey over typeValue. */ typeValueKey?: ParameterTypeValueKey; /** Optional type value string representing the parameter data type. */ typeValue?: ParameterTypeValueKey; /** * Suggested HTML form input type for the parameter. */ inputType?: ParameterInputType; /** Original unit value preserved for reference or restoration. */ originalUnit?: string; /** Interface unit value preserved for reference or restoration. */ interfaceUnit?: string; /** Original options preserved for reference or restoration. */ originalOptions?: Record; /** * Error when extending this parameter with ESI: unit, min/max, documentation and options. * Typically the error means there is no object in ESI that matches this parameter index and subindex. */ esiExtensionError?: Error; } /** * Represents a generic parameter with required properties: index, subindex, name, value, typeValueKey. */ export interface Parameter extends MotionMasterMessage.Status.DeviceParameterInfo.IParameter, MotionMasterMessage.Status.DeviceParameterValues.IParameterValue, ParameterEsiExtension { /** * Uniquely identifies this parameter. * For example, if this is a device parameter, the parameter ID could be "0x1080:02.8602-01-0000755-2243". */ id: string; /** * Index from the object dictionary or invented one for the virtual parameter. */ index: number; /** * Subindex from the object dictionary or invented one for the virtual parameter. */ subindex: number; /** * The 'name' property is mandatory. */ name: string; /** * The 'value' property can be a string, number, or buffer. */ value: ParameterValueType; /** * The 'typeValueKey' property represents the 'oneof type_value' from the proto file. * It is used when parameter values are set on the device. */ typeValueKey?: ParameterTypeValueKey; /** * Textual representation of numerical value options for a parameter. */ options?: { [key: string]: number; }; /** * Value of the parameter that is considered disabled. */ disabledValue?: number; /** * Optional plot configuration used for visualization on charts. */ plot?: ParameterPlot; /** * Sets a special unit type on this parameter that allows users to switch the unit. * Each unit type comes with multiple options and parser and formatter functions. * For example 'position' unit type has options 'inc', 'deg' and 'rad'. */ unitConverterId?: UnitConverterId; /** * Radix: binary, decimal or hexadecimal. * Used for parseInt and input display format. */ radix?: 2 | 16 | 10; /** * Is this parameter defined in SMM module. */ isSmm?: boolean; /** * Indicates if this parameter is considered a beta feature, * which may be subject to change or removal in future releases. * This flag can be used to conditionally display or hide the parameter in user interfaces, * or to provide warnings about its stability. */ isBeta?: boolean; /** * For parameters that correspond to motion master proto fields the fieldName should be * camelCase proto field name, otherwise the value is arbitrary. */ fieldName?: string; } export type ParameterIndexSubindex = Pick; /** * Make parameter id by providing a tuple of index and subindex. * * @param tuple - an array of index and subindex * @throws {Error} if index or subindex are less than 0 * @returns combined index and subindex in uppercase hexadecimal format, e.g. "0x60FE:02" */ export declare function makeParameterId(tuple: [number | null | undefined, number | null | undefined]): string; /** * Make parameter id by providing an object which has index and subindex properties. * * @param parameter - an object with optional index and subindex properties * @throws {Error} if index or subindex are less than 0 * @returns combined index and subindex in uppercase hexadecimal format, e.g. "0x60FE:02" */ export declare function makeParameterId(parameter: { index?: number | null; subindex?: number | null; }): string; /** * Make parameter id by providing index and subindex. * * @param index - from 0x0000 to 0xFFFF for objects defined in ESI and >0xFFFF for custom object * @param subindex - defaults to 0 if not provided * @throws {Error} if index or subindex are less than 0 * @returns combined index and subindex in uppercase hexadecimal format, e.g. "0x60FE:02" */ export declare function makeParameterId(index?: number | null, subindex?: number | null): string; /** * Make parameter id by providing different arguments. * * The purpose of this declaration is to expose the signature of the implementation for {@link makeDeviceParameterId} function. * * @param a - number or an object with index and subindex or tuple of index and subindex * @param b - optional subindex, defaults to 0 if not provided * @throws {Error} if index or subindex are less than 0 * @returns combined index and subindex in uppercase hexadecimal format, e.g. "0x60FE:02" */ export declare function makeParameterId(a?: (number | null) | { index?: number | null; subindex?: number | null; } | [number | null | undefined, number | null | undefined], b?: number | null): string; /** * Example of parameter id is "0x2110:1A" where: * - 0x2110 is object index in hexadecimal format * - 1A is subindex in hexadecimal format */ export declare const parameterIdRegExp: RegExp; /** * Split device parameter id into parts. * * @param id - parameter id like "0x2110:1A" * @returns tuple of index and subindex */ export declare function splitParameterId(id: string): [number, number]; /** * Check if the provided string matches the parameter ID. */ export declare function isParameterId(id: string): boolean; /** * Parameter comparison function. * * Typically provided to sorting functions. Compares parameters by index and subindex. */ export declare function parametersCompareFn(a: Pick, b: Pick): number; /** * Creates an array of parameters not included in the other given array. Compares by index and subindex. */ export declare function differenceParameters = Parameter, S extends Pick = Parameter>(p1: T[], p2: S[]): T[]; /** * Creates an array of unique parameters that are included in both given arrays. Compares by index and subindex. */ export declare function intersectionParameters = Parameter, S extends Pick = Parameter>(p1: T[], p2: S[]): T[]; /** * Creates an array of unique parameters that are included in both given arrays, but only if the values of parameters differ. */ export declare function intersectionParametersWithDifferentValues = Parameter, S extends Pick = Parameter>(p1: T[], p2: S[], epsilon?: number): T[]; /** * Represents the result of comparing parameter sets. * * The Differences tuple contains an array of parameters that exist in one array but not in the other array. * The Intersections tuple contains an array of parameters that exist in both sets. * The Comparisons tuple contains an array of parameters that exist in both sets, with the additional valueOther from the other set of the matching parameter. */ export interface ParametersComparison = Parameter, S extends Pick = Parameter, V = T & { valueOther: ParameterValueType; }, U = S & { valueOther: ParameterValueType; }> { differences: [T[], S[]]; intersections: [T[], S[]]; comparisons: [V[], U[]]; } /** * Compare parameters. * * Compare parameters by creating the parameters comparison result, which includes the differences, intersections, and comparisons {@link ParametersComparison}. */ export declare function compareParameters = Parameter, S extends Pick = Parameter>(p1: T[], p2: S[], epsilon?: number): ParametersComparison; export declare function getParameterTypeValueDefault(key: ParameterTypeValueKey): 0 | "" | Uint8Array; export declare function getParameterTypeValue(parameter: MotionMasterMessage.Status.DeviceParameterValues.IParameterValue): ParameterTypeValueKey | undefined; export declare function getParameterValue(parameter: MotionMasterMessage.Status.DeviceParameterValues.IParameterValue & { value?: ParameterValueType | null; }): ParameterValueType; export declare function parseParameterValue(type: ParameterTypeValueKey, value: number | string): string | number | Uint8Array; export declare function mapParameterTypeValueToObject(type: ParameterTypeValueKey, value: number | string): ParameterTypeValue; /** * The safety object index range in the CiA 402 profile is 0x6600 - 0x67EF. * In the manufacturer-specific area, we mirror this range with 0x2600 - 0x27EF. * However, prior to SMM, custom objects were added with indexes starting at 0x27. * To avoid conflicts, we need to adjust the condition to include only object indexes up to 0x2700. */ export declare function isSmmParameterIndex(index: number): boolean; export declare function isRxPdoIndex(index: number): boolean; export declare function isTxPdoIndex(index: number): boolean; export declare function isPdoIndex(index: number): boolean; export declare function filterRxPdoParameters(parameters: T[], excludeSubIndex000?: boolean): T[]; export declare function filterTxPdoParameters(parameters: T[], excludeSubIndex000?: boolean): T[]; /** * Fills in missing PDO mapping entries for each parameter group that starts with a subindex of 0. * * For each group of parameters with the same `index` and starting at `subindex` 0, this function: * 1. Adds the existing parameters to the output. * 2. Appends placeholder `Parameter` entries with incremented subindexes until the total count reaches `entriesPerPdo`. * * This is useful for ensuring that each PDO mapping table has a consistent number of entries, * even if some are unused and need to be filled with default placeholder values. * * @param parameters - The list of existing parameters to process. * @param entriesPerPdo - The number of total entries (including placeholders) each PDO should have. Defaults to 10. * * @returns A new array of `Parameter` objects where each PDO group is filled with entries up to `entriesPerPdo`. * * @example * ```ts * const params: Parameter[] = [ * { index: 0x1600, subindex: 0, ... }, * { index: 0x1600, subindex: 1, ... }, * ]; * * const filled = fillPdoParametersWithMappingEntries(params, 3); * // filled will include the two original entries plus one default placeholder with subindex 2 * ``` */ export declare function fillPdoParametersWithMappingEntries(parameters: Parameter[], entriesPerPdo?: number): Parameter[]; export declare function mapParameterToPdoSubItemValue(parameter: Parameter): number; export declare function mapValueTypeToBitSize(valueType: ValueType): number; export declare const valueTypeToParameterTypeValueKeyMap: Map; export declare function createPdoParameterValues(parameters: Array<{ index: number; subindex: number; typeValue?: ParameterTypeValueKey; }>, values: Array): ParameterAddressValue[]; /** * Resolves the index and subindex for the given parameter. * * @param parameter - The parameter to resolve, which can be a `ParameterIndexSubindex` object, a string, or a tuple of two numbers. * @returns A tuple containing the index and subindex. */ export declare function resolveParameterIndexAndSubindex(parameter: ParameterIndexSubindex | string | [number, number]): [number, number]; /** * Custom Parameter object for configuring UI features in the client library. */ export type UIFeaturesConfigParameter = Pick; /** * Represents the configuration options for UI applications using the client library. * Defines available features, displayed elements, and editable parameters within the UI. */ export interface UIFeaturesConfig { /** * A list of configuration parameters with restricted access. * Optional; defines parameters that are displayed but not editable. */ parameters?: UIFeaturesConfigParameter[]; /** * Specifies whether the encoder configuration is disabled. * Optional: If undefined, the feature is treated as enabled. * @deprecated Use `disabledEncoderConfigurationIndexes` instead. */ encoderConfigurationDisabled?: boolean; /** * Specifies the indexes of encoder configuration parameters that are disabled. */ disabledEncoderConfigurationIndexes?: number[]; /** * Specifies the type of Setup Wizard to be used. * - `'actilink'`: Uses the ACTILINK-S Setup Wizard, which supports unit configuration, limits setup, and auto-tuning. * - `'default'`: Uses the default Setup Wizard, which supports motor, brake, and encoder configuration. */ setupWizard: 'actilink' | 'default'; } /** * This array contains the list of parameters that are disabled by setting their value to a specific value. */ export declare const disabledValueParameters: Pick[]; /** * Determines if the value of the given parameter is considered disabled. * * For example, the "Velocity Following Error: Window" parameter is considered disabled when its value is 65535. * * @param parameter - The parameter to check, which can be an object with `index`, `subindex`, and `value` properties, or a tuple of three numbers. * @returns `true` if the parameter is disabled, `false` otherwise. */ export declare function isParameterValueDisabled>(parameter: T | [number, number, number]): boolean; export declare const parameterAddressToColor: { [addr: string]: string; }; /** * Builds a permissive ESI extension for a parameter that cannot be matched against the ESI file. * * A parameter present in the device object dictionary but missing from the ESI file has no object * definition to derive type, unit, constraint or option information from. Returning an empty * extension would leave `inputType` undefined and such a parameter could not be rendered as a form * input, so infer the input type from the parameter type and leave the value unconstrained. * * @param parameter - partial parameter providing the type used to infer the input type * * @returns A {@link ParameterEsiExtension} with an inferred `inputType` and no min/max constraints. */ export declare function getParameterEsiExtensionFallback(parameter: Pick & { typeValue?: ParameterTypeValueKey; }): ParameterEsiExtension; /** * Retrieves extended EtherCAT Slave Information (ESI) metadata for a given device parameter. * * This function extracts and constructs additional descriptive and validation * information for a device parameter based on the ESI file data, including * constraints, default values, units, descriptions, mapping capabilities, * and input type hints. * * The returned object extends the base device parameter with ESI-specific * metadata that can be used for validation, UI generation, and device * communication mapping. * * @param parameter - Partial device parameter containing `index`, `subindex`, `typeValueKey`, * and optionally `typeValue`. Identifies the parameter to extend. * @param info - The EtherCAT master or module info object containing * descriptions and device dictionaries as parsed from the ESI file. * (Type from `ecatmod.EtherCATInfo` expected but typed as `any` here.) * @param productCode - The EtherCAT device product code used to locate the matching device * description within the ESI data. * This product code can typically be read from the device's object dictionary * at index `0x1018` (Identity Object), subindex `2`. * * @returns A {@link ParameterEsiExtension} object containing extended parameter metadata, * such as mandatory flags, min/max constraints, default values, * units, bit sizes, descriptions, options, PDO mapping flags, SMM module flag, * group information, type keys, and UI input hints. * * @remarks * - Supports parameter metadata extraction from both the main device profile dictionary * and sub-modules (e.g., for modular devices like SMM LW2). * - For STRING types, the maximum length is adjusted to accommodate firmware limitations. * - Descriptions and options are parsed and cleaned from JSON-like strings. * - Handles both variable data type objects and complex objects with sub-items. * - Logs a warning if no matching device is found for the given product code. * - Preserves original unit and options for reference or restoration. * - When the parameter cannot be matched against the ESI file, falls back to * {@link getParameterEsiExtensionFallback} and sets `esiExtensionError` describing what is missing, * so that the parameter remains renderable and the gap in the ESI file stays reportable. */ export declare function getParameterEsiExtension(parameter: Pick & { typeValue?: ParameterTypeValueKey; }, info: any, productCode: number): ParameterEsiExtension;