motion-master-client 0.0.340 → 0.0.342

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.
@@ -2539,21 +2539,45 @@ class MotionMasterReqResClient {
2539
2539
  ], false, requestTimeout).pipe((0, operators_1.map)((values) => values[0] / values[1]));
2540
2540
  }
2541
2541
  /**
2542
- * Computes the Gear Ratio for a given device.
2542
+ * Computes the mechanical Gear Ratio for the specified device.
2543
2543
  *
2544
- * The Gear Ratio is calculated as the quotient of:
2545
- * - Gear Ratio Numerator (`0x6091:01` – Motor Revolutions)
2546
- * - Gear Ratio Denominator (`0x6091:02` – Shaft Revolutions)
2544
+ * The Gear Ratio is derived from device parameters representing:
2545
+ * - Motor-side revolutions (`0x6091:01`)
2546
+ * - Shaft-side revolutions (`0x6091:02`)
2547
2547
  *
2548
- * @param deviceRef - Reference to the device for which the Gear Ratio is computed.
2549
- * @param requestTimeout - Optional timeout in milliseconds for the parameter request (default: 5000).
2550
- * @returns An Observable that emits the computed Gear Ratio as a number.
2548
+ * Additionally, encoder assignments for the torque and position control loops
2549
+ * are retrieved to determine whether an external mechanical ratio is present.
2550
+ *
2551
+ * If both control loops use the same encoder source (non-zero and equal),
2552
+ * the returned ratio is `1`, indicating no external mechanical reduction.
2553
+ *
2554
+ * Otherwise, the ratio is computed as:
2555
+ *
2556
+ * motorRevolutions / shaftRevolutions
2557
+ *
2558
+ * If shaftRevolutions is `0` or unavailable, a fallback value of `1` is returned.
2559
+ *
2560
+ * @param deviceRef Reference to the device whose Gear Ratio is computed.
2561
+ * @param loadFromCache If true, previously cached parameter values will be used instead of initiating device requests.
2562
+ * @param requestTimeout Timeout (in milliseconds) applied when reading parameter values from the device. Defaults to `5000`.
2563
+ *
2564
+ * @returns An Observable emitting a numeric Gear Ratio.
2551
2565
  */
2552
- computeGearRatio(deviceRef, requestTimeout = 5000) {
2566
+ computeGearRatio(deviceRef, loadFromCache = false, requestTimeout = 5000) {
2553
2567
  return this.getParameterValues([
2554
- [deviceRef, 0x6091, 1],
2555
- [deviceRef, 0x6091, 2], // Gear Ratio Denominator (`0x6091:02` – Shaft Revolutions)
2556
- ], false, requestTimeout).pipe((0, operators_1.map)((values) => values[0] / values[1]));
2568
+ [deviceRef, 0x6091, 0x01],
2569
+ [deviceRef, 0x6091, 0x02],
2570
+ [deviceRef, 0x2010, 0x0c],
2571
+ [deviceRef, 0x2012, 0x09], // Position controller encoder source
2572
+ ], loadFromCache, requestTimeout).pipe((0, operators_1.map)((values) => {
2573
+ const [motorRevolutions, shaftRevolutions, torqueControllerEncoderSource, positionControllerEncoderSource] = values;
2574
+ return (0, device_1.computeGearRatio)({
2575
+ motorRevolutions,
2576
+ shaftRevolutions,
2577
+ torqueControllerEncoderSource,
2578
+ positionControllerEncoderSource,
2579
+ });
2580
+ }));
2557
2581
  }
2558
2582
  /**
2559
2583
  * Save the modified parameter values to the config.csv file so that they are used the next time the device is power cycled.
@@ -3762,38 +3786,6 @@ class MotionMasterReqResClient {
3762
3786
  }));
3763
3787
  }));
3764
3788
  }
3765
- // TODO: Move to another file
3766
- getMaxValuePercentageColor(percentage) {
3767
- if (percentage >= 50 && percentage <= 100) {
3768
- return '#6ba853';
3769
- }
3770
- else if (percentage > 20 && percentage < 50) {
3771
- return '#aeb303';
3772
- }
3773
- else if (percentage > 0 && percentage <= 20) {
3774
- return '#e69138';
3775
- }
3776
- else if (percentage <= 0) {
3777
- return '#fb262e';
3778
- }
3779
- return '';
3780
- }
3781
- // TODO: Move to another file
3782
- getMaxValuePercentageLabel(percentage) {
3783
- if (percentage >= 50 && percentage <= 100) {
3784
- return 'Calibration was successful. Encoder system is robust to mechanical displacements and temperature expansions.';
3785
- }
3786
- else if (percentage > 20 && percentage < 50) {
3787
- return 'Calibration was successful. Encoder system is robust to small mechanical displacements and temperature expansions.';
3788
- }
3789
- else if (percentage > 0 && percentage <= 20) {
3790
- return 'Calibration was successful. Mechanical displacement and temperature expansions should be avoided.';
3791
- }
3792
- else if (percentage <= 0) {
3793
- return "Phase error is too high. The absolute position can't be computed reliably. Adjust mechanical position and repeat calibration.";
3794
- }
3795
- return '';
3796
- }
3797
3789
  /**
3798
3790
  * Checks the Circulo encoder error status registers for a specified encoder ordinal.
3799
3791
  *
@@ -4168,35 +4160,6 @@ class MotionMasterReqResClient {
4168
4160
  }
4169
4161
  }));
4170
4162
  }
4171
- /**
4172
- * Reads the motor and shaft revolutions from a device and calculates the gear ratio.
4173
- *
4174
- * The gear ratio is defined as the number of motor revolutions per one shaft revolution:
4175
- *
4176
- * gearRatio = motorRev / shaftRev
4177
- *
4178
- * If either motorRev or shaftRev is zero or negative, the function returns a default value of 1.
4179
- *
4180
- * @param deviceRef - Reference to the device from which to read the values.
4181
- * @returns A Promise that resolves to the gear ratio (positive number). Returns 1 if the readings are invalid.
4182
- *
4183
- * @remarks
4184
- * - Both motorRev and shaftRev are read via `upload()` from the device object dictionary at index 0x6091.
4185
- * - Ensure that `upload()` returns numeric values and not raw buffers.
4186
- * - This function assumes positive values; a negative value may indicate an error or reversed rotation.
4187
- */
4188
- getGearRatio(deviceRef) {
4189
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
4190
- const motorRev = yield this.upload(deviceRef, 0x6091, 1);
4191
- const shaftRev = yield this.upload(deviceRef, 0x6091, 2);
4192
- if (motorRev > 0 && shaftRev > 0) {
4193
- return motorRev / shaftRev;
4194
- }
4195
- else {
4196
- return 1;
4197
- }
4198
- });
4199
- }
4200
4163
  /**
4201
4164
  * Retrieves the PDO mapping for the given device.
4202
4165
  *