motion-master-client 0.0.339 → 0.0.341

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/src/lib/device.js CHANGED
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.factoryResetDefaultFilesToKeep = exports.isFilenamePart = exports.emptyAppBase64 = exports.stackUnlockFilename = exports.computeZeroHomeOffsetFromPosition = exports.parseDeviceLogContent = exports.parseDeviceLog = exports.isValidDeviceRefObj = exports.isDeviceRef = exports.makeDeviceRefObj = exports.ensureDeviceRef = exports.getDeviceRefFromDeviceRefObj = exports.filenamePartRegExp = void 0;
4
4
  exports.filenamePartRegExp = /^(.*?)(?:\.zip(?:\.part\d+)?)$/;
5
+ /**
6
+ * Returns the first defined value from a {@link DeviceRefObj}.
7
+ */
5
8
  function getDeviceRefFromDeviceRefObj(deviceRefObj) {
6
9
  for (const [_, value] of Object.entries(deviceRefObj)) {
7
10
  if (value !== undefined) {
@@ -11,11 +14,23 @@ function getDeviceRefFromDeviceRefObj(deviceRefObj) {
11
14
  return null;
12
15
  }
13
16
  exports.getDeviceRefFromDeviceRefObj = getDeviceRefFromDeviceRefObj;
17
+ /**
18
+ * Ensures that a {@link DeviceRef} is numeric if possible.
19
+ *
20
+ * If the value is numeric-like, it is converted to a number; otherwise the original string is returned.
21
+ */
14
22
  function ensureDeviceRef(deviceRef) {
15
23
  const n = Number(deviceRef);
16
24
  return isNaN(n) ? deviceRef : n;
17
25
  }
18
26
  exports.ensureDeviceRef = ensureDeviceRef;
27
+ /**
28
+ * Converts a {@link DeviceRef} into a structured {@link DeviceRefObj}.
29
+ *
30
+ * - Numbers ≤ `0xffff` are treated as device positions.
31
+ * - Larger numbers are treated as device addresses.
32
+ * - Strings are treated as serial numbers.
33
+ */
19
34
  function makeDeviceRefObj(deviceRef) {
20
35
  deviceRef = ensureDeviceRef(deviceRef);
21
36
  if (typeof deviceRef === 'number') {
@@ -31,18 +46,30 @@ function makeDeviceRefObj(deviceRef) {
31
46
  }
32
47
  }
33
48
  exports.makeDeviceRefObj = makeDeviceRefObj;
49
+ /**
50
+ * Type guard verifying that a value is a valid {@link DeviceRef}.
51
+ */
34
52
  function isDeviceRef(deviceRef) {
35
53
  return (deviceRef !== undefined &&
36
54
  deviceRef !== null &&
37
55
  (typeof deviceRef === 'string' || (typeof deviceRef === 'number' && deviceRef >= 0)));
38
56
  }
39
57
  exports.isDeviceRef = isDeviceRef;
58
+ /**
59
+ * Validates the structure of a {@link DeviceRefObj}.
60
+ */
40
61
  function isValidDeviceRefObj(obj) {
41
62
  return (Number.isFinite(Number(obj.deviceAddress)) ||
42
63
  (typeof obj.devicePosition === 'number' && obj.devicePosition >= 0) ||
43
64
  typeof obj.deviceSerialNumber === 'string');
44
65
  }
45
66
  exports.isValidDeviceRefObj = isValidDeviceRefObj;
67
+ /**
68
+ * Parses a single device log line.
69
+ *
70
+ * Expected format:
71
+ * `HH:MM:SS.mmm LEVEL|MESSAGE`
72
+ */
46
73
  function parseDeviceLog(line) {
47
74
  const re = /^(\d{2}:\d{2}:\d{2}\.\d+)\s(.*)\|(.*)$/gm;
48
75
  const result = re.exec(line);
@@ -56,6 +83,9 @@ function parseDeviceLog(line) {
56
83
  return;
57
84
  }
58
85
  exports.parseDeviceLog = parseDeviceLog;
86
+ /**
87
+ * Parses multi-line log content into an array of {@link DeviceLogLine}.
88
+ */
59
89
  function parseDeviceLogContent(content) {
60
90
  return content
61
91
  .split('\n')
@@ -63,22 +93,35 @@ function parseDeviceLogContent(content) {
63
93
  .filter((l) => l !== undefined);
64
94
  }
65
95
  exports.parseDeviceLogContent = parseDeviceLogContent;
96
+ /**
97
+ * Computes the "zero home offset" given a home offset and the current device position.
98
+ */
66
99
  function computeZeroHomeOffsetFromPosition(homeOffset, position) {
67
100
  return homeOffset - position;
68
101
  }
69
102
  exports.computeZeroHomeOffsetFromPosition = computeZeroHomeOffsetFromPosition;
70
103
  /**
71
- * The FoE read command with the filename "fs-stackunlock=DD1317" enables writing or deleting protected files (i.e., files that begin with a dot ".").
104
+ * Name of the FoE file used to unlock protected filesystem operations.
105
+ *
106
+ * Sending a FoE read command with this filename allows writing or deleting
107
+ * protected files (i.e., files whose names start with a dot).
72
108
  */
73
109
  exports.stackUnlockFilename = 'fs-stackunlock=DD1317';
74
110
  /**
75
- * Base64-encoded empty firmware binary used during a Factory Reset to remove the currently installed firmware.
111
+ * Base64-encoded empty firmware image used during Factory Reset
112
+ * to remove the currently installed firmware.
76
113
  */
77
114
  exports.emptyAppBase64 = 'UEsDBBQACAAIABBye08AAAAAAAAAAAAAAAANACAAYXBwX2VtcHR5LmJpblVUDQAHMHfeXTB33l0wd95ddXgLAAEE6AMAAAToAwAAAwBQSwcIAAAAAAIAAAAAAAAAUEsBAhQDFAAIAAgAEHJ7TwAAAAACAAAAAAAAAA0AIAAAAAAAAAAAAKSBAAAAAGFwcF9lbXB0eS5iaW5VVA0ABzB33l0wd95dMHfeXXV4CwABBOgDAAAE6AMAAFBLBQYAAAAAAQABAFsAAABdAAAAAAA=';
115
+ /**
116
+ * Returns `true` if the filename represents a multi-part ZIP file.
117
+ */
78
118
  function isFilenamePart(filename) {
79
119
  return exports.filenamePartRegExp.test(filename);
80
120
  }
81
121
  exports.isFilenamePart = isFilenamePart;
122
+ /**
123
+ * Default set of files preserved during Factory Reset.
124
+ */
82
125
  exports.factoryResetDefaultFilesToKeep = [
83
126
  '.assembly_config',
84
127
  '.factory_config',
@@ -1 +1 @@
1
- {"version":3,"file":"device.js","sourceRoot":"","sources":["../../../../../libs/motion-master-client/src/lib/device.ts"],"names":[],"mappings":";;;AAMa,QAAA,kBAAkB,GAAG,gCAAgC,CAAC;AAqGnE,SAAgB,4BAA4B,CAAC,YAA0B;IACrE,KAAK,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;QACrD,IAAI,KAAK,KAAK,SAAS,EAAE;Y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CAA0C,CAAC;IACtD,MAAM,MAAM,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,IAAI,MAAM,EAAE;QACV,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;YACtB,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;YACvB,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;SAC1B,CAAC;KACH;IACD,OAAO;AACT,CAAC;AAXD,wCAWC;AAED,SAAgB,qBAAqB,CAAC,OAAe;IACnD,OAAO,OAAO;SACX,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;SAC7B,MAAM,CAAC,CAAC,CAAC,EAAsB,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;AACxD,CAAC;AALD,sDAKC;AAED,SAAgB,iCAAiC,CAAC,UAAkB,EAAE,QAAgB;IACpF,OAAO,UAAU,GAAG,QAAQ,CAAC;AAC/B,CAAC;AAFD,8EAEC;AAED;;GAEG;AACU,QAAA,mBAAmB,GAAG,uBAAuB,CAAC;AAE3D;;GAEG;AACU,QAAA,cAAc,GACzB,sRAAsR,CAAC;AAEzR,SAAgB,cAAc,CAAC,QAAgB;IAC7C,OAAO,0BAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC3C,CAAC;AAFD,wCAEC;AAEY,QAAA,8BAA8B,GAAG;IAC5C,kBAAkB;IAClB,iBAAiB;IACjB,uBAAuB;IACvB,UAAU;IACV,iBAAiB;CAClB,CAAC"}
1
+ {"version":3,"file":"device.js","sourceRoot":"","sources":["../../../../../libs/motion-master-client/src/lib/device.ts"],"names":[],"mappings":";;;AAMa,QAAA,kBAAkB,GAAG,gCAAgC,CAAC;AAwGnE;;GAEG;AACH,SAAgB,4BAA4B,CAAC,YAA0B;IACrE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kB;IAClB,iBAAiB;IACjB,uBAAuB;IACvB,UAAU;IACV,iBAAiB;CAClB,CAAC"}
@@ -1938,8 +1938,6 @@ export declare class MotionMasterReqResClient {
1938
1938
  * and lists the supported pin modes. If all pin modes for a pin are disabled, the array defaults to `[0]`.
1939
1939
  */
1940
1940
  getSupportedDios(deviceRef: DeviceRef): Observable<number[][]>;
1941
- getMaxValuePercentageColor(percentage: number): "" | "#6ba853" | "#aeb303" | "#e69138" | "#fb262e";
1942
- getMaxValuePercentageLabel(percentage: number): "" | "Calibration was successful. Encoder system is robust to mechanical displacements and temperature expansions." | "Calibration was successful. Encoder system is robust to small mechanical displacements and temperature expansions." | "Calibration was successful. Mechanical displacement and temperature expansions should be avoided." | "Phase error is too high. The absolute position can't be computed reliably. Adjust mechanical position and repeat calibration.";
1943
1941
  /**
1944
1942
  * Checks the Circulo encoder error status registers for a specified encoder ordinal.
1945
1943
  *
@@ -2137,4 +2135,16 @@ export declare class MotionMasterReqResClient {
2137
2135
  * - This function assumes positive values; a negative value may indicate an error or reversed rotation.
2138
2136
  */
2139
2137
  getGearRatio(deviceRef: DeviceRef): Promise<number>;
2138
+ /**
2139
+ * Retrieves the PDO mapping for the given device.
2140
+ *
2141
+ * This method attempts to get the device-specific UI configuration and returns
2142
+ * its PDO mapping. If the device does not have a specific UI configuration or
2143
+ * its PDO mapping is missing, the default PDO mapping (`uiConfigWithDefaultPdoMapping`)
2144
+ * is returned instead.
2145
+ *
2146
+ * @param deviceRef - Reference to the device for which the UI configuration is requested.
2147
+ * @returns An `Observable` that emits the RX and TX PDO mapping for the device.
2148
+ */
2149
+ getUiConfigOrDefaultPdoMapping(deviceRef: DeviceRef): Observable<UiPdoMapping>;
2140
2150
  }
@@ -3762,38 +3762,6 @@ class MotionMasterReqResClient {
3762
3762
  }));
3763
3763
  }));
3764
3764
  }
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
3765
  /**
3798
3766
  * Checks the Circulo encoder error status registers for a specified encoder ordinal.
3799
3767
  *
@@ -4197,6 +4165,20 @@ class MotionMasterReqResClient {
4197
4165
  }
4198
4166
  });
4199
4167
  }
4168
+ /**
4169
+ * Retrieves the PDO mapping for the given device.
4170
+ *
4171
+ * This method attempts to get the device-specific UI configuration and returns
4172
+ * its PDO mapping. If the device does not have a specific UI configuration or
4173
+ * its PDO mapping is missing, the default PDO mapping (`uiConfigWithDefaultPdoMapping`)
4174
+ * is returned instead.
4175
+ *
4176
+ * @param deviceRef - Reference to the device for which the UI configuration is requested.
4177
+ * @returns An `Observable` that emits the RX and TX PDO mapping for the device.
4178
+ */
4179
+ getUiConfigOrDefaultPdoMapping(deviceRef) {
4180
+ 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; }));
4181
+ }
4200
4182
  }
4201
4183
  exports.MotionMasterReqResClient = MotionMasterReqResClient;
4202
4184
  /**