motion-master-client 0.0.338 → 0.0.340

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.
@@ -1,7 +1,37 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parsePdoSubItemValue = exports.splitDeviceParameterId = exports.deviceParameterIdRegExp = exports.makeDeviceParameterId = void 0;
3
+ exports.flattenUiPdoMapping = exports.uiConfigWithDefaultPdoMapping = exports.parsePdoSubItemValue = exports.splitDeviceParameterId = exports.deviceParameterIdRegExp = exports.makeDeviceParameterId = void 0;
4
4
  const parameter_1 = require("./parameter");
5
+ /**
6
+ * Constructs a device parameter ID string from a device serial number and parameter identifiers.
7
+ *
8
+ * The resulting ID has the format:
9
+ * ```
10
+ * <parameterId>.<serialNumber>
11
+ * ```
12
+ * where `<parameterId>` is generated by `makeParameterId` and `<serialNumber>` is the device's serial number.
13
+ *
14
+ * @param serialNumber - The serial number of the device.
15
+ * @param a - Optional parameter identifier. Can be:
16
+ * - a number representing the index,
17
+ * - an object with optional `index` and `subindex` properties,
18
+ * - a tuple `[index, subindex]` where each element may be `number`, `null`, or `undefined`.
19
+ * @param b - Optional subindex if `a` is provided as a number.
20
+ *
21
+ * @returns The constructed device parameter ID string in the format `<parameterId>.<serialNumber>`.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const id1 = makeDeviceParameterId("Device123", 0x6040, 0x00);
26
+ * // id1 = "0x6040:00.Device123"
27
+ *
28
+ * const id2 = makeDeviceParameterId("Device123", { index: 0x6040, subindex: 0x01 });
29
+ * // id2 = "0x6040:01.Device123"
30
+ *
31
+ * const id3 = makeDeviceParameterId("Device123", [0x6040, 0x02]);
32
+ * // id3 = "0x6040:02.Device123"
33
+ * ```
34
+ */
5
35
  function makeDeviceParameterId(serialNumber, a, b) {
6
36
  const parameterId = (0, parameter_1.makeParameterId)(a, b);
7
37
  return `${parameterId}.${serialNumber}`;
@@ -15,10 +45,27 @@ exports.makeDeviceParameterId = makeDeviceParameterId;
15
45
  */
16
46
  exports.deviceParameterIdRegExp = /^0x([0-9a-fA-F]{4,}):([0-9a-fA-F]{2})\.([\d-]+)$/;
17
47
  /**
18
- * Split device parameter id into parts.
48
+ * Splits a device parameter ID string into its components: index, subindex, and device serial number.
49
+ *
50
+ * The expected format of the ID must match `deviceParameterIdRegExp`.
51
+ * If the ID does not match the expected format, an error is thrown.
52
+ *
53
+ * @param id - The device parameter ID string to split.
54
+ * @returns A tuple `[index, subindex, deviceSerial]` where:
55
+ * - `index` is the 16-bit parameter index (parsed from hexadecimal),
56
+ * - `subindex` is the 8-bit parameter subindex (parsed from hexadecimal),
57
+ * - `deviceSerial` is the device serial number as a string.
58
+ *
59
+ * @throws {Error} If the provided ID does not match the expected regular expression.
19
60
  *
20
- * @param id - device parameter id like "0x2110:1A.8502-03-0001353-2115"
21
- * @returns tuple of device serial number, index, and subindex
61
+ * @example
62
+ * ```ts
63
+ * const id = "0x6040:00.123-ABC";
64
+ * const [deviceSerial, index, subindex] = splitDeviceParameterId(id);
65
+ * // deviceSerial = "123-ABC"
66
+ * // index = 0x6040
67
+ * // subindex = 0x00
68
+ * ```
22
69
  */
23
70
  function splitDeviceParameterId(id) {
24
71
  const match = id.match(exports.deviceParameterIdRegExp);
@@ -61,4 +108,70 @@ function parsePdoSubItemValue(value) {
61
108
  return [index, subindex, bitlen];
62
109
  }
63
110
  exports.parsePdoSubItemValue = parsePdoSubItemValue;
111
+ /**
112
+ * Default UI configuration containing the PDO mapping.
113
+ *
114
+ * This configuration is used as a fallback when a device-specific UI configuration
115
+ * is not available. It defines both RX (receive) and TX (transmit) PDOs with
116
+ * their corresponding object dictionary entries.
117
+ *
118
+ * ⚠️ Important: Keep this in sync with the default PDO mapping in Motion Master
119
+ * to ensure consistent behavior across devices.
120
+ */
121
+ exports.uiConfigWithDefaultPdoMapping = {
122
+ pdoMapping: {
123
+ rx: {
124
+ '0x1600': ['0x60400010', '0x60600008', '0x60710010', '0x607a0020', '0x60ff0020', '0x60b20010', '0x27010020'],
125
+ '0x1601': ['0x60fe0120', '0x60fe0220'],
126
+ '0x1602': ['0x27030020', '0x60b10020', '0x20120120'],
127
+ },
128
+ tx: {
129
+ '0x1a00': [
130
+ '0x60410010',
131
+ '0x60610008',
132
+ '0x60640020',
133
+ '0x606c0020',
134
+ '0x60770010',
135
+ '0x60f40020',
136
+ '0x21110220',
137
+ '0x21130220',
138
+ ],
139
+ '0x1a01': ['0x24010010', '0x24020010', '0x24030010', '0x24040010', '0x27020020'],
140
+ '0x1a02': ['0x60fd0020'],
141
+ '0x1a03': ['0x27040020', '0x20f00020', '0x60fc0020', '0x606b0020', '0x60740010', '0x60790020'],
142
+ },
143
+ },
144
+ };
145
+ /**
146
+ * Flattens a PDO mapping into an array of [deviceRef, index, subindex] entries.
147
+ *
148
+ * This function iterates over both RX and TX PDOs in the provided `pdoMapping` and
149
+ * extracts the index and subindex from each 32-bit PDO entry using `parsePdoSubItemValue`.
150
+ *
151
+ * @param deviceRef - The reference to the device associated with this PDO mapping.
152
+ * @param pdoMapping - The UI PDO mapping object containing RX and TX PDO entries.
153
+ * @returns An array where each item is a tuple `[deviceRef, index, subindex]`.
154
+ *
155
+ * @example
156
+ * ```ts
157
+ * const deviceRef = 1;
158
+ * const flatArray = flattenUiPdoMapping(deviceRef, uiPdoMapping);
159
+ * // flatArray will contain tuples like [deviceRef, 0x2012, 0x01]
160
+ * ```
161
+ */
162
+ function flattenUiPdoMapping(deviceRef, pdoMapping) {
163
+ const result = [];
164
+ for (const pdoType of ['rx', 'tx']) {
165
+ for (const key in pdoMapping[pdoType]) {
166
+ const entries = pdoMapping[pdoType][key];
167
+ for (const entry of entries) {
168
+ const value = parseInt(entry, 16); // hex string -> number
169
+ const [index, subindex] = parsePdoSubItemValue(value); // ignore bitlen
170
+ result.push([deviceRef, index, subindex]);
171
+ }
172
+ }
173
+ }
174
+ return result;
175
+ }
176
+ exports.flattenUiPdoMapping = flattenUiPdoMapping;
64
177
  //# sourceMappingURL=device-parameter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"device-parameter.js","sourceRoot":"","sources":["../../../../../libs/motion-master-client/src/lib/device-parameter.ts"],"names":[],"mappings":";;;AAAA,2CAAyD;AA8FzD,SAAgB,qBAAqB,CACnC,YAAoB,EACpB,CAG0D,EAC1D,CAAiB;IAEjB,MAAM,WAAW,GAAG,IAAA,2BAAe,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1C,OAAO,GAAG,WAAW,IAAI,YAAY,EAAE,CAAC;AAC1C,CAAC;AAVD,sDAUC;AAED;;;;;GAKG;AACU,QAAA,uBAAuB,GAAG,kDAAkD,CAAC;AAE1F;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,EAAU;IAC/C,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,+BAAuB,CAAC,CAAC;IAEhD,IAAI,CAAC,KAAK,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,wBAAwB,EAAE,2CAA2C,+BAAuB,EAAE,CAAC,CAAC;KACjH;IAED,OAAO;QACL,KAAK,CAAC,CAAC,CAAC;QACR,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACtB,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,WAAW;KACpC,CAAC;AACJ,CAAC;AAZD,wDAYC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,oBAAoB,CAAC,KAAa;IAChD,MAAM,EAAE,GAAG,KAAK,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC;IAC/B,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IAChC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IAEhC,MAAM,KAAK,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC;IAC7B,MAAM,QAAQ,GAAG,EAAE,CAAC;IACpB,MAAM,MAAM,GAAG,EAAE,CAAC;IAElB,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AACnC,CAAC;AAXD,oDAWC"}
1
+ {"version":3,"file":"device-parameter.js","sourceRoot":"","sources":["../../../../../libs/motion-master-client/src/lib/device-parameter.ts"],"names":[],"mappings":";;;AAAA,2CAAyD;AA+FzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,SAAgB,qBAAqB,CACnC,YAAoB,EACpB,CAG0D,EAC1D,CAAiB;IAEjB,MAAM,WAAW,GAAG,IAAA,2BAAe,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1C,OAAO,GAAG,WAAW,IAAI,YAAY,EAAE,CAAC;AAC1C,CAAC;AAVD,sDAUC;AAED;;;;;GAKG;AACU,QAAA,uBAAuB,GAAG,kDAAkD,CAAC;AAE1F;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,sBAAsB,CAAC,EAAU;IAC/C,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,+BAAuB,CAAC,CAAC;IAEhD,IAAI,CAAC,KAAK,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,wBAAwB,EAAE,2CAA2C,+BAAuB,EAAE,CAAC,CAAC;KACjH;IAED,OAAO;QACL,KAAK,CAAC,CAAC,CAAC;QACR,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACtB,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,WAAW;KACpC,CAAC;AACJ,CAAC;AAZD,wDAYC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,oBAAoB,CAAC,KAAa;IAChD,MAAM,EAAE,GAAG,KAAK,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,G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E,CAAC;IAEjD,KAAK,MAAM,OAAO,IAAI,CAAC,IAAI,EAAE,IAAI,CAAU,EAAE;QAC3C,KAAK,MAAM,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,EAAE;YACrC,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;YACzC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;gBAC3B,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,uBAAuB;gBAC1D,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,gBAAgB;gBACvE,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;aAC3C;SACF;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAfD,kDAeC"}
@@ -2137,4 +2137,16 @@ export declare class MotionMasterReqResClient {
2137
2137
  * - This function assumes positive values; a negative value may indicate an error or reversed rotation.
2138
2138
  */
2139
2139
  getGearRatio(deviceRef: DeviceRef): Promise<number>;
2140
+ /**
2141
+ * Retrieves the PDO mapping for the given device.
2142
+ *
2143
+ * This method attempts to get the device-specific UI configuration and returns
2144
+ * its PDO mapping. If the device does not have a specific UI configuration or
2145
+ * its PDO mapping is missing, the default PDO mapping (`uiConfigWithDefaultPdoMapping`)
2146
+ * is returned instead.
2147
+ *
2148
+ * @param deviceRef - Reference to the device for which the UI configuration is requested.
2149
+ * @returns An `Observable` that emits the RX and TX PDO mapping for the device.
2150
+ */
2151
+ getUiConfigOrDefaultPdoMapping(deviceRef: DeviceRef): Observable<UiPdoMapping>;
2140
2152
  }
@@ -4197,6 +4197,20 @@ class MotionMasterReqResClient {
4197
4197
  }
4198
4198
  });
4199
4199
  }
4200
+ /**
4201
+ * Retrieves the PDO mapping for the given device.
4202
+ *
4203
+ * This method attempts to get the device-specific UI configuration and returns
4204
+ * its PDO mapping. If the device does not have a specific UI configuration or
4205
+ * its PDO mapping is missing, the default PDO mapping (`uiConfigWithDefaultPdoMapping`)
4206
+ * is returned instead.
4207
+ *
4208
+ * @param deviceRef - Reference to the device for which the UI configuration is requested.
4209
+ * @returns An `Observable` that emits the RX and TX PDO mapping for the device.
4210
+ */
4211
+ getUiConfigOrDefaultPdoMapping(deviceRef) {
4212
+ return this.getUiConfig(deviceRef).pipe((0, operators_1.map)((uiConfig) => { var _a; return (_a = uiConfig.pdoMapping) !== null && _a !== void 0 ? _a : device_parameter_1.uiConfigWithDefaultPdoMapping.pdoMapping; }));
4213
+ }
4200
4214
  }
4201
4215
  exports.MotionMasterReqResClient = MotionMasterReqResClient;
4202
4216
  /**