motion-master-client 0.0.18 → 0.0.20

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 +1 @@
1
- {"version":3,"file":"cia402.js","sourceRoot":"","sources":["../../../../../libs/motion-master-client/src/lib/cia402.ts"],"names":[],"mappings":";;;AAAA,IAAY,WASX;AATD,WAAY,WAAW;IACrB,iFAAsB,CAAA;IACtB,yEAAkB,CAAA;IAClB,yEAAkB,CAAA;IAClB,2DAAW,CAAA;IACX,uEAAiB,CAAA;IACjB,uEAAiB,CAAA;IACjB,+EAAqB,CAAA;IACrB,+CAAK,CAAA;AACP,CAAC,EATW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAStB;AAEY,QAAA,iBAAiB,GAAG;IAC/B,wBAAwB;IACxB,oBAAoB;IACpB,oBAAoB;IACpB,aAAa;IACb,mBAAmB;IACnB,mBAAmB;IACnB,uBAAuB;IACvB,OAAO;CACR,CAAC;AAEW,QAAA,0BAA0B,GAAG,IAAI,GAAG,CAAC;IAChD,CAAC,UAAU,EAAE,WAAW,CAAC,sBAAsB,CAAC;IAChD,CAAC,UAAU,EAAE,WAAW,CAAC,kBAAkB,CAAC;IAC5C,CAAC,UAAU,EAAE,WAAW,CAAC,kBAAkB,CAAC;IAC5C,CAAC,UAAU,EAAE,WAAW,CAAC,WAAW,CAAC;IACrC,CAAC,UAAU,EAAE,WAAW,CAAC,iBAAiB,CAAC;IAC3C,CAAC,UAAU,EAAE,WAAW,CAAC,iBAAiB,CAAC;IAC3C,CAAC,UAAU,EAAE,WAAW,CAAC,qBAAqB,CAAC;IAC/C,CAAC,UAAU,EAAE,WAAW,CAAC,KAAK,CAAC;CAChC,CAAC,CAAC;AAEH,SAAgB,4BAA4B,CAAC,UAAkB;IAC7D,OAAO,kCAA0B,CAAC,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC;WACzD,kCAA0B,CAAC,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC,CA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;IACd,cAAc;IACd,cAAc;CACf,CAAC"}
1
+ {"version":3,"file":"cia402.js","sourceRoot":"","sources":["../../../../../libs/motion-master-client/src/lib/cia402.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG;IAC5B,2BAA2B;IAC3B,kBAAkB;IAClB,wBAAwB;IACxB,WAAW;IACX,sBAAsB;IACtB,iBAAiB;IACjB,0BAA0B;IAC1B,aAAa;IACb,4BAA4B;IAC5B,aAAa;IACb,qBAAqB;IACrB,6BAA6B;IAC7B,+BAA+B;IAC/B,+BAA+B;IAC/B,4BAA4B;IAC5B,4BAA4B;CAC7B,CAAC;AAEF;;;;;GAKG;AACH,IAAY,WAkEX;AAlED,WAAY,WAAW;IACrB;;;;;OAKG;IACH,gEAAiD,CAAA;IAEjD;;;;;OAKG;IACH,wDAAyC,CAAA;IAEzC;;;;;OAKG;IACH,wDAAyC,CAAA;IAEzC;;;;;OAKG;IACH,0CAA2B,CAAA;IAE3B;;;;;OAKG;IACH,sDAAuC,CAAA;IAEvC;;;;;OAKG;IACH,sDAAuC,CAAA;IAEvC;;;;;;OAMG;IACH,8DAA+C,CAAA;IAE/C;;;;;;OAMG;IACH,8BAAe,CAAA;AACjB,CAAC,EAlEW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAkEtB;AAAA,CAAC;AAEW,QAAA,cAAc,GAAG,IAAI,GAAG,CAAC;IACpC,CAAC,UAAU,EAAE,WAAW,CAAC,sBAAsB,CAAC;IAChD,CAAC,UAAU,EAAE,WAAW,CAAC,kBAAkB,CAAC;IAC5C,CAAC,UAAU,EAAE,WAAW,CAAC,kBAAkB,CAAC;IAC5C,CAAC,UAAU,EAAE,WAAW,CAAC,WAAW,CAAC;IACrC,CAAC,UAAU,EAAE,WAAW,CAAC,iBAAiB,CAAC;IAC3C,CAAC,UAAU,EAAE,WAAW,CAAC,iBAAiB,CAAC;IAC3C,CAAC,UAAU,EAAE,WAAW,CAAC,qBAAqB,CAAC;IAC/C,CAAC,UAAU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AqB;IAC/D,qBAAqB,EAAE,gBAAgB,CAAC,mBAAmB;IAC3D,aAAa,EAAE,gBAAgB,CAAC,WAAW;IAC3C,kCAAkC,EAAE,gBAAgB,CAAC,yBAAyB;IAC9E,kCAAkC,EAAE,gBAAgB,CAAC,yBAAyB;IAC9E,gCAAgC,EAAE,gBAAgB,CAAC,uBAAuB;CAC3E,CAAC;AAEW,QAAA,uBAAuB,GAAG;IACrC,4BAA4B;IAC5B,oBAAoB;IACpB,4BAA4B;IAC5B,kBAAkB;IAClB,cAAc;IACd,kBAAkB;IAClB,iCAAiC;IACjC,wCAAwC;IACxC,wCAAwC;IACxC,sCAAsC;IACtC,cAAc;IACd,cAAc;IACd,cAAc;IACd,cAAc;IACd,cAAc;IACd,cAAc;CACf,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { Parameter } from './parameter';
2
+ import { Optional } from './types';
3
+ export type ConfigParameter = Optional<Parameter, 'name' | 'typeValue'>;
4
+ export declare class ConfigFile {
5
+ readonly content: string;
6
+ readonly file?: Pick<File, "name" | "type" | "size" | "lastModified"> | undefined;
7
+ readonly apiId?: string;
8
+ readonly firmwareVersion?: string;
9
+ readonly header?: string;
10
+ parameters: ConfigParameter[];
11
+ constructor(content: string, file?: Pick<File, "name" | "type" | "size" | "lastModified"> | undefined);
12
+ toString(): string;
13
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConfigFile = void 0;
4
+ const Papa = require("papaparse");
5
+ const parameter_1 = require("./parameter");
6
+ class ConfigFile {
7
+ constructor(content, file) {
8
+ var _a;
9
+ this.content = content;
10
+ this.file = file;
11
+ const parseResult = Papa.parse(content, {
12
+ skipEmptyLines: true,
13
+ transform: (value) => value.trim(),
14
+ });
15
+ if (((_a = parseResult === null || parseResult === void 0 ? void 0 : parseResult.errors) === null || _a === void 0 ? void 0 : _a.length) > 0) {
16
+ throw new Error('Failed to parse the config csv file');
17
+ }
18
+ const matchApiId = content.match(/^#\s+(\d{4}-\d{2})$/m);
19
+ if (matchApiId) {
20
+ this.apiId = matchApiId[1];
21
+ }
22
+ const matchFirmwareVersion = content.match(/^#\s+(v\d.*)$/m);
23
+ if (matchFirmwareVersion) {
24
+ this.firmwareVersion = matchFirmwareVersion[1];
25
+ }
26
+ const matchFirstParameterRow = content.match(/^0x\d{4}/m);
27
+ if (matchFirstParameterRow === null || matchFirstParameterRow === void 0 ? void 0 : matchFirstParameterRow.index) {
28
+ this.header = content.slice(0, matchFirstParameterRow.index - 1);
29
+ }
30
+ this.parameters = parseResult.data
31
+ .filter(([c0]) => c0.startsWith('0x'))
32
+ .map(([c0, c1, c2]) => {
33
+ const index = parseInt(c0, 16);
34
+ const subindex = parseInt(c1, 10);
35
+ const numValue = Number(c2);
36
+ const value = isNaN(numValue) ? c2 : numValue;
37
+ return { index, subindex, value };
38
+ })
39
+ .sort(parameter_1.parametersCompareFn);
40
+ }
41
+ toString() {
42
+ let out = this.parameters.map((p) => { var _a, _b; return `0x${(_a = p.index) === null || _a === void 0 ? void 0 : _a.toString(16)}, ${(_b = p.subindex) === null || _b === void 0 ? void 0 : _b.toString(10)}, ${p.value}`; }).join('\n');
43
+ if (this.header) {
44
+ out = this.header + '\n' + out;
45
+ }
46
+ return out + '\n';
47
+ }
48
+ }
49
+ exports.ConfigFile = ConfigFile;
50
+ //# sourceMappingURL=config-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-file.js","sourceRoot":"","sources":["../../../../../libs/motion-master-client/src/lib/config-file.ts"],"names":[],"mappings":";;;AAAA,kCAAkC;AAClC,2CAA6D;AAK7D,MAAa,UAAU;IAQrB,YACkB,OAAe,EACf,IAA4D;;QAD5D,YAAO,GAAP,OAAO,CAAQ;QACf,SAAI,GAAJ,IAAI,CAAwD;QAE5E,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAW,OAAO,EAAE;YAChD,cAAc,EAAE,IAAI;YACpB,SAAS,EAAE,CAAC,KAAa,E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AK,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;YAC9C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QACpC,CAAC,CAAC;aACD,IAAI,CAAC,+BAAmB,CAAC,CAAC;IAC/B,CAAC;IAED,QAAQ;QACN,IAAI,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,eAAC,OAAA,KAAK,MAAA,CAAC,CAAC,KAAK,0CAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,MAAA,CAAC,CAAC,QAAQ,0CAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAA,EAAA,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvH,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,GAAG,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,GAAG,CAAC;SAChC;QACD,OAAO,GAAG,GAAG,IAAI,CAAC;IACpB,CAAC;CAEF;AAxDD,gCAwDC"}
@@ -3,8 +3,8 @@ export interface HardwareComponent {
3
3
  version: string;
4
4
  serialNumber: string;
5
5
  }
6
- export declare type AssemblyComponent = HardwareComponent;
7
- export declare type DeviceComponent = HardwareComponent;
6
+ export type AssemblyComponent = HardwareComponent;
7
+ export type DeviceComponent = HardwareComponent;
8
8
  export interface Assembly {
9
9
  name: string;
10
10
  id: string;
@@ -1 +1 @@
1
- export declare const logger: import("roarr").Logger<import("roarr/dist/src/types").JsonObject>;
1
+ export declare const logger: import("roarr").Logger<import("roarr/dist/types").JsonObject>;
@@ -4,7 +4,8 @@ import { MotionMasterPubSubClient } from "./motion-master-pub-sub-client";
4
4
  import { MotionMasterPubSubSocket } from "./motion-master-pub-sub-socket";
5
5
  import { MotionMasterReqResClient } from "./motion-master-req-res-client";
6
6
  import { MotionMasterReqResSocket } from "./motion-master-req-res-socket";
7
- import { DeviceRef, ParameterValueType } from "./types";
7
+ import { DeviceParameterIds, DeviceRef, ParameterValueType } from "./types";
8
+ import { Parameter } from "./parameter";
8
9
  export declare function createMotionMasterClient(hostname: string): MotionMasterClient;
9
10
  export declare class MotionMasterClient {
10
11
  readonly reqResSocket: MotionMasterReqResSocket;
@@ -25,6 +26,7 @@ export declare class MotionMasterClient {
25
26
  ready$: Observable<true>;
26
27
  /**
27
28
  * This observable will emit only once when both req/res and pub/sub sockets are opened.
29
+ * NOTE: This observable might never emit and it doesn't timeout.
28
30
  */
29
31
  onceReady$: Observable<true>;
30
32
  /**
@@ -33,7 +35,17 @@ export declare class MotionMasterClient {
33
35
  * Otherwise, it will wait up to requestTimeout for both sockets to open, or throw an error.
34
36
  */
35
37
  whenReady(requestTimeout?: number): Promise<true>;
36
- startMonitoring(ids: string[] | [DeviceRef, number, number][], interval: number, config?: MonitoringConfig, requestTimeout?: number): Observable<ParameterValueType[]>;
38
+ startMonitoring(ids: DeviceParameterIds, interval: number, config?: MonitoringConfig, requestTimeout?: number): Observable<ParameterValueType[]>;
39
+ /**
40
+ * TODO: return device parameters instead of just parameters
41
+ * get parameters from ESI uprfront, and then when parameters are received
42
+ * from motion master just concatenate (spread operator) props from ESI and props from parameter
43
+ * assign device parameter id like 0x1018:00.12345
44
+ * when assembling device parameter, get parameter from device in ESI based on product code, see ESI service
45
+ * this should probably done for other get parameters functions, get ESI file from device or prepared, get data from it
46
+ */
47
+ startMonitoringDeviceParameters(ids: DeviceParameterIds, interval: number, config?: MonitoringConfig, requestTimeout?: number): Observable<Parameter[]>;
48
+ startMonitoringValue<T extends ParameterValueType = number>(id: string | [DeviceRef, number, number], interval: number, config?: MonitoringConfig, requestTimeout?: number): Observable<T>;
37
49
  stopMonitoring(messageId: string): void;
38
50
  closeSockets(): void;
39
51
  reopenSockets(): void;
@@ -36,6 +36,7 @@ class MotionMasterClient {
36
36
  this.ready$ = this.socketsOpened$.pipe((0, rxjs_1.filter)(Boolean));
37
37
  /**
38
38
  * This observable will emit only once when both req/res and pub/sub sockets are opened.
39
+ * NOTE: This observable might never emit and it doesn't timeout.
39
40
  */
40
41
  this.onceReady$ = this.ready$.pipe((0, rxjs_1.first)());
41
42
  this.request = new motion_master_req_res_client_1.MotionMasterReqResClient(this.reqResSocket);
@@ -86,6 +87,53 @@ class MotionMasterClient {
86
87
  });
87
88
  });
88
89
  }
90
+ /**
91
+ * TODO: return device parameters instead of just parameters
92
+ * get parameters from ESI uprfront, and then when parameters are received
93
+ * from motion master just concatenate (spread operator) props from ESI and props from parameter
94
+ * assign device parameter id like 0x1018:00.12345
95
+ * when assembling device parameter, get parameter from device in ESI based on product code, see ESI service
96
+ * this should probably done for other get parameters functions, get ESI file from device or prepared, get data from it
97
+ */
98
+ startMonitoringDeviceParameters(ids, interval, config, requestTimeout = 5000) {
99
+ return (0, rxjs_1.defer)(() => {
100
+ var _a, _b;
101
+ const topic = (_a = config === null || config === void 0 ? void 0 : config.topic) !== null && _a !== void 0 ? _a : (0, uuid_1.v4)();
102
+ const messageId = (_b = config === null || config === void 0 ? void 0 : config.messageId) !== null && _b !== void 0 ? _b : (0, uuid_1.v4)();
103
+ if (!config) {
104
+ config = { messageId, topic, bufferSize: 1, distinct: false };
105
+ }
106
+ this.request.resolveGetParameterValuesIds(ids).pipe((0, rxjs_1.mergeMap)((refs) => {
107
+ if ((new Set(refs.map(([deviceAddress]) => deviceAddress))).size !== 1) {
108
+ throw new Error('Start monitoring only supports a single device');
109
+ }
110
+ const deviceAddress = refs[0][0];
111
+ const props = {
112
+ getDeviceParameterValues: {
113
+ deviceAddress,
114
+ parameters: refs.map(([, index, subindex]) => ({ index, subindex, loadFromCache: false })),
115
+ sendProgress: false,
116
+ },
117
+ interval,
118
+ topic,
119
+ };
120
+ return this.request.startMonitoringDeviceParameterValues(props, requestTimeout, messageId);
121
+ })).subscribe();
122
+ this.monitor.subscribe(config);
123
+ const values$ = this.monitor.socket.data$.pipe((0, operators_1.selectMotionMasterMessageByTopic)(config.topic), (0, operators_1.mapMonitoringParameterValuesStatusMessageToDeviceParameters)(), (0, rxjs_1.map)((values) => values.slice(1)));
124
+ return new rxjs_1.Observable((subscriber) => {
125
+ const subscription = values$.subscribe(subscriber);
126
+ return () => {
127
+ subscription.unsubscribe();
128
+ this.stopMonitoring(messageId);
129
+ };
130
+ });
131
+ });
132
+ }
133
+ startMonitoringValue(id, interval, config, requestTimeout = 5000) {
134
+ const ids = typeof id === 'string' ? [id] : [id];
135
+ return this.startMonitoring(ids, interval, config, requestTimeout).pipe((0, rxjs_1.map)((parameters) => { var _a; return ((_a = parameters[0]) !== null && _a !== void 0 ? _a : 0); }));
136
+ }
89
137
  stopMonitoring(messageId) {
90
138
  this.request.stopMonitoringDeviceParameterValues({ startMonitoringRequestId: messageId });
91
139
  this.monitor.unsubscribe(messageId);
@@ -1 +1 @@
1
- {"version":3,"file":"motion-master-client.js","sourceRoot":"","sources":["../../../../../libs/motion-master-client/src/lib/motion-master-client.ts"],"names":[],"mappings":";;;;AAAA,+BAA+G;AAC/G,+BAA0B;AAE1B,iFAA0E;AAE1E,yFAAiF;AACjF,iFAA0E;AAE1E,yFAAiF;AACjF,2CAA2H;AAG3H,SAAgB,wBAAwB,CAAC,QAAgB;IACvD,MAAM,YAAY,GAAG,IAAI,8DAA2B,EAAE,CAAC;IACvD,MAAM,YAAY,GAAG,IAAI,8DAA2B,EAAE,CAAC;IAEvD,MAAM,MAAM,GAAG,IAAI,kBAAkB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IAElE,MAAM,QAAQ,GAAG,IAAA,SAAE,GAAE,CAAC;IACtB,YAAY,CAAC,IAAI,CAAC,QAAQ,QAAQ,mBAAmB,QAAQ,EAAE,CAAC,CAAC;IACjE,YAAY,CAAC,IAAI,CAAC,QAAQ,QAAQ,mBAAmB,QAAQ,EAAE,CAAC,CAAC;IAEjE,OAAO,MAAM,CAAC;AAChB,CAAC;AAXD,4DAWC;AAED,MAAa,kBA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C,EAC9C,IAAA,sEAA0D,GAAE,EAC5D,IAAA,UAAG,EAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CACjC,CAAC;YAEF,OAAO,IAAI,iBAAU,CAAuB,CAAC,UAAU,EAAE,EAAE;gBACzD,MAAM,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;gBACnD,OAAO,GAAG,EAAE;oBACV,YAAY,CAAC,WAAW,EAAE,CAAC;oBAC3B,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;gBACjC,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,cAAc,CAAC,SAAiB;QAC9B,IAAI,CAAC,OAAO,CAAC,mCAAmC,CAAC,EAAE,wBAAwB,EAAE,SAAS,EAAE,CAAC,CAAC;QAC1F,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;IAED,YAAY;QACV,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED,aAAa;QACX,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;IAC7B,CAAC;CAEF;AAvHD,gDAuHC"}
1
+ {"version":3,"file":"motion-master-client.js","sourceRoot":"","sources":["../../../../../libs/motion-master-client/src/lib/motion-master-client.ts"],"names":[],"mappings":";;;;AAAA,+BAA+G;AAC/G,+BAA0B;AAE1B,iFAA0E;AAE1E,yFAAiF;AACjF,iFAA0E;AAE1E,yFAAiF;AACjF,2CAAwL;AAIxL,SAAgB,wBAAwB,CAAC,QAAgB;IACvD,MAAM,YAAY,GAAG,IAAI,8DAA2B,EAAE,CAAC;IACvD,MAAM,YAAY,GAAG,IAAI,8DAA2B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;AAlMD,gDAkMC"}
@@ -3,7 +3,8 @@ import { Device } from "./device";
3
3
  import { DeviceParameter } from "./device-parameter";
4
4
  import { MotionMasterReqResSocket } from "./motion-master-req-res-socket";
5
5
  import { SystemLogLine } from "./system-log-line";
6
- 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 } from "./types";
6
+ 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 } from "./types";
7
+ import { ModesOfOperation, Cia402State } from "./cia402";
7
8
  /**
8
9
  * This class contains methods for making requests to Motion Master using the injected request/response socket.
9
10
  *
@@ -779,9 +780,9 @@ export declare class MotionMasterReqResClient {
779
780
  upload<T extends ParameterValueType = number>(deviceRef: DeviceRef, index: number, subindex: number, loadFromCache?: boolean, requestTimeout?: number, messageId?: string): Promise<T>;
780
781
  private createGetParameterValueObservable;
781
782
  private resolveGetDeviceParameterValueArguments;
782
- getParameterValues(ids: string[] | [DeviceRef, number, number][], loadFromCache?: boolean, requestTimeout?: number, messageId?: string): Observable<ParameterValueType[]>;
783
- uploadMany(ids: string[] | [DeviceRef, number, number][], loadFromCache?: boolean, requestTimeout?: number, messageId?: string): Promise<ParameterValueType[]>;
784
- resolveGetParameterValuesIds(ids: string[] | [DeviceRef, number, number][]): Observable<number[][]>;
783
+ getParameterValues(ids: DeviceParameterIds, loadFromCache?: boolean, requestTimeout?: number, messageId?: string): Observable<ParameterValueType[]>;
784
+ uploadMany(ids: DeviceParameterIds, loadFromCache?: boolean, requestTimeout?: number, messageId?: string): Promise<ParameterValueType[]>;
785
+ resolveGetParameterValuesIds(ids: DeviceParameterIds): Observable<number[][]>;
785
786
  setParameterValue(deviceParameterId: string, value: ParameterValueType, valueTypeKey?: keyof Required<ParameterTypeValue>, requestTimeout?: number, messageId?: string): Observable<void>;
786
787
  setParameterValue(deviceRef: DeviceRef, index: number, subindex: number, value: ParameterValueType, valueTypeKey?: keyof Required<ParameterTypeValue>, requestTimeout?: number, messageId?: string): Observable<void>;
787
788
  download(deviceParameterId: string, value: ParameterValueType, valueTypeKey?: keyof Required<ParameterTypeValue>, requestTimeout?: number, messageId?: string): Promise<void>;
@@ -809,16 +810,31 @@ export declare class MotionMasterReqResClient {
809
810
  progress: number;
810
811
  }>;
811
812
  /**
812
- * Get device files.
813
+ * Get files.
813
814
  */
814
- getDeviceFiles(deviceRef: DeviceRef, requestTimeout?: number, messageId?: string): Observable<string[]>;
815
+ getFiles(deviceRef: DeviceRef, requestTimeout?: number, messageId?: string): Observable<string[]>;
815
816
  /**
816
- * Get decoded device file.
817
+ * Get file.
818
+ */
819
+ getFile(deviceRef: DeviceRef, name: string, requestTimeout?: number, messageId?: string): Observable<Uint8Array | null | undefined>;
820
+ /**
821
+ * Get decoded file.
817
822
  *
818
823
  * Content of a device file is returned as a binary data buffer.
819
824
  * This functions tries to decode the content as a text in utf-8 character encoding.
820
825
  */
821
- getDecodedDeviceFile(deviceRef: DeviceRef, name: string, requestTimeout?: number, messageId?: string): Observable<string>;
826
+ getDecodedFile(deviceRef: DeviceRef, name: string, requestTimeout?: number, messageId?: string): Observable<string>;
827
+ /**
828
+ * Unlock protected files.
829
+ *
830
+ * This will enable the deletion of protected files.
831
+ * Protected files begin with a period, such as '.hardware_description'.
832
+ */
833
+ unlockProtectedFiles(deviceRef: DeviceRef, requestTimeout?: number, messageId?: string): Observable<string>;
834
+ /**
835
+ * Delete file.
836
+ */
837
+ deleteFile(deviceRef: DeviceRef, name: string, requestTimeout?: number, messageId?: string): Observable<DeviceFileStatus>;
822
838
  /**
823
839
  * Get system log lines.
824
840
  *
@@ -851,6 +867,7 @@ export declare class MotionMasterReqResClient {
851
867
  * @throws Will throw an error if the values do not match.
852
868
  */
853
869
  matchParameterValue(deviceRef: DeviceRef, index: number, subindex: number, expectedValue: number): Observable<void>;
870
+ matchCia402States(deviceRef: DeviceRef, expectedStates: Cia402State[]): Observable<void>;
854
871
  /**
855
872
  * Helper function to enable motion.
856
873
  */
@@ -863,4 +880,41 @@ export declare class MotionMasterReqResClient {
863
880
  * Helper function to set motion target.
864
881
  */
865
882
  setMotionTarget(deviceRef: DeviceRef, target: number, messageId?: string): Observable<never>;
883
+ /**
884
+ * Get CiA402 state.
885
+ */
886
+ getCia402State(deviceRef: DeviceRef, requestTimeout?: number, messageId?: string): Observable<Cia402State>;
887
+ /**
888
+ * Transition to CiA402 state.
889
+ *
890
+ * This function will utilize the current value of the controlword and modify it to transition to the requested CiA402 state.
891
+ *
892
+ * Only one transition will occur, except when the current CiA402 state is SWITCH_ON_DISABLED. In this case,
893
+ * the first transition is from SOD to RTSO, and then from RTSO to the requested CiA402 state.
894
+ *
895
+ * The Statusword will be polled to check if the device has successfully transitioned to the requested CiA402 state.
896
+ * When transitioning to QSA, the Statusword will be checked against both QSA and SOD.
897
+ * This is necessary because the automatic transition from QSA to SOD can occur faster than the client's polling interval.
898
+ */
899
+ transitionToCia402State(deviceRef: DeviceRef, targetState: Cia402State): Promise<void>;
900
+ resetFault(deviceRef: DeviceRef): Promise<void>;
901
+ quickStop(deviceRef: DeviceRef): Promise<void>;
902
+ /**
903
+ * Reset targets.
904
+ *
905
+ * Set torque and velocity targets to 0, and set the position target to the current position value.
906
+ */
907
+ resetTargets(deviceRef: DeviceRef): Promise<void>;
908
+ /**
909
+ * Get modes of operation.
910
+ *
911
+ * Retrieve the value of the 0x6061:00 Modes of operation display.
912
+ */
913
+ getModesOfOperation(deviceRef: DeviceRef, requestTimeout?: number, messageId?: string): Observable<number>;
914
+ /**
915
+ * Set modes of operation.
916
+ *
917
+ * Set the 0x6060:00 Modes of operation to one of the available options, such as Homing mode (6).
918
+ */
919
+ setModesOfOperation(deviceRef: DeviceRef, value: ModesOfOperation, requestTimeout?: number, messageId?: string): Observable<void>;
866
920
  }
@@ -11,6 +11,9 @@ const operators_2 = require("./operators");
11
11
  const parameter_1 = require("./parameter");
12
12
  const types_1 = require("./types");
13
13
  const util_1 = require("./util");
14
+ const cia402_1 = require("./cia402");
15
+ const cia402_2 = require("./cia402");
16
+ const cia402_3 = require("./cia402");
14
17
  /**
15
18
  * This class contains methods for making requests to Motion Master using the injected request/response socket.
16
19
  *
@@ -1058,7 +1061,7 @@ class MotionMasterReqResClient {
1058
1061
  this.deviceMap.clear();
1059
1062
  devices.forEach((device) => {
1060
1063
  if (!device.hardwareDescription) {
1061
- throw new Error(`Device ${device.deviceAddress} has no hardware description`);
1064
+ throw new Error(`Device ${device.position} has no hardware description`);
1062
1065
  }
1063
1066
  const deviceSerialNumber = (0, hardware_description_1.getSerialNumberFromHardwareDescription)(device.hardwareDescription);
1064
1067
  this.deviceMap.set(deviceSerialNumber, device);
@@ -1448,19 +1451,26 @@ class MotionMasterReqResClient {
1448
1451
  }));
1449
1452
  }
1450
1453
  /**
1451
- * Get device files.
1454
+ * Get files.
1452
1455
  */
1453
- getDeviceFiles(deviceRef, requestTimeout = 30000, messageId) {
1456
+ getFiles(deviceRef, requestTimeout = 30000, messageId) {
1454
1457
  const deviceRefObj = (0, util_1.makeDeviceRefObj)(deviceRef);
1455
1458
  return this.getDeviceFileList(deviceRefObj, requestTimeout, messageId).pipe((0, operators_1.map)((status) => { var _a, _b; return (_b = (_a = status.fileList) === null || _a === void 0 ? void 0 : _a.files) !== null && _b !== void 0 ? _b : []; }));
1456
1459
  }
1457
1460
  /**
1458
- * Get decoded device file.
1461
+ * Get file.
1462
+ */
1463
+ getFile(deviceRef, name, requestTimeout = 5000, messageId) {
1464
+ const deviceRefObj = (0, util_1.makeDeviceRefObj)(deviceRef);
1465
+ return this.getDeviceFile(Object.assign(Object.assign({}, deviceRefObj), { name }), requestTimeout, messageId).pipe((0, operators_1.map)(({ content }) => content));
1466
+ }
1467
+ /**
1468
+ * Get decoded file.
1459
1469
  *
1460
1470
  * Content of a device file is returned as a binary data buffer.
1461
1471
  * This functions tries to decode the content as a text in utf-8 character encoding.
1462
1472
  */
1463
- getDecodedDeviceFile(deviceRef, name, requestTimeout = 2000, messageId) {
1473
+ getDecodedFile(deviceRef, name, requestTimeout = 2000, messageId) {
1464
1474
  const deviceRefObj = (0, util_1.makeDeviceRefObj)(deviceRef);
1465
1475
  return this.getDeviceFile(Object.assign(Object.assign({}, deviceRefObj), { name }), requestTimeout, messageId).pipe((0, operators_1.map)(({ content }) => {
1466
1476
  if (content) {
@@ -1469,6 +1479,22 @@ class MotionMasterReqResClient {
1469
1479
  throw new Error(`Device file ${name} content for device ${deviceRef} is empty!}`);
1470
1480
  }));
1471
1481
  }
1482
+ /**
1483
+ * Unlock protected files.
1484
+ *
1485
+ * This will enable the deletion of protected files.
1486
+ * Protected files begin with a period, such as '.hardware_description'.
1487
+ */
1488
+ unlockProtectedFiles(deviceRef, requestTimeout = 3000, messageId) {
1489
+ return this.getDecodedFile(deviceRef, 'fs-stackunlock=DD1317', requestTimeout, messageId);
1490
+ }
1491
+ /**
1492
+ * Delete file.
1493
+ */
1494
+ deleteFile(deviceRef, name, requestTimeout = 3000, messageId) {
1495
+ const deviceRefObj = (0, util_1.makeDeviceRefObj)(deviceRef);
1496
+ return this.deleteDeviceFile(Object.assign(Object.assign({}, deviceRefObj), { name }), requestTimeout, messageId);
1497
+ }
1472
1498
  /**
1473
1499
  * Get system log lines.
1474
1500
  *
@@ -1515,6 +1541,14 @@ class MotionMasterReqResClient {
1515
1541
  }
1516
1542
  }));
1517
1543
  }
1544
+ matchCia402States(deviceRef, expectedStates) {
1545
+ return this.getParameterValue(deviceRef, 0x6041, 0).pipe((0, operators_1.map)((value) => {
1546
+ const state = (0, cia402_1.getCia402State)(value);
1547
+ if (!expectedStates.includes(state)) {
1548
+ throw new Error(`Device CiA402 state and the expected state don't match: ${state} ${expectedStates}`);
1549
+ }
1550
+ }));
1551
+ }
1518
1552
  /**
1519
1553
  * Helper function to enable motion.
1520
1554
  */
@@ -1536,6 +1570,111 @@ class MotionMasterReqResClient {
1536
1570
  const deviceRefObj = (0, util_1.makeDeviceRefObj)(deviceRef);
1537
1571
  return this.setMotionControllerParameters(Object.assign(Object.assign({}, deviceRefObj), { target }), messageId);
1538
1572
  }
1573
+ /**
1574
+ * Get CiA402 state.
1575
+ */
1576
+ getCia402State(deviceRef, requestTimeout = 1000, messageId) {
1577
+ return this.getParameterValue(deviceRef, 0x6041, 0, false, requestTimeout, messageId).pipe((0, operators_1.map)((value) => (0, cia402_1.getCia402State)(value)));
1578
+ }
1579
+ /**
1580
+ * Transition to CiA402 state.
1581
+ *
1582
+ * This function will utilize the current value of the controlword and modify it to transition to the requested CiA402 state.
1583
+ *
1584
+ * Only one transition will occur, except when the current CiA402 state is SWITCH_ON_DISABLED. In this case,
1585
+ * the first transition is from SOD to RTSO, and then from RTSO to the requested CiA402 state.
1586
+ *
1587
+ * The Statusword will be polled to check if the device has successfully transitioned to the requested CiA402 state.
1588
+ * When transitioning to QSA, the Statusword will be checked against both QSA and SOD.
1589
+ * This is necessary because the automatic transition from QSA to SOD can occur faster than the client's polling interval.
1590
+ */
1591
+ transitionToCia402State(deviceRef, targetState) {
1592
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
1593
+ let currentState = yield (0, rxjs_1.lastValueFrom)(this.getCia402State(deviceRef));
1594
+ if (targetState === currentState) {
1595
+ return;
1596
+ }
1597
+ if (currentState === cia402_1.Cia402State.NOT_READY_TO_SWITCH_ON || currentState === cia402_1.Cia402State.FAULT_REACTION_ACTIVE) {
1598
+ throw new Error(`It is not possible to transition from state ${currentState} to state ${targetState}. The transition from the current ${currentState} state is automatic.`);
1599
+ }
1600
+ let controlword = yield this.upload(deviceRef, 0x6040, 0);
1601
+ let transition = cia402_2.cia402Transitions.find(t => t.from === currentState && t.to === targetState);
1602
+ // From SOD it's only possible to transition to RTSO.
1603
+ if (currentState === cia402_1.Cia402State.SWITCH_ON_DISABLED && targetState !== cia402_1.Cia402State.READY_TO_SWITCH_ON) {
1604
+ transition = cia402_2.cia402Transitions.find(t => t.from === cia402_1.Cia402State.READY_TO_SWITCH_ON && t.to === targetState);
1605
+ }
1606
+ if (!transition) {
1607
+ throw new Error(`It is not possible to transition from state ${currentState} to state ${targetState}.`);
1608
+ }
1609
+ if (currentState === cia402_1.Cia402State.SWITCH_ON_DISABLED) {
1610
+ const sodToRtsoTransition = cia402_2.cia402Transitions[0];
1611
+ const command = (0, cia402_3.createControlwordCommand)(controlword, sodToRtsoTransition.command);
1612
+ yield (0, rxjs_1.lastValueFrom)(this.setParameterValue(deviceRef, 0x6040, 0, command).pipe((0, operators_1.mergeMap)(() => this.matchCia402States(deviceRef, [cia402_1.Cia402State.READY_TO_SWITCH_ON]).pipe((0, operators_1.retry)({ count: 5, delay: 1000 })))));
1613
+ controlword = yield this.upload(deviceRef, 0x6040, 0);
1614
+ currentState = yield (0, rxjs_1.lastValueFrom)(this.getCia402State(deviceRef));
1615
+ if (targetState === currentState) {
1616
+ return;
1617
+ }
1618
+ }
1619
+ const command = (0, cia402_3.createControlwordCommand)(controlword, transition.command);
1620
+ const expectedStates = [targetState];
1621
+ if (targetState === cia402_1.Cia402State.QUICK_STOP_ACTIVE) {
1622
+ expectedStates.push(cia402_1.Cia402State.SWITCH_ON_DISABLED);
1623
+ }
1624
+ yield (0, rxjs_1.lastValueFrom)(this.setParameterValue(deviceRef, 0x6040, 0, command).pipe((0, operators_1.mergeMap)(() => this.matchCia402States(deviceRef, expectedStates).pipe((0, operators_1.retry)({ count: 5, delay: 1000 }))), (0, operators_1.catchError)(() => {
1625
+ throw new Error(`Timeout occurred while transitioning from ${currentState} state to ${targetState} state.`);
1626
+ })));
1627
+ });
1628
+ }
1629
+ resetFault(deviceRef) {
1630
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
1631
+ const currentState = yield (0, rxjs_1.lastValueFrom)(this.getCia402State(deviceRef));
1632
+ if (currentState !== cia402_1.Cia402State.FAULT) {
1633
+ throw new Error(`Device ${deviceRef} is not in FAULT CiA402 state.`);
1634
+ }
1635
+ this.transitionToCia402State(deviceRef, cia402_1.Cia402State.SWITCH_ON_DISABLED);
1636
+ });
1637
+ }
1638
+ quickStop(deviceRef) {
1639
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
1640
+ const currentState = yield (0, rxjs_1.lastValueFrom)(this.getCia402State(deviceRef));
1641
+ if (currentState !== cia402_1.Cia402State.OPERATION_ENABLED) {
1642
+ throw new Error(`Device ${deviceRef} is not in OPERATION_ENABLED CiA402 state.`);
1643
+ }
1644
+ this.transitionToCia402State(deviceRef, cia402_1.Cia402State.QUICK_STOP_ACTIVE);
1645
+ });
1646
+ }
1647
+ /**
1648
+ * Reset targets.
1649
+ *
1650
+ * Set torque and velocity targets to 0, and set the position target to the current position value.
1651
+ */
1652
+ resetTargets(deviceRef) {
1653
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
1654
+ const positionActualValue = yield this.upload(deviceRef, 0x6064, 0);
1655
+ return this.downloadMany([
1656
+ [deviceRef, 0x6071, 0, 0],
1657
+ [deviceRef, 0x607A, 0, positionActualValue],
1658
+ [deviceRef, 0x60FF, 0, 0], // target velocity
1659
+ ]);
1660
+ });
1661
+ }
1662
+ /**
1663
+ * Get modes of operation.
1664
+ *
1665
+ * Retrieve the value of the 0x6061:00 Modes of operation display.
1666
+ */
1667
+ getModesOfOperation(deviceRef, requestTimeout = 1000, messageId) {
1668
+ return this.getParameterValue(deviceRef, 0x6061, 0, false, requestTimeout, messageId);
1669
+ }
1670
+ /**
1671
+ * Set modes of operation.
1672
+ *
1673
+ * Set the 0x6060:00 Modes of operation to one of the available options, such as Homing mode (6).
1674
+ */
1675
+ setModesOfOperation(deviceRef, value, requestTimeout = 1000, messageId) {
1676
+ return this.setParameterValue(deviceRef, 0x6060, 0, value, 'uintValue', requestTimeout, messageId);
1677
+ }
1539
1678
  }
1540
1679
  exports.MotionMasterReqResClient = MotionMasterReqResClient;
1541
1680
  //# sourceMappingURL=motion-master-req-res-client.js.map