motion-master-client 0.0.21 → 0.0.22

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 (126) hide show
  1. package/.babelrc +3 -0
  2. package/.eslintrc.json +18 -0
  3. package/jest.config.ts +16 -0
  4. package/motion-master.proto +1822 -0
  5. package/package.json +2 -17
  6. package/project.json +45 -0
  7. package/src/lib/cia402.spec.ts +77 -0
  8. package/src/lib/cia402.ts +414 -0
  9. package/src/lib/config-file.spec.ts +114 -0
  10. package/src/lib/config-file.ts +63 -0
  11. package/src/lib/device-log-line.ts +5 -0
  12. package/src/lib/device-parameter.spec.ts +85 -0
  13. package/src/lib/device-parameter.ts +79 -0
  14. package/src/lib/device.ts +10 -0
  15. package/src/lib/hardware-description.spec.ts +253 -0
  16. package/src/lib/hardware-description.ts +129 -0
  17. package/src/lib/logger.ts +5 -0
  18. package/src/lib/monitoring-config.ts +6 -0
  19. package/src/lib/{monitoring-entry.d.ts → monitoring-entry.ts} +5 -4
  20. package/src/lib/motion-master-client.ts +221 -0
  21. package/src/lib/motion-master-pub-sub-client.ts +95 -0
  22. package/src/lib/motion-master-pub-sub-socket.ts +40 -0
  23. package/src/lib/motion-master-pub-sub-web-socket.ts +78 -0
  24. package/src/lib/motion-master-pub-sub-worker-socket.ts +51 -0
  25. package/src/lib/motion-master-req-res-client.spec.ts +740 -0
  26. package/src/lib/motion-master-req-res-client.ts +2120 -0
  27. package/src/lib/motion-master-req-res-socket.ts +62 -0
  28. package/src/lib/motion-master-req-res-web-socket.ts +124 -0
  29. package/src/lib/motion-master-req-res-worker-socket.ts +87 -0
  30. package/src/lib/motion-master.proto.js +2 -2
  31. package/src/lib/operators.ts +90 -0
  32. package/src/lib/options.ts +12 -0
  33. package/src/lib/parameter.spec.ts +160 -0
  34. package/src/lib/parameter.ts +170 -0
  35. package/src/lib/product-id-range.ts +8 -0
  36. package/src/lib/request-status-resolver.ts +403 -0
  37. package/src/lib/system-log-line.ts +9 -0
  38. package/src/lib/{types.d.ts → types.ts} +74 -143
  39. package/src/lib/urls.ts +6 -0
  40. package/src/lib/util.ts +305 -0
  41. package/tsconfig.json +23 -0
  42. package/tsconfig.lib.json +10 -0
  43. package/tsconfig.spec.json +20 -0
  44. package/typedoc.json +10 -0
  45. package/src/index.js +0 -29
  46. package/src/index.js.map +0 -1
  47. package/src/lib/cia402.d.ts +0 -182
  48. package/src/lib/cia402.js +0 -392
  49. package/src/lib/cia402.js.map +0 -1
  50. package/src/lib/config-file.d.ts +0 -13
  51. package/src/lib/config-file.js +0 -50
  52. package/src/lib/config-file.js.map +0 -1
  53. package/src/lib/device-log-line.d.ts +0 -5
  54. package/src/lib/device-log-line.js +0 -3
  55. package/src/lib/device-log-line.js.map +0 -1
  56. package/src/lib/device-parameter.d.ts +0 -56
  57. package/src/lib/device-parameter.js +0 -39
  58. package/src/lib/device-parameter.js.map +0 -1
  59. package/src/lib/device.d.ts +0 -9
  60. package/src/lib/device.js +0 -3
  61. package/src/lib/device.js.map +0 -1
  62. package/src/lib/hardware-description.d.ts +0 -41
  63. package/src/lib/hardware-description.js +0 -94
  64. package/src/lib/hardware-description.js.map +0 -1
  65. package/src/lib/logger.d.ts +0 -1
  66. package/src/lib/logger.js +0 -8
  67. package/src/lib/logger.js.map +0 -1
  68. package/src/lib/monitoring-config.d.ts +0 -6
  69. package/src/lib/monitoring-config.js +0 -3
  70. package/src/lib/monitoring-config.js.map +0 -1
  71. package/src/lib/monitoring-entry.js +0 -3
  72. package/src/lib/monitoring-entry.js.map +0 -1
  73. package/src/lib/motion-master-client.d.ts +0 -52
  74. package/src/lib/motion-master-client.js +0 -151
  75. package/src/lib/motion-master-client.js.map +0 -1
  76. package/src/lib/motion-master-pub-sub-client.d.ts +0 -16
  77. package/src/lib/motion-master-pub-sub-client.js +0 -68
  78. package/src/lib/motion-master-pub-sub-client.js.map +0 -1
  79. package/src/lib/motion-master-pub-sub-socket.d.ts +0 -34
  80. package/src/lib/motion-master-pub-sub-socket.js +0 -3
  81. package/src/lib/motion-master-pub-sub-socket.js.map +0 -1
  82. package/src/lib/motion-master-pub-sub-web-socket.d.ts +0 -14
  83. package/src/lib/motion-master-pub-sub-web-socket.js +0 -67
  84. package/src/lib/motion-master-pub-sub-web-socket.js.map +0 -1
  85. package/src/lib/motion-master-pub-sub-worker-socket.d.ts +0 -14
  86. package/src/lib/motion-master-pub-sub-worker-socket.js +0 -42
  87. package/src/lib/motion-master-pub-sub-worker-socket.js.map +0 -1
  88. package/src/lib/motion-master-req-res-client.d.ts +0 -920
  89. package/src/lib/motion-master-req-res-client.js +0 -1680
  90. package/src/lib/motion-master-req-res-client.js.map +0 -1
  91. package/src/lib/motion-master-req-res-socket.d.ts +0 -52
  92. package/src/lib/motion-master-req-res-socket.js +0 -3
  93. package/src/lib/motion-master-req-res-socket.js.map +0 -1
  94. package/src/lib/motion-master-req-res-web-socket.d.ts +0 -24
  95. package/src/lib/motion-master-req-res-web-socket.js +0 -99
  96. package/src/lib/motion-master-req-res-web-socket.js.map +0 -1
  97. package/src/lib/motion-master-req-res-worker-socket.d.ts +0 -20
  98. package/src/lib/motion-master-req-res-worker-socket.js +0 -69
  99. package/src/lib/motion-master-req-res-worker-socket.js.map +0 -1
  100. package/src/lib/operators.d.ts +0 -18
  101. package/src/lib/operators.js +0 -76
  102. package/src/lib/operators.js.map +0 -1
  103. package/src/lib/options.d.ts +0 -10
  104. package/src/lib/options.js +0 -14
  105. package/src/lib/options.js.map +0 -1
  106. package/src/lib/parameter.d.ts +0 -72
  107. package/src/lib/parameter.js +0 -119
  108. package/src/lib/parameter.js.map +0 -1
  109. package/src/lib/product-id-range.d.ts +0 -7
  110. package/src/lib/product-id-range.js +0 -12
  111. package/src/lib/product-id-range.js.map +0 -1
  112. package/src/lib/request-status-resolver.d.ts +0 -4
  113. package/src/lib/request-status-resolver.js +0 -345
  114. package/src/lib/request-status-resolver.js.map +0 -1
  115. package/src/lib/system-log-line.d.ts +0 -9
  116. package/src/lib/system-log-line.js +0 -3
  117. package/src/lib/system-log-line.js.map +0 -1
  118. package/src/lib/types.js +0 -28
  119. package/src/lib/types.js.map +0 -1
  120. package/src/lib/urls.d.ts +0 -3
  121. package/src/lib/urls.js +0 -10
  122. package/src/lib/urls.js.map +0 -1
  123. package/src/lib/util.d.ts +0 -40
  124. package/src/lib/util.js +0 -316
  125. package/src/lib/util.js.map +0 -1
  126. /package/src/{index.d.ts → index.ts} +0 -0
