motion-master-client 0.0.288 → 0.0.290

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motion-master-client",
3
- "version": "0.0.288",
3
+ "version": "0.0.290",
4
4
  "type": "commonjs",
5
5
  "description": "A library and CLI program used for communicating with Motion Master.",
6
6
  "dependencies": {
@@ -9,6 +9,7 @@
9
9
  "commander": "^11.1.0",
10
10
  "cors": "^2.8.5",
11
11
  "debug": "^4.3.5",
12
+ "ecatmod": "^2.2.6",
12
13
  "express": "^4.19.2",
13
14
  "fast-deep-equal": "^3.1.3",
14
15
  "js-untar": "^2.0.0",
@@ -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 } 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 } 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';
@@ -847,11 +847,29 @@ export declare class MotionMasterReqResClient {
847
847
  resolveDeviceParameterTypeValueKey(deviceRefObj: DeviceRefObj, index: number, subindex: number, typeValueKey?: ParameterTypeValueKey): Observable<ParameterTypeValueKey>;
848
848
  resolveDeviceParameterInfoMap(deviceRef: DeviceRef | DeviceRefObj, requestTimeout?: number): Observable<Map<string, DeviceParameterInfo>>;
849
849
  /**
850
- * Get device parameters.
850
+ * Retrieves and constructs device parameters with optional ESI (EtherCAT Slave Information) extensions.
851
+ *
852
+ * This method resolves the target device, optionally loads and parses an ESI XML file,
853
+ * gathers device parameter metadata, and then fetches the actual parameter values.
854
+ * Optionally includes progress updates during value retrieval.
855
+ *
856
+ * @param props - An object containing the following properties:
857
+ * - `deviceId` or other identifying fields from `DeviceRefObj` to resolve the device.
858
+ * - `loadFromCache` (optional): Whether read from the device or from the cache in Motion Master.
859
+ * - `sendProgress` (optional): Whether to emit progress updates during parameter value retrieval.
860
+ * - `extendWithEsi` (optional): If true, attempts to load and parse the ESI XML file to enrich parameters with metadata.
861
+ * @param requestTimeout - Timeout in milliseconds to apply to the device parameter value retrieval. Defaults to 30,000 ms.
862
+ *
863
+ * @returns An Observable emitting an object containing:
864
+ * - `parameters`: An array of fully built `DeviceParameter` objects.
865
+ * - `progress`: A percentage (0–100) representing retrieval progress if `sendProgress` is enabled, otherwise 100.
866
+ *
867
+ * @throws An error if device parameter values could not be retrieved or are empty.
851
868
  */
852
869
  getDeviceParameters(props: {
853
870
  loadFromCache?: boolean;
854
871
  sendProgress?: boolean;
872
+ extendWithEsi?: boolean;
855
873
  } & DeviceRefObj, requestTimeout?: number): Observable<{
856
874
  parameters: DeviceParameter[];
857
875
  progress: number;
@@ -904,6 +922,37 @@ export declare class MotionMasterReqResClient {
904
922
  * Get the system log content and parse it into an array of lines, where each line contains the date, uptime, ID, file, level, and message.
905
923
  */
906
924
  getSystemLogLines(requestTimeout?: number, messageId?: string): Observable<SystemLogLine[]>;
925
+ /**
926
+ * Retrieves the UI configuration from the device's `ui.config.json` file.
927
+ *
928
+ * @param deviceRef - Reference to the target device from which to fetch the config.
929
+ * @param requestTimeout - Optional timeout in milliseconds for the file retrieval request (default is 10,000 ms).
930
+ * @param messageId - Optional message identifier for tracking or logging purposes.
931
+ * @returns An Observable emitting the parsed `UiConfig` object from the device, or an empty object if the content is unavailable.
932
+ */
933
+ getUiConfig(deviceRef: DeviceRef, requestTimeout?: number, messageId?: string): Observable<UiConfig>;
934
+ /**
935
+ * Updates the UI configuration file `ui.config.json` on the device by writing the provided PDO mapping.
936
+ *
937
+ * This method retrieves the current UI configuration from the device,
938
+ * updates its `pdoMapping` property with the provided mapping,
939
+ * then serializes and writes the updated configuration back to the device file system.
940
+ *
941
+ * @param deviceRef - Reference to the target device containing the UI configuration file.
942
+ * @param pdoMapping - The PDO mapping object to be saved within the UI configuration.
943
+ * @returns An Observable that emits the status of the file write operation.
944
+ */
945
+ writePdoMappingToUiConfigFile(deviceRef: DeviceRef, pdoMapping: UiPdoMapping): Observable<DeviceFileStatus>;
946
+ /**
947
+ * Removes the PDO mapping from the UI configuration file `ui.config.json` on the device.
948
+ *
949
+ * This method fetches the existing UI configuration, deletes the `pdoMapping` property if present,
950
+ * then writes the updated configuration back to the device.
951
+ *
952
+ * @param deviceRef - Reference to the target device containing the UI configuration file.
953
+ * @returns An Observable that emits the status of the file write operation.
954
+ */
955
+ removePdoMappingFromUiConfigFile(deviceRef: DeviceRef): Observable<DeviceFileStatus>;
907
956
  /**
908
957
  * Store parameters.
909
958
  *
@@ -27,6 +27,7 @@ const smm_1 = require("./smm");
27
27
  const firmware_1 = require("./firmware");
28
28
  const fetch_1 = require("./fetch");
29
29
  const circulo_1 = require("./circulo");
30
+ const { xmlToEsi } = require('ecatmod');
30
31
  /**
31
32
  * This class contains methods for making requests to Motion Master using the injected request/response socket.
32
33
  *
@@ -1606,13 +1607,34 @@ class MotionMasterReqResClient {
1606
1607
  }));
1607
1608
  }
1608
1609
  /**
1609
- * Get device parameters.
1610
+ * Retrieves and constructs device parameters with optional ESI (EtherCAT Slave Information) extensions.
1611
+ *
1612
+ * This method resolves the target device, optionally loads and parses an ESI XML file,
1613
+ * gathers device parameter metadata, and then fetches the actual parameter values.
1614
+ * Optionally includes progress updates during value retrieval.
1615
+ *
1616
+ * @param props - An object containing the following properties:
1617
+ * - `deviceId` or other identifying fields from `DeviceRefObj` to resolve the device.
1618
+ * - `loadFromCache` (optional): Whether read from the device or from the cache in Motion Master.
1619
+ * - `sendProgress` (optional): Whether to emit progress updates during parameter value retrieval.
1620
+ * - `extendWithEsi` (optional): If true, attempts to load and parse the ESI XML file to enrich parameters with metadata.
1621
+ * @param requestTimeout - Timeout in milliseconds to apply to the device parameter value retrieval. Defaults to 30,000 ms.
1622
+ *
1623
+ * @returns An Observable emitting an object containing:
1624
+ * - `parameters`: An array of fully built `DeviceParameter` objects.
1625
+ * - `progress`: A percentage (0–100) representing retrieval progress if `sendProgress` is enabled, otherwise 100.
1626
+ *
1627
+ * @throws An error if device parameter values could not be retrieved or are empty.
1610
1628
  */
1611
1629
  getDeviceParameters(props, requestTimeout = 30000) {
1630
+ const { loadFromCache, sendProgress, extendWithEsi } = props;
1612
1631
  return this.resolveDevice(props).pipe((0, operators_1.mergeMap)((device) => {
1613
- return this.getDeviceParameterInfo({ deviceAddress: device.deviceAddress }, requestTimeout).pipe((0, operators_1.mergeMap)((deviceParameterInfoStatus) => {
1632
+ return (0, rxjs_1.concat)(extendWithEsi ? this.upload(device.deviceAddress, 0x1018, 0x02) : (0, rxjs_1.of)(undefined), // productCode
1633
+ extendWithEsi ? this.getFile(device.deviceAddress, 'SOMANET_CiA_402.xml') : (0, rxjs_1.of)(undefined), // esiFileContent
1634
+ this.getDeviceParameterInfo({ deviceAddress: device.deviceAddress }, 5000) // deviceParameterInfoStatus
1635
+ ).pipe((0, operators_1.toArray)(), (0, operators_1.mergeMap)((results) => {
1614
1636
  var _a;
1615
- const { loadFromCache, sendProgress } = props;
1637
+ const [productCode, esiFileContent, deviceParameterInfoStatus] = results;
1616
1638
  const parameters = (_a = deviceParameterInfoStatus.parameters) === null || _a === void 0 ? void 0 : _a.map((p) => {
1617
1639
  var _a, _b;
1618
1640
  return ({
@@ -1621,6 +1643,11 @@ class MotionMasterReqResClient {
1621
1643
  loadFromCache,
1622
1644
  });
1623
1645
  });
1646
+ let esi = undefined;
1647
+ if (esiFileContent instanceof Uint8Array) {
1648
+ const xml = new TextDecoder('utf-8').decode(esiFileContent);
1649
+ esi = xmlToEsi(xml);
1650
+ }
1624
1651
  return this.getDeviceParameterValues({ deviceAddress: device.deviceAddress, sendProgress, parameters }, requestTimeout).pipe((0, operators_1.map)((deviceParameterValuesStatus) => {
1625
1652
  var _a, _b;
1626
1653
  if (!deviceParameterValuesStatus.parameterValues) {
@@ -1631,8 +1658,13 @@ class MotionMasterReqResClient {
1631
1658
  const index = (_a = value.index) !== null && _a !== void 0 ? _a : 0;
1632
1659
  const subindex = (_b = value.subindex) !== null && _b !== void 0 ? _b : 0;
1633
1660
  const id = (0, device_parameter_1.makeDeviceParameterId)(device.id, index, subindex);
1634
- return Object.assign(Object.assign(Object.assign({ id }, value), (_c = deviceParameterInfoStatus.parameters) === null || _c === void 0 ? void 0 : _c[i]), { index,
1661
+ let deviceParameter = Object.assign(Object.assign(Object.assign({ id }, value), (_c = deviceParameterInfoStatus.parameters) === null || _c === void 0 ? void 0 : _c[i]), { index,
1635
1662
  subindex, value: (0, parameter_1.getParameterValue)(value) });
1663
+ let esiExtension = {};
1664
+ if (esi) {
1665
+ esiExtension = (0, parameter_1.getParameterEsiExtension)(deviceParameter, esi === null || esi === void 0 ? void 0 : esi.value, productCode);
1666
+ }
1667
+ return Object.assign(Object.assign({}, deviceParameter), esiExtension);
1636
1668
  });
1637
1669
  const progress = sendProgress ? (_b = (_a = deviceParameterValuesStatus === null || deviceParameterValuesStatus === void 0 ? void 0 : deviceParameterValuesStatus.progress) === null || _a === void 0 ? void 0 : _a.percentage) !== null && _b !== void 0 ? _b : 0 : 100;
1638
1670
  return { parameters: deviceParameters, progress };
@@ -1740,6 +1772,64 @@ class MotionMasterReqResClient {
1740
1772
  getSystemLogLines(requestTimeout = 5000, messageId) {
1741
1773
  return this.getSystemLog(requestTimeout, messageId).pipe((0, operators_1.map)((systemLog) => { var _a; return (0, util_1.parseSystemLogContent)((_a = systemLog.content) !== null && _a !== void 0 ? _a : ''); }));
1742
1774
  }
1775
+ /**
1776
+ * Retrieves the UI configuration from the device's `ui.config.json` file.
1777
+ *
1778
+ * @param deviceRef - Reference to the target device from which to fetch the config.
1779
+ * @param requestTimeout - Optional timeout in milliseconds for the file retrieval request (default is 10,000 ms).
1780
+ * @param messageId - Optional message identifier for tracking or logging purposes.
1781
+ * @returns An Observable emitting the parsed `UiConfig` object from the device, or an empty object if the content is unavailable.
1782
+ */
1783
+ getUiConfig(deviceRef, requestTimeout = 10000, messageId) {
1784
+ return this.getFile(deviceRef, 'ui.config.json', requestTimeout, messageId).pipe((0, operators_1.map)((content) => {
1785
+ if (content) {
1786
+ const buffer = buffer_1.Buffer.from(content);
1787
+ const text = (0, util_1.decodeTextContent)(buffer);
1788
+ return JSON.parse(text);
1789
+ }
1790
+ else {
1791
+ return {};
1792
+ }
1793
+ }));
1794
+ }
1795
+ /**
1796
+ * Updates the UI configuration file `ui.config.json` on the device by writing the provided PDO mapping.
1797
+ *
1798
+ * This method retrieves the current UI configuration from the device,
1799
+ * updates its `pdoMapping` property with the provided mapping,
1800
+ * then serializes and writes the updated configuration back to the device file system.
1801
+ *
1802
+ * @param deviceRef - Reference to the target device containing the UI configuration file.
1803
+ * @param pdoMapping - The PDO mapping object to be saved within the UI configuration.
1804
+ * @returns An Observable that emits the status of the file write operation.
1805
+ */
1806
+ writePdoMappingToUiConfigFile(deviceRef, pdoMapping) {
1807
+ return this.getUiConfig(deviceRef).pipe((0, operators_1.mergeMap)((uiConfig) => {
1808
+ uiConfig.pdoMapping = pdoMapping;
1809
+ const jsonString = JSON.stringify(uiConfig);
1810
+ const content = new TextEncoder().encode(jsonString);
1811
+ return this.setFile(deviceRef, 'ui.config.json', content, true, 10000);
1812
+ }));
1813
+ }
1814
+ /**
1815
+ * Removes the PDO mapping from the UI configuration file `ui.config.json` on the device.
1816
+ *
1817
+ * This method fetches the existing UI configuration, deletes the `pdoMapping` property if present,
1818
+ * then writes the updated configuration back to the device.
1819
+ *
1820
+ * @param deviceRef - Reference to the target device containing the UI configuration file.
1821
+ * @returns An Observable that emits the status of the file write operation.
1822
+ */
1823
+ removePdoMappingFromUiConfigFile(deviceRef) {
1824
+ return this.getUiConfig(deviceRef).pipe((0, operators_1.mergeMap)((uiConfig) => {
1825
+ if ('pdoMapping' in uiConfig) {
1826
+ delete uiConfig.pdoMapping;
1827
+ }
1828
+ const jsonString = JSON.stringify(uiConfig);
1829
+ const content = new TextEncoder().encode(jsonString);
1830
+ return this.setFile(deviceRef, 'ui.config.json', content, true, 10000);
1831
+ }));
1832
+ }
1743
1833
  /**
1744
1834
  * Store parameters.
1745
1835
  *