motion-master-client 0.0.428 → 0.0.430
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.
- package/package.json +1 -1
- package/src/api.js +259 -215
- package/src/api.js.map +1 -1
- package/src/lib/config-file.js +26 -10
- package/src/lib/config-file.js.map +1 -1
- package/src/lib/firmware.js +13 -6
- package/src/lib/firmware.js.map +1 -1
- package/src/lib/homing.d.ts +18 -0
- package/src/lib/homing.js +19 -1
- package/src/lib/homing.js.map +1 -1
- package/src/lib/integro-encoder-calibration.js +5 -6
- package/src/lib/integro-encoder-calibration.js.map +1 -1
- package/src/lib/limited-range-system-identification.d.ts +28 -0
- package/src/lib/limited-range-system-identification.js +87 -41
- package/src/lib/limited-range-system-identification.js.map +1 -1
- package/src/lib/motion-master-client.d.ts +50 -6
- package/src/lib/motion-master-client.js +136 -64
- package/src/lib/motion-master-client.js.map +1 -1
- package/src/lib/motion-master-req-res-client.d.ts +138 -12
- package/src/lib/motion-master-req-res-client.js +257 -28
- package/src/lib/motion-master-req-res-client.js.map +1 -1
- package/src/lib/motion-master.proto.d.ts +179 -2
- package/src/lib/motion-master.proto.js +1998 -4
- package/src/lib/request-status-resolver.js +9 -0
- package/src/lib/request-status-resolver.js.map +1 -1
- package/src/lib/types.d.ts +61 -6
- package/src/lib/types.js +26 -1
- package/src/lib/types.js.map +1 -1
|
@@ -1306,6 +1306,45 @@ class MotionMasterReqResClient {
|
|
|
1306
1306
|
const id = this.sendRequest({ getDeviceSii }, messageId);
|
|
1307
1307
|
return this.socket.message$.pipe((0, operators_2.transformMotionMasterMessageToStatus)('deviceSii', requestTimeout, id));
|
|
1308
1308
|
}
|
|
1309
|
+
/**
|
|
1310
|
+
* Find the drives on a network adapter without opening a connection to any of them.
|
|
1311
|
+
*
|
|
1312
|
+
* Motion Master sends a PROFINET DCP Identify All and an EtherNet/IP ListIdentity broadcast, and listens for the
|
|
1313
|
+
* answers and for LLDP for `durationMs`. A drive with PROFINET firmware answers with or without an IP address and on
|
|
1314
|
+
* any subnet. A drive with EtherNet/IP firmware and an IP address answers too. Every other drive is found by LLDP,
|
|
1315
|
+
* which a drive sends about every 30 s, so a discovery of 35000 ms finds it.
|
|
1316
|
+
*
|
|
1317
|
+
* The status has one row per drive in `devices`, and `error` when the discovery could not run, for example for a
|
|
1318
|
+
* `durationMs` outside 1000 to 60000 ms or a missing privilege. The request works while the SOEM or the SPoE driver
|
|
1319
|
+
* runs, on the same network adapter too.
|
|
1320
|
+
*
|
|
1321
|
+
* {@link stopEthernetDiscovery} ends the discovery early, and so does a disconnect of this client. The status then
|
|
1322
|
+
* comes at once, with the drives found until then and `stopped` set.
|
|
1323
|
+
*
|
|
1324
|
+
* @param props.mac the MAC address of the network adapter, as Motion Master takes it in `--mac`
|
|
1325
|
+
* @param props.durationMs how long to collect answers, from 1000 to 60000 ms
|
|
1326
|
+
* @param requestTimeout how long to wait for the status; by default 5000 ms longer than `durationMs`
|
|
1327
|
+
*/
|
|
1328
|
+
discoverEthernetDevices(props, requestTimeout, messageId) {
|
|
1329
|
+
var _a;
|
|
1330
|
+
if (requestTimeout === void 0) { requestTimeout = ((_a = props.durationMs) !== null && _a !== void 0 ? _a : 0) + 5000; }
|
|
1331
|
+
const discoverEthernetDevices = types_1.MotionMasterMessage.Request.DiscoverEthernetDevices.create(props);
|
|
1332
|
+
const id = this.sendRequest({ discoverEthernetDevices }, messageId);
|
|
1333
|
+
return this.socket.message$.pipe((0, operators_2.transformMotionMasterMessageToStatus)('ethernetDiscovery', requestTimeout, id));
|
|
1334
|
+
}
|
|
1335
|
+
/**
|
|
1336
|
+
* Stop every running Ethernet discovery on a network adapter.
|
|
1337
|
+
*
|
|
1338
|
+
* Each stopped discovery sends its status at once, with the drives found until then and `stopped` set. The status of
|
|
1339
|
+
* this request says how many discoveries were stopped. It is 0 when none was running.
|
|
1340
|
+
*
|
|
1341
|
+
* @param props.mac the MAC address of the network adapter, as in {@link discoverEthernetDevices}
|
|
1342
|
+
*/
|
|
1343
|
+
stopEthernetDiscovery(props, requestTimeout = 5000, messageId) {
|
|
1344
|
+
const stopEthernetDiscovery = types_1.MotionMasterMessage.Request.StopEthernetDiscovery.create(props);
|
|
1345
|
+
const id = this.sendRequest({ stopEthernetDiscovery }, messageId);
|
|
1346
|
+
return this.socket.message$.pipe((0, operators_2.transformMotionMasterMessageToStatus)('ethernetDiscoveryStop', requestTimeout, id));
|
|
1347
|
+
}
|
|
1309
1348
|
//
|
|
1310
1349
|
// Helpers
|
|
1311
1350
|
//
|
|
@@ -1659,7 +1698,29 @@ class MotionMasterReqResClient {
|
|
|
1659
1698
|
}
|
|
1660
1699
|
return { deviceRefObj, index, subindex, value, valueTypeKey, requestTimeout, messageId };
|
|
1661
1700
|
}
|
|
1662
|
-
|
|
1701
|
+
/**
|
|
1702
|
+
* Writes several parameter values, on one or more devices, in one request.
|
|
1703
|
+
*
|
|
1704
|
+
* The values are grouped by device and sent with `setMultiDeviceParameterValues`. Before anything is sent,
|
|
1705
|
+
* the type of each value is resolved from the device parameter info, unless it is given; a parameter that
|
|
1706
|
+
* Motion Master does not list fails the call at this point, and no value is written.
|
|
1707
|
+
*
|
|
1708
|
+
* By default the call succeeds when Motion Master replies with a list of parameter values for every device.
|
|
1709
|
+
* It does **not** check the status of each value, so a value the drive refused (for example `NOT_CHANGED`
|
|
1710
|
+
* for a read-only object, or a value outside the accepted range) is not reported. Set
|
|
1711
|
+
* `options.failOnRefused` to make the call fail with {@link ParameterValuesRefusedError} in that case. That
|
|
1712
|
+
* error lists each value that was not applied, with the error code and message, and the values that were
|
|
1713
|
+
* applied. Applied values are not rolled back. Use {@link download} when one value must be applied before
|
|
1714
|
+
* the next step can run.
|
|
1715
|
+
*
|
|
1716
|
+
* @param ids - The values to write, as device parameter ids mapped to values, or as tuples of device
|
|
1717
|
+
* reference, index, subindex, value and optional type value key.
|
|
1718
|
+
* @param requestTimeout - The time to wait for the reply, in milliseconds.
|
|
1719
|
+
* @param messageId - The id of the request message.
|
|
1720
|
+
* @param options - `failOnRefused`: fail when any value was not applied. Defaults to `false`.
|
|
1721
|
+
* @returns An observable that emits once, when the reply has arrived, and then completes.
|
|
1722
|
+
*/
|
|
1723
|
+
setParameterValues(ids, requestTimeout = 9000, messageId, options = {}) {
|
|
1663
1724
|
if (ids.length === 0) {
|
|
1664
1725
|
return (0, rxjs_1.throwError)(() => new Error('The provided array of device parameter ids or addresses is empty!'));
|
|
1665
1726
|
}
|
|
@@ -1700,12 +1761,39 @@ class MotionMasterReqResClient {
|
|
|
1700
1761
|
throw new Error(`No parameterValues for device ${deviceAddress}`);
|
|
1701
1762
|
}
|
|
1702
1763
|
});
|
|
1764
|
+
if (options.failOnRefused) {
|
|
1765
|
+
const written = tuples.map(([deviceAddress, index, subindex, value], i) => ({
|
|
1766
|
+
deviceRef: refs[i][0],
|
|
1767
|
+
deviceAddress,
|
|
1768
|
+
index,
|
|
1769
|
+
subindex,
|
|
1770
|
+
value,
|
|
1771
|
+
}));
|
|
1772
|
+
const { refused, applied } = classifyWrittenParameterValues(written, multiDeviceParameterValues);
|
|
1773
|
+
if (refused.length > 0) {
|
|
1774
|
+
throw new types_1.ParameterValuesRefusedError(refused, applied);
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1703
1777
|
}));
|
|
1704
1778
|
}));
|
|
1705
1779
|
});
|
|
1706
1780
|
}
|
|
1707
|
-
|
|
1708
|
-
|
|
1781
|
+
/**
|
|
1782
|
+
* Writes several parameter values, on one or more devices, in one request, and resolves when the reply has
|
|
1783
|
+
* arrived.
|
|
1784
|
+
*
|
|
1785
|
+
* This is {@link setParameterValues} as a promise. By default it does **not** report a value the drive
|
|
1786
|
+
* refused; set `options.failOnRefused` to make it reject with {@link ParameterValuesRefusedError} in that
|
|
1787
|
+
* case. See {@link setParameterValues} for the details.
|
|
1788
|
+
*
|
|
1789
|
+
* @param ids - The values to write, as device parameter ids mapped to values, or as tuples of device
|
|
1790
|
+
* reference, index, subindex, value and optional type value key.
|
|
1791
|
+
* @param requestTimeout - The time to wait for the reply, in milliseconds.
|
|
1792
|
+
* @param messageId - The id of the request message.
|
|
1793
|
+
* @param options - `failOnRefused`: reject when any value was not applied. Defaults to `false`.
|
|
1794
|
+
*/
|
|
1795
|
+
downloadMany(ids, requestTimeout = 9000, messageId, options = {}) {
|
|
1796
|
+
return (0, rxjs_1.lastValueFrom)(this.setParameterValues(ids, requestTimeout, messageId, options));
|
|
1709
1797
|
}
|
|
1710
1798
|
resolveDeviceParameterTypeValueKey(deviceRefObj, index, subindex, typeValueKey) {
|
|
1711
1799
|
if (typeValueKey) {
|
|
@@ -1720,6 +1808,48 @@ class MotionMasterReqResClient {
|
|
|
1720
1808
|
return infoParameter.typeValueKey;
|
|
1721
1809
|
}));
|
|
1722
1810
|
}
|
|
1811
|
+
/**
|
|
1812
|
+
* Returns the objects from `ids` that the device does not have.
|
|
1813
|
+
*
|
|
1814
|
+
* The check uses the list of parameters Motion Master reports for the device, which the client
|
|
1815
|
+
* caches, so no SDO request is sent. Use it before reading or writing objects that not every drive
|
|
1816
|
+
* has, so that a procedure can fail, or leave a step out, before anything is written.
|
|
1817
|
+
*
|
|
1818
|
+
* @param deviceRef - Reference to the device.
|
|
1819
|
+
* @param ids - Index and subindex of each object to look for.
|
|
1820
|
+
* @returns The objects that the device does not have, in the order of `ids`. Empty when it has all of them.
|
|
1821
|
+
*/
|
|
1822
|
+
findMissingDeviceParameters(deviceRef, ids) {
|
|
1823
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
1824
|
+
const infoMap = yield (0, rxjs_1.lastValueFrom)(this.resolveDeviceParameterInfoMap(deviceRef));
|
|
1825
|
+
return ids.filter(([index, subindex]) => !infoMap.has((0, parameter_1.makeParameterId)(index, subindex)));
|
|
1826
|
+
});
|
|
1827
|
+
}
|
|
1828
|
+
/**
|
|
1829
|
+
* Reads the given objects that the device has, and leaves out the ones it does not have.
|
|
1830
|
+
*
|
|
1831
|
+
* Use it for objects that only some drives have, for example the Kd gains, which Jasper-based drives without
|
|
1832
|
+
* placeholder objects lack. Which objects exist is taken from the cached parameter list (see
|
|
1833
|
+
* {@link findMissingDeviceParameters}), so no SDO request is sent for a missing one. A read that fails for any
|
|
1834
|
+
* other reason rejects with that error.
|
|
1835
|
+
*
|
|
1836
|
+
* @param deviceRef - Reference to the device.
|
|
1837
|
+
* @param ids - Index and subindex of each object to read.
|
|
1838
|
+
* @returns The values keyed by parameter id, for example `{ '0x2011:01': 0.42 }`, in the order of `ids`.
|
|
1839
|
+
*/
|
|
1840
|
+
uploadExistingParameters(deviceRef, ids) {
|
|
1841
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
1842
|
+
const missing = new Set((yield this.findMissingDeviceParameters(deviceRef, ids)).map(([index, subindex]) => (0, parameter_1.makeParameterId)(index, subindex)));
|
|
1843
|
+
const values = {};
|
|
1844
|
+
for (const [index, subindex] of ids) {
|
|
1845
|
+
const id = (0, parameter_1.makeParameterId)(index, subindex);
|
|
1846
|
+
if (!missing.has(id)) {
|
|
1847
|
+
values[id] = yield this.upload(deviceRef, index, subindex);
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
return values;
|
|
1851
|
+
});
|
|
1852
|
+
}
|
|
1723
1853
|
resolveDeviceParameterInfoMap(deviceRef, requestTimeout = 5000) {
|
|
1724
1854
|
return this.resolveDevice(deviceRef).pipe((0, operators_1.mergeMap)(({ deviceAddress }) => {
|
|
1725
1855
|
let infoMap = this.deviceParameterInfoMap.get(deviceAddress);
|
|
@@ -2323,15 +2453,19 @@ class MotionMasterReqResClient {
|
|
|
2323
2453
|
* Reset targets.
|
|
2324
2454
|
*
|
|
2325
2455
|
* Set torque and velocity targets to 0, and set the position target to the current position value.
|
|
2456
|
+
*
|
|
2457
|
+
* @param deviceRef - Reference to the device.
|
|
2458
|
+
* @param options - Passed to {@link downloadMany}. With `failOnRefused`, the call rejects when the drive
|
|
2459
|
+
* does not apply one of the targets.
|
|
2326
2460
|
*/
|
|
2327
|
-
resetTargets(deviceRef) {
|
|
2461
|
+
resetTargets(deviceRef, options = {}) {
|
|
2328
2462
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
2329
2463
|
const positionActualValue = yield this.upload(deviceRef, 0x6064, 0);
|
|
2330
2464
|
yield this.downloadMany([
|
|
2331
2465
|
[deviceRef, 0x6071, 0, 0],
|
|
2332
2466
|
[deviceRef, 0x607a, 0, positionActualValue],
|
|
2333
2467
|
[deviceRef, 0x60ff, 0, 0], // target velocity
|
|
2334
|
-
]);
|
|
2468
|
+
], undefined, undefined, options);
|
|
2335
2469
|
});
|
|
2336
2470
|
}
|
|
2337
2471
|
/**
|
|
@@ -2783,13 +2917,16 @@ class MotionMasterReqResClient {
|
|
|
2783
2917
|
* - The file SOMANET_CiA_402.xml and its parts will not be removed.
|
|
2784
2918
|
*
|
|
2785
2919
|
* To retain multipart files (e.g., SOMANET_CiA_402.xml.zip.part000), include only the base name (e.g., "SOMANET_CiA_402.xml") in the `filesToKeep` list.
|
|
2920
|
+
*
|
|
2921
|
+
* The `filesToKeep` array is not modified; each call starts from the list it is given.
|
|
2786
2922
|
*/
|
|
2787
2923
|
factoryReset(deviceRef, filesToKeep = device_1.factoryResetDefaultFilesToKeep, installEmptyFirmware = true, reloadFirmware = false) {
|
|
2788
2924
|
return this.getFiles(deviceRef).pipe((0, operators_1.mergeMap)((files) => {
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2925
|
+
// A copy, so that neither the shared default list nor the caller's array is changed.
|
|
2926
|
+
const keep = installEmptyFirmware
|
|
2927
|
+
? [...filesToKeep]
|
|
2928
|
+
: [...filesToKeep, 'SOMANET_CiA_402.xml', 'stack_image.svg'];
|
|
2929
|
+
const filesToDelete = files.filter((file) => file !== '' && !keep.some((fileToKeep) => file.startsWith(fileToKeep)));
|
|
2793
2930
|
const fileDeletionObservables = filesToDelete.map((file) => {
|
|
2794
2931
|
if (file.startsWith('.')) {
|
|
2795
2932
|
return (0, rxjs_1.defer)(() => this.getFile(deviceRef, device_1.stackUnlockFilename).pipe((0, operators_1.mergeMap)(() => this.deleteFile(deviceRef, file))));
|
|
@@ -2809,6 +2946,38 @@ class MotionMasterReqResClient {
|
|
|
2809
2946
|
return (0, rxjs_1.of)({ request: 'succeeded' });
|
|
2810
2947
|
}));
|
|
2811
2948
|
}
|
|
2949
|
+
/**
|
|
2950
|
+
* Describes the fault of a device for an error message.
|
|
2951
|
+
*
|
|
2952
|
+
* Reads the error code (0x603F:00), which every drive has, and the error report (0x203F:01), which only
|
|
2953
|
+
* some firmware has. The error report is added only when it is a non-empty text: Jasper-based drives either
|
|
2954
|
+
* lack the object or have a placeholder that reads 0.
|
|
2955
|
+
*
|
|
2956
|
+
* @param deviceRef - Reference to the device.
|
|
2957
|
+
* @returns For example "Error code (0x603F): 0x7500. Error report (0x203F): Encoder communication lost".
|
|
2958
|
+
*/
|
|
2959
|
+
describeFault(deviceRef) {
|
|
2960
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
2961
|
+
let description;
|
|
2962
|
+
try {
|
|
2963
|
+
const errorCode = yield this.upload(deviceRef, 0x603f, 0x00);
|
|
2964
|
+
description = `Error code (0x603F): 0x${errorCode.toString(16).toUpperCase().padStart(4, '0')}.`;
|
|
2965
|
+
}
|
|
2966
|
+
catch (err) {
|
|
2967
|
+
description = `The error code (0x603F) could not be read: ${err instanceof Error ? err.message : err}.`;
|
|
2968
|
+
}
|
|
2969
|
+
try {
|
|
2970
|
+
const errorReport = yield this.upload(deviceRef, 0x203f, 0x01);
|
|
2971
|
+
if (typeof errorReport === 'string' && errorReport.trim() !== '') {
|
|
2972
|
+
description += ` Error report (0x203F): ${errorReport.trim()}`;
|
|
2973
|
+
}
|
|
2974
|
+
}
|
|
2975
|
+
catch (_a) {
|
|
2976
|
+
// Most Jasper-based drives do not have 0x203F; the error code above is enough.
|
|
2977
|
+
}
|
|
2978
|
+
return description;
|
|
2979
|
+
});
|
|
2980
|
+
}
|
|
2812
2981
|
/**
|
|
2813
2982
|
* Computes the Feed Constant for a given device.
|
|
2814
2983
|
*
|
|
@@ -2893,9 +3062,11 @@ class MotionMasterReqResClient {
|
|
|
2893
3062
|
* - `'merge'`: Reads the existing file, appends/updates it with the new data (input takes precedence), and writes the result back.
|
|
2894
3063
|
* @param retryConfig Configuration settings for retrying the restore default parameters operation.
|
|
2895
3064
|
* @param refresh A flag to refresh device parameter values after loading the new configuration. Defaults to `true`.
|
|
3065
|
+
* @param options Passed to {@link setParameterValues} for the PDO Guard step. With `failOnRefused`, loading fails
|
|
3066
|
+
* when the drive does not apply one of the RxPDO-mapped values.
|
|
2896
3067
|
* @returns An observable that emits `void` once the configuration has been successfully loaded and (optionally) refreshed.
|
|
2897
3068
|
*/
|
|
2898
|
-
loadConfig(deviceRef, data, strategy = 'replace', retryConfig = { count: 10, delay: 500 }, refresh = true) {
|
|
3069
|
+
loadConfig(deviceRef, data, strategy = 'replace', retryConfig = { count: 10, delay: 500 }, refresh = true, options = {}) {
|
|
2899
3070
|
const encoder = new TextEncoder();
|
|
2900
3071
|
const decoder = new TextDecoder();
|
|
2901
3072
|
const content = typeof data === 'string' ? encoder.encode(data) : data;
|
|
@@ -2949,7 +3120,7 @@ class MotionMasterReqResClient {
|
|
|
2949
3120
|
}
|
|
2950
3121
|
// Batch write all RxPDO-mapped parameters in one request
|
|
2951
3122
|
const ids = pdoMappedParams.map((p) => [deviceRef, p.index, p.subindex, p.value]);
|
|
2952
|
-
return this.setParameterValues(ids, 10000).pipe((0, operators_1.map)(() => finalParameters));
|
|
3123
|
+
return this.setParameterValues(ids, 10000, undefined, options).pipe((0, operators_1.map)(() => finalParameters));
|
|
2953
3124
|
}))),
|
|
2954
3125
|
// Refresh parameters (Using finalParameters).
|
|
2955
3126
|
(0, operators_1.mergeMap)((finalParameters) => {
|
|
@@ -3035,18 +3206,41 @@ class MotionMasterReqResClient {
|
|
|
3035
3206
|
* Sets the device mode of operation and then transitions the device
|
|
3036
3207
|
* to the specified CiA 402 state.
|
|
3037
3208
|
*
|
|
3038
|
-
* The
|
|
3039
|
-
* 1. The mode of operation is written to the device.
|
|
3040
|
-
* 2. The
|
|
3209
|
+
* The steps run one after another, each only after the previous one has succeeded:
|
|
3210
|
+
* 1. The mode of operation (0x6060) is written to the device.
|
|
3211
|
+
* 2. The modes of operation display (0x6061) is read until it shows the requested mode.
|
|
3212
|
+
* 3. The device is transitioned to the requested CiA 402 state.
|
|
3213
|
+
*
|
|
3214
|
+
* Nothing runs before the returned observable is subscribed to. When a step fails, the observable
|
|
3215
|
+
* errors and the later steps do not run, so the device is never enabled in another mode.
|
|
3041
3216
|
*
|
|
3042
3217
|
* @param deviceRef - Reference to the target device.
|
|
3043
3218
|
* @param modesOfOperation - Desired CiA 402 mode of operation.
|
|
3044
3219
|
* @param cia402State - Target CiA 402 state to transition to.
|
|
3220
|
+
* @param modesOfOperationDisplayTimeout - Time in milliseconds to wait for 0x6061 to show the requested mode.
|
|
3045
3221
|
*
|
|
3046
|
-
* @returns Observable that completes when
|
|
3222
|
+
* @returns Observable that completes when all steps have succeeded.
|
|
3047
3223
|
*/
|
|
3048
|
-
setModesOfOperationAndTransitionToCia402State(deviceRef, modesOfOperation, cia402State) {
|
|
3049
|
-
return (0, rxjs_1.concat)(this.setModesOfOperation(deviceRef, modesOfOperation), this.transitionToCia402State(deviceRef, cia402State));
|
|
3224
|
+
setModesOfOperationAndTransitionToCia402State(deviceRef, modesOfOperation, cia402State, modesOfOperationDisplayTimeout = 2000) {
|
|
3225
|
+
return (0, rxjs_1.concat)(this.setModesOfOperation(deviceRef, modesOfOperation), (0, rxjs_1.defer)(() => this.waitForModesOfOperationDisplay(deviceRef, modesOfOperation, modesOfOperationDisplayTimeout)), (0, rxjs_1.defer)(() => this.transitionToCia402State(deviceRef, cia402State)));
|
|
3226
|
+
}
|
|
3227
|
+
/**
|
|
3228
|
+
* Reads the modes of operation display (0x6061) until it shows the given mode.
|
|
3229
|
+
*
|
|
3230
|
+
* @throws Error when 0x6061 does not show the mode within the timeout.
|
|
3231
|
+
*/
|
|
3232
|
+
waitForModesOfOperationDisplay(deviceRef, modesOfOperation, timeout) {
|
|
3233
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
3234
|
+
const deadline = Date.now() + timeout;
|
|
3235
|
+
let modesOfOperationDisplay = yield this.upload(deviceRef, 0x6061, 0);
|
|
3236
|
+
while (modesOfOperationDisplay !== modesOfOperation) {
|
|
3237
|
+
if (Date.now() >= deadline) {
|
|
3238
|
+
throw new Error(`Device ${JSON.stringify(deviceRef)} shows the mode of operation ${modesOfOperationDisplay} (0x6061) instead of the requested ${modesOfOperation} after ${timeout} ms.`);
|
|
3239
|
+
}
|
|
3240
|
+
yield (0, util_1.resolveAfter)(50);
|
|
3241
|
+
modesOfOperationDisplay = yield this.upload(deviceRef, 0x6061, 0);
|
|
3242
|
+
}
|
|
3243
|
+
});
|
|
3050
3244
|
}
|
|
3051
3245
|
/**
|
|
3052
3246
|
* Installs the Integro Encoder Firmware by performing the following steps:
|
|
@@ -3163,11 +3357,13 @@ class MotionMasterReqResClient {
|
|
|
3163
3357
|
* @param {number[][]} pdoGroupedValues - A 2D array where each inner array represents a group of PDO values.
|
|
3164
3358
|
* The first element in each group is ignored, and the remaining values are processed.
|
|
3165
3359
|
* @param {0x1600 | 0x1A00} pdoIndex - The PDO index to update, either `0x1600` for RxPDO or `0x1A00` for TxPDO.
|
|
3360
|
+
* @param {SetParameterValuesOptions} options - Passed to each {@link setParameterValues} call. With `failOnRefused`,
|
|
3361
|
+
* the update stops at the first write the drive does not apply.
|
|
3166
3362
|
*
|
|
3167
3363
|
* @returns {Promise<void>} Resolves when all PDO parameter updates are complete.
|
|
3168
3364
|
* The function processes and applies updates sequentially to ensure they are performed in order.
|
|
3169
3365
|
*/
|
|
3170
|
-
updatePdoParameterGroupedValues(deviceRef, pdoGroupedValues, pdoIndex) {
|
|
3366
|
+
updatePdoParameterGroupedValues(deviceRef, pdoGroupedValues, pdoIndex, options = {}) {
|
|
3171
3367
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
3172
3368
|
for (const [i, groupedValues] of pdoGroupedValues.entries()) {
|
|
3173
3369
|
let values = groupedValues
|
|
@@ -3176,13 +3372,13 @@ class MotionMasterReqResClient {
|
|
|
3176
3372
|
.map((value) => (typeof value === 'string' ? parseInt(value, 10) : value));
|
|
3177
3373
|
const n = values.length; // number of new mapped parameters
|
|
3178
3374
|
values = values.concat(new Array(10 - n).fill(0));
|
|
3179
|
-
yield (0, rxjs_1.lastValueFrom)(this.setParameterValues([[deviceRef, pdoIndex + i, 0, 0]]));
|
|
3375
|
+
yield (0, rxjs_1.lastValueFrom)(this.setParameterValues([[deviceRef, pdoIndex + i, 0, 0]], undefined, undefined, options));
|
|
3180
3376
|
const parameterValues = values.reduce((acc, value, j) => {
|
|
3181
3377
|
acc.push([deviceRef, pdoIndex + i, j + 1, value, 'uintValue']);
|
|
3182
3378
|
return acc;
|
|
3183
3379
|
}, []);
|
|
3184
|
-
yield (0, rxjs_1.lastValueFrom)(this.setParameterValues(parameterValues));
|
|
3185
|
-
yield (0, rxjs_1.lastValueFrom)(this.setParameterValues([[deviceRef, pdoIndex + i, 0, n]]));
|
|
3380
|
+
yield (0, rxjs_1.lastValueFrom)(this.setParameterValues(parameterValues, undefined, undefined, options));
|
|
3381
|
+
yield (0, rxjs_1.lastValueFrom)(this.setParameterValues([[deviceRef, pdoIndex + i, 0, n]], undefined, undefined, options));
|
|
3186
3382
|
}
|
|
3187
3383
|
});
|
|
3188
3384
|
}
|
|
@@ -4893,16 +5089,18 @@ class MotionMasterReqResClient {
|
|
|
4893
5089
|
* @param deviceRef - Reference to the target device.
|
|
4894
5090
|
* @param notchFilter - Notch filter values to write to the device.
|
|
4895
5091
|
* @param requestTimeout - Optional timeout in milliseconds for the request (default: 1000).
|
|
5092
|
+
* @param options - Passed to {@link setParameterValues}. With `failOnRefused`, the call fails when the drive does
|
|
5093
|
+
* not apply one of the values.
|
|
4896
5094
|
* @returns An `Observable<void>` that completes when the parameter values have been written successfully.
|
|
4897
5095
|
*
|
|
4898
5096
|
*/
|
|
4899
|
-
setNotchFilterParameterValues(deviceRef, notchFilter, requestTimeout = 1000) {
|
|
5097
|
+
setNotchFilterParameterValues(deviceRef, notchFilter, requestTimeout = 1000, options = {}) {
|
|
4900
5098
|
return this.setParameterValues([
|
|
4901
5099
|
[deviceRef, 0x2023, 0x01, notchFilter.enabled ? 1 : 0],
|
|
4902
5100
|
[deviceRef, 0x2023, 0x02, Math.round(notchFilter.centerFrequency)],
|
|
4903
5101
|
[deviceRef, 0x2023, 0x03, Math.round(notchFilter.rejectionBand)],
|
|
4904
5102
|
[deviceRef, 0x2023, 0x04, notchFilter.depth],
|
|
4905
|
-
], requestTimeout);
|
|
5103
|
+
], requestTimeout, undefined, options);
|
|
4906
5104
|
}
|
|
4907
5105
|
/**
|
|
4908
5106
|
* Deletes all HRD data files (`hr_data0.bin` to `hr_data4.bin`) from the device.
|
|
@@ -5185,11 +5383,7 @@ class MotionMasterReqResClient {
|
|
|
5185
5383
|
if (cia402state !== cia402_1.Cia402State.OPERATION_ENABLED) {
|
|
5186
5384
|
let errorMessage = 'Device is not in the expected state for running diagnostics. Please ensure the device is in OPERATION ENABLED state.';
|
|
5187
5385
|
if (cia402state === cia402_1.Cia402State.FAULT) {
|
|
5188
|
-
|
|
5189
|
-
const errorReport = yield this.upload(deviceRef, 0x203f, 0x01);
|
|
5190
|
-
errorMessage += ` Device has a fault. Error report (0x203F): ${errorReport}`;
|
|
5191
|
-
}
|
|
5192
|
-
catch (_a) { }
|
|
5386
|
+
errorMessage += ` Device has a fault. ${yield this.describeFault(deviceRef)}`;
|
|
5193
5387
|
}
|
|
5194
5388
|
subscriber.error(new Error(errorMessage));
|
|
5195
5389
|
return;
|
|
@@ -5321,4 +5515,39 @@ function extractFirmwareProductSupportedOptions(supportedOptionsPromise, firmwar
|
|
|
5321
5515
|
return (_b = (_a = supportedOptions[`${major}.${minor}`]) === null || _a === void 0 ? void 0 : _a[`${versionedDeviceProductId}`]) !== null && _b !== void 0 ? _b : [];
|
|
5322
5516
|
}));
|
|
5323
5517
|
}
|
|
5518
|
+
/**
|
|
5519
|
+
* Splits the values of a multi-parameter write into the ones Motion Master reports as applied and the ones it
|
|
5520
|
+
* does not.
|
|
5521
|
+
*
|
|
5522
|
+
* Each written value is matched to the reply entry of its device with the same index and subindex. A value
|
|
5523
|
+
* that is written twice is matched to the reply entries in order. A value counts as applied only when its
|
|
5524
|
+
* entry has a success status; an entry with an error, or with no status, and a value without an entry count
|
|
5525
|
+
* as not applied.
|
|
5526
|
+
*/
|
|
5527
|
+
function classifyWrittenParameterValues(written, status) {
|
|
5528
|
+
var _a, _b, _c, _d, _e;
|
|
5529
|
+
const remaining = new Map();
|
|
5530
|
+
for (const { deviceAddress, parameterValues } of (_a = status.collection) !== null && _a !== void 0 ? _a : []) {
|
|
5531
|
+
if (deviceAddress !== undefined && deviceAddress !== null) {
|
|
5532
|
+
remaining.set(deviceAddress, [...(parameterValues !== null && parameterValues !== void 0 ? parameterValues : [])]);
|
|
5533
|
+
}
|
|
5534
|
+
}
|
|
5535
|
+
const refused = [];
|
|
5536
|
+
const applied = [];
|
|
5537
|
+
for (const entry of written) {
|
|
5538
|
+
const entries = (_b = remaining.get(entry.deviceAddress)) !== null && _b !== void 0 ? _b : [];
|
|
5539
|
+
const i = entries.findIndex((p) => { var _a, _b; return ((_a = p.index) !== null && _a !== void 0 ? _a : 0) === entry.index && ((_b = p.subindex) !== null && _b !== void 0 ? _b : 0) === entry.subindex; });
|
|
5540
|
+
const reply = i >= 0 ? entries.splice(i, 1)[0] : undefined;
|
|
5541
|
+
if (reply === null || reply === void 0 ? void 0 : reply.success) {
|
|
5542
|
+
applied.push(entry);
|
|
5543
|
+
}
|
|
5544
|
+
else if (reply === null || reply === void 0 ? void 0 : reply.error) {
|
|
5545
|
+
refused.push(Object.assign(Object.assign({}, entry), { errorCode: (_d = types_1.MotionMasterMessage.Status.DeviceParameterValues.ParameterValue.Error.Code[(_c = reply.error.code) !== null && _c !== void 0 ? _c : 0]) !== null && _d !== void 0 ? _d : String(reply.error.code), errorMessage: (_e = reply.error.message) !== null && _e !== void 0 ? _e : '' }));
|
|
5546
|
+
}
|
|
5547
|
+
else {
|
|
5548
|
+
refused.push(Object.assign(Object.assign({}, entry), { errorCode: 'NO_STATUS', errorMessage: '' }));
|
|
5549
|
+
}
|
|
5550
|
+
}
|
|
5551
|
+
return { refused, applied };
|
|
5552
|
+
}
|
|
5324
5553
|
//# sourceMappingURL=motion-master-req-res-client.js.map
|