@synapticon/motion-master-client 2.3.0-beta.0 → 6.0.0-alpha.100

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.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/dist/api-error.d.ts +25 -0
  3. package/dist/api-error.js +52 -0
  4. package/dist/client.d.ts +20 -0
  5. package/dist/client.js +37 -0
  6. package/dist/constants.d.ts +2 -0
  7. package/dist/constants.js +8 -0
  8. package/dist/eni.d.ts +197 -0
  9. package/dist/eni.js +61 -0
  10. package/dist/generated/Api.d.ts +1886 -0
  11. package/dist/generated/Api.js +1293 -0
  12. package/dist/generated/data-contracts.d.ts +2282 -0
  13. package/dist/generated/data-contracts.js +12 -0
  14. package/dist/generated/http-client.d.ts +60 -0
  15. package/dist/generated/http-client.js +171 -0
  16. package/dist/hex.d.ts +2 -0
  17. package/dist/hex.js +20 -0
  18. package/dist/index.d.ts +13 -7
  19. package/dist/index.js +20 -22
  20. package/dist/lan.d.ts +4 -0
  21. package/dist/lan.js +59 -0
  22. package/dist/mmpd.d.ts +53 -0
  23. package/dist/mmpd.js +322 -0
  24. package/dist/sdo.d.ts +17 -0
  25. package/dist/sdo.js +219 -0
  26. package/dist/web-socket-connection.d.ts +70 -0
  27. package/dist/web-socket-connection.js +237 -0
  28. package/dist/wire-time.d.ts +2 -0
  29. package/dist/wire-time.js +18 -0
  30. package/package.json +29 -35
  31. package/.vscode/launch.json +0 -23
  32. package/README.md +0 -118
  33. package/box.config.json +0 -7
  34. package/dist/index.d.ts.map +0 -1
  35. package/dist/index.js.map +0 -1
  36. package/dist/motion-master-client-web-socket-connection.d.ts +0 -43
  37. package/dist/motion-master-client-web-socket-connection.d.ts.map +0 -1
  38. package/dist/motion-master-client-web-socket-connection.js +0 -91
  39. package/dist/motion-master-client-web-socket-connection.js.map +0 -1
  40. package/dist/motion-master-client.d.ts +0 -105
  41. package/dist/motion-master-client.d.ts.map +0 -1
  42. package/dist/motion-master-client.js +0 -348
  43. package/dist/motion-master-client.js.map +0 -1
  44. package/dist/motion-master-notification-subscribe-data.d.ts +0 -8
  45. package/dist/motion-master-notification-subscribe-data.d.ts.map +0 -1
  46. package/dist/motion-master-notification-subscribe-data.js +0 -3
  47. package/dist/motion-master-notification-subscribe-data.js.map +0 -1
  48. package/dist/motion-master-notification-web-socket-connection.d.ts +0 -56
  49. package/dist/motion-master-notification-web-socket-connection.d.ts.map +0 -1
  50. package/dist/motion-master-notification-web-socket-connection.js +0 -115
  51. package/dist/motion-master-notification-web-socket-connection.js.map +0 -1
  52. package/dist/motion-master-notification.d.ts +0 -31
  53. package/dist/motion-master-notification.d.ts.map +0 -1
  54. package/dist/motion-master-notification.js +0 -44
  55. package/dist/motion-master-notification.js.map +0 -1
  56. package/dist/util.d.ts +0 -16
  57. package/dist/util.d.ts.map +0 -1
  58. package/dist/util.js +0 -24
  59. package/dist/util.js.map +0 -1
  60. package/licenses.format.json +0 -4
  61. package/motion-master-client.config.json +0 -7
  62. package/smm_data_dic.json +0 -1213
  63. package/src/index.ts +0 -7
  64. package/src/motion-master-client-web-socket-connection.ts +0 -104
  65. package/src/motion-master-client.ts +0 -468
  66. package/src/motion-master-notification-subscribe-data.ts +0 -7
  67. package/src/motion-master-notification-web-socket-connection.ts +0 -143
  68. package/src/motion-master-notification.ts +0 -51
  69. package/src/util.ts +0 -22
  70. package/test.sh +0 -122
  71. package/tsconfig.json +0 -63
  72. package/tslint.json +0 -118
