motion-master-client 0.0.299 → 0.0.300-hanging-load-tuner.1

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.
@@ -0,0 +1,236 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HangingLoadTuner = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const rxjs_1 = require("rxjs");
6
+ const cia402_1 = require("./cia402");
7
+ class HangingLoadTuner {
8
+ constructor(client) {
9
+ this.client = client;
10
+ this.notifications$ = new rxjs_1.Subject();
11
+ this.isRunning$ = new rxjs_1.BehaviorSubject(false);
12
+ this.monitoringCsvData = null;
13
+ this.timePrePostTrigger = 500; // Pre and post trigger for chirp signal recording in ms
14
+ this.controlGainUpdateTime = 10; // Control gain update cycle time in ms
15
+ }
16
+ /**
17
+ * Performs a hanging load tuning procedure on the specified device.
18
+ *
19
+ * The procedure:
20
+ * 1. Forces on-demand parameter update and disables the position feedback filter.
21
+ * 2. Checks and adjusts position encoder to match commutation encoder.
22
+ * 3. Reads commutation encoder resolution and feed constants to compute effective lambda.
23
+ * 4. Reads and stores initial controller parameters for restoration after the tuner is finished.
24
+ * 5. Calculates initial proportional gain (kpInit) based on torque limits, lambda, and encoder configuration.
25
+ * 6. Sets initial P-controller parameters on the device.
26
+ * 7. Starts monitoring the actual position during chirp signal injection.
27
+ * 8. Dynamically updates P-gain during execution based on actual error.
28
+ * 9. Executes a chirp signal.
29
+ * 10. Transitions device state back to SWITCH_ON_DISABLED.
30
+ * 11. Restores original encoder configuration, feedback filter, and controller parameters.
31
+ * 12. Returns the monitored data as a CSV string.
32
+ *
33
+ * @param deviceRef Target device reference (string | number).
34
+ * @param startFrequency Chirp signal start frequency (Hz).
35
+ * @param targetFrequency Chirp signal target frequency (Hz).
36
+ * @param targetAmplitude Chirp signal target amplitude.
37
+ * @param transitionTime Chirp signal transition time (ms).
38
+ * @param motionRangeLimit Chirp signal motion range limit (Inc or Feed).
39
+ * @returns Promise<boolean> indicating success or failure of the tuning procedure.
40
+ */
41
+ runHangingLoadTuner(deviceRef, startFrequency, targetFrequency, targetAmplitude, transitionTime, motionRangeLimit) {
42
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
43
+ this.isRunning$.next(true);
44
+ yield this.client.request.forceOnDemandParametersUpdate(deviceRef);
45
+ try {
46
+ yield this.client.request.download(deviceRef, 0x2022, 1, 0);
47
+ this.notifications$.next('Position feedback filter (0x2022:1) disabled.');
48
+ }
49
+ catch (error) {
50
+ this.handleAbortAndCleanup('Aborting: Unable to turn off position feedback filter (0x2022:1).');
51
+ }
52
+ const commutationEncoder = yield this.client.request.upload(deviceRef, 0x2010, 12);
53
+ const positionEncoder = yield this.client.request.upload(deviceRef, 0x2012, 9);
54
+ if (positionEncoder === 0) {
55
+ this.handleAbortAndCleanup('Aborting: No position encoder (0x2012:9) configured.');
56
+ }
57
+ if (positionEncoder !== commutationEncoder) {
58
+ yield this.client.request.download(deviceRef, 0x2012, 9, commutationEncoder);
59
+ yield this.client.request.forceOnDemandParametersUpdate(deviceRef);
60
+ }
61
+ else {
62
+ this.notifications$.next('Position feedback source already set to commutation encoder.');
63
+ }
64
+ let commutationEncoderResolution;
65
+ if (commutationEncoder === 1) {
66
+ commutationEncoderResolution = yield this.client.request.upload(deviceRef, 0x2110, 3);
67
+ }
68
+ else if (commutationEncoder === 2) {
69
+ commutationEncoderResolution = yield this.client.request.upload(deviceRef, 0x2112, 3);
70
+ }
71
+ else {
72
+ this.handleAbortAndCleanup('Invalid commutation encoder configuration detected.', false);
73
+ return false;
74
+ }
75
+ this.notifications$.next(`Commutation encoder resolution: ${commutationEncoderResolution}.`);
76
+ const lambdaMin = 1000; // Minimum permissable movement range
77
+ const feedConstantFeed = yield this.client.request.upload(deviceRef, 0x6092, 1);
78
+ const feedConstantShaftRevolutions = yield this.client.request.upload(deviceRef, 0x6092, 2);
79
+ let feedConstant = feedConstantFeed / feedConstantShaftRevolutions;
80
+ let lambdaMinEff;
81
+ if (feedConstant === 0 || feedConstant === 4294967295) {
82
+ this.notifications$.next('Feed constant is disabled.');
83
+ lambdaMinEff = lambdaMin;
84
+ }
85
+ else {
86
+ this.notifications$.next(`Feed constant: ${feedConstant}.`);
87
+ if (feedConstant / commutationEncoderResolution > 1) {
88
+ lambdaMinEff = Math.round((lambdaMin * feedConstant) / commutationEncoderResolution);
89
+ }
90
+ else {
91
+ lambdaMinEff = lambdaMin;
92
+ }
93
+ }
94
+ const initialControllerParameters = yield this.client.request.uploadMany([
95
+ [deviceRef, 0x2012, 1],
96
+ [deviceRef, 0x2012, 2],
97
+ [deviceRef, 0x2012, 3],
98
+ [deviceRef, 0x2002, 0],
99
+ ]);
100
+ const kpp = initialControllerParameters[0];
101
+ const kip = initialControllerParameters[1];
102
+ const kdp = initialControllerParameters[2];
103
+ const controlMode = initialControllerParameters[3];
104
+ const maxTorque = yield this.client.request.upload(deviceRef, 0x6072, 0);
105
+ const motorRevolutions = yield this.client.request.upload(deviceRef, 0x6091, 1);
106
+ const shaftRevolutions = yield this.client.request.upload(deviceRef, 0x6091, 2);
107
+ const gearRatio = motorRevolutions / shaftRevolutions;
108
+ const lambda = motionRangeLimit * gearRatio;
109
+ let kpInit;
110
+ let xiSquared;
111
+ if (feedConstant === 0 || feedConstant === 4294967295) {
112
+ xiSquared = Math.min(maxTorque, 1000 * Math.sqrt(lambda / lambdaMinEff)) * lambda;
113
+ kpInit = xiSquared / Math.pow(lambda, 2);
114
+ }
115
+ else {
116
+ xiSquared =
117
+ ((Math.min(maxTorque, 1000 * Math.sqrt(lambda / lambdaMinEff)) * lambda) / feedConstant) *
118
+ commutationEncoderResolution;
119
+ kpInit = xiSquared / Math.pow((lambda / feedConstant) * commutationEncoderResolution, 2);
120
+ }
121
+ this.notifications$.next(`Xi squared: ${xiSquared}`);
122
+ this.notifications$.next(`Initial P-gain: ${kpInit}`);
123
+ yield this.client.request.downloadMany([
124
+ [deviceRef, 0x2002, 0, 1],
125
+ [deviceRef, 0x2012, 1, kpInit],
126
+ [deviceRef, 0x2012, 2, 0],
127
+ [deviceRef, 0x2012, 3, 0],
128
+ ]);
129
+ this.notifications$.next(`Initial P-controller set with gain ${kpInit.toFixed(6)}.`);
130
+ let actualPosition;
131
+ const dataMonitoring = this.client.createDataMonitoring([
132
+ [deviceRef, 0x20f0, 0],
133
+ [deviceRef, 0x6064, 0], // Position actual value
134
+ ], 1);
135
+ dataMonitoring.start(true).subscribe((data) => {
136
+ actualPosition = data[1];
137
+ });
138
+ const positionActualValue = yield this.client.request.upload(deviceRef, 0x6064, 0);
139
+ this.updateControlGain(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
140
+ const e = positionActualValue - actualPosition;
141
+ let kp;
142
+ if (feedConstant === 0 || feedConstant === 4294967295) {
143
+ kp = xiSquared / Math.pow(Math.max(lambda - Math.abs(e), 1), 2);
144
+ }
145
+ else {
146
+ kp =
147
+ xiSquared / Math.pow((Math.max(lambda - Math.abs(e), 1) / feedConstant) * commutationEncoderResolution, 2);
148
+ }
149
+ yield this.client.request.download(deviceRef, 0x2012, 1, kp);
150
+ }), () => this.isRunning$.getValue());
151
+ try {
152
+ yield this.client.request.download(deviceRef, 0x607a, 0, positionActualValue);
153
+ this.notifications$.next(`Target position set to actual position: ${positionActualValue}.`);
154
+ }
155
+ catch (_a) {
156
+ this.handleAbortAndCleanup('Aborting: Failed to set target position.', true, true, dataMonitoring);
157
+ }
158
+ let hrdStreamingDuration = transitionTime + this.timePrePostTrigger * 2;
159
+ if (hrdStreamingDuration > 10000) {
160
+ this.notifications$.next('Warning: HRD Streaming Duration exceeded 10000 ms, capping to 10000 ms.');
161
+ hrdStreamingDuration = 10000;
162
+ }
163
+ try {
164
+ this.notifications$.next('Running chirp signal...');
165
+ const chirpSignalResult = yield (0, rxjs_1.lastValueFrom)(this.client.request.runChirpSignal(deviceRef, startFrequency, targetFrequency, targetAmplitude, transitionTime, 0, hrdStreamingDuration));
166
+ if (!chirpSignalResult) {
167
+ this.handleAbortAndCleanup('Aborting: Chirp signal failed.', true, true, dataMonitoring);
168
+ }
169
+ else if ('request' in chirpSignalResult && chirpSignalResult.request === 'succeeded') {
170
+ this.notifications$.next('Chirp signal executed successfully.');
171
+ }
172
+ else {
173
+ const errorName = chirpSignalResult && 'errorName' in chirpSignalResult ? chirpSignalResult.errorName : 'Unknown';
174
+ const errorDescription = chirpSignalResult && 'errorDescription' in chirpSignalResult
175
+ ? chirpSignalResult.errorDescription
176
+ : 'No description';
177
+ this.handleAbortAndCleanup(`Aborting: ${errorName} - ${errorDescription}.`, true, true, dataMonitoring);
178
+ return false;
179
+ }
180
+ }
181
+ catch (_b) {
182
+ this.handleAbortAndCleanup('Aborting: Failed to run chirp signal.', true, true, dataMonitoring);
183
+ }
184
+ try {
185
+ yield this.client.request.transitionToCia402State(deviceRef, cia402_1.Cia402State.SWITCH_ON_DISABLED);
186
+ this.notifications$.next('Transitioned to SWITCH_ON_DISABLED state.');
187
+ }
188
+ catch (_c) {
189
+ this.handleAbortAndCleanup('Aborting: Failed to transition to SWITCH_ON_DISABLED state.', true, true, dataMonitoring);
190
+ }
191
+ dataMonitoring.stop();
192
+ if (positionEncoder !== commutationEncoder) {
193
+ yield this.client.request.download(deviceRef, 0x2012, 9, positionEncoder);
194
+ yield this.client.request.forceOnDemandParametersUpdate(deviceRef);
195
+ this.notifications$.next('Original position encoder configuration has been restored.');
196
+ }
197
+ yield this.client.request.download(deviceRef, 0x2022, 1, 1);
198
+ this.notifications$.next('Position feedback filter has been turned on again.');
199
+ yield this.client.request.downloadMany([
200
+ [deviceRef, 0x2002, 0, controlMode],
201
+ [deviceRef, 0x2012, 1, kpp],
202
+ [deviceRef, 0x2012, 2, kip],
203
+ [deviceRef, 0x2012, 3, kdp],
204
+ ]);
205
+ this.notifications$.next('Original controller parameters have been restored.');
206
+ this.isRunning$.next(false);
207
+ this.monitoringCsvData = dataMonitoring.csv;
208
+ return true;
209
+ });
210
+ }
211
+ handleAbortAndCleanup(notificationEntry, stopTheFunction = true, isMonitoringRunning, dataMonitoring) {
212
+ this.isRunning$.next(false);
213
+ this.notifications$.next(notificationEntry);
214
+ if (isMonitoringRunning) {
215
+ this.monitoringCsvData = (dataMonitoring === null || dataMonitoring === void 0 ? void 0 : dataMonitoring.csv) || null;
216
+ dataMonitoring === null || dataMonitoring === void 0 ? void 0 : dataMonitoring.stop();
217
+ }
218
+ if (stopTheFunction) {
219
+ return false;
220
+ }
221
+ else {
222
+ return true;
223
+ }
224
+ }
225
+ updateControlGain(calculateControlGain, stopFlag) {
226
+ const intervalId = setInterval(() => {
227
+ if (stopFlag()) {
228
+ clearInterval(intervalId);
229
+ return;
230
+ }
231
+ calculateControlGain();
232
+ }, 100);
233
+ }
234
+ }
235
+ exports.HangingLoadTuner = HangingLoadTuner;
236
+ //# sourceMappingURL=hanging-load-tuner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hanging-load-tuner.js","sourceRoot":"","sources":["../../../../../libs/motion-master-client/src/lib/hanging-load-tuner.ts"],"names":[],"mappings":";;;;AAAA,+BAA+E;AAC/E,qCAAyD;AAKzD,MAAa,gBAAgB;IAU3B,YAA4B,MAA0B;QAA1B,WAAM,GAAN,MAAM,CAAoB;QATtC,mBAAc,GAAG,IAAI,cAAO,EAAU,CAAC;QAEvC,eAAU,GAAG,IAAI,sBAAe,CAAU,KAAK,CAAC,CAAC;QAE1D,sBAAiB,GAAkB,IAAI,CAAC;QAE/C,uBAAkB,GAAG,GAAG,CAAC,CAAC,wDAAwD;QAClF,0BAAqB,GAAG,EAAE,CAAC,CAAC,uCAAuC;IAEV,CAAC;IAE1D;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,mBAAmB,CACvB,SAAoB,EACpB,cAAsB,EACtB,eAAuB,EACvB,eAAuB,EACvB,cAAsB,EACtB,gBAAwB;;YAExB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC3B,MAAM,IAAI,CAAC,MAAM,CAAC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EAAE,CAAC,EAAE,GAAG,CAAC;aAC5B,CAAC,CAAC;YAEH,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;YAC/E,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC5B,IAAI,CAAC,iBAAiB,GAAG,cAAc,CAAC,GAAG,CAAC;YAE5C,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;IAEO,qBAAqB,CAC3B,iBAAyB,EACzB,kBAA2B,IAAI,EAC/B,mBAA6B,EAC7B,cAA+B;QAE/B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC5C,IAAI,mBAAmB,EAAE;YACvB,IAAI,CAAC,iBAAiB,GAAG,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,GAAG,KAAI,IAAI,CAAC;YACrD,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,IAAI,EAAE,CAAC;SACxB;QACD,IAAI,eAAe,EAAE;YACnB,OAAO,KAAK,CAAC;SACd;aAAM;YACL,OAAO,IAAI,CAAC;SACb;IACH,CAAC;IAED,iBAAiB,CAAC,oBAAgC,EAAE,QAAmB;QACrE,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE;YAClC,IAAI,QAAQ,EAAE,EAAE;gBACd,aAAa,CAAC,UAAU,CAAC,CAAC;gBAC1B,OAAO;aACR;YACD,oBAAoB,EAAE,CAAC;QACzB,CAAC,EAAE,GAAG,CAAC,CAAC;IACV,CAAC;CACF;AA5RD,4CA4RC"}
@@ -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 } 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 } 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';
@@ -1836,17 +1836,6 @@ export declare class MotionMasterReqResClient {
1836
1836
  * @returns An observable that emits an array of `EncoderRegisterCommunicationOsCommandResponse` objects.
1837
1837
  */
1838
1838
  readCirculoIntegratedEncoderKeyConfigurationRegisters(deviceRef: DeviceRef, encoderOrdinal: number, commandTimeout?: number): Observable<EncoderRegisterCommunicationOsCommandResponse[]>;
1839
- /**
1840
- * Retrieves the supported encoder configuration types for the specified device.
1841
- *
1842
- * Resolves the device reference, fetches the supported encoder options and firmware version,
1843
- * then combines these to determine which encoder configurations are supported.
1844
- *
1845
- * @param deviceRef - A reference to the device for which to fetch supported encoder configurations.
1846
- * @returns An Observable emitting a two-dimensional array of numbers, where each inner array corresponds to
1847
- * the supported encoder configuration types for a specific encoder port.
1848
- */
1849
- getSupportedEncoderConfigurationTypes(deviceRef: DeviceRef): Observable<number[][]>;
1850
1839
  /**
1851
1840
  * Retrieves the supported analog input (AI) modes for the specified device.
1852
1841
  *
@@ -1885,4 +1874,72 @@ export declare class MotionMasterReqResClient {
1885
1874
  * all errors found in the queried encoder status registers.
1886
1875
  */
1887
1876
  checkCirculoEncoderErrors(deviceRef: DeviceRef, encoderOrdinal: number): Observable<EncoderRegisterError[]>;
1877
+ /**
1878
+ * Uploads and configures SMM parameters on the specified device from a CSV configuration file.
1879
+ *
1880
+ * This function performs the following steps in sequence:
1881
+ * 1. Parses the CSV config file into structured parameters.
1882
+ * 2. Resolves the SMM parameter structure version for the device.
1883
+ * 3. Groups and maps parameters according to the SMM Object Dictionary.
1884
+ * 4. Validates that the parameter counts match between the config and SMM structure.
1885
+ * 5. Logs out from the SMM if already logged in.
1886
+ * 6. Logs in for parameter download using provided credentials.
1887
+ * 7. Transmits the parameters to the device.
1888
+ * 8. Verifies transmitted parameters by reloading and matching values.
1889
+ * 9. Sequentially verifies each parameter group on the device.
1890
+ * 10. Loads and validates the safety parameters validation file.
1891
+ * 11. Reloads the SMM parameters to refresh the stored values.
1892
+ * 12. Ensures proper logout in all cases, including errors.
1893
+ *
1894
+ * @param deviceRef - Reference to the target device to configure.
1895
+ * @param username - Username used to log in for parameter download.
1896
+ * @param password - Password used to log in for parameter download.
1897
+ * @param configFileContent - The raw CSV content of the configuration file.
1898
+ *
1899
+ * @returns An Observable that emits a status object:
1900
+ * - `{ request: 'succeeded' }` on successful configuration.
1901
+ * - `{ request: 'failed', error: { message } }` on failure with an error message.
1902
+ *
1903
+ * @remarks
1904
+ * This method uses RxJS operators to ensure that each asynchronous step completes before the next begins.
1905
+ * It also guarantees logout from the device when the operation finishes or if any error occurs.
1906
+ */
1907
+ configureSmmFromFile(deviceRef: DeviceRef, username: string, password: string, configFileContent: string): Observable<{
1908
+ request: RequestStatus;
1909
+ error?: {
1910
+ message?: string;
1911
+ };
1912
+ }>;
1913
+ /**
1914
+ * Executes a sequential system identification chirp signal workflow on the specified device.
1915
+ *
1916
+ * This method performs the following steps in strict sequence:
1917
+ * 1. Sets the device's mode of operation to CYCLIC_SYNC_POSITION_MODE.
1918
+ * 2. Transitions the device to the OPERATION_ENABLED state.
1919
+ * 3. Configures the chirp signal parameters:
1920
+ * - Start frequency
1921
+ * - Target frequency
1922
+ * - Target amplitude
1923
+ * - Transition time
1924
+ * - Signal type
1925
+ * - Start the procedure
1926
+ * 4. Sends start commands for system identification.
1927
+ * 5. Configures HRD streaming for system identification data with the specified streaming duration.
1928
+ * 6. Starts HRD streaming for data collection.
1929
+ *
1930
+ * This ensures the device is fully prepared and triggered for executing a chirp signal for system identification,
1931
+ * while strictly maintaining the required execution order to prevent device misconfiguration.
1932
+ *
1933
+ * @param deviceRef - Reference to the device on which the chirp signal should be executed.
1934
+ * @param startFrequency - The starting frequency of the chirp signal (mHz).
1935
+ * @param targetFrequency - The target frequency of the chirp signal (mHz).
1936
+ * @param targetAmplitude - The target amplitude of the chirp signal (permils of rated torque).
1937
+ * @param transitionTime - The time in milliseconds for the signal to transition from start to target frequency (ms).
1938
+ * @param signalType - The type of signal to use for the chirp (e.g., logarithmic, linear).
1939
+ * @param hrdStreamingDuration - The duration in milliseconds for HRD streaming during system identification.
1940
+ *
1941
+ * @returns An Observable that emits the last emitted `SystemIdentificationOsCommandResponse` or `HrdStreamingOsCommandResponse`
1942
+ * from the sequence, or `void` if the underlying command emits no payload.
1943
+ */
1944
+ runChirpSignal(deviceRef: DeviceRef, startFrequency: number, targetFrequency: number, targetAmplitude: number, transitionTime: number, signalType: number, hrdStreamingDuration: number): Observable<void | SystemIdentificationOsCommandResponse | HrdStreamingOsCommandResponse>;
1888
1945
  }
