motion-master-client 0.0.2 → 0.0.6
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/README.md +123 -49
- package/package.json +21 -6
- package/src/{index.ts → index.d.ts} +23 -22
- package/src/index.js +27 -0
- package/src/index.js.map +1 -0
- package/src/lib/cia402.d.ts +30 -0
- package/src/lib/cia402.js +112 -0
- package/src/lib/cia402.js.map +1 -0
- package/src/lib/device-log-line.d.ts +5 -0
- package/src/lib/device-log-line.js +3 -0
- package/src/lib/device-log-line.js.map +1 -0
- package/src/lib/{device-parameter.ts → device-parameter.d.ts} +56 -69
- package/src/lib/device-parameter.js +39 -0
- package/src/lib/device-parameter.js.map +1 -0
- package/src/lib/device.d.ts +8 -0
- package/src/lib/device.js +3 -0
- package/src/lib/device.js.map +1 -0
- package/src/lib/examples/get-firmware-version-for-all-devices.d.ts +1 -0
- package/src/lib/examples/get-firmware-version-for-all-devices.js +15 -0
- package/src/lib/examples/get-firmware-version-for-all-devices.js.map +1 -0
- package/src/lib/hardware-description.d.ts +37 -0
- package/src/lib/hardware-description.js +48 -0
- package/src/lib/hardware-description.js.map +1 -0
- package/src/lib/logger.d.ts +1 -0
- package/src/lib/logger.js +8 -0
- package/src/lib/logger.js.map +1 -0
- package/src/lib/monitoring-config.d.ts +6 -0
- package/src/lib/monitoring-config.js +3 -0
- package/src/lib/monitoring-config.js.map +1 -0
- package/src/lib/monitoring-entry.d.ts +9 -0
- package/src/lib/monitoring-entry.js +3 -0
- package/src/lib/monitoring-entry.js.map +1 -0
- package/src/lib/motion-master-client.d.ts +18 -0
- package/src/lib/motion-master-client.js +73 -0
- package/src/lib/motion-master-client.js.map +1 -0
- package/src/lib/motion-master-pub-sub-client.d.ts +16 -0
- package/src/lib/motion-master-pub-sub-client.js +68 -0
- package/src/lib/motion-master-pub-sub-client.js.map +1 -0
- package/src/lib/motion-master-pub-sub-socket.d.ts +28 -0
- package/src/lib/motion-master-pub-sub-socket.js +3 -0
- package/src/lib/motion-master-pub-sub-socket.js.map +1 -0
- package/src/lib/motion-master-pub-sub-web-socket.d.ts +13 -0
- package/src/lib/motion-master-pub-sub-web-socket.js +61 -0
- package/src/lib/motion-master-pub-sub-web-socket.js.map +1 -0
- package/src/lib/motion-master-pub-sub-worker-socket.d.ts +13 -0
- package/src/lib/motion-master-pub-sub-worker-socket.js +37 -0
- package/src/lib/motion-master-pub-sub-worker-socket.js.map +1 -0
- package/src/lib/motion-master-req-res-client.d.ts +956 -0
- package/src/lib/motion-master-req-res-client.js +1521 -0
- package/src/lib/motion-master-req-res-client.js.map +1 -0
- package/src/lib/motion-master-req-res-socket.d.ts +38 -0
- package/src/lib/motion-master-req-res-socket.js +3 -0
- package/src/lib/motion-master-req-res-socket.js.map +1 -0
- package/src/lib/motion-master-req-res-web-socket.d.ts +20 -0
- package/src/lib/motion-master-req-res-web-socket.js +100 -0
- package/src/lib/motion-master-req-res-web-socket.js.map +1 -0
- package/src/lib/motion-master-req-res-worker-socket.d.ts +15 -0
- package/src/lib/motion-master-req-res-worker-socket.js +53 -0
- package/src/lib/motion-master-req-res-worker-socket.js.map +1 -0
- package/src/lib/motion-master.proto.js +5 -3
- package/src/lib/operators.d.ts +21 -0
- package/src/lib/operators.js +71 -0
- package/src/lib/operators.js.map +1 -0
- package/src/lib/options.d.ts +34 -0
- package/src/lib/options.js +38 -0
- package/src/lib/options.js.map +1 -0
- package/src/lib/parameter.d.ts +65 -0
- package/src/lib/parameter.js +70 -0
- package/src/lib/parameter.js.map +1 -0
- package/src/lib/request-status-resolver.d.ts +4 -0
- package/src/lib/request-status-resolver.js +345 -0
- package/src/lib/request-status-resolver.js.map +1 -0
- package/src/lib/system-log-line.d.ts +8 -0
- package/src/lib/system-log-line.js +3 -0
- package/src/lib/system-log-line.js.map +1 -0
- package/src/lib/types.d.ts +50 -0
- package/src/lib/types.js +23 -0
- package/src/lib/types.js.map +1 -0
- package/src/lib/urls.d.ts +3 -0
- package/src/lib/urls.js +10 -0
- package/src/lib/urls.js.map +1 -0
- package/src/lib/util.d.ts +30 -0
- package/src/lib/util.js +279 -0
- package/src/lib/util.js.map +1 -0
- package/.babelrc +0 -3
- package/.eslintrc.json +0 -18
- package/jest.config.ts +0 -15
- package/motion-master.proto +0 -1822
- package/src/lib/device-log-line.ts +0 -5
- package/src/lib/device-parameter.spec.ts +0 -85
- package/src/lib/hardware-description.spec.ts +0 -223
- package/src/lib/hardware-description.ts +0 -79
- package/src/lib/logger.ts +0 -5
- package/src/lib/monitoring-config.ts +0 -6
- package/src/lib/monitoring-entry.ts +0 -11
- package/src/lib/motion-master-client.ts +0 -94
- package/src/lib/motion-master-pub-sub-client.ts +0 -94
- package/src/lib/motion-master-pub-sub-socket.ts +0 -33
- package/src/lib/motion-master-pub-sub-web-socket.ts +0 -71
- package/src/lib/motion-master-pub-sub-worker-socket.ts +0 -58
- package/src/lib/motion-master-req-res-client.spec.ts +0 -126
- package/src/lib/motion-master-req-res-client.ts +0 -1625
- package/src/lib/motion-master-req-res-socket.ts +0 -45
- package/src/lib/motion-master-req-res-web-socket.ts +0 -119
- package/src/lib/motion-master-req-res-worker-socket.ts +0 -63
- package/src/lib/operators.ts +0 -93
- package/src/lib/options.ts +0 -12
- package/src/lib/parameter.spec.ts +0 -81
- package/src/lib/parameter.ts +0 -119
- package/src/lib/request-status-resolver.ts +0 -380
- package/src/lib/system-log-line.ts +0 -8
- package/src/lib/types.ts +0 -58
- package/src/lib/urls.ts +0 -6
- package/src/lib/util.ts +0 -261
- package/tsconfig.json +0 -22
- package/tsconfig.lib.json +0 -10
- package/tsconfig.spec.json +0 -20
- package/typedoc.json +0 -10
|
@@ -1,1625 +0,0 @@
|
|
|
1
|
-
import { defer, EMPTY, from, lastValueFrom, Observable, tap } from "rxjs";
|
|
2
|
-
import { delay, map, mergeMap } from "rxjs/operators";
|
|
3
|
-
import { v4 } from "uuid";
|
|
4
|
-
import { splitDeviceParameterId } from "./device-parameter";
|
|
5
|
-
import { getApiIdentifierFromHardwareDescription, getSerialNumberFromHardwareDescription, HardwareDescription } from "./hardware-description";
|
|
6
|
-
import { MotionMasterReqResSocket } from "./motion-master-req-res-socket";
|
|
7
|
-
import { retryWithDelay, transformMotionMasterMessageToStatus } from "./operators";
|
|
8
|
-
import { makeParameterId, Parameter, splitParameterId } from "./parameter";
|
|
9
|
-
import { SystemLogLine } from "./system-log-line";
|
|
10
|
-
import { MotionMasterMessage, ParameterValueType, ParameterTypeValue, ParameterInfoAndValue, DeviceParameterValuesStatus, ParameterAddressValue, ParameterTypeValueKey, DeviceRefObj, RequestError } from "./types";
|
|
11
|
-
import { decodeTextContent, valueTypeToParameterTypeValueKeyMap, getParameterValue, parseSystemLogContent, makeDeviceRefObj } from "./util";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* This class contains methods for making requests to Motion Master using the injected request/response socket.
|
|
15
|
-
*
|
|
16
|
-
* Each request message defined in the proto file has two corresponding request methods in this class. One method supports Reactive and the other Promise-based API.
|
|
17
|
-
* Reactive API is the default one. Unlike promises which resolve to a single value, observables can emit multiple values over time. For some requests like firmware installation,
|
|
18
|
-
* Motion Master will send progress messages until the firmware installation is done.
|
|
19
|
-
* Reactive request methods are named like `getDeviceInfo` and Promise-based are named like `getDeviceInfoAsync` (notice the `Async` suffix).
|
|
20
|
-
*
|
|
21
|
-
* Reactive and Promise-based request methods have the same set of input parameters, but they differ in the return values.
|
|
22
|
-
* Call to Reactive request methods will return an Observable of (1) corresponding status message, for example call to `getDeviceInfo`
|
|
23
|
-
* will return an instance of `MotionMasterMessage.Status.DeviceInfo`, (2) request status, and (3) request message id.
|
|
24
|
-
* Promise-based request methods can only return (resolve to) a single value. These methods call the corresponding Reactive request method and return data
|
|
25
|
-
* from the last emmited status message. For example `getDeviceInfoAsync` calls `getDeviceInfo` and returns a list of devices from
|
|
26
|
-
* the last emmited status message. If the request fails on Motion Master the function will throw an error. It can also throw an error if request times out.
|
|
27
|
-
*
|
|
28
|
-
* Request methods have optional `messageId` input parameter. If `messageId` is not provided, one will be generated before sending the request message to Motion Master.
|
|
29
|
-
* Status messages (responses) received from Motion Master that correspond to the previous request will have the same `messageId` as the one in the request.
|
|
30
|
-
* This is how we match request with response messages in the full-duplex asynchronous communication (WebSockets, ZeroMQ).
|
|
31
|
-
* Matching request/response by message id is inspired by [JSON-RPC 2.0 Specification](https://www.jsonrpc.org/specification).
|
|
32
|
-
*
|
|
33
|
-
* Almost all request methods have mandatory `requestTimeout` input parameter.
|
|
34
|
-
* This parameter specifies how long (in milliseconds) will the client wait for the status (response) messages corresponding to the previous request.
|
|
35
|
-
* If status message is not received in due time the request method will throw a timeout error.
|
|
36
|
-
* The error doesn't mean the request has failed on Motion Master, but rather that client has given up waiting for the response(s).
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* How to handle Reactive request method timeout error:
|
|
40
|
-
* ```ts
|
|
41
|
-
* req.getDeviceInfo(10).subscribe({
|
|
42
|
-
* next: (status) => console.log(status),
|
|
43
|
-
* error: (err: unknown) => {
|
|
44
|
-
* if (err instanceof TimeoutError) {
|
|
45
|
-
* alert('Request has timed out');
|
|
46
|
-
* }
|
|
47
|
-
* }
|
|
48
|
-
* });
|
|
49
|
-
* ```
|
|
50
|
-
* How to handle Promise-based request method timeout error:
|
|
51
|
-
* ```ts
|
|
52
|
-
* async () => {
|
|
53
|
-
* try {
|
|
54
|
-
* const devices = await req.getDeviceInfoAsync(10);
|
|
55
|
-
* console.log(devices);
|
|
56
|
-
* } catch (err: unknown) {
|
|
57
|
-
* if (err instanceof TimeoutError) {
|
|
58
|
-
* alert('Request has timed out');
|
|
59
|
-
* }
|
|
60
|
-
* }
|
|
61
|
-
* }
|
|
62
|
-
* ```
|
|
63
|
-
*
|
|
64
|
-
* Request methods for a particular device, like `getDeviceParameterInfo`, as the first input parameter accept the type of request message as defined in the proto file.
|
|
65
|
-
* For `getDeviceParameterInfo` that's `MotionMasterMessage.Request.IGetDeviceParameterInfo`. This type is extended (via type intersection) by `DeviceRefObj`.
|
|
66
|
-
* This is done in order to support multiple ways to reference a device. Motion Master only supports device address which it re-generates for each device on power-cycle.
|
|
67
|
-
* Because device address can change, for scripts and applications it's preferred to use a device reference that won't change.
|
|
68
|
-
* Device serial number in the hardware description file uniquely identifies device and doesn't change. This is what each request message is extended with.
|
|
69
|
-
* Before sending the request message to Motion Master, device address gets resolved and is set on the request message.
|
|
70
|
-
* Beside device address and device serial number, devices can be referenced by position (sequence number in the network).
|
|
71
|
-
*
|
|
72
|
-
* It is ensured that Observable returned from a call to Reactive request method will eventually complete, so a call to unsubscribe is not required.
|
|
73
|
-
* Observable will complete when request status is either "succeeded" or "failed", and it can complete (error) due to timeout.
|
|
74
|
-
* Finding out if a request has completed, failed or is it still on-going is different for each request - it dependends on the status messages, see {@link requestStatusResolver}.
|
|
75
|
-
* Reactive request methods handle this and for each request they will emit status messages with one of "succeeded", "failed", or "running" request status.
|
|
76
|
-
*
|
|
77
|
-
* Beside the request methods this class contains many helper methods such as the ones for getting and setting device parameter values and
|
|
78
|
-
* saving all parameters which involves complex logic like multiple repeating requests in order to determine if saving all parameters has completed successfully.
|
|
79
|
-
*/
|
|
80
|
-
export class MotionMasterReqResClient {
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Map device address to a map of parameter id to type value key.
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* ```ts
|
|
87
|
-
* new Map([
|
|
88
|
-
* [2045285448, new Map([
|
|
89
|
-
* ["0x1018:02", "uintValue"]
|
|
90
|
-
* ])]
|
|
91
|
-
* ]);
|
|
92
|
-
* ```
|
|
93
|
-
*
|
|
94
|
-
* When setting a parameter value only one of int, uint, float, string, or raw type value fields must be set.
|
|
95
|
-
* This is defined in the proto file SetDeviceParameterValues request message.
|
|
96
|
-
*
|
|
97
|
-
* Device parameters have richer set of base types defined in ESI and they're provided by DeviceParameterInfo status message.
|
|
98
|
-
* When device parameter info is fetched this map gets updated by mapping device parameters type to oneof proto type, e.g. `INTEGER32 -> intValue`.
|
|
99
|
-
*
|
|
100
|
-
* This map helps in simplifying the API by allowing users to set parameter values without specifying the type value field.
|
|
101
|
-
* One can simply call `await setParameterValue(2045285448, 0x2004, 0x03, 2500)` and the correct type value field on the proto message will be set, `uintValue` in this example.
|
|
102
|
-
*/
|
|
103
|
-
readonly parameterTypeValueKeyMap = new Map<number, Map<string, ParameterTypeValueKey>>();
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Map device serial number to device address.
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* ```ts
|
|
110
|
-
* new Map([
|
|
111
|
-
* ["8502-03-0001353-2115", 2045285448]
|
|
112
|
-
* ]);
|
|
113
|
-
* ```
|
|
114
|
-
*
|
|
115
|
-
* When making requests related to a device, device address is used as an identifier.
|
|
116
|
-
* Device address is not permanent. The number is re-generated by Motion Master when devices are power-cycled.
|
|
117
|
-
* For scripts and applications that use this library, having a permanent device identifier is a better option.
|
|
118
|
-
* Device serial number read from the hardware description file (.hardware_description) stored on a device is a permanent identifier.
|
|
119
|
-
*
|
|
120
|
-
* This map helps in making all request functions related to a device accept device reference instead of just device address as an identifier.
|
|
121
|
-
* Device reference can be one of: device address, device serial number, or device position.
|
|
122
|
-
* Prior to sending a request message to Motion Master, device address is resolved from device reference and this map is used for that.
|
|
123
|
-
*/
|
|
124
|
-
readonly deviceAddressMap = new Map<string, number>();
|
|
125
|
-
|
|
126
|
-
constructor(
|
|
127
|
-
public readonly socket: MotionMasterReqResSocket,
|
|
128
|
-
) { }
|
|
129
|
-
|
|
130
|
-
//
|
|
131
|
-
// Requests
|
|
132
|
-
//
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Ping system.
|
|
136
|
-
*
|
|
137
|
-
* Client must send messages to Motion Master in regular intervals in order for Motion Master to consider it alive.
|
|
138
|
-
* When client is considered "not alive", Motion Master will stop the ongoing procedures and monitorings started by that client.
|
|
139
|
-
* Each client on the Motion Master side has its own default timeout which can be changed by {@link setSystemClientTimeout}.
|
|
140
|
-
*/
|
|
141
|
-
pingSystem(messageId?: string) {
|
|
142
|
-
const pingSystem = MotionMasterMessage.Request.PingSystem.create();
|
|
143
|
-
this.sendRequest({ pingSystem }, messageId);
|
|
144
|
-
return EMPTY;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* {@inheritDoc pingSystem}
|
|
149
|
-
*/
|
|
150
|
-
async pingSystemAsync(messageId?: string) {
|
|
151
|
-
return await lastValueFrom(this.pingSystem(messageId), { defaultValue: undefined });
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Get system version.
|
|
156
|
-
*
|
|
157
|
-
* Motion Master version follows [Semantic Versioning 2.0.0](https://semver.org/).
|
|
158
|
-
*/
|
|
159
|
-
getSystemVersion(requestTimeout: number, messageId?: string) {
|
|
160
|
-
const getSystemVersion = MotionMasterMessage.Request.GetSystemVersion.create();
|
|
161
|
-
const id = this.sendRequest({ getSystemVersion }, messageId);
|
|
162
|
-
return this.socket.message$.pipe(
|
|
163
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.SystemVersion>('systemVersion', requestTimeout, id),
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* {@inheritDoc getSystemVersion}
|
|
169
|
-
*/
|
|
170
|
-
async getSystemVersionAsync(requestTimeout: number, messageId?: string) {
|
|
171
|
-
const status = await lastValueFrom(this.getSystemVersion(requestTimeout, messageId));
|
|
172
|
-
|
|
173
|
-
if (status.request === 'succeeded') {
|
|
174
|
-
return status.version;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
throw new RequestError('Get system version request failed.');
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Get device info.
|
|
182
|
-
*
|
|
183
|
-
* Device info includes a list of devices on network.
|
|
184
|
-
* Call this method to get device addresses for requests specific to devices.
|
|
185
|
-
*/
|
|
186
|
-
getDeviceInfo(requestTimeout: number, messageId?: string) {
|
|
187
|
-
const getDeviceInfo = MotionMasterMessage.Request.GetDeviceInfo.create();
|
|
188
|
-
const id = this.sendRequest({ getDeviceInfo }, messageId);
|
|
189
|
-
return this.socket.message$.pipe(
|
|
190
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.DeviceInfo>('deviceInfo', requestTimeout, id),
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* {@inheritDoc getDeviceInfo}
|
|
196
|
-
*/
|
|
197
|
-
async getDeviceInfoAsync(requestTimeout: number, messageId?: string) {
|
|
198
|
-
const status = await lastValueFrom(this.getDeviceInfo(requestTimeout, messageId));
|
|
199
|
-
|
|
200
|
-
if (status.request === 'succeeded') {
|
|
201
|
-
return status.devices;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
throw new Error('Get device info request failed.');
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
getDeviceParameterInfo(props: MotionMasterMessage.Request.IGetDeviceParameterInfo & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
208
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
209
|
-
mergeMap((deviceAddress) => {
|
|
210
|
-
const getDeviceParameterInfo = MotionMasterMessage.Request.GetDeviceParameterInfo.create({ ...props, deviceAddress });
|
|
211
|
-
const id = this.sendRequest({ getDeviceParameterInfo }, messageId);
|
|
212
|
-
return this.socket.message$.pipe(
|
|
213
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.DeviceParameterInfo>('deviceParameterInfo', requestTimeout, id),
|
|
214
|
-
tap((deviceParameterInfo) => {
|
|
215
|
-
const parameters = deviceParameterInfo?.parameters;
|
|
216
|
-
if (parameters) {
|
|
217
|
-
const map: Map<string, ParameterTypeValueKey> = new Map();
|
|
218
|
-
this.parameterTypeValueKeyMap.set(+deviceAddress, map);
|
|
219
|
-
for (const parameter of parameters) {
|
|
220
|
-
if (parameter.valueType) {
|
|
221
|
-
const typeValueKey = valueTypeToParameterTypeValueKeyMap.get(parameter.valueType);
|
|
222
|
-
if (typeValueKey) {
|
|
223
|
-
map.set(makeParameterId(parameter), typeValueKey);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}),
|
|
229
|
-
);
|
|
230
|
-
}),
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
async getDeviceParameterInfoAsync(props: MotionMasterMessage.Request.IGetDeviceParameterInfo & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<MotionMasterMessage.Status.DeviceParameterInfo.IParameter[]> {
|
|
235
|
-
const status = await lastValueFrom(this.getDeviceParameterInfo(props, requestTimeout, messageId));
|
|
236
|
-
|
|
237
|
-
if (status.request === 'succeeded') {
|
|
238
|
-
return status.parameters;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
throw new Error('Get device parameter info request failed.');
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
getDeviceParameterValues(props: MotionMasterMessage.Request.IGetDeviceParameterValues & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
245
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
246
|
-
mergeMap((deviceAddress) => {
|
|
247
|
-
const getDeviceParameterValues = MotionMasterMessage.Request.GetDeviceParameterValues.create({ ...props, deviceAddress });
|
|
248
|
-
const id = this.sendRequest({ getDeviceParameterValues }, messageId);
|
|
249
|
-
return this.socket.message$.pipe(
|
|
250
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.DeviceParameterValues>('deviceParameterValues', requestTimeout, id),
|
|
251
|
-
);
|
|
252
|
-
}),
|
|
253
|
-
)
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
async getDeviceParameterValuesAsync(props: MotionMasterMessage.Request.IGetDeviceParameterValues & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<MotionMasterMessage.Status.DeviceParameterValues.IParameterValue[]> {
|
|
257
|
-
const status = await lastValueFrom(this.getDeviceParameterValues(props, requestTimeout, messageId));
|
|
258
|
-
|
|
259
|
-
return status.parameterValues;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
getMultiDeviceParameterValues(props: MotionMasterMessage.Request.IGetMultiDeviceParameterValues, requestTimeout: number, messageId?: string) {
|
|
263
|
-
const getMultiDeviceParameterValues = MotionMasterMessage.Request.GetMultiDeviceParameterValues.create(props);
|
|
264
|
-
const id = this.sendRequest({ getMultiDeviceParameterValues }, messageId);
|
|
265
|
-
return this.socket.message$.pipe(
|
|
266
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.MultiDeviceParameterValues>('multiDeviceParameterValues', requestTimeout, id),
|
|
267
|
-
);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
async getMultiDeviceParameterValuesAsync(props: MotionMasterMessage.Request.IGetMultiDeviceParameterValues, requestTimeout: number, messageId?: string): Promise<MotionMasterMessage.Status.IDeviceParameterValues[]> {
|
|
271
|
-
const status = await lastValueFrom(this.getMultiDeviceParameterValues(props, requestTimeout, messageId));
|
|
272
|
-
|
|
273
|
-
return status.collection;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
setDeviceParameterValues(props: MotionMasterMessage.Request.ISetDeviceParameterValues & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
277
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
278
|
-
mergeMap((deviceAddress) => {
|
|
279
|
-
const setDeviceParameterValues = MotionMasterMessage.Request.SetDeviceParameterValues.create({ ...props, deviceAddress });
|
|
280
|
-
const id = this.sendRequest({ setDeviceParameterValues }, messageId);
|
|
281
|
-
return this.socket.message$.pipe(
|
|
282
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.DeviceParameterValues>('deviceParameterValues', requestTimeout, id),
|
|
283
|
-
);
|
|
284
|
-
}),
|
|
285
|
-
);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
async setDeviceParameterValuesAsync(props: MotionMasterMessage.Request.ISetDeviceParameterValues & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<MotionMasterMessage.Status.DeviceParameterValues.IParameterValue[]> {
|
|
289
|
-
const status = await lastValueFrom(this.setDeviceParameterValues(props, requestTimeout, messageId));
|
|
290
|
-
|
|
291
|
-
return status.parameterValues;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
setMultiDeviceParameterValues(props: MotionMasterMessage.Request.ISetMultiDeviceParameterValues, requestTimeout: number, messageId?: string) {
|
|
295
|
-
const setMultiDeviceParameterValues = MotionMasterMessage.Request.SetMultiDeviceParameterValues.create(props);
|
|
296
|
-
const id = this.sendRequest({ setMultiDeviceParameterValues }, messageId);
|
|
297
|
-
return this.socket.message$.pipe(
|
|
298
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.MultiDeviceParameterValues>('multiDeviceParameterValues', requestTimeout, id),
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
async setMultiDeviceParameterValuesAsync(props: MotionMasterMessage.Request.ISetMultiDeviceParameterValues, requestTimeout: number, messageId?: string): Promise<MotionMasterMessage.Status.IDeviceParameterValues[]> {
|
|
303
|
-
const status = await lastValueFrom(this.setMultiDeviceParameterValues(props, requestTimeout, messageId));
|
|
304
|
-
|
|
305
|
-
return status.collection;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Get device file list.
|
|
310
|
-
*
|
|
311
|
-
* Motion Master will use Filetransfer over EtherCAT (FoE) to get the list of files from a device.
|
|
312
|
-
* There isn't really a command for getting the list, but rather the content of a specially named file "fs-getlist" is the file list.
|
|
313
|
-
* The list can be read like any other file from a device using the IgH EtherCAT Master for Linux CLI program:
|
|
314
|
-
*
|
|
315
|
-
* ```
|
|
316
|
-
* $ ethercat foe_read fs-getlist
|
|
317
|
-
* ```
|
|
318
|
-
*
|
|
319
|
-
* At the time of writing this document "fs-getlist" returns only 32 files in the list. This is the firmware's limitation.
|
|
320
|
-
* More than 32 files can be stored on device flash memory, but they won't appear in the list.
|
|
321
|
-
* Also note that FoE can behave differently in the bootstrap firmware which runs in the BOOT EtherCAT state and
|
|
322
|
-
* SOMANET firmware which runs in other EtherCAT states like OP. Bootstrap tends to be buggier since it cannot be updated easily, so
|
|
323
|
-
* Motion Master has certain workarounds to overcome the FoE differences.
|
|
324
|
-
*/
|
|
325
|
-
getDeviceFileList(props: MotionMasterMessage.Request.IGetDeviceFileList & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
326
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
327
|
-
mergeMap((deviceAddress) => {
|
|
328
|
-
const getDeviceFileList = MotionMasterMessage.Request.GetDeviceFileList.create({ ...props, deviceAddress });
|
|
329
|
-
const id = this.sendRequest({ getDeviceFileList }, messageId);
|
|
330
|
-
return this.socket.message$.pipe(
|
|
331
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.DeviceFileList>('deviceFileList', requestTimeout, id),
|
|
332
|
-
);
|
|
333
|
-
}),
|
|
334
|
-
);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* {@inheritDoc getDeviceFileList}
|
|
339
|
-
*/
|
|
340
|
-
async getDeviceFileListAsync(props: MotionMasterMessage.Request.IGetDeviceFileList & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<string[]> {
|
|
341
|
-
const status = await lastValueFrom(this.getDeviceFileList(props, requestTimeout, messageId));
|
|
342
|
-
|
|
343
|
-
if (status.request === 'succeeded') {
|
|
344
|
-
return status.fileList?.files ?? [];
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
throw new Error(`Failed to get device file list. ${status.error?.message} ${JSON.stringify(props)}`);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Get device file.
|
|
352
|
-
*
|
|
353
|
-
* Motion Master uses the Filetransfer over EtherCAT (FoE) to read and send back the content of a file from device flash memory.
|
|
354
|
-
*
|
|
355
|
-
* The IgH EtherCAT Master library used by Motion Master limits the file read buffer to 9KB, so any file written to flash that is larger than 9KB
|
|
356
|
-
* needs to be split into parts of max 9KB. Motion Master does this automatically on request to {@link setDeviceFile}.
|
|
357
|
-
*
|
|
358
|
-
* Upon receiving this request Motion Master will first read the list of files on a device, see {@link getDeviceFileList}.
|
|
359
|
-
* It does that in order to determine if the requested file, for example "SOMANET_CiA402.xml", has been stored in multiple parts.
|
|
360
|
-
* The parts are named like "SOMANET_CiA_402.xml.zip.part000", "SOMANET_CiA_402.xml.zip.part001" and so on.
|
|
361
|
-
* Motion Master will read all parts of the requested file, unzip it and send the content back to a client.
|
|
362
|
-
* Since the number of items in the list of files is limited to 32 (based on the firmware version) Motion Master might not see the file,
|
|
363
|
-
* but in any case it will try to read the content of it. If the file exists it will return its content, otherwise it will send the file not found error.
|
|
364
|
-
*
|
|
365
|
-
* In BOOT EtherCAT state it's only allowed to read the .hardware_description file. This was done because
|
|
366
|
-
* the bootloader firmware would hang when trying to read a corrupted or missing file.
|
|
367
|
-
*
|
|
368
|
-
* If file content is empty Motion Master will return not found error. This is a subject to change now that Motion Master reads the file error codes.
|
|
369
|
-
*/
|
|
370
|
-
getDeviceFile(props: MotionMasterMessage.Request.IGetDeviceFile & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
371
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
372
|
-
mergeMap((deviceAddress) => {
|
|
373
|
-
const getDeviceFile = MotionMasterMessage.Request.GetDeviceFile.create({ ...props, deviceAddress });
|
|
374
|
-
const id = this.sendRequest({ getDeviceFile }, messageId);
|
|
375
|
-
return this.socket.message$.pipe(
|
|
376
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.DeviceFile>('deviceFile', requestTimeout, id),
|
|
377
|
-
);
|
|
378
|
-
}),
|
|
379
|
-
);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* {@inheritDoc getDeviceFile}
|
|
384
|
-
*/
|
|
385
|
-
async getDeviceFileAsync(props: MotionMasterMessage.Request.IGetDeviceFile & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<Uint8Array> {
|
|
386
|
-
const status = await lastValueFrom(this.getDeviceFile(props, requestTimeout, messageId));
|
|
387
|
-
|
|
388
|
-
if (status.request === 'succeeded') {
|
|
389
|
-
if (status.content) {
|
|
390
|
-
return status.content;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
throw new Error(`Failed to get device file. ${status.error?.message} ${JSON.stringify(props)}`);
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* Set device file.
|
|
399
|
-
*
|
|
400
|
-
* Motion Master uses the Filetransfer over EtherCAT (FoE) to write files to device flash memory.
|
|
401
|
-
*
|
|
402
|
-
* The IgH EtherCAT Master library used by Motion Master limits the file read buffer to 9KB, so any file written to flash that is larger than 9KB
|
|
403
|
-
* needs to be split into parts of max 9KB. Motion Master does this automatically by first zipping the content and then writing the parts.
|
|
404
|
-
* The parts are named like "SOMANET_CiA_402.xml.zip.part000", "SOMANET_CiA_402.xml.zip.part001" and so on.
|
|
405
|
-
*/
|
|
406
|
-
setDeviceFile(props: MotionMasterMessage.Request.ISetDeviceFile & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
407
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
408
|
-
mergeMap((deviceAddress) => {
|
|
409
|
-
const setDeviceFile = MotionMasterMessage.Request.SetDeviceFile.create({ ...props, deviceAddress });
|
|
410
|
-
const id = this.sendRequest({ setDeviceFile }, messageId);
|
|
411
|
-
return this.socket.message$.pipe(
|
|
412
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.DeviceFile>('deviceFile', requestTimeout, id),
|
|
413
|
-
);
|
|
414
|
-
}),
|
|
415
|
-
);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* {@inheritDoc setDeviceFile}
|
|
420
|
-
*/
|
|
421
|
-
async setDeviceFileAsync(props: MotionMasterMessage.Request.ISetDeviceFile & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<void> {
|
|
422
|
-
const status = await lastValueFrom(this.setDeviceFile(props, requestTimeout, messageId));
|
|
423
|
-
|
|
424
|
-
if (status.request === 'succeeded') {
|
|
425
|
-
return;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
throw new Error(`Failed to set device file. ${status.error?.message} ${JSON.stringify(props)}`);
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
deleteDeviceFile(props: MotionMasterMessage.Request.IDeleteDeviceFile & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
432
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
433
|
-
mergeMap((deviceAddress) => {
|
|
434
|
-
const deleteDeviceFile = MotionMasterMessage.Request.DeleteDeviceFile.create({ ...props, deviceAddress });
|
|
435
|
-
const id = this.sendRequest({ deleteDeviceFile }, messageId);
|
|
436
|
-
return this.socket.message$.pipe(
|
|
437
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.DeviceFile>('deviceFile', requestTimeout, id),
|
|
438
|
-
);
|
|
439
|
-
}),
|
|
440
|
-
);
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
async deleteDeviceFileAsync(props: MotionMasterMessage.Request.IDeleteDeviceFile & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<void> {
|
|
444
|
-
const status = await lastValueFrom(this.deleteDeviceFile(props, requestTimeout, messageId));
|
|
445
|
-
|
|
446
|
-
if (status.request === 'succeeded') {
|
|
447
|
-
return;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
throw new Error(`Failed to delete device file. ${status.error?.message} ${JSON.stringify(props)}`);
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
/**
|
|
454
|
-
* Reset device fault.
|
|
455
|
-
*
|
|
456
|
-
* When error occurs on a device it will go to Fault reaction active state (transition 13) and then automatically to Fault state (transition 14).
|
|
457
|
-
* The CiA402 state of a device can be derived from the value of Statusword object (0x6041:00).
|
|
458
|
-
* In order to go out of Fault and into Switch on disabled state (transition 15) master must send Fault reset command via Controlword object (0x6040:00).
|
|
459
|
-
*
|
|
460
|
-
* When this request is sent to Motion Master it will try to reset fault. Resetting fault can succeed or fail.
|
|
461
|
-
* While resetting the fault Motion Master will use the current Controlword value and set the Reset fault bit to 1,
|
|
462
|
-
* but when it completes (either success or error) it will set it back to 0.
|
|
463
|
-
*
|
|
464
|
-
* Motion Master will return "No Fault" warning when this request is sent and device is not in Fault or Fault reaction active state.
|
|
465
|
-
* If this request is sent when device is in Fault reaction active state, then Motion Master will
|
|
466
|
-
* wait for the automatic transition (14) to Fault state before trying to reset fault.
|
|
467
|
-
* When Motion Master sets the Controlword Fault bit to 1, it will occasionally check if device is no longer in Fault state.
|
|
468
|
-
* After a couple of seconds, if device is still in Fault state, it will give up and return the time out error.
|
|
469
|
-
*/
|
|
470
|
-
resetDeviceFault(props: MotionMasterMessage.Request.IResetDeviceFault & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
471
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
472
|
-
mergeMap((deviceAddress) => {
|
|
473
|
-
const resetDeviceFault = MotionMasterMessage.Request.ResetDeviceFault.create({ ...props, deviceAddress });
|
|
474
|
-
const id = this.sendRequest({ resetDeviceFault }, messageId);
|
|
475
|
-
return this.socket.message$.pipe(
|
|
476
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.IDeviceFaultReset>('deviceFaultReset', requestTimeout, id),
|
|
477
|
-
);
|
|
478
|
-
}),
|
|
479
|
-
);
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
/**
|
|
483
|
-
* {@inheritDoc resetDeviceFault}
|
|
484
|
-
*/
|
|
485
|
-
async resetDeviceFaultAsync(props: MotionMasterMessage.Request.IResetDeviceFault & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<void> {
|
|
486
|
-
const status = await lastValueFrom(this.resetDeviceFault(props, requestTimeout, messageId));
|
|
487
|
-
|
|
488
|
-
if (status.request === 'succeeded') {
|
|
489
|
-
return;
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
throw new Error(`Failed to reset device fault. ${status.error?.message} ${JSON.stringify(props)}`);
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
/**
|
|
496
|
-
* Stop device.
|
|
497
|
-
*
|
|
498
|
-
* Motion Master will use the current value of the Controlword object and set the command on it to Quick stop.
|
|
499
|
-
* It will then wait for up to 2 seconds for a device to get into one of the following CiA402 states: Switch on disabled, Operation enabled, Fault.
|
|
500
|
-
* It does that by periodically checking the value of the Statusword object. If the device doesn't go into one of those states
|
|
501
|
-
* Motion Master will return the timeout or quick stop failed error.
|
|
502
|
-
*/
|
|
503
|
-
stopDevice(props: MotionMasterMessage.Request.IStopDevice & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
504
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
505
|
-
mergeMap((deviceAddress) => {
|
|
506
|
-
const stopDevice = MotionMasterMessage.Request.StopDevice.create({ ...props, deviceAddress });
|
|
507
|
-
const id = this.sendRequest({ stopDevice }, messageId);
|
|
508
|
-
return this.socket.message$.pipe(
|
|
509
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.DeviceStop>('deviceStop', requestTimeout, id),
|
|
510
|
-
);
|
|
511
|
-
}),
|
|
512
|
-
);
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
* {@inheritDoc stopDevice}
|
|
517
|
-
*/
|
|
518
|
-
async stopDeviceAsync(props: MotionMasterMessage.Request.IStopDevice & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<void> {
|
|
519
|
-
const status = await lastValueFrom(this.stopDevice(props, requestTimeout, messageId));
|
|
520
|
-
|
|
521
|
-
if (status.request === 'succeeded') {
|
|
522
|
-
return;
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
throw new Error(`Failed to stop device. ${status.error?.message} ${JSON.stringify(props)}`);
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
startDeviceFirmwareInstallation(props: MotionMasterMessage.Request.IStartDeviceFirmwareInstallation & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
529
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
530
|
-
mergeMap((deviceAddress) => {
|
|
531
|
-
const startDeviceFirmwareInstallation = MotionMasterMessage.Request.StartDeviceFirmwareInstallation.create({ ...props, deviceAddress });
|
|
532
|
-
const id = this.sendRequest({ startDeviceFirmwareInstallation }, messageId);
|
|
533
|
-
return this.socket.message$.pipe(
|
|
534
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.DeviceFirmwareInstallation>('deviceFirmwareInstallation', requestTimeout, id),
|
|
535
|
-
);
|
|
536
|
-
}),
|
|
537
|
-
);
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
async startDeviceFirmwareInstallationAsync(props: MotionMasterMessage.Request.IStartDeviceFirmwareInstallation & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<void> {
|
|
541
|
-
const status = await lastValueFrom(this.startDeviceFirmwareInstallation(props, requestTimeout, messageId));
|
|
542
|
-
|
|
543
|
-
if (status.request === 'succeeded') {
|
|
544
|
-
return;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
throw new Error(`Failed to start device firmware installation. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
getDeviceLog(props: MotionMasterMessage.Request.IGetDeviceLog & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
551
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
552
|
-
mergeMap((deviceAddress) => {
|
|
553
|
-
const getDeviceLog = MotionMasterMessage.Request.GetDeviceLog.create({ ...props, deviceAddress });
|
|
554
|
-
const id = this.sendRequest({ getDeviceLog }, messageId);
|
|
555
|
-
return this.socket.message$.pipe(
|
|
556
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.IDeviceLog>('deviceLog', requestTimeout, id),
|
|
557
|
-
);
|
|
558
|
-
}),
|
|
559
|
-
);
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
async getDeviceLogAsync(props: MotionMasterMessage.Request.IGetDeviceLog & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<string | null | undefined> {
|
|
563
|
-
const status = await lastValueFrom(this.getDeviceLog(props, requestTimeout, messageId));
|
|
564
|
-
|
|
565
|
-
if (status.request === 'succeeded') {
|
|
566
|
-
return status.content;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
throw new Error(`Failed to get device log. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
startCoggingTorqueRecording(props: MotionMasterMessage.Request.IStartCoggingTorqueRecording & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
573
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
574
|
-
mergeMap((deviceAddress) => {
|
|
575
|
-
const startCoggingTorqueRecording = MotionMasterMessage.Request.StartCoggingTorqueRecording.create({ ...props, deviceAddress });
|
|
576
|
-
const id = this.sendRequest({ startCoggingTorqueRecording }, messageId);
|
|
577
|
-
return this.socket.message$.pipe(
|
|
578
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.ICoggingTorqueRecording>('coggingTorqueRecording', requestTimeout, id),
|
|
579
|
-
);
|
|
580
|
-
}),
|
|
581
|
-
);
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
async startCoggingTorqueRecordingAsync(props: MotionMasterMessage.Request.IStartCoggingTorqueRecording & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<void> {
|
|
585
|
-
const status = await lastValueFrom(this.startCoggingTorqueRecording(props, requestTimeout, messageId));
|
|
586
|
-
|
|
587
|
-
if (status.request === 'succeeded') {
|
|
588
|
-
return;
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
throw new Error(`Failed to start cogging torque recording. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
getCoggingTorqueData(props: MotionMasterMessage.Request.IGetCoggingTorqueData & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
595
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
596
|
-
mergeMap((deviceAddress) => {
|
|
597
|
-
const getCoggingTorqueData = MotionMasterMessage.Request.GetCoggingTorqueData.create({ ...props, deviceAddress });
|
|
598
|
-
const id = this.sendRequest({ getCoggingTorqueData }, messageId);
|
|
599
|
-
return this.socket.message$.pipe(
|
|
600
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.ICoggingTorqueData>('coggingTorqueData', requestTimeout, id),
|
|
601
|
-
);
|
|
602
|
-
}),
|
|
603
|
-
);
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
async getCoggingTorqueDataAsync(props: MotionMasterMessage.Request.IGetCoggingTorqueData & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<number[]> {
|
|
607
|
-
const status = await lastValueFrom(this.getCoggingTorqueData(props, requestTimeout, messageId));
|
|
608
|
-
|
|
609
|
-
if (status.request === 'succeeded') {
|
|
610
|
-
return status.table?.data ?? [];
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
throw new Error(`Failed to get cogging torque data. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
startOffsetDetection(props: MotionMasterMessage.Request.IStartOffsetDetection & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
617
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
618
|
-
mergeMap((deviceAddress) => {
|
|
619
|
-
const startOffsetDetection = MotionMasterMessage.Request.StartOffsetDetection.create({ ...props, deviceAddress });
|
|
620
|
-
const id = this.sendRequest({ startOffsetDetection }, messageId);
|
|
621
|
-
return this.socket.message$.pipe(
|
|
622
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.IOffsetDetection>('offsetDetection', requestTimeout, id),
|
|
623
|
-
);
|
|
624
|
-
}),
|
|
625
|
-
);
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
async startOffsetDetectionAsync(props: MotionMasterMessage.Request.IStartOffsetDetection & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<void> {
|
|
629
|
-
const status = await lastValueFrom(this.startOffsetDetection(props, requestTimeout, messageId));
|
|
630
|
-
|
|
631
|
-
if (status.request === 'succeeded') {
|
|
632
|
-
return;
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
throw new Error(`Failed start offset detection. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
/**
|
|
639
|
-
* @deprecated
|
|
640
|
-
*/
|
|
641
|
-
startPlantIdentification(props: MotionMasterMessage.Request.IStartPlantIdentification & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
642
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
643
|
-
mergeMap((deviceAddress) => {
|
|
644
|
-
const startPlantIdentification = MotionMasterMessage.Request.StartPlantIdentification.create({ ...props, deviceAddress });
|
|
645
|
-
const id = this.sendRequest({ startPlantIdentification }, messageId);
|
|
646
|
-
return this.socket.message$.pipe(
|
|
647
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.IPlantIdentification>('plantIdentification', requestTimeout, id),
|
|
648
|
-
);
|
|
649
|
-
}),
|
|
650
|
-
);
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
/**
|
|
654
|
-
* @deprecated
|
|
655
|
-
*/
|
|
656
|
-
async startPlantIdentificationAsync(props: MotionMasterMessage.Request.IStartPlantIdentification & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
657
|
-
const status = await lastValueFrom(this.startPlantIdentification(props, requestTimeout, messageId));
|
|
658
|
-
|
|
659
|
-
if (status.request === 'succeeded') {
|
|
660
|
-
return;
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
throw new Error(`Failed start plant identification. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
computeAutoTuningGains(props: MotionMasterMessage.Request.IComputeAutoTuningGains & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
667
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
668
|
-
mergeMap((deviceAddress) => {
|
|
669
|
-
const computeAutoTuningGains = MotionMasterMessage.Request.ComputeAutoTuningGains.create({ ...props, deviceAddress });
|
|
670
|
-
const id = this.sendRequest({ computeAutoTuningGains }, messageId);
|
|
671
|
-
return this.socket.message$.pipe(
|
|
672
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.IAutoTuning>('autoTuning', requestTimeout, id),
|
|
673
|
-
);
|
|
674
|
-
}),
|
|
675
|
-
);
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
async computeAutoTuningGainsAsync(props: MotionMasterMessage.Request.IComputeAutoTuningGains & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
679
|
-
const status = await lastValueFrom(this.computeAutoTuningGains(props, requestTimeout, messageId));
|
|
680
|
-
|
|
681
|
-
if (status.request === 'succeeded') {
|
|
682
|
-
return;
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
throw new Error(`Failed to compute auto tuning gains. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
setMotionControllerParameters(props: MotionMasterMessage.Request.ISetMotionControllerParameters & DeviceRefObj, messageId?: string) {
|
|
689
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
690
|
-
mergeMap((deviceAddress) => {
|
|
691
|
-
const setMotionControllerParameters = MotionMasterMessage.Request.SetMotionControllerParameters.create({ ...props, deviceAddress });
|
|
692
|
-
this.sendRequest({ setMotionControllerParameters }, messageId);
|
|
693
|
-
return EMPTY;
|
|
694
|
-
}),
|
|
695
|
-
);
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
async setMotionControllerParametersAsync(props: MotionMasterMessage.Request.ISetMotionControllerParameters & DeviceRefObj, messageId?: string): Promise<void> {
|
|
699
|
-
return await lastValueFrom(this.setMotionControllerParameters(props, messageId), { defaultValue: undefined });
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
enableMotionController(props: MotionMasterMessage.Request.IEnableMotionController & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
703
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
704
|
-
mergeMap((deviceAddress) => {
|
|
705
|
-
const enableMotionController = MotionMasterMessage.Request.EnableMotionController.create({ ...props, deviceAddress });
|
|
706
|
-
const id = this.sendRequest({ enableMotionController }, messageId);
|
|
707
|
-
return this.socket.message$.pipe(
|
|
708
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.MotionController>('motionController', requestTimeout, id),
|
|
709
|
-
);
|
|
710
|
-
}),
|
|
711
|
-
);
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
async enableMotionControllerAsync(props: MotionMasterMessage.Request.IEnableMotionController & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<{ controllerType: MotionMasterMessage.Request.EnableMotionController.ControllerType, enabled: boolean, filter: boolean }> {
|
|
715
|
-
const status = await lastValueFrom(this.enableMotionController(props, requestTimeout, messageId));
|
|
716
|
-
|
|
717
|
-
if (status.request === 'succeeded') {
|
|
718
|
-
return (({ controllerType, enabled, filter }) => ({ controllerType, enabled, filter }))(status);
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
throw new Error(`Failed to enable motion controller. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
disableMotionController(props: MotionMasterMessage.Request.IDisableMotionController & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
725
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
726
|
-
mergeMap((deviceAddress) => {
|
|
727
|
-
const disableMotionController = MotionMasterMessage.Request.DisableMotionController.create({ ...props, deviceAddress });
|
|
728
|
-
const id = this.sendRequest({ disableMotionController }, messageId);
|
|
729
|
-
return this.socket.message$.pipe(
|
|
730
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.MotionController>('motionController', requestTimeout, id),
|
|
731
|
-
);
|
|
732
|
-
}),
|
|
733
|
-
);
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
async disableMotionControllerAsync(props: MotionMasterMessage.Request.IDisableMotionController & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<{ controllerType: MotionMasterMessage.Request.EnableMotionController.ControllerType, enabled: boolean, filter: boolean }> {
|
|
737
|
-
const status = await lastValueFrom(this.disableMotionController(props, requestTimeout, messageId));
|
|
738
|
-
|
|
739
|
-
if (status.request === 'succeeded') {
|
|
740
|
-
return (({ controllerType, enabled, filter }) => ({ controllerType, enabled, filter }))(status);
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
throw new Error(`Failed to disable motion controller. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
setSignalGeneratorParameters(props: MotionMasterMessage.Request.ISetSignalGeneratorParameters & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
747
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
748
|
-
mergeMap((deviceAddress) => {
|
|
749
|
-
const setSignalGeneratorParameters = MotionMasterMessage.Request.SetSignalGeneratorParameters.create({ ...props, deviceAddress });
|
|
750
|
-
const id = this.sendRequest({ setSignalGeneratorParameters }, messageId);
|
|
751
|
-
return this.socket.message$.pipe(
|
|
752
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.SignalGenerator>('signalGenerator', requestTimeout, id),
|
|
753
|
-
);
|
|
754
|
-
}),
|
|
755
|
-
);
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
async setSignalGeneratorParametersAsync(props: MotionMasterMessage.Request.ISetSignalGeneratorParameters & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<void> {
|
|
759
|
-
const status = await lastValueFrom(this.setSignalGeneratorParameters(props, requestTimeout, messageId));
|
|
760
|
-
|
|
761
|
-
if (status.request === 'succeeded') {
|
|
762
|
-
return;
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
throw new Error(`Failed to set signal generator parameters. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
startSignalGenerator(props: MotionMasterMessage.Request.IStartSignalGenerator & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
769
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
770
|
-
mergeMap((deviceAddress) => {
|
|
771
|
-
const startSignalGenerator = MotionMasterMessage.Request.StartSignalGenerator.create({ ...props, deviceAddress });
|
|
772
|
-
const id = this.sendRequest({ startSignalGenerator }, messageId);
|
|
773
|
-
return this.socket.message$.pipe(
|
|
774
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.SignalGenerator>('signalGenerator', requestTimeout, id),
|
|
775
|
-
);
|
|
776
|
-
}),
|
|
777
|
-
);
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
async startSignalGeneratorAsync(props: MotionMasterMessage.Request.IStartSignalGenerator & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<void> {
|
|
781
|
-
const status = await lastValueFrom(this.startSignalGenerator(props, requestTimeout, messageId));
|
|
782
|
-
|
|
783
|
-
if (status.request === 'succeeded') {
|
|
784
|
-
return;
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
throw new Error(`Failed to start signal generator. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
stopSignalGenerator(props: MotionMasterMessage.Request.IStopSignalGenerator & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
791
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
792
|
-
mergeMap((deviceAddress) => {
|
|
793
|
-
const stopSignalGenerator = MotionMasterMessage.Request.StopSignalGenerator.create({ ...props, deviceAddress });
|
|
794
|
-
const id = this.sendRequest({ stopSignalGenerator }, messageId);
|
|
795
|
-
return this.socket.message$.pipe(
|
|
796
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.SignalGenerator>('signalGenerator', requestTimeout, id),
|
|
797
|
-
);
|
|
798
|
-
}),
|
|
799
|
-
);
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
async stopSignalGeneratorAsync(props: MotionMasterMessage.Request.IStopSignalGenerator & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<void> {
|
|
803
|
-
const status = await lastValueFrom(this.stopSignalGenerator(props, requestTimeout, messageId));
|
|
804
|
-
|
|
805
|
-
if (status.request === 'succeeded') {
|
|
806
|
-
return;
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
throw new Error(`Failed to stop signal generator. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
startMonitoringDeviceParameterValues(props: MotionMasterMessage.Request.IStartMonitoringDeviceParameterValues, requestTimeout: number, messageId?: string) {
|
|
813
|
-
const startMonitoringDeviceParameterValues = MotionMasterMessage.Request.StartMonitoringDeviceParameterValues.create(props);
|
|
814
|
-
const id = this.sendRequest({ startMonitoringDeviceParameterValues }, messageId);
|
|
815
|
-
return this.socket.message$.pipe(
|
|
816
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.MonitoringParameterValues>('monitoringParameterValues', requestTimeout, id),
|
|
817
|
-
);
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
async startMonitoringDeviceParameterValuesAsync(props: MotionMasterMessage.Request.IStartMonitoringDeviceParameterValues, requestTimeout: number, messageId?: string): Promise<string | undefined> {
|
|
821
|
-
const status = await lastValueFrom(this.startMonitoringDeviceParameterValues(props, requestTimeout, messageId));
|
|
822
|
-
|
|
823
|
-
if (status.request === 'succeeded') {
|
|
824
|
-
return status.messageId;
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
throw new Error(`Failed to start monitoring device parameter values. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
stopMonitoringDeviceParameterValues(props: MotionMasterMessage.Request.IStopMonitoringDeviceParameterValues, messageId?: string) {
|
|
831
|
-
const stopMonitoringDeviceParameterValues = MotionMasterMessage.Request.StopMonitoringDeviceParameterValues.create(props);
|
|
832
|
-
this.sendRequest({ stopMonitoringDeviceParameterValues }, messageId);
|
|
833
|
-
return EMPTY;
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
async stopMonitoringDeviceParameterValuesAsync(props: MotionMasterMessage.Request.IStopMonitoringDeviceParameterValues, messageId?: string) {
|
|
837
|
-
return await lastValueFrom(this.stopMonitoringDeviceParameterValues(props, messageId), { defaultValue: undefined });
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
getEthercatNetworkState(props: MotionMasterMessage.Request.IGetEthercatNetworkState & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
841
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
842
|
-
mergeMap((deviceAddress) => {
|
|
843
|
-
const getEthercatNetworkState = MotionMasterMessage.Request.GetEthercatNetworkState.create({ ...props, deviceAddress });
|
|
844
|
-
const id = this.sendRequest({ getEthercatNetworkState }, messageId);
|
|
845
|
-
return this.socket.message$.pipe(
|
|
846
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.IEthercatNetworkState>('ethercatNetworkState', requestTimeout, id),
|
|
847
|
-
);
|
|
848
|
-
}),
|
|
849
|
-
);
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
async getEthercatNetworkStateAsync(props: MotionMasterMessage.Request.IGetEthercatNetworkState & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<MotionMasterMessage.Status.EthercatNetworkState.State> {
|
|
853
|
-
const status = await lastValueFrom(this.getEthercatNetworkState(props, requestTimeout, messageId));
|
|
854
|
-
|
|
855
|
-
if (status.request === 'succeeded') {
|
|
856
|
-
if (typeof status.state === 'number') {
|
|
857
|
-
return status.state;
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
throw new Error(`Failed get ethercat network state. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
setEthercatNetworkState(props: MotionMasterMessage.Request.ISetEthercatNetworkState & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
865
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
866
|
-
mergeMap((deviceAddress) => {
|
|
867
|
-
const setEthercatNetworkState = MotionMasterMessage.Request.SetEthercatNetworkState.create({ ...props, deviceAddress });
|
|
868
|
-
const id = this.sendRequest({ setEthercatNetworkState }, messageId);
|
|
869
|
-
return this.socket.message$.pipe(
|
|
870
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.IEthercatNetworkState>('ethercatNetworkState', requestTimeout, id),
|
|
871
|
-
);
|
|
872
|
-
}),
|
|
873
|
-
);
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
async setEthercatNetworkStateAsync(props: MotionMasterMessage.Request.ISetEthercatNetworkState & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<void> {
|
|
877
|
-
const status = await lastValueFrom(this.setEthercatNetworkState(props, requestTimeout, messageId));
|
|
878
|
-
|
|
879
|
-
if (status.request === 'succeeded') {
|
|
880
|
-
return;
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
throw new Error(`Failed set ethercat network state. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
/**
|
|
887
|
-
* @deprecated
|
|
888
|
-
*/
|
|
889
|
-
startNarrowAngleCalibration(props: MotionMasterMessage.Request.IStartNarrowAngleCalibration & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
890
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
891
|
-
mergeMap((deviceAddress) => {
|
|
892
|
-
const startNarrowAngleCalibration = MotionMasterMessage.Request.StartNarrowAngleCalibration.create({ ...props, deviceAddress });
|
|
893
|
-
const id = this.sendRequest({ startNarrowAngleCalibration }, messageId);
|
|
894
|
-
return this.socket.message$.pipe(
|
|
895
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.INarrowAngleCalibration>('narrowAngleCalibration', requestTimeout, id),
|
|
896
|
-
);
|
|
897
|
-
}),
|
|
898
|
-
);
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
/**
|
|
902
|
-
* @deprecated
|
|
903
|
-
*/
|
|
904
|
-
async startNarrowAngleCalibrationAsync(props: MotionMasterMessage.Request.IStartNarrowAngleCalibration & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<void> {
|
|
905
|
-
const status = await lastValueFrom(this.startNarrowAngleCalibration(props, requestTimeout, messageId));
|
|
906
|
-
|
|
907
|
-
if (status.request === 'succeeded') {
|
|
908
|
-
return;
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
throw new Error(`Failed start narrow angle calibration. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
setSystemClientTimeout(props: MotionMasterMessage.Request.ISetSystemClientTimeout, messageId?: string) {
|
|
915
|
-
const setSystemClientTimeout = MotionMasterMessage.Request.SetSystemClientTimeout.create(props);
|
|
916
|
-
this.sendRequest({ setSystemClientTimeout }, messageId);
|
|
917
|
-
return EMPTY;
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
async setSystemClientTimeoutAsync(props: MotionMasterMessage.Request.ISetSystemClientTimeout, messageId?: string) {
|
|
921
|
-
return await lastValueFrom(this.setSystemClientTimeout(props, messageId), { defaultValue: undefined });
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
startSystemIdentification(props: MotionMasterMessage.Request.IStartSystemIdentification & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
925
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
926
|
-
mergeMap((deviceAddress) => {
|
|
927
|
-
const startSystemIdentification = MotionMasterMessage.Request.StartSystemIdentification.create({ ...props, deviceAddress });
|
|
928
|
-
const id = this.sendRequest({ startSystemIdentification }, messageId);
|
|
929
|
-
return this.socket.message$.pipe(
|
|
930
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.ISystemIdentification>('systemIdentification', requestTimeout, id),
|
|
931
|
-
);
|
|
932
|
-
}),
|
|
933
|
-
);
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
async startSystemIdentificationAsync(props: MotionMasterMessage.Request.IStartSystemIdentification & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<void> {
|
|
937
|
-
const status = await lastValueFrom(this.startSystemIdentification(props, requestTimeout, messageId));
|
|
938
|
-
|
|
939
|
-
if (status.request === 'succeeded') {
|
|
940
|
-
return;
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
throw new Error(`Failed start system identification. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
getCirculoEncoderMagnetDistance(props: MotionMasterMessage.Request.IGetCirculoEncoderMagnetDistance & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
947
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
948
|
-
mergeMap((deviceAddress) => {
|
|
949
|
-
const getCirculoEncoderMagnetDistance = MotionMasterMessage.Request.GetCirculoEncoderMagnetDistance.create({ ...props, deviceAddress });
|
|
950
|
-
const id = this.sendRequest({ getCirculoEncoderMagnetDistance }, messageId);
|
|
951
|
-
return this.socket.message$.pipe(
|
|
952
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.ICirculoEncoderMagnetDistance>('circuloEncoderMagnetDistance', requestTimeout, id),
|
|
953
|
-
);
|
|
954
|
-
}),
|
|
955
|
-
);
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
async getCirculoEncoderMagnetDistanceAsync(props: MotionMasterMessage.Request.IGetCirculoEncoderMagnetDistance & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<{ distance: number | null | undefined, encoderOrdinal: number | null | undefined, position: number | null | undefined }> {
|
|
959
|
-
const status = await lastValueFrom(this.getCirculoEncoderMagnetDistance(props, requestTimeout, messageId));
|
|
960
|
-
|
|
961
|
-
if (status.request === 'succeeded') {
|
|
962
|
-
return (({ distance, encoderOrdinal, position }) => ({ distance, encoderOrdinal, position }))(status);
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
throw new Error(`Failed to get circulo encoder magnet distance. ${JSON.stringify(props)}`);
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
startCirculoEncoderNarrowAngleCalibrationProcedure(props: MotionMasterMessage.Request.IStartCirculoEncoderNarrowAngleCalibrationProcedure & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
969
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
970
|
-
mergeMap((deviceAddress) => {
|
|
971
|
-
const startCirculoEncoderNarrowAngleCalibrationProcedure = MotionMasterMessage.Request.StartCirculoEncoderNarrowAngleCalibrationProcedure.create({ ...props, deviceAddress });
|
|
972
|
-
const id = this.sendRequest({ startCirculoEncoderNarrowAngleCalibrationProcedure }, messageId);
|
|
973
|
-
return this.socket.message$.pipe(
|
|
974
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.CirculoEncoderNarrowAngleCalibrationProcedure>('circuloEncoderNarrowAngleCalibrationProcedure', requestTimeout, id),
|
|
975
|
-
);
|
|
976
|
-
}),
|
|
977
|
-
);
|
|
978
|
-
}
|
|
979
|
-
|
|
980
|
-
async startCirculoEncoderNarrowAngleCalibrationProcedureAsync(props: MotionMasterMessage.Request.IStartCirculoEncoderNarrowAngleCalibrationProcedure & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
981
|
-
const status = await lastValueFrom(this.startCirculoEncoderNarrowAngleCalibrationProcedure(props, requestTimeout, messageId));
|
|
982
|
-
|
|
983
|
-
if (status.request === 'succeeded') {
|
|
984
|
-
return;
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
throw new Error(`Failed start circulo encoder narrow angle calibration procedure. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
getDeviceCia402State(props: MotionMasterMessage.Request.IGetDeviceCiA402State & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
991
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
992
|
-
mergeMap((deviceAddress) => {
|
|
993
|
-
const getDeviceCia402State = MotionMasterMessage.Request.GetDeviceCiA402State.create({ ...props, deviceAddress });
|
|
994
|
-
const id = this.sendRequest({ getDeviceCia402State }, messageId);
|
|
995
|
-
return this.socket.message$.pipe(
|
|
996
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.DeviceCiA402State>('deviceCia402State', requestTimeout, id),
|
|
997
|
-
);
|
|
998
|
-
}),
|
|
999
|
-
);
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
async getDeviceCia402StateAsync(props: MotionMasterMessage.Request.IGetDeviceCiA402State & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<MotionMasterMessage.Status.DeviceCiA402State.State> {
|
|
1003
|
-
const status = await lastValueFrom(this.getDeviceCia402State(props, requestTimeout, messageId));
|
|
1004
|
-
|
|
1005
|
-
if (status.request === 'succeeded') {
|
|
1006
|
-
if (status.state) {
|
|
1007
|
-
return status.state;
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
throw new Error(`Failed to get device cia 402 state. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
setDeviceCia402State(props: MotionMasterMessage.Request.ISetDeviceCiA402State & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
1015
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
1016
|
-
mergeMap((deviceAddress) => {
|
|
1017
|
-
const setDeviceCia402State = MotionMasterMessage.Request.SetDeviceCiA402State.create({ ...props, deviceAddress });
|
|
1018
|
-
const id = this.sendRequest({ setDeviceCia402State }, messageId);
|
|
1019
|
-
return this.socket.message$.pipe(
|
|
1020
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.DeviceCiA402State>('deviceCia402State', requestTimeout, id),
|
|
1021
|
-
);
|
|
1022
|
-
}),
|
|
1023
|
-
);
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
async setDeviceCia402StateAsync(props: MotionMasterMessage.Request.ISetDeviceCiA402State & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<void> {
|
|
1027
|
-
const status = await lastValueFrom(this.setDeviceCia402State(props, requestTimeout, messageId));
|
|
1028
|
-
|
|
1029
|
-
if (status.request === 'succeeded') {
|
|
1030
|
-
return;
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
throw new Error(`Failed to set device cia 402 state. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
getSystemLog(requestTimeout: number, messageId?: string) {
|
|
1037
|
-
const getSystemLog = MotionMasterMessage.Request.GetSystemVersion.create();
|
|
1038
|
-
const id = this.sendRequest({ getSystemLog }, messageId);
|
|
1039
|
-
return this.socket.message$.pipe(
|
|
1040
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.SystemLog>('systemLog', requestTimeout, id),
|
|
1041
|
-
);
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
async getSystemLogAsync(requestTimeout: number): Promise<{ content: string, runEnv: string }> {
|
|
1045
|
-
const status = await lastValueFrom(this.getSystemLog(requestTimeout));
|
|
1046
|
-
|
|
1047
|
-
if (status.request === 'succeeded') {
|
|
1048
|
-
return (({ content, runEnv }) => ({ content, runEnv }))(status);
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
throw new Error(`Failed to get system log.`);
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
startDeviceSiiRestore(props: MotionMasterMessage.Request.IStartDeviceSiiRestore, requestTimeout: number, messageId?: string) {
|
|
1055
|
-
const startDeviceSiiRestore = MotionMasterMessage.Request.StartDeviceSiiRestore.create(props);
|
|
1056
|
-
const id = this.sendRequest({ startDeviceSiiRestore }, messageId);
|
|
1057
|
-
return this.socket.message$.pipe(
|
|
1058
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.DeviceSiiRestore>('deviceSiiRestore', requestTimeout, id),
|
|
1059
|
-
);
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
async startDeviceSiiRestoreAsync(props: MotionMasterMessage.Request.IStartDeviceSiiRestore, requestTimeout: number, messageId?: string): Promise<void> {
|
|
1063
|
-
const status = await lastValueFrom(this.startDeviceSiiRestore(props, requestTimeout, messageId));
|
|
1064
|
-
|
|
1065
|
-
if (status.request === 'succeeded') {
|
|
1066
|
-
return;
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
throw new Error(`Failed to start device sii restore. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
startOpenLoopFieldControl(props: MotionMasterMessage.Request.IStartOpenLoopFieldControl & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
1073
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
1074
|
-
mergeMap((deviceAddress) => {
|
|
1075
|
-
const startOpenLoopFieldControl = MotionMasterMessage.Request.StartOpenLoopFieldControl.create({ ...props, deviceAddress });
|
|
1076
|
-
const id = this.sendRequest({ startOpenLoopFieldControl }, messageId);
|
|
1077
|
-
return this.socket.message$.pipe(
|
|
1078
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.OpenLoopFieldControl>('openLoopFieldControl', requestTimeout, id),
|
|
1079
|
-
);
|
|
1080
|
-
}),
|
|
1081
|
-
);
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
async startOpenLoopFieldControlAsync(props: MotionMasterMessage.Request.IStartOpenLoopFieldControl & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<void> {
|
|
1085
|
-
const status = await lastValueFrom(this.startOpenLoopFieldControl(props, requestTimeout, messageId));
|
|
1086
|
-
|
|
1087
|
-
if (status.request === 'succeeded') {
|
|
1088
|
-
return;
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
throw new Error(`Failed to start open loop field control. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
/**
|
|
1095
|
-
* @deprecated
|
|
1096
|
-
*/
|
|
1097
|
-
computeFullAutoTuningGains(props: MotionMasterMessage.Request.IComputeFullAutoTuningGains & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
1098
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
1099
|
-
mergeMap((deviceAddress) => {
|
|
1100
|
-
const computeFullAutoTuningGains = MotionMasterMessage.Request.ComputeFullAutoTuningGains.create({ ...props, deviceAddress });
|
|
1101
|
-
const id = this.sendRequest({ computeFullAutoTuningGains }, messageId);
|
|
1102
|
-
return this.socket.message$.pipe(
|
|
1103
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.FullAutoTuning>('fullAutoTuning', requestTimeout, id),
|
|
1104
|
-
);
|
|
1105
|
-
}),
|
|
1106
|
-
);
|
|
1107
|
-
}
|
|
1108
|
-
|
|
1109
|
-
/**
|
|
1110
|
-
* @deprecated
|
|
1111
|
-
*/
|
|
1112
|
-
async computeFullAutoTuningGainsAsync(props: MotionMasterMessage.Request.IComputeFullAutoTuningGains & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<void> {
|
|
1113
|
-
const status = await lastValueFrom(this.computeFullAutoTuningGains(props, requestTimeout, messageId));
|
|
1114
|
-
|
|
1115
|
-
if (status.request === 'succeeded') {
|
|
1116
|
-
return;
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
throw new Error(`Failed to compute full auto tuning gains. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
startFullAutoTuning(props: MotionMasterMessage.Request.IStartFullAutoTuning & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
1123
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
1124
|
-
mergeMap((deviceAddress) => {
|
|
1125
|
-
const startFullAutoTuning = MotionMasterMessage.Request.StartFullAutoTuning.create({ ...props, deviceAddress });
|
|
1126
|
-
const id = this.sendRequest({ startFullAutoTuning }, messageId);
|
|
1127
|
-
return this.socket.message$.pipe(
|
|
1128
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.FullAutoTuning>('fullAutoTuning', requestTimeout, id),
|
|
1129
|
-
);
|
|
1130
|
-
}),
|
|
1131
|
-
);
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
async startFullAutoTuningAsync(props: MotionMasterMessage.Request.IStartFullAutoTuning & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
1135
|
-
const status = await lastValueFrom(this.startFullAutoTuning(props, requestTimeout, messageId));
|
|
1136
|
-
|
|
1137
|
-
if (status.request === 'succeeded') {
|
|
1138
|
-
if (status.settlingTimeOrBandwidth === 'bandwidth') {
|
|
1139
|
-
return (({ bandwidth, dampingRatio }) => ({ bandwidth, dampingRatio }))(status);
|
|
1140
|
-
} else if (status.settlingTimeOrBandwidth === 'settlingTime') {
|
|
1141
|
-
return (({ settlingTime, dampingRatio }) => ({ dampingRatio, settlingTime }))(status);
|
|
1142
|
-
}
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
throw new Error(`Failed to start full auto tuning. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
stopFullAutoTuning(props: MotionMasterMessage.Request.IStopFullAutoTuning & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
1149
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
1150
|
-
mergeMap((deviceAddress) => {
|
|
1151
|
-
const stopFullAutoTuning = MotionMasterMessage.Request.StopFullAutoTuning.create({ ...props, deviceAddress });
|
|
1152
|
-
const id = this.sendRequest({ stopFullAutoTuning }, messageId);
|
|
1153
|
-
return this.socket.message$.pipe(
|
|
1154
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.FullAutoTuning>('fullAutoTuning', requestTimeout, id),
|
|
1155
|
-
map((status) => {
|
|
1156
|
-
if (status.success?.code === MotionMasterMessage.Status.FullAutoTuning.Success.Code.POSITION_STOPPED ||
|
|
1157
|
-
status.success?.code === MotionMasterMessage.Status.FullAutoTuning.Success.Code.VELOCITY_STOPPED) {
|
|
1158
|
-
// Full auto tuning status is shared between start and stop.
|
|
1159
|
-
// When full auto tuning has stopped this request is considered successful.
|
|
1160
|
-
status.request = 'succeeded';
|
|
1161
|
-
}
|
|
1162
|
-
return status;
|
|
1163
|
-
}),
|
|
1164
|
-
);
|
|
1165
|
-
}),
|
|
1166
|
-
);
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
async stopFullAutoTuningAsync(props: MotionMasterMessage.Request.IStopFullAutoTuning & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<void> {
|
|
1170
|
-
const status = await lastValueFrom(this.stopFullAutoTuning(props, requestTimeout, messageId));
|
|
1171
|
-
|
|
1172
|
-
if (status.request === 'succeeded') {
|
|
1173
|
-
return;
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
throw new Error(`Failed to stop full auto tuning. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
startCirculoEncoderConfiguration(props: MotionMasterMessage.Request.IStartCirculoEncoderConfiguration & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
1180
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
1181
|
-
mergeMap((deviceAddress) => {
|
|
1182
|
-
const startCirculoEncoderConfiguration = MotionMasterMessage.Request.StartCirculoEncoderConfiguration.create({ ...props, deviceAddress });
|
|
1183
|
-
const id = this.sendRequest({ startCirculoEncoderConfiguration }, messageId);
|
|
1184
|
-
return this.socket.message$.pipe(
|
|
1185
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.CirculoEncoderConfiguration>('circuloEncoderConfiguration', requestTimeout, id),
|
|
1186
|
-
);
|
|
1187
|
-
}),
|
|
1188
|
-
);
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
async startCirculoEncoderConfigurationAsync(props: MotionMasterMessage.Request.IStartCirculoEncoderConfiguration & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<void> {
|
|
1192
|
-
const status = await lastValueFrom(this.startCirculoEncoderConfiguration(props, requestTimeout, messageId));
|
|
1193
|
-
|
|
1194
|
-
if (status.request === 'succeeded') {
|
|
1195
|
-
return;
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
|
-
throw new Error(`Failed to start circulo encoder configuration. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
1199
|
-
}
|
|
1200
|
-
|
|
1201
|
-
stopCirculoEncoderNarrowAngleCalibrationProcedure(props: MotionMasterMessage.Request.IStopCirculoEncoderNarrowAngleCalibrationProcedure & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
1202
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
1203
|
-
mergeMap((deviceAddress) => {
|
|
1204
|
-
const stopCirculoEncoderNarrowAngleCalibrationProcedure = MotionMasterMessage.Request.StopCirculoEncoderNarrowAngleCalibrationProcedure.create({ ...props, deviceAddress });
|
|
1205
|
-
const id = this.sendRequest({ stopCirculoEncoderNarrowAngleCalibrationProcedure }, messageId);
|
|
1206
|
-
return this.socket.message$.pipe(
|
|
1207
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.CirculoEncoderNarrowAngleCalibrationProcedure>('circuloEncoderNarrowAngleCalibrationProcedure', requestTimeout, id),
|
|
1208
|
-
);
|
|
1209
|
-
}),
|
|
1210
|
-
);
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
|
-
async stopCirculoEncoderNarrowAngleCalibrationProcedureAsync(props: MotionMasterMessage.Request.IStopCirculoEncoderNarrowAngleCalibrationProcedure & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
1214
|
-
const status = await lastValueFrom(this.stopCirculoEncoderNarrowAngleCalibrationProcedure(props, requestTimeout, messageId));
|
|
1215
|
-
|
|
1216
|
-
if (status.request === 'succeeded') {
|
|
1217
|
-
return;
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
throw new Error(`Failed to stop circulo encoder narrow angle calibration procedure. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
1221
|
-
}
|
|
1222
|
-
|
|
1223
|
-
startOsCommand(props: MotionMasterMessage.Request.IStartOsCommand & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
1224
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
1225
|
-
mergeMap((deviceAddress) => {
|
|
1226
|
-
const startOsCommand = MotionMasterMessage.Request.StartOsCommand.create({ ...props, deviceAddress });
|
|
1227
|
-
const id = this.sendRequest({ startOsCommand }, messageId);
|
|
1228
|
-
return this.socket.message$.pipe(
|
|
1229
|
-
transformMotionMasterMessageToStatus<MotionMasterMessage.Status.OsCommand>('osCommand', requestTimeout, id),
|
|
1230
|
-
);
|
|
1231
|
-
}),
|
|
1232
|
-
);
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
|
-
async startOsCommandAsync(props: MotionMasterMessage.Request.IStartOsCommand & DeviceRefObj, requestTimeout: number, messageId?: string): Promise<Uint8Array> {
|
|
1236
|
-
const status = await lastValueFrom(this.startOsCommand(props, requestTimeout, messageId));
|
|
1237
|
-
|
|
1238
|
-
if (status.request === 'succeeded') {
|
|
1239
|
-
return status.response;
|
|
1240
|
-
}
|
|
1241
|
-
|
|
1242
|
-
throw new Error(`Failed to start os command. ${status.error?.code}: ${status.error?.message} ${JSON.stringify(props)}`);
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
sendRequest(request: MotionMasterMessage.IRequest, messageId?: string) {
|
|
1246
|
-
const id = messageId ?? v4();
|
|
1247
|
-
const message = MotionMasterMessage.create({ request, id });
|
|
1248
|
-
this.socket.send(message);
|
|
1249
|
-
return id;
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
//
|
|
1253
|
-
// Helpers
|
|
1254
|
-
//
|
|
1255
|
-
|
|
1256
|
-
async resolveDeviceAddress(deviceRefObj: DeviceRefObj): Promise<number> {
|
|
1257
|
-
if (deviceRefObj.deviceAddress) {
|
|
1258
|
-
return deviceRefObj.deviceAddress;
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1261
|
-
if (this.deviceAddressMap.size === 0) {
|
|
1262
|
-
const devices = await this.getDeviceInfoAsync(2000);
|
|
1263
|
-
for (const device of devices) {
|
|
1264
|
-
if (device.deviceAddress) {
|
|
1265
|
-
const hardwareDescripition = await this.getDeviceHardwareDescription(device.deviceAddress);
|
|
1266
|
-
const serialNumber = getSerialNumberFromHardwareDescription(hardwareDescripition);
|
|
1267
|
-
this.deviceAddressMap.set(serialNumber, device.deviceAddress);
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
if (deviceRefObj.deviceSerialNumber) {
|
|
1273
|
-
const deviceAddress = this.deviceAddressMap.get(deviceRefObj.deviceSerialNumber);
|
|
1274
|
-
if (deviceAddress) {
|
|
1275
|
-
return deviceAddress;
|
|
1276
|
-
}
|
|
1277
|
-
throw new Error(`No device found by device serial number "${deviceRefObj.deviceSerialNumber}" when resolving device address`);
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1280
|
-
if (typeof deviceRefObj.devicePosition === 'number') {
|
|
1281
|
-
const values = Array.from(this.deviceAddressMap.values());
|
|
1282
|
-
const deviceAddress = values[deviceRefObj.devicePosition];
|
|
1283
|
-
if (typeof deviceAddress === 'number') {
|
|
1284
|
-
return deviceAddress;
|
|
1285
|
-
}
|
|
1286
|
-
throw new Error(`No device found by device position when resolving device address: ${deviceRefObj.devicePosition}`);
|
|
1287
|
-
}
|
|
1288
|
-
|
|
1289
|
-
throw new Error(`Failed to resolve device address. One of device address, serial number, or position must be specified.`);
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1292
|
-
async getDeviceAddresses(requestTimeout = 2000): Promise<number[]> {
|
|
1293
|
-
const deviceInfo = await this.getDeviceInfoAsync(requestTimeout);
|
|
1294
|
-
if (deviceInfo) {
|
|
1295
|
-
return deviceInfo.reduce((acc, val) => {
|
|
1296
|
-
if (typeof val.deviceAddress === 'number') {
|
|
1297
|
-
acc.push(val.deviceAddress);
|
|
1298
|
-
}
|
|
1299
|
-
return acc;
|
|
1300
|
-
}, [] as number[]);
|
|
1301
|
-
}
|
|
1302
|
-
return [];
|
|
1303
|
-
}
|
|
1304
|
-
|
|
1305
|
-
async getDeviceHardwareDescription(deviceRef: number | string, requestTimeout = 2000): Promise<HardwareDescription> {
|
|
1306
|
-
const deviceRefObj = makeDeviceRefObj(deviceRef);
|
|
1307
|
-
const content = await this.getDecodedDeviceFile({ ...deviceRefObj, name: '.hardware_description' }, requestTimeout);
|
|
1308
|
-
return JSON.parse(content) as HardwareDescription;
|
|
1309
|
-
}
|
|
1310
|
-
|
|
1311
|
-
async getSystemLogLines(requestTimeout = 2000): Promise<SystemLogLine[]> {
|
|
1312
|
-
const systemLog = await this.getSystemLogAsync(requestTimeout);
|
|
1313
|
-
return parseSystemLogContent(systemLog.content);
|
|
1314
|
-
}
|
|
1315
|
-
|
|
1316
|
-
getAllParameters(props: { loadFromCache?: boolean, sendProgress?: boolean } & DeviceRefObj, requestTimeout: number): Observable<Parameter[]> {
|
|
1317
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
1318
|
-
mergeMap((deviceAddress) => {
|
|
1319
|
-
return this.getDeviceParameterInfo({ deviceAddress }, requestTimeout).pipe(
|
|
1320
|
-
mergeMap(deviceParameterInfoStatus => {
|
|
1321
|
-
const { loadFromCache, sendProgress } = props;
|
|
1322
|
-
const parameters = deviceParameterInfoStatus.parameters.map(p => ({ index: p.index ?? 0, subindex: p.subindex ?? 0, loadFromCache }));
|
|
1323
|
-
return this.getDeviceParameterValues({ deviceAddress, sendProgress, parameters }, requestTimeout).pipe(
|
|
1324
|
-
map(deviceParameterValuesStatus => {
|
|
1325
|
-
const parameters: Parameter[] = deviceParameterValuesStatus.parameterValues.map((value, i) => {
|
|
1326
|
-
const index = value.index ?? 0;
|
|
1327
|
-
const subindex = value.subindex ?? 0;
|
|
1328
|
-
return ({ ...value, ...deviceParameterInfoStatus.parameters[i], index, subindex, value: getParameterValue(value) }) as Parameter;
|
|
1329
|
-
});
|
|
1330
|
-
return parameters;
|
|
1331
|
-
}),
|
|
1332
|
-
);
|
|
1333
|
-
}),
|
|
1334
|
-
);
|
|
1335
|
-
}),
|
|
1336
|
-
);
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
async getAllParametersAsync(props: { loadFromCache?: boolean, sendProgress?: boolean } & DeviceRefObj, requestTimeout: number) {
|
|
1340
|
-
return await lastValueFrom(
|
|
1341
|
-
this.getAllParameters(props, requestTimeout),
|
|
1342
|
-
);
|
|
1343
|
-
}
|
|
1344
|
-
|
|
1345
|
-
async getParameterValue<T extends ParameterValueType = number>(deviceParameterId: string, loadFromCache?: boolean, requestTimeout?: number): Promise<T>;
|
|
1346
|
-
async getParameterValue<T extends ParameterValueType = number>(deviceRef: number | string, parameter: [number, number] | { index: number, subindex: number } | string, loadFromCache?: boolean, requestTimeout?: number): Promise<T>;
|
|
1347
|
-
async getParameterValue<T extends ParameterValueType = number>(deviceRef: number | string, index: number, subindex: number, loadFromCache?: boolean, requestTimeout?: number): Promise<T>;
|
|
1348
|
-
async getParameterValue<T extends ParameterValueType = number>(a: string | number, b?: boolean | { index: number, subindex: number } | [number, number] | number | string, c?: number | boolean, d?: boolean | number, e?: number): Promise<T> {
|
|
1349
|
-
let deviceSerialNumber: string;
|
|
1350
|
-
let index: number | undefined;
|
|
1351
|
-
let subindex = 0;
|
|
1352
|
-
let loadFromCache = false;
|
|
1353
|
-
let requestTimeout = 1000;
|
|
1354
|
-
let deviceRefObj: DeviceRefObj | undefined;
|
|
1355
|
-
|
|
1356
|
-
if (Array.isArray(b)) { // tuple of index and subindex, e.g. [0x2110, 0]
|
|
1357
|
-
deviceRefObj = makeDeviceRefObj(a);
|
|
1358
|
-
[index, subindex] = b;
|
|
1359
|
-
if (typeof c === 'boolean') {
|
|
1360
|
-
loadFromCache = c;
|
|
1361
|
-
}
|
|
1362
|
-
if (typeof d === 'number') {
|
|
1363
|
-
requestTimeout = d;
|
|
1364
|
-
}
|
|
1365
|
-
} else if (typeof b === 'object') { // object with index and subindex properties, e.g. { index: 0x2110, subindex: 0x1A }
|
|
1366
|
-
deviceRefObj = makeDeviceRefObj(a);
|
|
1367
|
-
index = b.index;
|
|
1368
|
-
subindex = b.subindex;
|
|
1369
|
-
if (typeof c === 'boolean') {
|
|
1370
|
-
loadFromCache = c;
|
|
1371
|
-
}
|
|
1372
|
-
if (typeof d === 'number') {
|
|
1373
|
-
requestTimeout = d;
|
|
1374
|
-
}
|
|
1375
|
-
} else if (typeof b === 'string') { // parameter id, e.g. "0x2110:1A"
|
|
1376
|
-
[index, subindex] = splitParameterId(b);
|
|
1377
|
-
deviceRefObj = makeDeviceRefObj(a);
|
|
1378
|
-
if (typeof c === 'boolean') {
|
|
1379
|
-
loadFromCache = c;
|
|
1380
|
-
}
|
|
1381
|
-
if (typeof d === 'number') {
|
|
1382
|
-
requestTimeout = d;
|
|
1383
|
-
}
|
|
1384
|
-
} else if (typeof b === 'number') { // object index, e.g. 0x2110
|
|
1385
|
-
deviceRefObj = makeDeviceRefObj(a);
|
|
1386
|
-
index = b;
|
|
1387
|
-
if (typeof c === 'number') {
|
|
1388
|
-
subindex = c;
|
|
1389
|
-
}
|
|
1390
|
-
if (typeof d === 'boolean') {
|
|
1391
|
-
loadFromCache = d;
|
|
1392
|
-
}
|
|
1393
|
-
if (typeof e === 'number') {
|
|
1394
|
-
requestTimeout = e;
|
|
1395
|
-
}
|
|
1396
|
-
} else if (typeof a === 'string') { // device parameter id, e.g. "0x2110:1A.8502-03-0001353-2115"
|
|
1397
|
-
[deviceSerialNumber, index, subindex] = splitDeviceParameterId(a);
|
|
1398
|
-
deviceRefObj = makeDeviceRefObj(deviceSerialNumber);
|
|
1399
|
-
if (typeof b === 'boolean') {
|
|
1400
|
-
loadFromCache = b;
|
|
1401
|
-
}
|
|
1402
|
-
if (typeof c === 'number') {
|
|
1403
|
-
requestTimeout = c;
|
|
1404
|
-
}
|
|
1405
|
-
}
|
|
1406
|
-
|
|
1407
|
-
const status = await lastValueFrom(
|
|
1408
|
-
this.getDeviceParameterValues({ ...deviceRefObj, parameters: [{ index, subindex, loadFromCache }] }, requestTimeout),
|
|
1409
|
-
);
|
|
1410
|
-
|
|
1411
|
-
const parameterValue = status.parameterValues[0] as MotionMasterMessage.Status.DeviceParameterValues.ParameterValue;
|
|
1412
|
-
|
|
1413
|
-
if (parameterValue.success) {
|
|
1414
|
-
const typeValue = parameterValue.typeValue;
|
|
1415
|
-
if (typeValue) {
|
|
1416
|
-
return status.parameterValues[0][typeValue] as T;
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
|
|
1420
|
-
const props = { ...deviceRefObj, index, subindex, loadFromCache };
|
|
1421
|
-
|
|
1422
|
-
const errorCodeName = MotionMasterMessage.Status.DeviceParameterValues.ParameterValue.Error.Code[status.parameterValues[0]?.error?.code ?? 0];
|
|
1423
|
-
throw new Error(`Failed to get parameter value. ${errorCodeName} ${JSON.stringify(props)}`);
|
|
1424
|
-
}
|
|
1425
|
-
|
|
1426
|
-
async setParameterValue(deviceRef: number | string, index: number, subindex: number, value: ParameterValueType, valueTypeKey?: keyof Required<ParameterTypeValue>, requestTimeout = 1000): Promise<void> {
|
|
1427
|
-
const deviceRefObj = makeDeviceRefObj(deviceRef);
|
|
1428
|
-
const deviceAddress = await this.resolveDeviceAddress(deviceRefObj);
|
|
1429
|
-
|
|
1430
|
-
const props = { ...deviceRefObj, index, subindex, value, valueTypeKey };
|
|
1431
|
-
|
|
1432
|
-
if (!valueTypeKey) {
|
|
1433
|
-
const parameterId = makeParameterId(index, subindex);
|
|
1434
|
-
valueTypeKey = this.parameterTypeValueKeyMap.get(deviceAddress)?.get(parameterId);
|
|
1435
|
-
if (!valueTypeKey) {
|
|
1436
|
-
throw new Error(`Failed to set device parameter value. Value type key is not set. ${JSON.stringify(props)}`);
|
|
1437
|
-
}
|
|
1438
|
-
}
|
|
1439
|
-
|
|
1440
|
-
const parameterValue: MotionMasterMessage.Request.SetDeviceParameterValues.IParameterValue = { index, subindex, [valueTypeKey]: value };
|
|
1441
|
-
|
|
1442
|
-
const status = await lastValueFrom(
|
|
1443
|
-
this.setDeviceParameterValues({ deviceAddress, parameterValues: [parameterValue] }, requestTimeout),
|
|
1444
|
-
);
|
|
1445
|
-
|
|
1446
|
-
if (status.request === 'succeeded') {
|
|
1447
|
-
return;
|
|
1448
|
-
}
|
|
1449
|
-
|
|
1450
|
-
throw new Error(`Failed to set device parameter value. ${status.parameterValues[0]?.error?.message} ${JSON.stringify(props)}`);
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1453
|
-
async setParameterValues(deviceRef: number | string, values: ParameterAddressValue[], requestTimeout = 1000): Promise<void> {
|
|
1454
|
-
const deviceRefObj = makeDeviceRefObj(deviceRef);
|
|
1455
|
-
const deviceAddress = await this.resolveDeviceAddress(deviceRefObj);
|
|
1456
|
-
|
|
1457
|
-
const props = { deviceAddress, parameters: values };
|
|
1458
|
-
|
|
1459
|
-
const parameterValues = values.map(([index, subindex, value, valueTypeKey]) => {
|
|
1460
|
-
if (!valueTypeKey) {
|
|
1461
|
-
const parameterId = makeParameterId(index, subindex);
|
|
1462
|
-
valueTypeKey = this.parameterTypeValueKeyMap.get(deviceAddress)?.get(parameterId);
|
|
1463
|
-
if (!valueTypeKey) {
|
|
1464
|
-
throw new Error(`Failed to set device parameter values. Value type key is not set. ${JSON.stringify(props)}`);
|
|
1465
|
-
}
|
|
1466
|
-
}
|
|
1467
|
-
return { index, subindex, [valueTypeKey]: value };
|
|
1468
|
-
}) as MotionMasterMessage.Request.SetDeviceParameterValues.IParameterValue[];
|
|
1469
|
-
|
|
1470
|
-
const status = await lastValueFrom(
|
|
1471
|
-
this.setDeviceParameterValues({ deviceAddress, parameterValues }, requestTimeout),
|
|
1472
|
-
);
|
|
1473
|
-
|
|
1474
|
-
if (status.request === 'succeeded') {
|
|
1475
|
-
return;
|
|
1476
|
-
}
|
|
1477
|
-
|
|
1478
|
-
throw new Error(`Failed to set device parameter values. ${status.parameterValues[0]?.error?.message} ${JSON.stringify(props)}`);
|
|
1479
|
-
}
|
|
1480
|
-
|
|
1481
|
-
async getDecodedDeviceFile(props: MotionMasterMessage.Request.IGetDeviceFile, requestTimeout: number, messageId?: string): Promise<string> {
|
|
1482
|
-
const content = await this.getDeviceFileAsync(props, requestTimeout, messageId);
|
|
1483
|
-
return decodeTextContent(content);
|
|
1484
|
-
}
|
|
1485
|
-
|
|
1486
|
-
async getDeviceFiles(deviceRef: number | string, requestTimeout = 30000) {
|
|
1487
|
-
const deviceRefObj = makeDeviceRefObj(deviceRef);
|
|
1488
|
-
return this.getDeviceFileListAsync(deviceRefObj, requestTimeout);
|
|
1489
|
-
}
|
|
1490
|
-
|
|
1491
|
-
getDeviceParameterInfoAndValues(props: { deviceAddress?: number | null, loadFromCache?: boolean | null, sendProgress?: boolean | null }, requestTimeout: number): Observable<DeviceParameterValuesStatus> {
|
|
1492
|
-
const { deviceAddress, loadFromCache, sendProgress } = props;
|
|
1493
|
-
return this.getDeviceParameterInfo({ deviceAddress }, requestTimeout).pipe(
|
|
1494
|
-
mergeMap(deviceParameterInfo => {
|
|
1495
|
-
const parameters = deviceParameterInfo.parameters.map(p => ({ index: p.index ?? 0, subindex: p.subindex ?? 0, loadFromCache }));
|
|
1496
|
-
return this.getDeviceParameterValues({ deviceAddress, parameters, sendProgress }, requestTimeout).pipe(
|
|
1497
|
-
map(deviceParameterValues => {
|
|
1498
|
-
const parameters: ParameterInfoAndValue[] = deviceParameterValues.parameterValues
|
|
1499
|
-
.map((value, index) => ({ ...value, ...deviceParameterInfo.parameters[index] }));
|
|
1500
|
-
deviceParameterValues.parameterValues = parameters;
|
|
1501
|
-
return deviceParameterValues;
|
|
1502
|
-
}),
|
|
1503
|
-
);
|
|
1504
|
-
}),
|
|
1505
|
-
);
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
async getDeviceParameterInfoAndValuesAsync(props: { deviceAddress?: number | null, loadFromCache?: boolean | null, sendProgress?: boolean | null }, requestTimeout: number) {
|
|
1509
|
-
const status = await lastValueFrom(
|
|
1510
|
-
this.getDeviceParameterInfoAndValues(props, requestTimeout),
|
|
1511
|
-
);
|
|
1512
|
-
|
|
1513
|
-
if (status.request === 'succeeded') {
|
|
1514
|
-
return status.parameterValues;
|
|
1515
|
-
}
|
|
1516
|
-
|
|
1517
|
-
throw new Error(`Failed to get device parameter info and values. ${JSON.stringify(props)}`);
|
|
1518
|
-
}
|
|
1519
|
-
|
|
1520
|
-
saveAllParameters(deviceRef: number | string, requestTimeout: number) {
|
|
1521
|
-
const deviceRefObj = makeDeviceRefObj(deviceRef);
|
|
1522
|
-
|
|
1523
|
-
return from(this.resolveDeviceAddress(deviceRefObj)).pipe(
|
|
1524
|
-
mergeMap((deviceAddress) => {
|
|
1525
|
-
const parameter: MotionMasterMessage.Request.SetDeviceParameterValues.IParameterValue = { index: 0x1010, subindex: 1, uintValue: 0x65766173 }; // "evas"
|
|
1526
|
-
const parameterId = makeParameterId(parameter);
|
|
1527
|
-
|
|
1528
|
-
const result$ = defer(() => this.checkDeviceParameterValue({ deviceAddress, parameter, expectedValue: 1 }, requestTimeout)).pipe(
|
|
1529
|
-
retryWithDelay<void>(500, 10),
|
|
1530
|
-
);
|
|
1531
|
-
|
|
1532
|
-
return this.setDeviceParameterValues({ deviceAddress, parameterValues: [parameter] }, requestTimeout).pipe(
|
|
1533
|
-
delay(2000), // give some initial time for operation to complete
|
|
1534
|
-
mergeMap(({ parameterValues }) => {
|
|
1535
|
-
const parameter = parameterValues[0];
|
|
1536
|
-
if (parameter) {
|
|
1537
|
-
if (parameter.error) {
|
|
1538
|
-
throw new Error(`Failed to set ${parameterId} value to ${parameter.uintValue} on device ${deviceAddress}`);
|
|
1539
|
-
}
|
|
1540
|
-
} else {
|
|
1541
|
-
throw new Error(`No parameters in status for ${parameterId} on device ${deviceAddress}`);
|
|
1542
|
-
}
|
|
1543
|
-
return result$;
|
|
1544
|
-
}),
|
|
1545
|
-
);
|
|
1546
|
-
}),
|
|
1547
|
-
);
|
|
1548
|
-
}
|
|
1549
|
-
|
|
1550
|
-
restoreAllDefaultParameters(deviceRef: number | string, requestTimeout: number) {
|
|
1551
|
-
const deviceRefObj = makeDeviceRefObj(deviceRef);
|
|
1552
|
-
|
|
1553
|
-
return from(this.resolveDeviceAddress(deviceRefObj)).pipe(
|
|
1554
|
-
mergeMap((deviceAddress) => {
|
|
1555
|
-
const parameter: MotionMasterMessage.Request.SetDeviceParameterValues.IParameterValue = { index: 0x1011, subindex: 1, uintValue: 0x64616f6c }; // "daol"
|
|
1556
|
-
const parameterId = makeParameterId(parameter);
|
|
1557
|
-
|
|
1558
|
-
const result$ = defer(() => this.checkDeviceParameterValue({ deviceAddress, parameter, expectedValue: 1 }, requestTimeout)).pipe(
|
|
1559
|
-
retryWithDelay<void>(500, 10),
|
|
1560
|
-
);
|
|
1561
|
-
|
|
1562
|
-
return this.setDeviceParameterValues({ deviceAddress, parameterValues: [parameter] }, requestTimeout).pipe(
|
|
1563
|
-
delay(500), // give some initial time for operation to complete
|
|
1564
|
-
mergeMap(({ parameterValues }) => {
|
|
1565
|
-
const parameter = parameterValues[0];
|
|
1566
|
-
if (parameter) {
|
|
1567
|
-
if (parameter.error) {
|
|
1568
|
-
throw new Error(`Failed to set ${parameterId} value to ${parameter.uintValue} on device ${deviceAddress}`);
|
|
1569
|
-
}
|
|
1570
|
-
} else {
|
|
1571
|
-
throw new Error(`No parameters in status for ${parameterId} on device ${deviceAddress}`);
|
|
1572
|
-
}
|
|
1573
|
-
return result$;
|
|
1574
|
-
}),
|
|
1575
|
-
);
|
|
1576
|
-
}),
|
|
1577
|
-
);
|
|
1578
|
-
}
|
|
1579
|
-
|
|
1580
|
-
checkDeviceParameterValue(props: { parameter: MotionMasterMessage.Request.GetDeviceParameterValues.IParameter, expectedValue: number | string } & DeviceRefObj, requestTimeout: number, messageId?: string) {
|
|
1581
|
-
return from(this.resolveDeviceAddress(props)).pipe(
|
|
1582
|
-
mergeMap((deviceAddress) => {
|
|
1583
|
-
const { expectedValue } = props;
|
|
1584
|
-
const parameterId = makeParameterId(props.parameter);
|
|
1585
|
-
|
|
1586
|
-
return this.getDeviceParameterValues({ deviceAddress, parameters: [props.parameter] }, requestTimeout, messageId).pipe(
|
|
1587
|
-
map(({ parameterValues }) => {
|
|
1588
|
-
const parameter = parameterValues[0];
|
|
1589
|
-
if (parameter) {
|
|
1590
|
-
const parameterValue = getParameterValue(parameter);
|
|
1591
|
-
if (parameter.error) {
|
|
1592
|
-
throw new Error(`Failed to get ${parameterId} on device ${deviceAddress}`);
|
|
1593
|
-
} else if (parameterValue !== expectedValue) {
|
|
1594
|
-
throw new Error(`Value of ${parameterId} didn't change to ${expectedValue} on device ${deviceAddress}`);
|
|
1595
|
-
}
|
|
1596
|
-
} else {
|
|
1597
|
-
throw new Error(`No parameters in status for ${parameterId} on ${deviceAddress}`);
|
|
1598
|
-
}
|
|
1599
|
-
}),
|
|
1600
|
-
);
|
|
1601
|
-
}),
|
|
1602
|
-
);
|
|
1603
|
-
}
|
|
1604
|
-
|
|
1605
|
-
async getDeviceApiIdentifier(deviceRef: number | string, requestTimeout = 2000) {
|
|
1606
|
-
const hardwareDescription = await this.getDeviceHardwareDescription(deviceRef, requestTimeout);
|
|
1607
|
-
return getApiIdentifierFromHardwareDescription(hardwareDescription);
|
|
1608
|
-
}
|
|
1609
|
-
|
|
1610
|
-
async enableMotion(deviceRef: number | string, controllerType: MotionMasterMessage.Request.EnableMotionController.ControllerType, filter = false, requestTimeout = 2000) {
|
|
1611
|
-
const deviceRefObj = makeDeviceRefObj(deviceRef);
|
|
1612
|
-
return await this.enableMotionControllerAsync({ ...deviceRefObj, controllerType, filter }, requestTimeout);
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
async setMotionTarget(deviceRef: number | string, target: number) {
|
|
1616
|
-
const deviceRefObj = makeDeviceRefObj(deviceRef);
|
|
1617
|
-
return await this.setMotionControllerParametersAsync({ ...deviceRefObj, target });
|
|
1618
|
-
}
|
|
1619
|
-
|
|
1620
|
-
async disableMotion(deviceRef: number | string, requestTimeout = 3000) {
|
|
1621
|
-
const deviceRefObj = makeDeviceRefObj(deviceRef);
|
|
1622
|
-
return await this.disableMotionControllerAsync(deviceRefObj, requestTimeout);
|
|
1623
|
-
}
|
|
1624
|
-
|
|
1625
|
-
}
|