package/src/index.ts DELETED
@@ -1,7 +0,0 @@
1
- export { MotionMasterClientWebSocketConnection } from './motion-master-client-web-socket-connection';
2
- export { MotionMasterClient } from './motion-master-client';
3
- export { IMotionMasterNotificationSubscribeData } from './motion-master-notification-subscribe-data';
4
- export { MotionMasterNotificationWebSocketConnection } from './motion-master-notification-web-socket-connection';
5
- export { MotionMasterNotification } from './motion-master-notification';
6
-
7
- export * from './util';
@@ -1,104 +0,0 @@
1
- import { BehaviorSubject, interval, Observable, Subscription } from 'rxjs';
2
- import { filter, map, tap } from 'rxjs/operators';
3
- import { webSocket, WebSocketSubject, WebSocketSubjectConfig } from 'rxjs/webSocket';
4
-
5
- import { MotionMasterClient } from './motion-master-client';
6
- import { MotionMasterMessage } from './util';
7
-
8
- export class MotionMasterClientWebSocketConnection {
9
-
10
- /**
11
- * An instance of MotionMasterClient bound to this WebSocket connection.
12
- */
13
- readonly client = new MotionMasterClient();
14
-
15
- /**
16
- * Emits a boolean value when connection gets opened or closed.
17
- */
18
- readonly connected$ = new BehaviorSubject<boolean>(false);
19
-
20
- /**
21
- * Emits a boolean value when Motion Master is considered alive. True when messages are received
22
- * in regular interval, or false when alive timeout expires.
23
- */
24
- readonly alive$ = new BehaviorSubject<boolean>(false);
25
-
26
- private pingSystemIntervalObserver = { next: () => this.client.requestPingSystem() };
27
-
28
- private pingSystemIntervalSubscription = new Subscription();
29
-
30
- private aliveTimeoutId = 0;
31
-
32
- private closeObserver = {
33
- next: () => {
34
- this.pingSystemIntervalSubscription.unsubscribe();
35
- this.connected$.next(false);
36
- self.clearTimeout(this.aliveTimeoutId);
37
- this.alive$.next(false);
38
- },
39
- };
40
-
41
- private openObserver = {
42
- next: () => {
43
- this.pingSystemIntervalSubscription = interval(this.pingSystemPeriod).subscribe(this.pingSystemIntervalObserver);
44
- this.connected$.next(true);
45
- },
46
- };
47
-
48
- private wssConfig: WebSocketSubjectConfig<Uint8Array> = {
49
- binaryType: 'arraybuffer',
50
- closeObserver: this.closeObserver,
51
- deserializer: (e: MessageEvent) => new Uint8Array(e.data),
52
- openObserver: this.openObserver,
53
- serializer: (value) => value,
54
- url: this.wssUrl,
55
- };
56
-
57
- readonly wss$: WebSocketSubject<Uint8Array> = webSocket(this.wssConfig);
58
-
59
- readonly message$: Observable<MotionMasterMessage> = this.wss$.pipe(
60
- map((data) => MotionMasterMessage.decode(data)),
61
- );
62
-
63
- private messageSubscription = new Subscription();
64
- private clientOutputSubscription = new Subscription();
65
-
66
- /**
67
- * MotionMasterClientWebSocketConnection constructor.
68
- * @param wssUrl Motion Master Bridge WebSocket client URL.
69
- * @param pingSystemPeriod timeframe in which to send ping system message to Motion Master.
70
- * @param aliveTimeout how long to wait for Motion Master message before emitting it's not alive.
71
- */
72
- constructor(
73
- public wssUrl = `ws://${location.hostname}:63524`,
74
- public pingSystemPeriod = 150,
75
- public aliveTimeout = 1000,
76
- ) { }
77
-
78
- close() {
79
- this.messageSubscription.unsubscribe();
80
- this.clientOutputSubscription.unsubscribe();
81
- }
82
-
83
- open() {
84
- this.messageSubscription = this.message$.pipe(
85
- tap(() => this.keepalive()),
86
- filter((message) => message && message.status ? !message.status.systemPong : false),
87
- ).subscribe((message) => {
88
- this.client.input$.next(message);
89
- });
90
-
91
- this.clientOutputSubscription = this.client.output$.subscribe((message) => {
92
- this.wss$.next(MotionMasterMessage.encode(message).finish());
93
- });
94
- }
95
-
96
- private keepalive() {
97
- if (this.alive$.getValue() === false) {
98
- this.alive$.next(true);
99
- }
100
- self.clearTimeout(this.aliveTimeoutId);
101
- this.aliveTimeoutId = self.setTimeout(() => this.alive$.next(false), this.aliveTimeout);
102
- }
103
-
104
- }
@@ -1,468 +0,0 @@
1
- import { Observable, Subject } from 'rxjs';
2
- import { filter, first, map } from 'rxjs/operators';
3
- import { v4 } from 'uuid';
4
-
5
- import { IMotionMasterMessage, MotionMasterMessage } from './util';
6
-
7
- export type RequestType = keyof MotionMasterMessage.IRequest;
8
- export type StatusType = keyof MotionMasterMessage.IStatus;
9
- export type SignalGeneratorType = keyof MotionMasterMessage.Request.ISetSignalGeneratorParameters;
10
- export type ComputeAutoTuningGainsType = keyof MotionMasterMessage.Request.IComputeAutoTuningGains;
11
-
12
- export type DeviceAddressType = number | null | undefined;
13
-
14
- /**
15
- * Select observable of Status message based on status type argument.
16
- * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#conditional-types
17
- */
18
- export type StatusTypeObservable<T extends StatusType> =
19
- T extends 'systemPong' ? Observable<MotionMasterMessage.Status.SystemPong> :
20
- T extends 'systemVersion' ? Observable<MotionMasterMessage.Status.SystemVersion> :
21
- T extends 'systemEvent' ? Observable<MotionMasterMessage.Status.SystemEvent> :
22
- T extends 'deviceInfo' ? Observable<MotionMasterMessage.Status.DeviceInfo> :
23
- T extends 'deviceParameterInfo' ? Observable<MotionMasterMessage.Status.DeviceParameterInfo> :
24
- T extends 'deviceParameterValues' ? Observable<MotionMasterMessage.Status.DeviceParameterValues> :
25
- T extends 'multiDeviceParameterValues' ? Observable<MotionMasterMessage.Status.MultiDeviceParameterValues> :
26
- T extends 'deviceFileList' ? Observable<MotionMasterMessage.Status.DeviceFileList> :
27
- T extends 'deviceFile' ? Observable<MotionMasterMessage.Status.DeviceFile> :
28
- T extends 'deviceEvent' ? Observable<MotionMasterMessage.Status.DeviceEvent> :
29
- T extends 'deviceFirmwareInstallation' ? Observable<MotionMasterMessage.Status.DeviceFirmwareInstallation> :
30
- T extends 'deviceLog' ? Observable<MotionMasterMessage.Status.DeviceLog> :
31
- T extends 'deviceFaultReset' ? Observable<MotionMasterMessage.Status.DeviceFaultReset> :
32
- T extends 'coggingTorqueRecording' ? Observable<MotionMasterMessage.Status.CoggingTorqueRecording> :
33
- T extends 'coggingTorqueData' ? Observable<MotionMasterMessage.Status.CoggingTorqueData> :
34
- T extends 'offsetDetection' ? Observable<MotionMasterMessage.Status.OffsetDetection> :
35
- T extends 'plantIdentification' ? Observable<MotionMasterMessage.Status.PlantIdentification> :
36
- T extends 'autoTuning' ? Observable<MotionMasterMessage.Status.AutoTuning> :
37
- T extends 'motionController' ? Observable<MotionMasterMessage.Status.MotionController> :
38
- T extends 'signalGenerator' ? Observable<MotionMasterMessage.Status.SignalGenerator> :
39
- T extends 'monitoringParameterValues' ? Observable<MotionMasterMessage.Status.MonitoringParameterValues> :
40
- T extends 'deviceStop' ? Observable<MotionMasterMessage.Status.DeviceStop> :
41
- T extends 'ethercatNetworkState' ? Observable<MotionMasterMessage.Status.EthercatNetworkState> :
42
- T extends 'narrowAngleCalibration' ? Observable<MotionMasterMessage.Status.NarrowAngleCalibration> :
43
- T extends 'systemIdentification' ? Observable<MotionMasterMessage.Status.SystemIdentification> :
44
- T extends 'circuloEncoderMagnetDistance' ? Observable<MotionMasterMessage.Status.CirculoEncoderMagnetDistance> :
45
- T extends 'circuloEncoderNarrowAngleCalibrationProcedure' ? Observable<MotionMasterMessage.Status.CirculoEncoderNarrowAngleCalibrationProcedure> :
46
- T extends 'deviceCia402State' ? Observable<MotionMasterMessage.Status.DeviceCiA402State> :
47
- T extends 'systemLog' ? Observable<MotionMasterMessage.Status.SystemLog> :
48
- T extends 'deviceSiiRestore' ? Observable<MotionMasterMessage.Status.DeviceSiiRestore> :
49
- T extends 'openLoopFieldControl' ? Observable<MotionMasterMessage.Status.OpenLoopFieldControl> :
50
- T extends 'fullAutoTuning' ? Observable<MotionMasterMessage.Status.FullAutoTuning> :
51
- T extends 'circuloEncoderConfiguration' ? Observable<MotionMasterMessage.Status.CirculoEncoderConfiguration> :
52
- T extends 'osCommand' ? Observable<MotionMasterMessage.Status.OsCommand> :
53
- Observable<any>;
54
-
55
- export class MotionMasterClient {
56
-
57
- /**
58
- * Decoded message instances coming from Motion Master.
59
- * @see https://github.com/protobufjs/protobuf.js#toolset Message.decode
60
- */
61
- readonly input$ = new Subject<MotionMasterMessage>();
62
-
63
- /**
64
- * Message instances or objects going to Motion Master.
65
- * @see https://github.com/protobufjs/protobuf.js#toolset Message.encode
66
- */
67
- readonly output$ = new Subject<IMotionMasterMessage>();
68
-
69
- requestPingSystem(messageId?: string) {
70
- const pingSystem = MotionMasterMessage.Request.PingSystem.create();
71
- const id = this.sendRequest({ pingSystem }, messageId);
72
- return this.selectMessageStatus('systemPong', id);
73
- }
74
-
75
- requestGetSystemVersion(messageId?: string) {
76
- const getSystemVersion = MotionMasterMessage.Request.GetSystemVersion.create();
77
- const id = this.sendRequest({ getSystemVersion }, messageId);
78
- return this.selectMessageStatus('systemVersion', id);
79
- }
80
-
81
- requestGetDeviceInfo(messageId?: string) {
82
- const getDeviceInfo = MotionMasterMessage.Request.GetDeviceInfo.create();
83
- const id = this.sendRequest({ getDeviceInfo }, messageId);
84
- return this.selectMessageStatus('deviceInfo', id);
85
- }
86
-
87
- requestGetDeviceParameterInfo(deviceAddress: DeviceAddressType, messageId?: string) {
88
- const getDeviceParameterInfo = MotionMasterMessage.Request.GetDeviceParameterInfo.create({ deviceAddress });
89
- const id = this.sendRequest({ getDeviceParameterInfo }, messageId);
90
- return this.selectMessageStatus('deviceParameterInfo', id);
91
- }
92
-
93
- requestGetDeviceParameterValues(deviceAddress: DeviceAddressType, parameters: MotionMasterMessage.Request.GetDeviceParameterValues.IParameter[], sendProgress = false, messageId?: string) {
94
- const getDeviceParameterValues = MotionMasterMessage.Request.GetDeviceParameterValues.create({ deviceAddress, parameters, sendProgress });
95
- const id = this.sendRequest({ getDeviceParameterValues }, messageId);
96
- return this.selectMessageStatus('deviceParameterValues', id);
97
- }
98
-
99
- requestSetDeviceParameterValues(deviceAddress: DeviceAddressType, parameterValues: MotionMasterMessage.Request.SetDeviceParameterValues.IParameterValue[], messageId?: string) {
100
- const setDeviceParameterValues = MotionMasterMessage.Request.SetDeviceParameterValues.create({ deviceAddress, parameterValues });
101
- const id = this.sendRequest({ setDeviceParameterValues }, messageId);
102
- return this.selectMessageStatus('deviceParameterValues', id);
103
- }
104
-
105
- requestGetDeviceFileList(deviceAddress: DeviceAddressType, messageId?: string) {
106
- const getDeviceFileList = MotionMasterMessage.Request.GetDeviceFileList.create({ deviceAddress });
107
- const id = this.sendRequest({ getDeviceFileList }, messageId);
108
- return this.selectMessageStatus('deviceFileList', id);
109
- }
110
-
111
- requestGetDeviceFile(deviceAddress: DeviceAddressType, name: string, messageId?: string) {
112
- const getDeviceFile = MotionMasterMessage.Request.GetDeviceFile.create({ deviceAddress, name });
113
- const id = this.sendRequest({ getDeviceFile }, messageId);
114
- return this.selectMessageStatus('deviceFile', id);
115
- }
116
-
117
- requestSetDeviceFile(deviceAddress: DeviceAddressType, name: string, content: Uint8Array, overwrite: boolean, messageId?: string) {
118
- const setDeviceFile = MotionMasterMessage.Request.SetDeviceFile.create({ deviceAddress, name, content, overwrite });
119
- const id = this.sendRequest({ setDeviceFile }, messageId);
120
- return this.selectMessageStatus('deviceFile', id);
121
- }
122
-
123
- requestDeleteDeviceFile(deviceAddress: DeviceAddressType, name: string, messageId?: string) {
124
- const deleteDeviceFile = MotionMasterMessage.Request.DeleteDeviceFile.create({ deviceAddress, name });
125
- const id = this.sendRequest({ deleteDeviceFile }, messageId);
126
- return this.selectMessageStatus('deviceFile', id);
127
- }
128
-
129
- requestResetDeviceFault(deviceAddress: DeviceAddressType, messageId?: string) {
130
- const resetDeviceFault = MotionMasterMessage.Request.ResetDeviceFault.create({ deviceAddress });
131
- const id = this.sendRequest({ resetDeviceFault }, messageId);
132
- return this.selectMessageStatus('deviceFaultReset', id);
133
- }
134
-
135
- requestStopDevice(deviceAddress: DeviceAddressType, messageId?: string) {
136
- const stopDevice = MotionMasterMessage.Request.StopDevice.create({ deviceAddress });
137
- const id = this.sendRequest({ stopDevice }, messageId);
138
- return id;
139
- }
140
-
141
- requestStartDeviceFirmwareInstallation(deviceAddress: DeviceAddressType, firmwarePackageContent: Uint8Array, skipSiiInstallation = false, messageId?: string) {
142
- const startDeviceFirmwareInstallation = MotionMasterMessage.Request.StartDeviceFirmwareInstallation.create({ deviceAddress, firmwarePackageContent, skipSiiInstallation });
143
- const id = this.sendRequest({ startDeviceFirmwareInstallation }, messageId);
144
- return this.selectMessageStatus('deviceFirmwareInstallation', id);
145
- }
146
-
147
- requestGetDeviceLog(deviceAddress: DeviceAddressType, messageId?: string) {
148
- const getDeviceLog = MotionMasterMessage.Request.GetDeviceLog.create({ deviceAddress });
149
- const id = this.sendRequest({ getDeviceLog }, messageId);
150
- return this.selectMessageStatus('deviceLog', id);
151
- }
152
-
153
- requestStartCoggingTorqueRecording(deviceAddress: DeviceAddressType, skipAutoTuning: boolean, messageId?: string) {
154
- const startCoggingTorqueRecording = MotionMasterMessage.Request.StartCoggingTorqueRecording.create({ deviceAddress, skipAutoTuning });
155
- const id = this.sendRequest({ startCoggingTorqueRecording }, messageId);
156
- return this.selectMessageStatus('coggingTorqueRecording', id);
157
- }
158
-
159
- requestGetCoggingTorqueData(deviceAddress: DeviceAddressType, messageId?: string) {
160
- const getCoggingTorqueData = MotionMasterMessage.Request.GetCoggingTorqueData.create({ deviceAddress });
161
- const id = this.sendRequest({ getCoggingTorqueData }, messageId);
162
- return this.selectMessageStatus('coggingTorqueData', id);
163
- }
164
-
165
- requestStartOffsetDetection(deviceAddress: DeviceAddressType, messageId?: string) {
166
- const startOffsetDetection = MotionMasterMessage.Request.StartOffsetDetection.create({ deviceAddress });
167
- const id = this.sendRequest({ startOffsetDetection }, messageId);
168
- return this.selectMessageStatus('offsetDetection', id);
169
- }
170
-
171
- requestStartPlantIdentification(deviceAddress: DeviceAddressType, durationSeconds: number, torqueAmplitude: number, startFrequency: number, endFrequency: number, cutoffFrequency: number, messageId?: string) {
172
- const startPlantIdentification = MotionMasterMessage.Request.StartPlantIdentification.create({
173
- deviceAddress,
174
- durationSeconds,
175
- torqueAmplitude,
176
- startFrequency,
177
- endFrequency,
178
- cutoffFrequency,
179
- });
180
- const id = this.sendRequest({ startPlantIdentification }, messageId);
181
- return this.selectMessageStatus('plantIdentification', id);
182
- }
183
-
184
- requestComputePositionAutoTuningGains(
185
- deviceAddress: DeviceAddressType,
186
- positionParameters: MotionMasterMessage.Request.ComputeAutoTuningGains.IPositionParameters,
187
- messageId?: string,
188
- ) {
189
- const computeAutoTuningGains = MotionMasterMessage.Request.ComputeAutoTuningGains.create({ deviceAddress, positionParameters });
190
- const id = this.sendRequest({ computeAutoTuningGains }, messageId);
191
- return this.selectMessageStatus('autoTuning', id);
192
- }
193
-
194
- requestComputeVelocityAutoTuningGains(
195
- deviceAddress: DeviceAddressType,
196
- velocityParameters: MotionMasterMessage.Request.ComputeAutoTuningGains.IVelocityParameters,
197
- messageId?: string,
198
- ) {
199
- const computeAutoTuningGains = MotionMasterMessage.Request.ComputeAutoTuningGains.create({ deviceAddress, velocityParameters });
200
- const id = this.sendRequest({ computeAutoTuningGains }, messageId);
201
- return this.selectMessageStatus('autoTuning', id);
202
- }
203
-
204
- requestComputeFullAutoTuningGains(
205
- deviceAddress: DeviceAddressType,
206
- type: MotionMasterMessage.Request.ComputeFullAutoTuningGains.Type,
207
- controllerType: MotionMasterMessage.Request.ComputeAutoTuningGains.PositionParameters.ControllerType = MotionMasterMessage.Request.ComputeFullAutoTuningGains.ControllerType.UNSPECIFIED,
208
- messageId?: string,
209
- ) {
210
- const computeFullAutoTuningGains = MotionMasterMessage.Request.ComputeFullAutoTuningGains.create({ deviceAddress, type, controllerType });
211
- const id = this.sendRequest({ computeFullAutoTuningGains }, messageId);
212
- return this.selectMessageStatus('fullAutoTuning', id);
213
- }
214
-
215
- requestSetMotionControllerParameters(deviceAddress: DeviceAddressType, target: number, messageId?: string) {
216
- const setMotionControllerParameters = MotionMasterMessage.Request.SetMotionControllerParameters.create({
217
- deviceAddress,
218
- target,
219
- });
220
- const id = this.sendRequest({ setMotionControllerParameters }, messageId);
221
- return id;
222
- }
223
-
224
- requestEnableMotionController(deviceAddress: DeviceAddressType, controllerType: MotionMasterMessage.Request.EnableMotionController.ControllerType, filterValue: boolean, messageId?: string) {
225
- const enableMotionController = MotionMasterMessage.Request.EnableMotionController.create({
226
- deviceAddress,
227
- controllerType,
228
- filter: filterValue,
229
- });
230
- const id = this.sendRequest({ enableMotionController }, messageId);
231
- return this.selectMessageStatus('motionController', id);
232
- }
233
-
234
- requestDisableMotionController(deviceAddress: DeviceAddressType, messageId?: string) {
235
- const disableMotionController = MotionMasterMessage.Request.DisableMotionController.create({ deviceAddress });
236
- const id = this.sendRequest({ disableMotionController }, messageId);
237
- return this.selectMessageStatus('motionController', id);
238
- }
239
-
240
- requestSetSignalGeneratorParameters(
241
- setSignalGeneratorParameters: MotionMasterMessage.Request.ISetSignalGeneratorParameters,
242
- messageId?: string,
243
- ) {
244
- const id = this.sendRequest({ setSignalGeneratorParameters }, messageId);
245
- return id;
246
- }
247
-
248
- requestStartSignalGenerator(deviceAddress: DeviceAddressType, messageId?: string) {
249
- const startSignalGenerator = MotionMasterMessage.Request.StartSignalGenerator.create({ deviceAddress });
250
- const id = this.sendRequest({ startSignalGenerator }, messageId);
251
- return this.selectMessageStatus('signalGenerator', id);
252
- }
253
-
254
- requestStopSignalGenerator(deviceAddress: DeviceAddressType, messageId?: string) {
255
- const stopSignalGenerator = MotionMasterMessage.Request.StopSignalGenerator.create({ deviceAddress });
256
- const id = this.sendRequest({ stopSignalGenerator }, messageId);
257
- return this.selectMessageStatus('signalGenerator', id);
258
- }
259
-
260
- requestStartMonitoringDeviceParameterValues(deviceAddress: DeviceAddressType, parameters: MotionMasterMessage.Request.GetDeviceParameterValues.IParameter[], interval: number, topic: string, messageId?: string) {
261
- const getDeviceParameterValues = { deviceAddress, parameters };
262
- const startMonitoringDeviceParameterValues = MotionMasterMessage.Request.StartMonitoringDeviceParameterValues.create({ getDeviceParameterValues, interval, topic });
263
- const id = this.sendRequest({ startMonitoringDeviceParameterValues }, messageId);
264
- return this.selectMessageStatus('monitoringParameterValues', id);
265
- }
266
-
267
- requestStopMonitoringDeviceParameterValues(startMonitoringRequestId: string, messageId?: string) {
268
- const stopMonitoringDeviceParameterValues = MotionMasterMessage.Request.StopMonitoringDeviceParameterValues.create({ startMonitoringRequestId });
269
- const id = this.sendRequest({ stopMonitoringDeviceParameterValues }, messageId);
270
- return this.selectMessageStatus('monitoringParameterValues', id);
271
- }
272
-
273
- requestGetEthercatNetworkState(deviceAddress: DeviceAddressType, messageId?: string) {
274
- const getEthercatNetworkState = MotionMasterMessage.Request.GetEthercatNetworkState.create({ deviceAddress });
275
- const id = this.sendRequest({ getEthercatNetworkState }, messageId);
276
- return this.selectMessageStatus('ethercatNetworkState', id);
277
- }
278
-
279
- requestSetEthercatNetworkState(deviceAddress: DeviceAddressType, state: MotionMasterMessage.Request.SetEthercatNetworkState.State, messageId?: string) {
280
- const setEthercatNetworkState = MotionMasterMessage.Request.SetEthercatNetworkState.create({ deviceAddress, state });
281
- const id = this.sendRequest({ setEthercatNetworkState }, messageId);
282
- return this.selectMessageStatus('ethercatNetworkState', id);
283
- }
284
-
285
- requestStartNarrowAngleCalibration(deviceAddress: DeviceAddressType, messageId?: string) {
286
- const startNarrowAngleCalibration = MotionMasterMessage.Request.StartNarrowAngleCalibration.create({ deviceAddress });
287
- const id = this.sendRequest({ startNarrowAngleCalibration }, messageId);
288
- return this.selectMessageStatus('narrowAngleCalibration', id);
289
- }
290
-
291
- requestSetSystemClientTimeout(timeoutMs: number, messageId?: string) {
292
- const setSystemClientTimeout = MotionMasterMessage.Request.SetSystemClientTimeout.create({ timeoutMs });
293
- const id = this.sendRequest({ setSystemClientTimeout }, messageId);
294
- return id;
295
- }
296
-
297
- requestStartSystemIdentification(deviceAddress: DeviceAddressType, durationSeconds: number, torqueAmplitude: number, startFrequency: number, endFrequency: number, messageId?: string) {
298
- const startSystemIdentification = MotionMasterMessage.Request.StartSystemIdentification.create({
299
- deviceAddress,
300
- durationSeconds,
301
- torqueAmplitude,
302
- startFrequency,
303
- endFrequency,
304
- });
305
- const id = this.sendRequest({ startSystemIdentification }, messageId);
306
- return this.selectMessageStatus('systemIdentification', id);
307
- }
308
-
309
- requestGetCirculoEncoderMagnetDistance(deviceAddress: DeviceAddressType, encoderOrdinal: number, ringRevision: number, messageId?: string) {
310
- const getCirculoEncoderMagnetDistance = MotionMasterMessage.Request.GetCirculoEncoderMagnetDistance.create({
311
- deviceAddress,
312
- encoderOrdinal,
313
- ringRevision,
314
- });
315
- const id = this.sendRequest({ getCirculoEncoderMagnetDistance }, messageId);
316
- return this.selectMessageStatus('circuloEncoderMagnetDistance', id);
317
- }
318
-
319
- requestStartCirculoEncoderNarrowAngleCalibrationProcedure(deviceAddress: DeviceAddressType, encoderOrdinal: number, messageId?: string) {
320
- const startCirculoEncoderNarrowAngleCalibrationProcedure = MotionMasterMessage.Request.StartCirculoEncoderNarrowAngleCalibrationProcedure.create({
321
- deviceAddress,
322
- encoderOrdinal,
323
- });
324
- const id = this.sendRequest({ startCirculoEncoderNarrowAngleCalibrationProcedure }, messageId);
325
- return this.selectMessageStatus('circuloEncoderNarrowAngleCalibrationProcedure', id);
326
- }
327
-
328
- requestGetDeviceCia402State(deviceAddress: DeviceAddressType, messageId?: string) {
329
- const getDeviceCia402State = MotionMasterMessage.Request.GetDeviceCiA402State.create({ deviceAddress });
330
- const id = this.sendRequest({ getDeviceCia402State }, messageId);
331
- return this.selectMessageStatus('deviceCia402State', id);
332
- }
333
-
334
- requestSetDeviceCia402State(deviceAddress: DeviceAddressType, state: MotionMasterMessage.Status.DeviceCiA402State.State, messageId?: string) {
335
- const setDeviceCia402State = MotionMasterMessage.Request.SetDeviceCiA402State.create({ deviceAddress, state });
336
- const id = this.sendRequest({ setDeviceCia402State }, messageId);
337
- return this.selectMessageStatus('deviceCia402State', id);
338
- }
339
-
340
- requestGetSystemLog(messageId?: string) {
341
- const getSystemLog = MotionMasterMessage.Request.GetSystemLog.create({});
342
- const id = this.sendRequest({ getSystemLog }, messageId);
343
- return this.selectMessageStatus('systemLog', id);
344
- }
345
-
346
- requestStartDeviceSiiRestore(devicePosition: number, siiContent: Uint8Array, messageId?: string) {
347
- const startDeviceSiiRestore = MotionMasterMessage.Request.StartDeviceSiiRestore.create({
348
- devicePosition,
349
- siiContent,
350
- });
351
- const id = this.sendRequest({ startDeviceSiiRestore }, messageId);
352
- return this.selectMessageStatus('deviceSiiRestore', id);
353
- }
354
-
355
- requestStartOpenLoopFieldControl(properties: MotionMasterMessage.Request.IStartOpenLoopFieldControl, messageId?: string) {
356
- const startOpenLoopFieldControl = MotionMasterMessage.Request.StartOpenLoopFieldControl.create(properties);
357
- const id = this.sendRequest({ startOpenLoopFieldControl }, messageId);
358
- return this.selectMessageStatus('openLoopFieldControl', id);
359
- }
360
-
361
- requestStartFullAutoTuning(
362
- deviceAddress: DeviceAddressType,
363
- type: MotionMasterMessage.Request.StartFullAutoTuning.Type,
364
- controllerType: MotionMasterMessage.Request.ComputeAutoTuningGains.PositionParameters.ControllerType = MotionMasterMessage.Request.StartFullAutoTuning.ControllerType.UNSPECIFIED,
365
- messageId?: string,
366
- ) {
367
- const startFullAutoTuning = MotionMasterMessage.Request.StartFullAutoTuning.create({ deviceAddress, type, controllerType });
368
- const id = this.sendRequest({ startFullAutoTuning }, messageId);
369
- return this.selectMessageStatus('fullAutoTuning', id);
370
- }
371
-
372
- requestStopFullAutoTuning(deviceAddress: DeviceAddressType, messageId?: string) {
373
- const stopFullAutoTuning = MotionMasterMessage.Request.StopFullAutoTuning.create({ deviceAddress });
374
- const id = this.sendRequest({ stopFullAutoTuning }, messageId);
375
- return this.selectMessageStatus('fullAutoTuning', id);
376
- }
377
-
378
- requestStartCirculoEncoderConfiguration(deviceAddress: DeviceAddressType, encoderOrdinal: number, messageId?: string) {
379
- const startCirculoEncoderConfiguration = MotionMasterMessage.Request.StartCirculoEncoderConfiguration.create({ deviceAddress, encoderOrdinal });
380
- const id = this.sendRequest({ startCirculoEncoderConfiguration }, messageId);
381
- return this.selectMessageStatus('circuloEncoderConfiguration', id);
382
- }
383
-
384
- requestStopCirculoEncoderNarrowAngleCalibrationProcedure(deviceAddress: DeviceAddressType, encoderOrdinal: number, messageId?: string) {
385
- const stopCirculoEncoderNarrowAngleCalibrationProcedure = MotionMasterMessage.Request.StopCirculoEncoderNarrowAngleCalibrationProcedure.create({ deviceAddress, encoderOrdinal });
386
- const id = this.sendRequest({ stopCirculoEncoderNarrowAngleCalibrationProcedure }, messageId);
387
- return this.selectMessageStatus('circuloEncoderNarrowAngleCalibrationProcedure', id);
388
- }
389
-
390
- requestStartOsCommand(deviceAddress: DeviceAddressType, timeoutMs: number, command: Uint8Array, messageId?: string) {
391
- const startOsCommand = MotionMasterMessage.Request.StartOsCommand.create({ command, deviceAddress, timeoutMs });
392
- const id = this.sendRequest({ startOsCommand }, messageId);
393
- return this.selectMessageStatus('osCommand', id);
394
- }
395
-
396
- /**
397
- * Select device at position in EtherCAT chain. This function makes an initial request to fetch a list of devices.
398
- * @param position device position in EtherCAT chain
399
- * @returns an observable of device messages
400
- */
401
- selectDeviceAtPosition(position: number) {
402
- return this.requestGetDeviceInfo().pipe(
403
- first(),
404
- map((deviceInfo: MotionMasterMessage.Status.IDeviceInfo) => {
405
- if (deviceInfo.devices) {
406
- return deviceInfo.devices.find((device) => device.position === position);
407
- } else {
408
- return null;
409
- }
410
- }),
411
- );
412
- }
413
-
414
- /**
415
- * Select incoming messages by id.
416
- *
417
- * This function filters messages by id as there can be multiple messages coming in for a single request,
418
- * e.g. startOffsetDetection → started → progress → done. Ensure that you unsubscribe or use `takeWhile` operator.
419
- *
420
- * @param messageId
421
- * @returns an observable of motion master messages
422
- */
423
- selectMessage(messageId: string) {
424
- return this.input$.pipe(
425
- filter((message) => message.id === messageId),
426
- );
427
- }
428
-
429
- /**
430
- * Select incoming messages by id (optionally) and get their status response.
431
- *
432
- * This function filters messages by id as there can be multiple messages coming in for a single request,
433
- * e.g. startOffsetDetection → started → progress → done. Ensure that you unsubscribe or use `takeWhile` operator.
434
- *
435
- * @param messageId
436
- * @param type of status message received as a response
437
- */
438
- selectMessageStatus<T extends StatusType>(type: T, messageId?: string): StatusTypeObservable<T> {
439
- const message$ = messageId === undefined
440
- ? this.input$
441
- : this.input$.pipe(
442
- filter((message) => message.id === messageId),
443
- );
444
-
445
- // we expect Status to be ALWAYS defined on input message
446
- const status$ = message$.pipe(map((message) => message.status)) as Observable<MotionMasterMessage.Status>;
447
- return status$.pipe(map((status) => status[type])) as any;
448
- }
449
-
450
- /**
451
- * Send Request message to output.
452
- * @param request proto message
453
- * @param [messageId] identifies request, if no messageId is provided one is generated with uuid v4 and returned
454
- * @returns passed or generated messageId
455
- */
456
- sendRequest(request: MotionMasterMessage.IRequest, messageId?: string) {
457
- const id = messageId || v4();
458
- const message = MotionMasterMessage.create({ request, id });
459
- this.output$.next(message);
460
- return id;
461
- }
462
-
463
- sendMessage(message: IMotionMasterMessage) {
464
- this.output$.next(message);
465
- return message.id;
466
- }
467
-
468
- }
@@ -1,7 +0,0 @@
1
- export interface IMotionMasterNotificationSubscribeData {
2
- bufferSize?: number;
3
- distinct?: boolean;
4
- id?: string;
5
- topic: string;
6
- monitoringTimeoutDue?: number;
7
- }