motion-master-client 0.0.308 → 0.0.309

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.
@@ -6,7 +6,7 @@ import { HardwareDescription, StackInfo } from './hardware-description';
6
6
  import { MotionMasterReqResSocket } from './motion-master-req-res-socket';
7
7
  import { UIFeaturesConfig } from './parameter';
8
8
  import { SystemLogLine } from './system-log-line';
9
- import { MotionMasterMessage, ParameterValueType, ParameterTypeValue, DeviceParameterValuesStatus, ParameterTypeValueKey, DeviceRefObj, DeviceRef, FullAutoTuningStatus, SystemVersionStatus, DeviceInfoStatus, DeviceParameterInfoStatus, GetDeviceParameterInfoRequest, GetDeviceParameterValuesRequest, GetMultiDeviceParameterValuesRequest, MultiDeviceParameterValuesStatus, SetDeviceParameterValuesRequest, SetMultiDeviceParameterValuesRequest, GetDeviceFileListRequest, DeviceFileListStatus, GetDeviceFileRequest, DeviceFileStatus, SetDeviceFileRequest, DeleteDeviceFileRequest, ResetDeviceFaultRequest, DeviceFaultResetStatus, StopDeviceRequest, DeviceStopStatus, StartDeviceFirmwareInstallationRequest, DeviceFirmwareInstallationStatus, GetDeviceLogRequest, DeviceLogStatus, StartCoggingTorqueRecordingRequest, CoggingTorqueRecordingStatus, GetCoggingTorqueDataRequest, CoggingTorqueDataStatus, StartOffsetDetectionRequest, OffsetDetectionStatus, StartPlantModelIdentificationRequest, PlantIdentificationStatus, ComputeAutoTuningGainsRequest, AutoTuningStatus, SetMotionControllerParametersRequest, MotionControllerStatus, EnableMotionControllerRequest, SetSignalGeneratorParametersRequest, SignalGeneratorStatus, StopSignalGeneratorRequest, StartMonitoringDeviceParameterValuesRequest, MonitoringParameterValuesStatus, StopMonitoringDeviceParameterValuesRequest, GetEthercatNetworkStateRequest, EthercatNetworkStateStatus, SetEthercatNetworkStateRequest, StartNarrowAngleCalibrationRequest, NarrowAngleCalibrationStatus, SetSystemClientTimeoutRequest, StartSystemIdentificationRequest, SystemIdentificationStatus, CirculoEncoderMagnetDistanceStatus, StartCirculoEncoderNarrowAngleCalibrationProcedureRequest, CirculoEncoderNarrowAngleCalibrationProcedureStatus, GetDeviceCiA402StateRequest, DeviceCiA402StateStatus, SetDeviceCiA402StateRequest, SystemLogStatus, StartDeviceSiiRestoreRequest, DeviceSiiRestoreStatus, StartOpenLoopFieldControlRequest, OpenLoopFieldControlStatus, ComputeFullAutoTuningGainsRequest, StartFullAutoTuningRequest, StopFullAutoTuningRequest, StartCirculoEncoderConfigurationRequest, CirculoEncoderConfigurationStatus, StopCirculoEncoderNarrowAngleCalibrationProcedureRequest, StartOsCommandRequest, OsCommandStatus, RestoreDefaultParametersType, DeviceParameterAddressValue, DeviceParameterIds, DeviceParameterInfo, RequestStatusMessage, UiPdoMapping, UiConfig, RequestStatus, ExecuteForwardCallRequest, ForwardCallStatus, PlantModel } from './types';
9
+ import { MotionMasterMessage, ParameterValueType, ParameterTypeValue, DeviceParameterValuesStatus, ParameterTypeValueKey, DeviceRefObj, DeviceRef, FullAutoTuningStatus, SystemVersionStatus, DeviceInfoStatus, DeviceParameterInfoStatus, GetDeviceParameterInfoRequest, GetDeviceParameterValuesRequest, GetMultiDeviceParameterValuesRequest, MultiDeviceParameterValuesStatus, SetDeviceParameterValuesRequest, SetMultiDeviceParameterValuesRequest, GetDeviceFileListRequest, DeviceFileListStatus, GetDeviceFileRequest, DeviceFileStatus, SetDeviceFileRequest, DeleteDeviceFileRequest, ResetDeviceFaultRequest, DeviceFaultResetStatus, StopDeviceRequest, DeviceStopStatus, StartDeviceFirmwareInstallationRequest, DeviceFirmwareInstallationStatus, GetDeviceLogRequest, DeviceLogStatus, StartCoggingTorqueRecordingRequest, CoggingTorqueRecordingStatus, GetCoggingTorqueDataRequest, CoggingTorqueDataStatus, StartOffsetDetectionRequest, OffsetDetectionStatus, StartPlantModelIdentificationRequest, PlantIdentificationStatus, ComputeAutoTuningGainsRequest, AutoTuningStatus, SetMotionControllerParametersRequest, MotionControllerStatus, EnableMotionControllerRequest, SetSignalGeneratorParametersRequest, SignalGeneratorStatus, StopSignalGeneratorRequest, StartMonitoringDeviceParameterValuesRequest, MonitoringParameterValuesStatus, StopMonitoringDeviceParameterValuesRequest, GetEthercatNetworkStateRequest, EthercatNetworkStateStatus, SetEthercatNetworkStateRequest, StartNarrowAngleCalibrationRequest, NarrowAngleCalibrationStatus, SetSystemClientTimeoutRequest, StartSystemIdentificationRequest, SystemIdentificationStatus, CirculoEncoderMagnetDistanceStatus, StartCirculoEncoderNarrowAngleCalibrationProcedureRequest, CirculoEncoderNarrowAngleCalibrationProcedureStatus, GetDeviceCiA402StateRequest, DeviceCiA402StateStatus, SetDeviceCiA402StateRequest, SystemLogStatus, StartDeviceSiiRestoreRequest, DeviceSiiRestoreStatus, StartOpenLoopFieldControlRequest, OpenLoopFieldControlStatus, ComputeFullAutoTuningGainsRequest, StartFullAutoTuningRequest, StopFullAutoTuningRequest, StartCirculoEncoderConfigurationRequest, CirculoEncoderConfigurationStatus, StopCirculoEncoderNarrowAngleCalibrationProcedureRequest, StartOsCommandRequest, OsCommandStatus, RestoreDefaultParametersType, DeviceParameterAddressValue, DeviceParameterIds, DeviceParameterInfo, RequestStatusMessage, UiPdoMapping, UiConfig, RequestStatus, ExecuteForwardCallRequest, ForwardCallStatus, PlantModel, NotchFilter, LoadConfigStrategy } from './types';
10
10
  import { Cia402State, ModesOfOperation } from './cia402';