@@ -3488,26 +3488,6 @@ class MotionMasterReqResClient {
3488
3488
  const defferedOsCommands = registerAddresses.map((registerAddress) => (0, rxjs_1.defer)(() => this.runEncoderRegisterCommunicationOsCommand(deviceRef, encoderOrdinal, 0, 0, registerAddress, undefined, commandTimeout).pipe((0, operators_1.last)())));
3489
3489
  return (0, rxjs_1.concat)(...defferedOsCommands).pipe((0, operators_1.toArray)());
3490
3490
  }
3491
- /**
3492
- * Retrieves the supported encoder configuration types for the specified device.
3493
- *
3494
- * Resolves the device reference, fetches the supported encoder options and firmware version,
3495
- * then combines these to determine which encoder configurations are supported.
3496
- *
3497
- * @param deviceRef - A reference to the device for which to fetch supported encoder configurations.
3498
- * @returns An Observable emitting a two-dimensional array of numbers, where each inner array corresponds to
3499
- * the supported encoder configuration types for a specific encoder port.
3500
- */
3501
- getSupportedEncoderConfigurationTypes(deviceRef) {
3502
- return this.resolveDevice(deviceRef).pipe((0, operators_1.mergeMap)((device) => {
3503
- if (!device.versionedDeviceProductId) {
3504
- return [];
3505
- }
3506
- const supportedOptionsPromise = (0, fetch_1.fetchSupportedEncoderConfigurationTypes)();
3507
- const firmwareVersionPromise = this.upload(deviceRef, 0x100a, 0);
3508
- return extractFirmwareProductSupportedOptions(supportedOptionsPromise, firmwareVersionPromise, device.versionedDeviceProductId);
3509
- }));
3510
- }
3511
3491
  /**
3512
3492
  * Retrieves the supported analog input (AI) modes for the specified device.
3513
3493
  *
@@ -3632,6 +3612,151 @@ class MotionMasterReqResClient {
3632
3612
  ];
3633
3613
  }));
3634
3614
  }
3615
+ /**
3616
+ * Uploads and configures SMM parameters on the specified device from a CSV configuration file.
3617
+ *
3618
+ * This function performs the following steps in sequence:
3619
+ * 1. Parses the CSV config file into structured parameters.
3620
+ * 2. Resolves the SMM parameter structure version for the device.
3621
+ * 3. Groups and maps parameters according to the SMM Object Dictionary.
3622
+ * 4. Validates that the parameter counts match between the config and SMM structure.
3623
+ * 5. Logs out from the SMM if already logged in.
3624
+ * 6. Logs in for parameter download using provided credentials.
3625
+ * 7. Transmits the parameters to the device.
3626
+ * 8. Verifies transmitted parameters by reloading and matching values.
3627
+ * 9. Sequentially verifies each parameter group on the device.
3628
+ * 10. Loads and validates the safety parameters validation file.
3629
+ * 11. Reloads the SMM parameters to refresh the stored values.
3630
+ * 12. Ensures proper logout in all cases, including errors.
3631
+ *
3632
+ * @param deviceRef - Reference to the target device to configure.
3633
+ * @param username - Username used to log in for parameter download.
3634
+ * @param password - Password used to log in for parameter download.
3635
+ * @param configFileContent - The raw CSV content of the configuration file.
3636
+ *
3637
+ * @returns An Observable that emits a status object:
3638
+ * - `{ request: 'succeeded' }` on successful configuration.
3639
+ * - `{ request: 'failed', error: { message } }` on failure with an error message.
3640
+ *
3641
+ * @remarks
3642
+ * This method uses RxJS operators to ensure that each asynchronous step completes before the next begins.
3643
+ * It also guarantees logout from the device when the operation finishes or if any error occurs.
3644
+ */
3645
+ configureSmmFromFile(deviceRef, username, password, configFileContent) {
3646
+ // Parse the configuration file content into a ConfigFile object.
3647
+ const configFile = new config_file_1.ConfigFile(configFileContent);
3648
+ // Fail lambda to handle errors in a consistent way.
3649
+ const fail = (message) => (0, rxjs_1.throwError)(() => new Error(message));
3650
+ // Resolve the SMM parameter structure version for getting the correct SMM OD.
3651
+ return this.resolveSmmParameterStructureVersion(deviceRef).pipe((0, operators_1.concatMap)((parameterStructureVersion) => {
3652
+ const smmOd = (0, smm_1.resolveSmmOd)(parameterStructureVersion);
3653
+ // Group SMM safety parameters by their 'group' property,
3654
+ // then for each group, map the SMM OD parameters to the matching
3655
+ // config file values (or 0 if missing). Also add the structure version
3656
+ // as a special 'None' group used for transmission.
3657
+ const groupedValues = {};
3658
+ for (const [group, smmOdParameters] of (0, util_1.mapByProperty)(smmOd.parameters.safety, 'group')) {
3659
+ const values = smmOdParameters.map(({ index, subindex }) => { var _a, _b; return (_b = (_a = configFile.parameters.find((p) => p.index === index && p.subindex === subindex)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0; });
3660
+ groupedValues[group] = values;
3661
+ }
3662
+ groupedValues['None'] = [parameterStructureVersion];
3663
+ // Convert the grouped values into a format suitable for transmission.
3664
+ const values = (0, smm_1.convertGroupedSmmParametersToTransmitData)(groupedValues);
3665
+ // Ensure the number of values (excluding the structure version) matches the config file parameter count.
3666
+ if (values.length - 1 !== configFile.parameters.length) {
3667
+ return fail(`Mismatch: the configuration file contains ${configFile.parameters.length} parameters, but the SMM parameter structure expects ${values.length - 1}.`);
3668
+ }
3669
+ // Log out from SMM if already logged in, then log in for parameter download.
3670
+ return this.logoutFromSmm(deviceRef).pipe((0, operators_1.concatMap)(() => this.loginToSmmForParameterDownload(deviceRef, username, password)), (0, operators_1.concatMap)((loginSuccess) => {
3671
+ if (!loginSuccess) {
3672
+ return fail('Failed to log in for parameter download.');
3673
+ }
3674
+ // Transmit the SMM parameters, then verify them by loading and checking against the original values.
3675
+ return this.transmitSmmParameters(deviceRef, values, parameterStructureVersion).pipe((0, operators_1.concatMap)((transmitSuccess) => {
3676
+ if (!transmitSuccess) {
3677
+ return fail('Failed to transmit SMM parameters.');
3678
+ }
3679
+ // Load the SMM parameters for verification.
3680
+ return this.loadSmmParametersForVerification(deviceRef).pipe((0, operators_1.concatMap)((status) => {
3681
+ if (status.request === 'failed') {
3682
+ const message = status.errorName && status.errorDescription
3683
+ ? `${status.errorName}: ${status.errorDescription}`
3684
+ : status.errorName || status.errorDescription || '';
3685
+ return fail(message);
3686
+ }
3687
+ // Verify that the loaded values match the original values.
3688
+ if (status.values.join(',') !== values.join(',')) {
3689
+ return fail('Verification mismatch after loading parameters.');
3690
+ }
3691
+ // Group entries excluding the structure version for verification.
3692
+ const groupEntries = Object.entries(groupedValues).slice(1);
3693
+ // Sequentially verify each parameter group on the SMM.
3694
+ // For each group entry, call verifySmmParameters and fail if any group fails verification.
3695
+ // Uses concatMap to ensure groups are verified one after another in order.
3696
+ return (0, rxjs_1.from)(groupEntries).pipe((0, operators_1.concatMap)(([_, groupValues], i) => this.verifySmmParameters(deviceRef, groupValues, i + 1, // Skipping the first group (None).
3697
+ parameterStructureVersion).pipe((0, operators_1.concatMap)((verifySuccess) => {
3698
+ if (!verifySuccess) {
3699
+ return fail(`Verification failed for parameter group ${i + 1}.`);
3700
+ }
3701
+ return (0, rxjs_1.of)(true);
3702
+ }))), (0, operators_1.toArray)(), // Collect all verification results.
3703
+ (0, operators_1.concatMap)(() => this.loadSmmValidationFileAndReadSafetyParametersReportFile(deviceRef).pipe((0, operators_1.concatMap)((validationFile) => {
3704
+ if (!validationFile) {
3705
+ return fail('Failed to load the safety parameters validation file.');
3706
+ }
3707
+ // Encode validation file content as Uint8Array for transmission.
3708
+ const report = new TextEncoder().encode(validationFile);
3709
+ return this.validateSmmConfiguration(deviceRef, report, new Date(), username, password).pipe((0, operators_1.concatMap)((validateSuccess) => {
3710
+ if (!validateSuccess) {
3711
+ return fail('SMM configuration validation failed.');
3712
+ }
3713
+ // Re-read the SMM parameters to update the values stored on the Motion Master.
3714
+ return this.getSmmOdParameters(deviceRef, parameterStructureVersion, 'device', false).pipe((0, operators_1.map)(() => ({
3715
+ request: 'succeeded',
3716
+ })));
3717
+ }));
3718
+ }))));
3719
+ }));
3720
+ }));
3721
+ }));
3722
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)({ request: 'failed', error: { message: error.message } })), (0, operators_1.finalize)(() => {
3723
+ this.logoutFromSmm(deviceRef).subscribe();
3724
+ }));
3725
+ }
3726
+ /**
3727
+ * Executes a sequential system identification chirp signal workflow on the specified device.
3728
+ *
3729
+ * This method performs the following steps in strict sequence:
3730
+ * 1. Sets the device's mode of operation to CYCLIC_SYNC_POSITION_MODE.
3731
+ * 2. Transitions the device to the OPERATION_ENABLED state.
3732
+ * 3. Configures the chirp signal parameters:
3733
+ * - Start frequency
3734
+ * - Target frequency
3735
+ * - Target amplitude
3736
+ * - Transition time
3737
+ * - Signal type
3738
+ * - Start the procedure
3739
+ * 4. Sends start commands for system identification.
3740
+ * 5. Configures HRD streaming for system identification data with the specified streaming duration.
3741
+ * 6. Starts HRD streaming for data collection.
3742
+ *
3743
+ * This ensures the device is fully prepared and triggered for executing a chirp signal for system identification,
3744
+ * while strictly maintaining the required execution order to prevent device misconfiguration.
3745
+ *
3746
+ * @param deviceRef - Reference to the device on which the chirp signal should be executed.
3747
+ * @param startFrequency - The starting frequency of the chirp signal (mHz).
3748
+ * @param targetFrequency - The target frequency of the chirp signal (mHz).
3749
+ * @param targetAmplitude - The target amplitude of the chirp signal (permils of rated torque).
3750
+ * @param transitionTime - The time in milliseconds for the signal to transition from start to target frequency (ms).
3751
+ * @param signalType - The type of signal to use for the chirp (e.g., logarithmic, linear).
3752
+ * @param hrdStreamingDuration - The duration in milliseconds for HRD streaming during system identification.
3753
+ *
3754
+ * @returns An Observable that emits the last emitted `SystemIdentificationOsCommandResponse` or `HrdStreamingOsCommandResponse`
3755
+ * from the sequence, or `void` if the underlying command emits no payload.
3756
+ */
3757
+ runChirpSignal(deviceRef, startFrequency, targetFrequency, targetAmplitude, transitionTime, signalType, hrdStreamingDuration) {
3758
+ return (0, rxjs_1.concat)(this.setModesOfOperation(deviceRef, cia402_1.ModesOfOperation.CYCLIC_SYNC_POSITION_MODE), this.transitionToCia402State(deviceRef, cia402_1.Cia402State.OPERATION_ENABLED), this.runSystemIdentificationOsCommand(deviceRef, 0, startFrequency, 30000), this.runSystemIdentificationOsCommand(deviceRef, 1, targetFrequency, 30000), this.runSystemIdentificationOsCommand(deviceRef, 2, targetAmplitude, 30000), this.runSystemIdentificationOsCommand(deviceRef, 3, transitionTime, 30000), this.runSystemIdentificationOsCommand(deviceRef, 4, signalType, 30000), this.runSystemIdentificationOsCommand(deviceRef, 5, 0, 30000), this.runSystemIdentificationOsCommand(deviceRef, 5, 2, 30000), this.runHrdStreamingOsCommand(deviceRef, os_command_1.HrdStreamingOsCommandAction.CONFIGURE_STREAM, os_command_1.HrdStreamingOsCommandDataIndex.SYSTEM_IDENTIFICATION_DATA, hrdStreamingDuration !== null && hrdStreamingDuration !== void 0 ? hrdStreamingDuration : 5000, 30000), this.runHrdStreamingOsCommand(deviceRef, os_command_1.HrdStreamingOsCommandAction.START_STREAM, os_command_1.HrdStreamingOsCommandDataIndex.SYSTEM_IDENTIFICATION_DATA, hrdStreamingDuration !== null && hrdStreamingDuration !== void 0 ? hrdStreamingDuration : 5000, 30000));
3759
+ }
3635
3760
  }
3636
3761
  exports.MotionMasterReqResClient = MotionMasterReqResClient;
3637
3762
  /**