@@ -0,0 +1,170 @@
1
+ import { MotionMasterMessage, ParameterTypeValueKey, ParameterValueType } from "./types";
2
+ import { differenceWith, intersectionWith, round } from "lodash";
3
+
4
+ export interface Parameter extends MotionMasterMessage.Status.DeviceParameterInfo.IParameter, MotionMasterMessage.Status.DeviceParameterValues.IParameterValue {
5
+ index: number;
6
+ subindex: number;
7
+ name: string;
8
+ value: ParameterValueType;
9
+ typeValue: ParameterTypeValueKey;
10
+ options?: { [key: string]: number };
11
+ }
12
+
13
+ export type ParameterIndexSubindex = Pick<Parameter, 'index' | 'subindex'>;
14
+
15
+ /**
16
+ * Make parameter id by providing a tuple of index and subindex.
17
+ *
18
+ * @param tuple - an array of index and subindex
19
+ * @throws {Error} if index or subindex are less than 0
20
+ * @returns combined index and subindex in uppercase hexadecimal format, e.g. "0x60FE:02"
21
+ */
22
+ export function makeParameterId(tuple: [(number | null | undefined), (number | null | undefined)]): string;
23
+
24
+ /**
25
+ * Make parameter id by providing an object which has index and subindex properties.
26
+ *
27
+ * @param parameter - an object with optional index and subindex properties
28
+ * @throws {Error} if index or subindex are less than 0
29
+ * @returns combined index and subindex in uppercase hexadecimal format, e.g. "0x60FE:02"
30
+ */
31
+ export function makeParameterId(parameter: { index?: (number | null), subindex?: (number | null) }): string;
32
+
33
+ /**
34
+ * Make parameter id by providing index and subindex.
35
+ *
36
+ * @param index - from 0x0000 to 0xFFFF for objects defined in ESI and >0xFFFF for custom object
37
+ * @param subindex - defaults to 0 if not provided
38
+ * @throws {Error} if index or subindex are less than 0
39
+ * @returns combined index and subindex in uppercase hexadecimal format, e.g. "0x60FE:02"
40
+ */
41
+ export function makeParameterId(index?: (number | null), subindex?: (number | null)): string;
42
+
43
+ /**
44
+ * Make parameter id by providing different arguments.
45
+ *
46
+ * The purpose of this declaration is to expose the signature of the implementation for {@link makeDeviceParameterId} function.
47
+ *
48
+ * @param a - number or an object with index and subindex or tuple of index and subindex
49
+ * @param b - optional subindex, defaults to 0 if not provided
50
+ * @throws {Error} if index or subindex are less than 0
51
+ * @returns combined index and subindex in uppercase hexadecimal format, e.g. "0x60FE:02"
52
+ */
53
+ export function makeParameterId(a?: (number | null) | { index?: (number | null), subindex?: (number | null) } | [(number | null | undefined), (number | null | undefined)], b?: (number | null)): string;
54
+
55
+ export function makeParameterId(a?: (number | null) | { index?: (number | null), subindex?: (number | null) } | [(number | null | undefined), (number | null | undefined)], b?: (number | null)): string {
56
+ let index = 0;
57
+ let subindex = 0;
58
+
59
+ if (Array.isArray(a)) {
60
+ if (a[0]) {
61
+ index = a[0];
62
+ }
63
+ if (a[1]) {
64
+ subindex = a[1];
65
+ }
66
+ } else if (typeof a === 'object') {
67
+ if (a?.index) {
68
+ index = a.index;
69
+ }
70
+ if (a?.subindex) {
71
+ subindex = a.subindex;
72
+ }
73
+ } else {
74
+ if (typeof a === 'number') {
75
+ index = a;
76
+ }
77
+ if (typeof b === 'number') {
78
+ subindex = b;
79
+ }
80
+ }
81
+
82
+ if (index < 0) {
83
+ throw new Error(`The provided index to makeParameterId must be greater than 0: ${index}`);
84
+ }
85
+
86
+ if (subindex < 0) {
87
+ throw new Error(`The provided subindex to makeParameterId must be greater than 0: ${subindex}`);
88
+ }
89
+
90
+ const indexMaxLength = index > 0xFFFF ? 8 : 4;
91
+ const x = index.toString(16).toUpperCase().padStart(indexMaxLength, '0');
92
+ const y = subindex.toString(16).toUpperCase().padStart(2, '0');
93
+
94
+ return `0x${x}:${y}`;
95
+ }
96
+
97
+ /**
98
+ * Example of parameter id is "0x2110:1A" where:
99
+ * - 0x2110 is object index in hexadecimal format
100
+ * - 1A is subindex in hexadecimal format
101
+ */
102
+ export const parameterIdRegExp = /^0x([0-9a-fA-F]{4,}):([0-9a-fA-F]{2})$/;
103
+
104
+ /**
105
+ * Split device parameter id into parts.
106
+ *
107
+ * @param id - parameter id like "0x2110:1A"
108
+ * @returns tuple of index and subindex
109
+ */
110
+ export function splitParameterId(id: string): [number, number] {
111
+ const match = id.match(parameterIdRegExp);
112
+
113
+ if (!match) {
114
+ throw new Error(`Parameter id "${id}" doesn't match the regular expression: ${parameterIdRegExp}`);
115
+ }
116
+
117
+ return [
118
+ parseInt(match[1], 16), // index
119
+ parseInt(match[2], 16), // subindex
120
+ ];
121
+ }
122
+
123
+ export function isParameterId(id: string): boolean {
124
+ return parameterIdRegExp.test(id);
125
+ }
126
+
127
+ export function parametersCompareFn(
128
+ a: Pick<Parameter, 'index' | 'subindex'>,
129
+ b: Pick<Parameter, 'index' | 'subindex'>,
130
+ ): number {
131
+ if (a.index > b.index) {
132
+ return 1;
133
+ } else if (a.index < b.index) {
134
+ return -1;
135
+ } else {
136
+ if (a.subindex > b.subindex) {
137
+ return 1;
138
+ } else if (a.subindex < b.subindex) {
139
+ return -1;
140
+ } else {
141
+ return 0;
142
+ }
143
+ }
144
+ }
145
+
146
+ export function differenceParameters<T extends Pick<Parameter, 'index' | 'subindex'>>(p1: T[], p2: T[]): T[] {
147
+ return differenceWith(p1, p2, (a, b) => a.index === b.index && a.subindex === b.subindex);
148
+ }
149
+
150
+ export function intersectionParameters<T extends Pick<Parameter, 'index' | 'subindex'>>(p1: T[], p2: T[]): T[] {
151
+ return intersectionWith(p1, p2, (a, b) => a.index === b.index && a.subindex === b.subindex);
152
+ }
153
+
154
+ export function intersectionParametersWithDifferentValues<T extends Pick<Parameter, 'index' | 'subindex' | 'value'>>(p1: T[], p2: T[], roundFloats = false): T[] {
155
+ return intersectionWith(p1, p2, (a, b) => {
156
+ if (a.index === b.index && a.subindex === b.subindex) {
157
+ // values that are very close but have a different number of decimal places are treated as not equal
158
+ if (roundFloats && typeof a.value === 'number' && typeof b.value === 'number') {
159
+ const v1 = round(a.value, 7);
160
+ const v2 = round(b.value, 7);
161
+ return v1 !== v2;
162
+ } else if (Array.isArray(a.value) && Array.isArray(b.value)) {
163
+ return JSON.stringify(a.value) !== JSON.stringify(b.value);
164
+ } else {
165
+ return a.value !== b.value;
166
+ }
167
+ }
168
+ return false;
169
+ });
170
+ }
@@ -0,0 +1,8 @@
1
+ // https://docs.google.com/spreadsheets/d/1XJX1eqGau1X3sse10fuF-tVVgosbxCo-3ioUUG2CDYQ
2
+ export const productIdRange = {
3
+ 'CIRCULO_SAFE_MOTION': [8600, 8699],
4
+ 'INTEGRO': [9000, 9499],
5
+ 'NODE': [9500, 9599],
6
+ 'NODE_SAFETY': [9600, 9998],
7
+ 'INTERNAL': [9999, 9999],
8
+ };
@@ -0,0 +1,403 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-nocheck
3
+
4
+ import { MotionMasterMessage, RequestStatus, StatusKey } from "./types";
5
+
6
+ export const requestStatusResolver: { [key in StatusKey]: <T>(status: T) => RequestStatus } = {
7
+ systemPong: () => 'succeeded',
8
+ systemVersion: (status: MotionMasterMessage.Status.ISystemVersion) => {
9
+ return status.version ? 'succeeded' : 'failed';
10
+ },
11
+ systemEvent: (status: MotionMasterMessage.Status.ISystemEvent) => {
12
+ if (status.error) {
13
+ return 'failed';
14
+ }
15
+
16
+ return 'succeeded';
17
+ },
18
+ deviceInfo: (status: MotionMasterMessage.Status.IDeviceInfo) => {
19
+ return status.devices ? 'succeeded' : 'failed';
20
+ },
21
+ deviceParameterInfo: (status: MotionMasterMessage.Status.IDeviceParameterInfo) => {
22
+ return status.parameters ? 'succeeded' : 'failed';
23
+ },
24
+ deviceParameterValues: (status: MotionMasterMessage.Status.IDeviceParameterValues) => {
25
+ if (status.progress) {
26
+ if (status.progress.percentage === 100) {
27
+ return 'succeeded';
28
+ } else {
29
+ return 'running';
30
+ }
31
+ }
32
+
33
+ if (status.parameterValues) {
34
+ const allSucceeded = status.parameterValues.every((value) => value.success);
35
+ if (allSucceeded) {
36
+ return 'succeeded';
37
+ }
38
+ }
39
+
40
+ return 'failed';
41
+ },
42
+ multiDeviceParameterValues: (status: MotionMasterMessage.Status.IMultiDeviceParameterValues) => {
43
+ if (status.collection) {
44
+ const items = status.collection.flat();
45
+ const allSucceeded = items.every((item) => item.parameterValues?.every(value => value.success));
46
+ if (allSucceeded) {
47
+ return 'succeeded';
48
+ }
49
+
50
+ if (items.every(item => item.progress === 100)) {
51
+ return 'succeeded';
52
+ } else {
53
+ return 'running';
54
+ };
55
+ }
56
+
57
+ return 'failed';
58
+ },
59
+ deviceFileList: (status: MotionMasterMessage.Status.IDeviceFileList) => {
60
+ if (status.error) {
61
+ return 'failed';
62
+ }
63
+
64
+ return 'succeeded';
65
+ },
66
+ deviceFile: (status: MotionMasterMessage.Status.IDeviceFile) => {
67
+ if (status.error) {
68
+ return 'failed';
69
+ }
70
+
71
+ return 'succeeded';
72
+ },
73
+ deviceEvent: (status: MotionMasterMessage.Status.IDeviceEvent) => {
74
+ if (status.error) {
75
+ return 'failed';
76
+ }
77
+
78
+ return 'succeeded';
79
+ },
80
+ deviceFirmwareInstallation: (status: MotionMasterMessage.Status.IDeviceFirmwareInstallation) => {
81
+ if (status.error) {
82
+ return 'failed';
83
+ }
84
+
85
+ if (status.success) {
86
+ if (status.success.code === MotionMasterMessage.Status.DeviceFirmwareInstallation.Success.Code.DONE) {
87
+ return 'succeeded';
88
+ }
89
+
90
+ if (status.success.code === MotionMasterMessage.Status.DeviceFirmwareInstallation.Success.Code.UNSPECIFIED) {
91
+ return 'succeeded';
92
+ }
93
+ }
94
+
95
+ return 'running';
96
+ },
97
+ deviceLog: (status: MotionMasterMessage.Status.IDeviceLog) => {
98
+ if (status.error) {
99
+ return 'failed';
100
+ }
101
+
102
+ return 'succeeded';
103
+ },
104
+ deviceFaultReset: (status: MotionMasterMessage.Status.IDeviceFaultReset) => {
105
+ if (status.error) {
106
+ return 'failed';
107
+ }
108
+
109
+ return 'succeeded';
110
+ },
111
+ coggingTorqueRecording: (status: MotionMasterMessage.Status.ICoggingTorqueRecording) => {
112
+ if (status.error) {
113
+ return 'failed';
114
+ }
115
+
116
+ if (status.success) {
117
+ if (status.success.code === MotionMasterMessage.Status.CoggingTorqueRecording.Success.Code.DONE) {
118
+ return 'succeeded';
119
+ }
120
+
121
+ if (status.success.code === MotionMasterMessage.Status.CoggingTorqueRecording.Success.Code.UNSPECIFIED) {
122
+ return 'succeeded';
123
+ }
124
+ }
125
+
126
+ return 'running';
127
+ },
128
+ coggingTorqueData: (status: MotionMasterMessage.Status.ICoggingTorqueData) => {
129
+ if (status.error) {
130
+ return 'failed';
131
+ }
132
+
133
+ return 'succeeded';
134
+ },
135
+ offsetDetection: (status: MotionMasterMessage.Status.IOffsetDetection) => {
136
+ if (status.error) {
137
+ return 'failed';
138
+ }
139
+
140
+ if (status.success) {
141
+ if (status.success.code === MotionMasterMessage.Status.OffsetDetection.Success.Code.DONE) {
142
+ return 'succeeded';
143
+ }
144
+
145
+ if (status.success.code === MotionMasterMessage.Status.OffsetDetection.Success.Code.UNSPECIFIED) {
146
+ return 'succeeded';
147
+ }
148
+ }
149
+
150
+ return 'running';
151
+ },
152
+ plantIdentification: (status: MotionMasterMessage.Status.IPlantIdentification) => {
153
+ if (status.error) {
154
+ return 'failed';
155
+ }
156
+
157
+ if (status.success) {
158
+ if (status.success.code === MotionMasterMessage.Status.PlantIdentification.Success.Code.DONE) {
159
+ return 'succeeded';
160
+ }
161
+
162
+ if (status.success.code === MotionMasterMessage.Status.PlantIdentification.Success.Code.UNSPECIFIED) {
163
+ return 'succeeded';
164
+ }
165
+ }
166
+
167
+ return 'running';
168
+ },
169
+ autoTuning: (status: MotionMasterMessage.Status.IAutoTuning) => {
170
+ if (status.error) {
171
+ return 'failed';
172
+ }
173
+
174
+ if (status.success) {
175
+ if (status.success.code === MotionMasterMessage.Status.AutoTuning.Success.Code.POSITION_DONE ||
176
+ status.success.code === MotionMasterMessage.Status.AutoTuning.Success.Code.VELOCITY_DONE) {
177
+ return 'succeeded';
178
+ }
179
+
180
+ if (status.success === MotionMasterMessage.Status.AutoTuning.Success.Code.UNSPECIFIED) {
181
+ return 'succeeded';
182
+ }
183
+ }
184
+
185
+ return 'running';
186
+ },
187
+ motionController: (status: MotionMasterMessage.Status.IMotionController) => {
188
+ if (status.error) {
189
+ return 'failed';
190
+ }
191
+
192
+ return 'succeeded';
193
+ },
194
+ signalGenerator: (status: MotionMasterMessage.Status.ISignalGenerator) => {
195
+ if (status.error) {
196
+ return 'failed';
197
+ }
198
+
199
+ if (status.success) {
200
+ if (status.success.code === MotionMasterMessage.Status.SignalGenerator.Success.Code.DONE) {
201
+ return 'succeeded';
202
+ }
203
+
204
+ if (status.success.code === MotionMasterMessage.Status.SignalGenerator.Success.Code.PARAMETERS_SET) {
205
+ return 'succeeded';
206
+ }
207
+
208
+ if (status.success.code === MotionMasterMessage.Status.SignalGenerator.Success.Code.UNSPECIFIED) {
209
+ return 'succeeded';
210
+ }
211
+ }
212
+
213
+ return 'running';
214
+ },
215
+ monitoringParameterValues: (status: MotionMasterMessage.Status.IMonitoringParameterValues) => {
216
+ if (status.error) {
217
+ return 'failed';
218
+ }
219
+
220
+ return 'succeeded';
221
+ },
222
+ deviceStop: (status: MotionMasterMessage.Status.IDeviceStop) => {
223
+ if (status.error) {
224
+ return 'failed';
225
+ }
226
+
227
+ return 'succeeded';
228
+ },
229
+ ethercatNetworkState: (status: MotionMasterMessage.Status.IEthercatNetworkState) => {
230
+ if (status.error) {
231
+ return 'failed';
232
+ }
233
+
234
+ return 'succeeded';
235
+ },
236
+ narrowAngleCalibration: (status: MotionMasterMessage.Status.INarrowAngleCalibration) => {
237
+ if (status.error) {
238
+ return 'failed';
239
+ }
240
+
241
+ if (status.success) {
242
+ if (status.success.code === MotionMasterMessage.Status.NarrowAngleCalibration.Success.Code.DONE) {
243
+ return 'succeeded';
244
+ }
245
+
246
+ if (status.success.code === MotionMasterMessage.Status.NarrowAngleCalibration.Success.Code.UNSPECIFIED) {
247
+ return 'succeeded';
248
+ }
249
+ }
250
+
251
+ return 'running';
252
+ },
253
+ systemIdentification: (status: MotionMasterMessage.Status.ISystemIdentification) => {
254
+ if (status.error) {
255
+ return 'failed';
256
+ }
257
+
258
+ if (status.success) {
259
+ if (status.success.code === MotionMasterMessage.Status.SystemIdentification.Success.Code.DONE) {
260
+ return 'succeeded';
261
+ }
262
+
263
+ if (status.success.code === MotionMasterMessage.Status.SystemIdentification.Success.Code.UNSPECIFIED) {
264
+ return 'succeeded';
265
+ }
266
+ }
267
+
268
+ return 'running';
269
+ },
270
+ circuloEncoderMagnetDistance: (status: MotionMasterMessage.Status.ICirculoEncoderMagnetDistance) => {
271
+ if (typeof status.distance === 'number' || typeof status.position === 'number') {
272
+ return 'succeeded';
273
+ }
274
+
275
+ return 'failed';
276
+ },
277
+ circuloEncoderNarrowAngleCalibrationProcedure: (status: MotionMasterMessage.Status.ICirculoEncoderNarrowAngleCalibrationProcedure) => {
278
+ if (status.error) {
279
+ return 'failed';
280
+ }
281
+
282
+ if (status.success) {
283
+ if (status.success.code === MotionMasterMessage.Status.CirculoEncoderNarrowAngleCalibrationProcedure.Success.Code.STOPPED) {
284
+ return 'failed';
285
+ }
286
+
287
+ if (status.success.code === MotionMasterMessage.Status.CirculoEncoderNarrowAngleCalibrationProcedure.Success.Code.DONE) {
288
+ return 'succeeded';
289
+ }
290
+
291
+ if (status.success === MotionMasterMessage.Status.CirculoEncoderNarrowAngleCalibrationProcedure.Success.Code.UNSPECIFIED) {
292
+ return 'succeeded';
293
+ }
294
+ }
295
+
296
+ return 'running';
297
+ },
298
+ deviceCia402State: (status: MotionMasterMessage.Status.IDeviceCiA402State) => {
299
+ if (status.error) {
300
+ return 'failed';
301
+ }
302
+
303
+ return 'succeeded';
304
+ },
305
+ systemLog: (status: MotionMasterMessage.Status.ISystemLog) => {
306
+ if (status.content) {
307
+ return 'succeeded';
308
+ }
309
+
310
+ return 'failed';
311
+ },
312
+ deviceSiiRestore: (status: MotionMasterMessage.Status.IDeviceSiiRestore) => {
313
+ if (status.error) {
314
+ return 'failed';
315
+ }
316
+
317
+ if (status.success) {
318
+ if (status.success.code === MotionMasterMessage.Status.DeviceSiiRestore.Success.Code.DONE) {
319
+ return 'succeeded';
320
+ }
321
+
322
+ if (status.success.code === MotionMasterMessage.Status.DeviceSiiRestore.Success.Code.UNSPECIFIED) {
323
+ return 'succeeded';
324
+ }
325
+ }
326
+
327
+ return 'running';
328
+ },
329
+ openLoopFieldControl: (status: MotionMasterMessage.Status.IOpenLoopFieldControl) => {
330
+ if (status.error) {
331
+ return 'failed';
332
+ }
333
+
334
+ if (status.success) {
335
+ if (status.success.code === MotionMasterMessage.Status.OpenLoopFieldControl.Success.Code.DONE) {
336
+ return 'succeeded';
337
+ }
338
+
339
+ if (status.success.code === MotionMasterMessage.Status.OpenLoopFieldControl.Success.Code.UNSPECIFIED) {
340
+ return 'succeeded';
341
+ }
342
+ }
343
+
344
+ return 'running';
345
+ },
346
+ fullAutoTuning: (status: MotionMasterMessage.Status.IFullAutoTuning) => {
347
+ if (status.error) {
348
+ return 'failed';
349
+ }
350
+
351
+ if (status.success) {
352
+ if (status.success.code === MotionMasterMessage.Status.FullAutoTuning.Success.Code.POSITION_STOPPED ||
353
+ status.success.code === MotionMasterMessage.Status.FullAutoTuning.Success.Code.VELOCITY_STOPPED) {
354
+ return 'failed';
355
+ }
356
+
357
+ if (status.success.code === MotionMasterMessage.Status.FullAutoTuning.Success.Code.POSITION_DONE ||
358
+ status.success.code === MotionMasterMessage.Status.FullAutoTuning.Success.Code.VELOCITY_DONE) {
359
+ return 'succeeded';
360
+ }
361
+
362
+ if (status.success === MotionMasterMessage.Status.FullAutoTuning.Success.Code.UNSPECIFIED) {
363
+ return 'succeeded';
364
+ }
365
+ }
366
+
367
+ return 'running';
368
+ },
369
+ circuloEncoderConfiguration: (status: MotionMasterMessage.Status.ICirculoEncoderConfiguration) => {
370
+ if (status.error) {
371
+ return 'failed';
372
+ }
373
+
374
+ if (status.success) {
375
+ if (status.success.code === MotionMasterMessage.Status.CirculoEncoderConfiguration.Success.Code.DONE) {
376
+ return 'succeeded'
377
+ }
378
+
379
+ if (status.success.code === MotionMasterMessage.Status.CirculoEncoderConfiguration.Success.Code.UNSPECIFIED) {
380
+ return 'succeeded'
381
+ }
382
+ }
383
+
384
+ return 'running';
385
+ },
386
+ osCommand: (status: MotionMasterMessage.Status.IOsCommand) => {
387
+ if (status.error) {
388
+ return 'failed';
389
+ }
390
+
391
+ if (status.success) {
392
+ if (status.success.code === MotionMasterMessage.Status.OsCommand.Success.Code.DONE) {
393
+ return 'succeeded';
394
+ }
395
+
396
+ if (status.success.code === MotionMasterMessage.Status.OsCommand.Success.Code.UNSPECIFIED) {
397
+ return 'succeeded';
398
+ }
399
+ }
400
+
401
+ return 'running';
402
+ },
403
+ };
@@ -0,0 +1,9 @@
1
+ export interface SystemLogLine {
2
+ line: string;
3
+ date: Date;
4
+ uptime: string;
5
+ id: string;
6
+ file: string;
7
+ level: string;
8
+ message: string;
9
+ }