11
11
  import { EncoderRegisterCommunicationOsCommandResponse, MotorPhaseOrderDetectionOsCommandResponse, OpenPhaseDetectionOsCommandResponse, OsCommandMode, OsCommandResponse, PhaseResistanceMeasurementOsCommandResponse, PhaseInductanceMeasurementOsCommandResponse, PolePairDetectionOsCommandResponse, CommutationOffsetMeasurementOsCommandResponse, IcMuCalibrationModeOsCommandResponse, OpenLoopFieldModeOsCommandResponse, HrdStreamingOsCommandResponse, TorqueConstantMeasurementOsCommandResponse, SkippedCyclesCounterOsCommandResponse, IgnoreBissStatusBitsOsCommandResponse, SystemIdentificationOsCommandResponse, KublerEncoderCommandOsCommandResponse, UseInternalEncoderVelocityOsCommandResponse, KublerEncoderRegisterCommunicationOsCommandResponse, SmmAcyclicHandlerOsCommandResponse, HrdStreamingOsCommandAction, HrdStreamingOsCommandDataIndex, SmmAcyclicHandlerLoadParametersForVerificationOsCommandResponse } from './os-command';
12
12
  import { IntegroVariant } from './integro-variant';
@@ -1255,17 +1255,18 @@ export declare class MotionMasterReqResClient {
1255
1255
  */
1256
1256
  saveConfig(deviceRef: DeviceRef): Observable<void>;
1257
1257
  /**
1258
- * Replace the contents of the config.csv file with the provided data and instruct the device to load the updated configuration.
1258
+ * Replace or merge the contents of the config.csv file with the provided data and instruct the device to load the updated configuration.
1259
1259
  * The new configuration is loaded using the 0x1011:01 Restore All Default Parameters.
1260
1260
  * Optionally refreshes the device parameter values on Motion Master after applying the new configuration.
1261
1261
  *
1262
1262
  * @param deviceRef A reference to the device where the configuration will be applied.
1263
1263
  * @param data The new configuration data to be written to the config.csv file.
1264
+ * @param strategy The strategy to use when loading the configuration. Can be either 'replace' to overwrite the existing configuration or 'merge' to combine the new configuration with the existing one.
1264
1265
  * @param retryConfig Configuration settings for retrying the restore default parameters operation.
1265
1266
  * @param refresh A flag to refresh device parameter values after loading the new configuration, as Motion Master will otherwise use the old values.
1266
1267
  * @returns An observable that emits once the configuration has been successfully loaded.
1267
1268
  */
1268
- loadConfig(deviceRef: DeviceRef, data: Uint8Array | string, retryConfig?: RetryConfig, refresh?: boolean): Observable<void>;
1269
+ loadConfig(deviceRef: DeviceRef, data: Uint8Array | string, strategy?: LoadConfigStrategy, retryConfig?: RetryConfig, refresh?: boolean): Observable<void>;
1269
1270
  /**
1270
1271
  * Checks if the device has firmware by reading the Manufacturer Software Version parameter (0x100A:00).
1271
1272
  */
@@ -1303,7 +1304,7 @@ export declare class MotionMasterReqResClient {
1303
1304
  /**
1304
1305
  * @link https://www.wrike.com/open.htm?id=1375749957
1305
1306
  *
1306
- * TODO: Verify if the device is an Actilink S device and check the corresponding variant file.
1307
+ * @todo: Verify if the device is an Actilink S device and check the corresponding variant file.
1307
1308
  */
1308
1309
  isIntegroWithMultiturnEncoder(deviceRef: DeviceRef): Promise<boolean>;
1309
1310
  /**
@@ -1981,4 +1982,35 @@ export declare class MotionMasterReqResClient {
1981
1982
  * ```
1982
1983
  */
1983
1984
  executeForwardCallAndParseResponse(data: Uint8Array | string | object, requestTimeout?: number, messageId?: string): Observable<any>;
1985
+ /**
1986
+ * Auto-tunes the notch filter parameters based on the device's plant model.
1987
+ *
1988
+ * @param deviceSerialNumber - The serial number of the target device.
1989
+ * @returns An `Observable<NotchFilter>` that emits the parsed notch filter configuration upon success.
1990
+ *
1991
+ * @throws Will throw an error if:
1992
+ * - `deviceRef` is invalid.
1993
+ * - The device does not have a plant model.
1994
+ * - The forward call to the device fails.
1995
+ * - The auto-tune notch filter does not return finite valid values.
1996
+ * - The response cannot be parsed as valid JSON.
1997
+ */
1998
+ autoTuneNotchFilter(deviceRef: DeviceRef): Observable<NotchFilter>;
1999
+ /**
2000
+ *
2001
+ * Writes notch filter parameter values to the specified device.
2002
+ *
2003
+ * This method sets the individual parameters of the notch filter (0x2023) on the device:
2004
+ * - Subindex `0x01` → enabled flag
2005
+ * - Subindex `0x02` → center frequency (rounded to nearest integer)
2006
+ * - Subindex `0x03` → rejection band (rounded to nearest integer)
2007
+ * - Subindex `0x04` → depth
2008
+ *
2009
+ * @param deviceRef - Reference to the target device.
2010
+ * @param notchFilter - Notch filter values to write to the device.
2011
+ * @param requestTimeout - Optional timeout in milliseconds for the request (default: 1000).
2012
+ * @returns An `Observable<void>` that completes when the parameter values have been written successfully.
2013
+ *
2014
+ */
2015
+ setNotchFilterParameterValues(deviceRef: DeviceRef, notchFilter: NotchFilter, requestTimeout?: number): Observable<void>;
1984
2016
  }
@@ -2505,34 +2505,53 @@ class MotionMasterReqResClient {
2505
2505
  return this.storeParameters(deviceRef);
2506
2506
  }
2507
2507
  /**
2508
- * Replace the contents of the config.csv file with the provided data and instruct the device to load the updated configuration.
2508
+ * Replace or merge the contents of the config.csv file with the provided data and instruct the device to load the updated configuration.
2509
2509
  * The new configuration is loaded using the 0x1011:01 Restore All Default Parameters.
2510
2510
  * Optionally refreshes the device parameter values on Motion Master after applying the new configuration.
2511
2511
  *
2512
2512
  * @param deviceRef A reference to the device where the configuration will be applied.
2513
2513
  * @param data The new configuration data to be written to the config.csv file.
2514
+ * @param strategy The strategy to use when loading the configuration. Can be either 'replace' to overwrite the existing configuration or 'merge' to combine the new configuration with the existing one.
2514
2515
  * @param retryConfig Configuration settings for retrying the restore default parameters operation.
2515
2516
  * @param refresh A flag to refresh device parameter values after loading the new configuration, as Motion Master will otherwise use the old values.
2516
2517
  * @returns An observable that emits once the configuration has been successfully loaded.
2517
2518
  */
2518
- loadConfig(deviceRef, data, retryConfig = { count: 10, delay: 500 }, refresh = true) {
2519
- let content;
2520
- if (typeof data === 'string') {
2521
- const encoder = new TextEncoder();
2522
- content = encoder.encode(data);
2523
- }
2524
- else {
2525
- content = data;
2526
- }
2527
- return this.setFile(deviceRef, 'config.csv', content, true).pipe((0, operators_1.mergeMap)(() => this.restoreDefaultParameters(deviceRef, types_1.RestoreDefaultParametersType.RESTORE_ALL_DEFAULT_PARAMETERS, retryConfig)), (0, operators_1.mergeMap)(() => {
2519
+ loadConfig(deviceRef, data, strategy = 'replace', retryConfig = { count: 10, delay: 500 }, refresh = true) {
2520
+ const encoder = new TextEncoder(); // always utf-8
2521
+ const decoder = new TextDecoder('utf-8'); // explicitly set utf-8
2522
+ const content = typeof data === 'string' ? encoder.encode(data) : data;
2523
+ // If merging, parse the user-provided config file to extract its parameters.
2524
+ const csv = decoder.decode(content);
2525
+ const userConfigFile = new config_file_1.ConfigFile(csv);
2526
+ // Function to write the config file to the device.
2527
+ const setConfigFile = (content) => (0, rxjs_1.defer)(() => this.setFile(deviceRef, 'config.csv', content, true));
2528
+ // If merging, read the existing config file from the device, merge it with the user-provided config, and prepare the merged content for writing.
2529
+ const mergeConfigFiles$ = (0, rxjs_1.defer)(() => this.getDecodedFile(deviceRef, 'config.csv').pipe((0, operators_1.map)((text) => {
2530
+ const deviceConfigFile = new config_file_1.ConfigFile(text);
2531
+ // Merge user and device parameters. The order is important: userConfig parameters
2532
+ // are kept in case of duplicates. Finally, sort by index/subindex for consistency.
2533
+ deviceConfigFile.parameters = [...userConfigFile.parameters, ...deviceConfigFile.parameters]
2534
+ .filter((item, index, array) => array.findIndex((obj) => obj.index === item.index && obj.subindex === item.subindex) === index)
2535
+ .sort((a, b) => a.index - b.index || a.subindex - b.subindex);
2536
+ return encoder.encode(deviceConfigFile.toString());
2537
+ })));
2538
+ const setConfigFile$ = (0, rxjs_1.defer)(() => strategy === 'merge'
2539
+ ? mergeConfigFiles$.pipe((0, operators_1.mergeMap)((configContent) => setConfigFile(configContent)))
2540
+ : setConfigFile(content));
2541
+ return setConfigFile$.pipe((0, operators_1.mergeMap)(() => this.restoreDefaultParameters(deviceRef, types_1.RestoreDefaultParametersType.RESTORE_ALL_DEFAULT_PARAMETERS, retryConfig)), (0, operators_1.mergeMap)(() => {
2528
2542
  if (!refresh) {
2529
2543
  return rxjs_1.EMPTY;
2530
2544
  }
2531
- const decoder = new TextDecoder('utf-8'); // You can specify the encoding if needed
2532
- const text = decoder.decode(content);
2533
- const config = new config_file_1.ConfigFile(text);
2534
2545
  const deviceRefObj = (0, device_1.makeDeviceRefObj)(deviceRef);
2535
- return this.getDeviceParameterValues(Object.assign(Object.assign({}, deviceRefObj), { parameters: config.parameters.map((p) => ({ index: p.index, subindex: p.subindex, loadFromCache: false })), sendProgress: false }), 30000).pipe((0, operators_1.map)(() => undefined));
2546
+ return this.getDeviceParameterValues(Object.assign(Object.assign({}, deviceRefObj), {
2547
+ // TODO: Currently using `userConfigFile.parameters`.
2548
+ // Ideally, use the combined parameters when merging,
2549
+ // otherwise some parameters written to the device's config.csv might not get refreshed.
2550
+ parameters: userConfigFile.parameters.map((p) => ({
2551
+ index: p.index,
2552
+ subindex: p.subindex,
2553
+ loadFromCache: false,
2554
+ })), sendProgress: false }), 30000).pipe((0, operators_1.map)(() => undefined));
2536
2555
  }));
2537
2556
  }
2538
2557
  /**
@@ -2605,7 +2624,7 @@ class MotionMasterReqResClient {
2605
2624
  /**
2606
2625
  * @link https://www.wrike.com/open.htm?id=1375749957
2607
2626
  *
2608
- * TODO: Verify if the device is an Actilink S device and check the corresponding variant file.
2627
+ * @todo: Verify if the device is an Actilink S device and check the corresponding variant file.
2609
2628
  */
2610
2629
  isIntegroWithMultiturnEncoder(deviceRef) {
2611
2630
  var _a;
@@ -3858,6 +3877,70 @@ class MotionMasterReqResClient {
3858
3877
  throw new Error(`Failed to execute forward call: ${((_a = status.error) === null || _a === void 0 ? void 0 : _a.message) || 'Unknown error'}`);
3859
3878
  }));
3860
3879
  }
3880
+ /**
3881
+ * Auto-tunes the notch filter parameters based on the device's plant model.
3882
+ *
3883
+ * @param deviceSerialNumber - The serial number of the target device.
3884
+ * @returns An `Observable<NotchFilter>` that emits the parsed notch filter configuration upon success.
3885
+ *
3886
+ * @throws Will throw an error if:
3887
+ * - `deviceRef` is invalid.
3888
+ * - The device does not have a plant model.
3889
+ * - The forward call to the device fails.
3890
+ * - The auto-tune notch filter does not return finite valid values.
3891
+ * - The response cannot be parsed as valid JSON.
3892
+ */
3893
+ autoTuneNotchFilter(deviceRef) {
3894
+ return this.getPlantModel(deviceRef).pipe((0, operators_1.mergeMap)((plantModel) => {
3895
+ if (!plantModel) {
3896
+ throw new Error('Plant model is not available on the device.');
3897
+ }
3898
+ return this.executeForwardCallAndParseResponse({
3899
+ run: 'auto_tune_notch',
3900
+ data: {
3901
+ plant_model: {
3902
+ numerator: plantModel.numerator,
3903
+ denominator: plantModel.denominator,
3904
+ },
3905
+ },
3906
+ });
3907
+ }), (0, operators_1.map)((response) => {
3908
+ var _a;
3909
+ if (response.notch_dp === null || response.notch_fc === null || response.notch_fw === null) {
3910
+ throw new Error('Auto-tune notch filter returned null values.');
3911
+ }
3912
+ return {
3913
+ enabled: (_a = response.notch_en) !== null && _a !== void 0 ? _a : false,
3914
+ centerFrequency: response.notch_fc,
3915
+ rejectionBand: response.notch_fw,
3916
+ depth: response.notch_dp,
3917
+ };
3918
+ }));
3919
+ }
3920
+ /**
3921
+ *
3922
+ * Writes notch filter parameter values to the specified device.
3923
+ *
3924
+ * This method sets the individual parameters of the notch filter (0x2023) on the device:
3925
+ * - Subindex `0x01` → enabled flag
3926
+ * - Subindex `0x02` → center frequency (rounded to nearest integer)
3927
+ * - Subindex `0x03` → rejection band (rounded to nearest integer)
3928
+ * - Subindex `0x04` → depth
3929
+ *
3930
+ * @param deviceRef - Reference to the target device.
3931
+ * @param notchFilter - Notch filter values to write to the device.
3932
+ * @param requestTimeout - Optional timeout in milliseconds for the request (default: 1000).
3933
+ * @returns An `Observable<void>` that completes when the parameter values have been written successfully.
3934
+ *
3935
+ */
3936
+ setNotchFilterParameterValues(deviceRef, notchFilter, requestTimeout = 1000) {
3937
+ return this.setParameterValues([
3938
+ [deviceRef, 0x2023, 0x01, notchFilter.enabled ? 1 : 0],
3939
+ [deviceRef, 0x2023, 0x02, Math.round(notchFilter.centerFrequency)],
3940
+ [deviceRef, 0x2023, 0x03, Math.round(notchFilter.rejectionBand)],
3941
+ [deviceRef, 0x2023, 0x04, notchFilter.depth],
3942
+ ], requestTimeout);
3943
+ }
3861
3944
  }
3862
3945
  exports.MotionMasterReqResClient = MotionMasterReqResClient;
3863
3946
  /**