motion-master-client 0.0.1 → 0.0.3
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/.babelrc +3 -0
- package/.eslintrc.json +18 -0
- package/README.md +44 -2
- package/jest.config.ts +15 -0
- package/motion-master.proto +1822 -0
- package/package.json +6 -9
- package/src/{index.d.ts → index.ts} +1 -0
- package/src/lib/device-log-line.ts +5 -0
- package/src/lib/device-parameter.spec.ts +85 -0
- package/src/lib/device-parameter.ts +69 -0
- package/src/lib/hardware-description.spec.ts +223 -0
- package/src/lib/hardware-description.ts +79 -0
- package/src/lib/logger.ts +5 -0
- package/src/lib/monitoring-config.ts +6 -0
- package/src/lib/monitoring-entry.ts +11 -0
- package/src/lib/motion-master-client.ts +94 -0
- package/src/lib/motion-master-pub-sub-client.ts +94 -0
- package/src/lib/motion-master-pub-sub-socket.ts +33 -0
- package/src/lib/motion-master-pub-sub-web-socket.ts +71 -0
- package/src/lib/motion-master-pub-sub-worker-socket.ts +58 -0
- package/src/lib/motion-master-req-res-client.spec.ts +126 -0
- package/src/lib/motion-master-req-res-client.ts +1990 -0
- package/src/lib/motion-master-req-res-socket.ts +45 -0
- package/src/lib/motion-master-req-res-web-socket.ts +119 -0
- package/src/lib/motion-master-req-res-worker-socket.ts +63 -0
- package/src/lib/motion-master.proto.d.ts +5084 -0
- package/src/lib/motion-master.proto.js +52278 -0
- package/src/lib/operators.ts +93 -0
- package/src/lib/{options.js → options.ts} +7 -6
- package/src/lib/parameter.spec.ts +81 -0
- package/src/lib/parameter.ts +119 -0
- package/src/lib/request-status-resolver.ts +380 -0
- package/src/lib/system-log-line.ts +8 -0
- package/src/lib/types.ts +58 -0
- package/src/lib/{urls.js → urls.ts} +3 -3
- package/src/lib/util.ts +261 -0
- package/tsconfig.json +22 -0
- package/tsconfig.lib.json +10 -0
- package/tsconfig.spec.json +20 -0
- package/typedoc.json +10 -0
- package/src/index.js +0 -22
- package/src/index.js.map +0 -1
- package/src/lib/device-log-line.d.ts +0 -5
- package/src/lib/device-log-line.js +0 -2
- package/src/lib/device-log-line.js.map +0 -1
- package/src/lib/hardware-description.d.ts +0 -36
- package/src/lib/hardware-description.js +0 -38
- package/src/lib/hardware-description.js.map +0 -1
- package/src/lib/logger.d.ts +0 -1
- package/src/lib/logger.js +0 -5
- package/src/lib/logger.js.map +0 -1
- package/src/lib/monitoring-config.d.ts +0 -6
- package/src/lib/monitoring-config.js +0 -2
- package/src/lib/monitoring-config.js.map +0 -1
- package/src/lib/monitoring-entry.d.ts +0 -10
- package/src/lib/monitoring-entry.js +0 -2
- package/src/lib/monitoring-entry.js.map +0 -1
- package/src/lib/motion-master-client.d.ts +0 -18
- package/src/lib/motion-master-client.js +0 -48
- package/src/lib/motion-master-client.js.map +0 -1
- package/src/lib/motion-master-pub-sub-client.d.ts +0 -16
- package/src/lib/motion-master-pub-sub-client.js +0 -64
- package/src/lib/motion-master-pub-sub-client.js.map +0 -1
- package/src/lib/motion-master-pub-sub-socket.d.ts +0 -28
- package/src/lib/motion-master-pub-sub-socket.js +0 -2
- package/src/lib/motion-master-pub-sub-socket.js.map +0 -1
- package/src/lib/motion-master-pub-sub-web-socket.d.ts +0 -13
- package/src/lib/motion-master-pub-sub-web-socket.js +0 -57
- package/src/lib/motion-master-pub-sub-web-socket.js.map +0 -1
- package/src/lib/motion-master-pub-sub-worker-socket.d.ts +0 -16
- package/src/lib/motion-master-pub-sub-worker-socket.js +0 -37
- package/src/lib/motion-master-pub-sub-worker-socket.js.map +0 -1
- package/src/lib/motion-master-req-res-client.d.ts +0 -370
- package/src/lib/motion-master-req-res-client.js +0 -1067
- package/src/lib/motion-master-req-res-client.js.map +0 -1
- package/src/lib/motion-master-req-res-socket.d.ts +0 -38
- package/src/lib/motion-master-req-res-socket.js +0 -2
- package/src/lib/motion-master-req-res-socket.js.map +0 -1
- package/src/lib/motion-master-req-res-web-socket.d.ts +0 -20
- package/src/lib/motion-master-req-res-web-socket.js +0 -96
- package/src/lib/motion-master-req-res-web-socket.js.map +0 -1
- package/src/lib/motion-master-req-res-worker-socket.d.ts +0 -15
- package/src/lib/motion-master-req-res-worker-socket.js +0 -49
- package/src/lib/motion-master-req-res-worker-socket.js.map +0 -1
- package/src/lib/operators.d.ts +0 -21
- package/src/lib/operators.js +0 -62
- package/src/lib/operators.js.map +0 -1
- package/src/lib/options.d.ts +0 -10
- package/src/lib/options.js.map +0 -1
- package/src/lib/parameter.d.ts +0 -9
- package/src/lib/parameter.js +0 -2
- package/src/lib/parameter.js.map +0 -1
- package/src/lib/request-status-resolver.d.ts +0 -4
- package/src/lib/request-status-resolver.js +0 -320
- package/src/lib/request-status-resolver.js.map +0 -1
- package/src/lib/system-log-line.d.ts +0 -8
- package/src/lib/system-log-line.js +0 -2
- package/src/lib/system-log-line.js.map +0 -1
- package/src/lib/types.d.ts +0 -41
- package/src/lib/types.js +0 -9
- package/src/lib/types.js.map +0 -1
- package/src/lib/urls.d.ts +0 -3
- package/src/lib/urls.js.map +0 -1
- package/src/lib/util.d.ts +0 -33
- package/src/lib/util.js +0 -247
- package/src/lib/util.js.map +0 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { pipe, filter, map, timeout, takeWhile, retryWhen, concat, take, Observable, delay } from 'rxjs';
|
|
2
|
+
import { getParameterValue } from './util';
|
|
3
|
+
import { requestStatusResolver } from './request-status-resolver';
|
|
4
|
+
import { MotionMasterMessage, ParameterValueType, RequestStatus, StatusKey } from './types';
|
|
5
|
+
|
|
6
|
+
export function selectMotionMasterMessageStatusByMessageId<T>(key: StatusKey, id?: string) {
|
|
7
|
+
return pipe(
|
|
8
|
+
filter((message: MotionMasterMessage) => message.id === id),
|
|
9
|
+
map((message) => {
|
|
10
|
+
// Handling the special case when Motion Master sends SystemEvent instead of e.g. DeviceParameterInfo status for
|
|
11
|
+
// GetDeviceParameterInfo request message. This typically happens when request contains an invalid device address.
|
|
12
|
+
if (message.status?.systemEvent && key !== 'systemEvent') {
|
|
13
|
+
if (message.status.systemEvent.error) {
|
|
14
|
+
throw new Error(`Error selecting message: ${message.status.systemEvent.error.message ?? ''}`);
|
|
15
|
+
} else {
|
|
16
|
+
throw new Error(`Error selecting message. Received System Event instead of "${key.toString()}": ${JSON.stringify(message)}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return message.status?.[key] as T;
|
|
20
|
+
}),
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function extendStatus<T>(data: { statusKey: StatusKey, messageId: string }) {
|
|
25
|
+
return pipe(
|
|
26
|
+
map((status: T) => {
|
|
27
|
+
const { statusKey, messageId } = data;
|
|
28
|
+
const request = requestStatusResolver[statusKey]?.<T>(status);
|
|
29
|
+
return { ...status, messageId, request };
|
|
30
|
+
}),
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function transformMotionMasterMessageToStatus<T>(statusKey: StatusKey, requestTimeout: number, messageId: string) {
|
|
35
|
+
if (typeof requestTimeout !== 'number') {
|
|
36
|
+
throw new Error(`Invalid requestTimeout=${requestTimeout} provided for ${statusKey}`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return pipe(
|
|
40
|
+
selectMotionMasterMessageStatusByMessageId<T>(statusKey, messageId),
|
|
41
|
+
timeout(requestTimeout),
|
|
42
|
+
extendStatus({ statusKey, messageId }),
|
|
43
|
+
takeWhile((status) => status.request !== 'succeeded' && status.request !== 'failed', true),
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function selectMotionMasterMessageByTopic<T>(topic: string) {
|
|
48
|
+
return pipe(
|
|
49
|
+
filter(([t]: [string, T]) => t === topic),
|
|
50
|
+
map(([, data]) => data),
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function selectMotionMasterMessageStatusByKey<T>(key: keyof MotionMasterMessage.IStatus) {
|
|
55
|
+
return pipe(
|
|
56
|
+
filter((message: MotionMasterMessage) => !!(message.status && message.status[key])),
|
|
57
|
+
map((message) => message.status?.[key] as T),
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Retry (resubscribe) to the source observable a number of attempts with delay timeout.
|
|
63
|
+
*/
|
|
64
|
+
export function retryWithDelay<T>(delayTimeout = 1000, attempts = 3) {
|
|
65
|
+
return pipe(
|
|
66
|
+
retryWhen<T>((errors: Observable<Error>) => concat(
|
|
67
|
+
errors.pipe(
|
|
68
|
+
delay(delayTimeout),
|
|
69
|
+
take(attempts),
|
|
70
|
+
),
|
|
71
|
+
errors.pipe(
|
|
72
|
+
map(error => {
|
|
73
|
+
throw error; // rethrow the source observable error if all attempts fail
|
|
74
|
+
}),
|
|
75
|
+
),
|
|
76
|
+
)),
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function mapStatusMessageToParameterValues() {
|
|
81
|
+
return pipe(
|
|
82
|
+
map((message: MotionMasterMessage) => {
|
|
83
|
+
if (message.status?.monitoringParameterValues) {
|
|
84
|
+
const { timestamp, deviceParameterValues } = message.status.monitoringParameterValues;
|
|
85
|
+
return [
|
|
86
|
+
timestamp,
|
|
87
|
+
...(deviceParameterValues?.parameterValues?.map((parameterValue) => getParameterValue(parameterValue)) ?? []),
|
|
88
|
+
] as ParameterValueType[];
|
|
89
|
+
}
|
|
90
|
+
return [];
|
|
91
|
+
}),
|
|
92
|
+
);
|
|
93
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { MotionMasterMessage } from './types';
|
|
2
|
+
|
|
2
3
|
export const parameterValueTypeOptions = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
'intValue': 'intValue',
|
|
5
|
+
'uintValue': 'uintValue',
|
|
6
|
+
'floatValue': 'floatValue',
|
|
7
|
+
'stringValue': 'stringValue',
|
|
8
|
+
'rawValue': 'rawValue',
|
|
8
9
|
};
|
|
10
|
+
|
|
9
11
|
export const ethercatNetworkStateOptions = MotionMasterMessage.Status.EthercatNetworkState.State;
|
|
10
12
|
export const positionControllerTypeOptions = MotionMasterMessage.Request.ComputeAutoTuningGains.PositionParameters.ControllerType;
|
|
11
|
-
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { makeParameterId, splitParameterId } from "./parameter";
|
|
2
|
+
|
|
3
|
+
describe('parameter', () => {
|
|
4
|
+
|
|
5
|
+
describe('makeParameterId', () => {
|
|
6
|
+
|
|
7
|
+
test.each<[[(number | null | undefined), (number | null | undefined)], string]>([
|
|
8
|
+
[[0x1234, 123], '0x1234:7B'],
|
|
9
|
+
[[23, 23], '0x0017:17'],
|
|
10
|
+
[[0, 0], '0x0000:00'],
|
|
11
|
+
[[0x2000, undefined], '0x2000:00'],
|
|
12
|
+
[[0x2003, null], '0x2003:00'],
|
|
13
|
+
[[0x10000, 3], '0x00010000:03'],
|
|
14
|
+
[[0x100F0, undefined], '0x000100F0:00'],
|
|
15
|
+
])('should for tuple %j return "%s"', (tuple, expected) => {
|
|
16
|
+
const result = makeParameterId(tuple);
|
|
17
|
+
|
|
18
|
+
expect(result).toBe(expected);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test.each([
|
|
22
|
+
[{}, '0x0000:00'],
|
|
23
|
+
[{ index: 0x2004, subindex: 4 }, '0x2004:04'],
|
|
24
|
+
[{ index: 0x1024 }, '0x1024:00'],
|
|
25
|
+
])('should for parameter %j return "%s"', (parameter, expected) => {
|
|
26
|
+
const result = makeParameterId(parameter);
|
|
27
|
+
|
|
28
|
+
expect(result).toBe(expected);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test.each([
|
|
32
|
+
[0x1234, 123, '0x1234:7B'],
|
|
33
|
+
[23, 23, '0x0017:17'],
|
|
34
|
+
[0, 0, '0x0000:00'],
|
|
35
|
+
[0x2000, undefined, '0x2000:00'],
|
|
36
|
+
[0x2003, null, '0x2003:00'],
|
|
37
|
+
[0x10000, 3, '0x00010000:03'],
|
|
38
|
+
[0x100F0, undefined, '0x000100F0:00'],
|
|
39
|
+
])('should for index %d and subindex %d return "%s"', (index, subindex, expected) => {
|
|
40
|
+
const result = makeParameterId(index, subindex);
|
|
41
|
+
|
|
42
|
+
expect(result).toBe(expected);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should throw if index is less than 0', () => {
|
|
46
|
+
expect(() => {
|
|
47
|
+
makeParameterId(-123, 0);
|
|
48
|
+
}).toThrow();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should throw if subindex is less than 0', () => {
|
|
52
|
+
expect(() => {
|
|
53
|
+
makeParameterId(0x1024, -3);
|
|
54
|
+
}).toThrow();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('splitParameterId', () => {
|
|
60
|
+
|
|
61
|
+
test.each([
|
|
62
|
+
['0x1234:7B', [4660, 123]],
|
|
63
|
+
['0x000100F0:00', [65776, 0]],
|
|
64
|
+
])('should for id "%s" return tuple %j', (id, expected) => {
|
|
65
|
+
const result = splitParameterId(id);
|
|
66
|
+
|
|
67
|
+
expect(result).toEqual(expected);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test.each([
|
|
71
|
+
['0x12:7B'],
|
|
72
|
+
['0x1234:F'],
|
|
73
|
+
['0x1234:FG'],
|
|
74
|
+
['0x1H34:FF'],
|
|
75
|
+
])('should throw error for id "%s"', (id) => {
|
|
76
|
+
expect(() => splitParameterId(id)).toThrow();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { MotionMasterMessage, ParameterTypeValueKey, ParameterValueType } from "./types";
|
|
2
|
+
|
|
3
|
+
export interface Parameter extends MotionMasterMessage.Status.DeviceParameterInfo.IParameter, MotionMasterMessage.Status.DeviceParameterValues.IParameterValue {
|
|
4
|
+
index: number;
|
|
5
|
+
subindex: number;
|
|
6
|
+
name: string;
|
|
7
|
+
value: ParameterValueType;
|
|
8
|
+
typeValue: ParameterTypeValueKey;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type ParameterIndexSubindex = Pick<Parameter, 'index' | 'subindex'>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Make parameter id by providing a tuple of index and subindex.
|
|
15
|
+
*
|
|
16
|
+
* @param tuple - an array of index and subindex
|
|
17
|
+
* @throws {Error} if index or subindex are less than 0
|
|
18
|
+
* @returns combined index and subindex in uppercase hexadecimal format, e.g. "0x60FE:02"
|
|
19
|
+
*/
|
|
20
|
+
export function makeParameterId(tuple: [(number | null | undefined), (number | null | undefined)]): string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Make parameter id by providing an object which has index and subindex properties.
|
|
24
|
+
*
|
|
25
|
+
* @param parameter - an object with optional index and subindex properties
|
|
26
|
+
* @throws {Error} if index or subindex are less than 0
|
|
27
|
+
* @returns combined index and subindex in uppercase hexadecimal format, e.g. "0x60FE:02"
|
|
28
|
+
*/
|
|
29
|
+
export function makeParameterId(parameter: { index?: (number | null), subindex?: (number | null) }): string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Make parameter id by providing index and subindex.
|
|
33
|
+
*
|
|
34
|
+
* @param index - from 0x0000 to 0xFFFF for objects defined in ESI and >0xFFFF for custom object
|
|
35
|
+
* @param subindex - defaults to 0 if not provided
|
|
36
|
+
* @throws {Error} if index or subindex are less than 0
|
|
37
|
+
* @returns combined index and subindex in uppercase hexadecimal format, e.g. "0x60FE:02"
|
|
38
|
+
*/
|
|
39
|
+
export function makeParameterId(index?: (number | null), subindex?: (number | null)): string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Make parameter id by providing different arguments.
|
|
43
|
+
*
|
|
44
|
+
* The purpose of this declaration is to expose the signature of the implementation for {@link makeDeviceParameterId} function.
|
|
45
|
+
*
|
|
46
|
+
* @param a - number or an object with index and subindex or tuple of index and subindex
|
|
47
|
+
* @param b - optional subindex, defaults to 0 if not provided
|
|
48
|
+
* @throws {Error} if index or subindex are less than 0
|
|
49
|
+
* @returns combined index and subindex in uppercase hexadecimal format, e.g. "0x60FE:02"
|
|
50
|
+
*/
|
|
51
|
+
export function makeParameterId(a?: (number | null) | { index?: (number | null), subindex?: (number | null) } | [(number | null | undefined), (number | null | undefined)], b?: (number | null)): string;
|
|
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
|
+
let index = 0;
|
|
55
|
+
let subindex = 0;
|
|
56
|
+
|
|
57
|
+
if (Array.isArray(a)) {
|
|
58
|
+
if (a[0]) {
|
|
59
|
+
index = a[0];
|
|
60
|
+
}
|
|
61
|
+
if (a[1]) {
|
|
62
|
+
subindex = a[1];
|
|
63
|
+
}
|
|
64
|
+
} else if (typeof a === 'object') {
|
|
65
|
+
if (a?.index) {
|
|
66
|
+
index = a.index;
|
|
67
|
+
}
|
|
68
|
+
if (a?.subindex) {
|
|
69
|
+
subindex = a.subindex;
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
if (typeof a === 'number') {
|
|
73
|
+
index = a;
|
|
74
|
+
}
|
|
75
|
+
if (typeof b === 'number') {
|
|
76
|
+
subindex = b;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (index < 0) {
|
|
81
|
+
throw new Error(`The provided index to makeParameterId must be greater than 0: ${index}`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (subindex < 0) {
|
|
85
|
+
throw new Error(`The provided subindex to makeParameterId must be greater than 0: ${subindex}`);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const indexMaxLength = index > 0xFFFF ? 8 : 4;
|
|
89
|
+
const x = index.toString(16).toUpperCase().padStart(indexMaxLength, '0');
|
|
90
|
+
const y = subindex.toString(16).toUpperCase().padStart(2, '0');
|
|
91
|
+
|
|
92
|
+
return `0x${x}:${y}`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Example of parameter id is "0x2110:1A" where:
|
|
97
|
+
* - 0x2110 is object index in hexadecimal format
|
|
98
|
+
* - 1A is subindex in hexadecimal format
|
|
99
|
+
*/
|
|
100
|
+
export const parameterIdRegExp = /^0x([0-9a-fA-F]{4,}):([0-9a-fA-F]{2})$/;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Split device parameter id into parts.
|
|
104
|
+
*
|
|
105
|
+
* @param id - parameter id like "0x2110:1A"
|
|
106
|
+
* @returns tuple of index and subindex
|
|
107
|
+
*/
|
|
108
|
+
export function splitParameterId(id: string): [number, number] {
|
|
109
|
+
const match = id.match(parameterIdRegExp);
|
|
110
|
+
|
|
111
|
+
if (!match) {
|
|
112
|
+
throw new Error(`Parameter id "${id}" doesn't match the regular expression: ${parameterIdRegExp}`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return [
|
|
116
|
+
parseInt(match[1], 16), // index
|
|
117
|
+
parseInt(match[2], 16), // subindex
|
|
118
|
+
];
|
|
119
|
+
}
|
|
@@ -0,0 +1,380 @@
|
|
|
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
|
+
return 'succeeded';
|
|
34
|
+
},
|
|
35
|
+
multiDeviceParameterValues: () => 'succeeded',
|
|
36
|
+
deviceFileList: (status: MotionMasterMessage.Status.IDeviceFileList) => {
|
|
37
|
+
if (status.error) {
|
|
38
|
+
return 'failed';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return 'succeeded';
|
|
42
|
+
},
|
|
43
|
+
deviceFile: (status: MotionMasterMessage.Status.IDeviceFile) => {
|
|
44
|
+
if (status.error) {
|
|
45
|
+
return 'failed';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return 'succeeded';
|
|
49
|
+
},
|
|
50
|
+
deviceEvent: (status: MotionMasterMessage.Status.IDeviceEvent) => {
|
|
51
|
+
if (status.error) {
|
|
52
|
+
return 'failed';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return 'succeeded';
|
|
56
|
+
},
|
|
57
|
+
deviceFirmwareInstallation: (status: MotionMasterMessage.Status.IDeviceFirmwareInstallation) => {
|
|
58
|
+
if (status.error) {
|
|
59
|
+
return 'failed';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (status.success) {
|
|
63
|
+
if (status.success.code === MotionMasterMessage.Status.DeviceFirmwareInstallation.Success.Code.DONE) {
|
|
64
|
+
return 'succeeded';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (status.success.code === MotionMasterMessage.Status.DeviceFirmwareInstallation.Success.Code.UNSPECIFIED) {
|
|
68
|
+
return 'succeeded';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return 'running';
|
|
73
|
+
},
|
|
74
|
+
deviceLog: (status: MotionMasterMessage.Status.IDeviceLog) => {
|
|
75
|
+
if (status.error) {
|
|
76
|
+
return 'failed';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return 'succeeded';
|
|
80
|
+
},
|
|
81
|
+
deviceFaultReset: (status: MotionMasterMessage.Status.IDeviceFaultReset) => {
|
|
82
|
+
if (status.error) {
|
|
83
|
+
return 'failed';
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return 'succeeded';
|
|
87
|
+
},
|
|
88
|
+
coggingTorqueRecording: (status: MotionMasterMessage.Status.ICoggingTorqueRecording) => {
|
|
89
|
+
if (status.error) {
|
|
90
|
+
return 'failed';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (status.success) {
|
|
94
|
+
if (status.success.code === MotionMasterMessage.Status.CoggingTorqueRecording.Success.Code.DONE) {
|
|
95
|
+
return 'succeeded';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (status.success.code === MotionMasterMessage.Status.CoggingTorqueRecording.Success.Code.UNSPECIFIED) {
|
|
99
|
+
return 'succeeded';
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return 'running';
|
|
104
|
+
},
|
|
105
|
+
coggingTorqueData: (status: MotionMasterMessage.Status.ICoggingTorqueData) => {
|
|
106
|
+
if (status.error) {
|
|
107
|
+
return 'failed';
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return 'succeeded';
|
|
111
|
+
},
|
|
112
|
+
offsetDetection: (status: MotionMasterMessage.Status.IOffsetDetection) => {
|
|
113
|
+
if (status.error) {
|
|
114
|
+
return 'failed';
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (status.success) {
|
|
118
|
+
if (status.success.code === MotionMasterMessage.Status.OffsetDetection.Success.Code.DONE) {
|
|
119
|
+
return 'succeeded';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (status.success.code === MotionMasterMessage.Status.OffsetDetection.Success.Code.UNSPECIFIED) {
|
|
123
|
+
return 'succeeded';
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return 'running';
|
|
128
|
+
},
|
|
129
|
+
plantIdentification: (status: MotionMasterMessage.Status.IPlantIdentification) => {
|
|
130
|
+
if (status.error) {
|
|
131
|
+
return 'failed';
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (status.success) {
|
|
135
|
+
if (status.success.code === MotionMasterMessage.Status.PlantIdentification.Success.Code.DONE) {
|
|
136
|
+
return 'succeeded';
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (status.success.code === MotionMasterMessage.Status.PlantIdentification.Success.Code.UNSPECIFIED) {
|
|
140
|
+
return 'succeeded';
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return 'running';
|
|
145
|
+
},
|
|
146
|
+
autoTuning: (status: MotionMasterMessage.Status.IAutoTuning) => {
|
|
147
|
+
if (status.error) {
|
|
148
|
+
return 'failed';
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (status.success) {
|
|
152
|
+
if (status.success.code === MotionMasterMessage.Status.AutoTuning.Success.Code.POSITION_DONE ||
|
|
153
|
+
status.success.code === MotionMasterMessage.Status.AutoTuning.Success.Code.VELOCITY_DONE) {
|
|
154
|
+
return 'succeeded';
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (status.success === MotionMasterMessage.Status.AutoTuning.Success.Code.UNSPECIFIED) {
|
|
158
|
+
return 'succeeded';
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return 'running';
|
|
163
|
+
},
|
|
164
|
+
motionController: (status: MotionMasterMessage.Status.IMotionController) => {
|
|
165
|
+
if (status.error) {
|
|
166
|
+
return 'failed';
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return 'succeeded';
|
|
170
|
+
},
|
|
171
|
+
signalGenerator: (status: MotionMasterMessage.Status.ISignalGenerator) => {
|
|
172
|
+
if (status.error) {
|
|
173
|
+
return 'failed';
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (status.success) {
|
|
177
|
+
if (status.success.code === MotionMasterMessage.Status.SignalGenerator.Success.Code.DONE) {
|
|
178
|
+
return 'succeeded';
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (status.success.code === MotionMasterMessage.Status.SignalGenerator.Success.Code.PARAMETERS_SET) {
|
|
182
|
+
return 'succeeded';
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (status.success.code === MotionMasterMessage.Status.SignalGenerator.Success.Code.UNSPECIFIED) {
|
|
186
|
+
return 'succeeded';
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return 'running';
|
|
191
|
+
},
|
|
192
|
+
monitoringParameterValues: (status: MotionMasterMessage.Status.IMonitoringParameterValues) => {
|
|
193
|
+
if (status.error) {
|
|
194
|
+
return 'failed';
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return 'succeeded';
|
|
198
|
+
},
|
|
199
|
+
deviceStop: (status: MotionMasterMessage.Status.IDeviceStop) => {
|
|
200
|
+
if (status.error) {
|
|
201
|
+
return 'failed';
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return 'succeeded';
|
|
205
|
+
},
|
|
206
|
+
ethercatNetworkState: (status: MotionMasterMessage.Status.IEthercatNetworkState) => {
|
|
207
|
+
if (status.error) {
|
|
208
|
+
return 'failed';
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return 'succeeded';
|
|
212
|
+
},
|
|
213
|
+
narrowAngleCalibration: (status: MotionMasterMessage.Status.INarrowAngleCalibration) => {
|
|
214
|
+
if (status.error) {
|
|
215
|
+
return 'failed';
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (status.success) {
|
|
219
|
+
if (status.success.code === MotionMasterMessage.Status.NarrowAngleCalibration.Success.Code.DONE) {
|
|
220
|
+
return 'succeeded';
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (status.success.code === MotionMasterMessage.Status.NarrowAngleCalibration.Success.Code.UNSPECIFIED) {
|
|
224
|
+
return 'succeeded';
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return 'running';
|
|
229
|
+
},
|
|
230
|
+
systemIdentification: (status: MotionMasterMessage.Status.ISystemIdentification) => {
|
|
231
|
+
if (status.error) {
|
|
232
|
+
return 'failed';
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (status.success) {
|
|
236
|
+
if (status.success.code === MotionMasterMessage.Status.SystemIdentification.Success.Code.DONE) {
|
|
237
|
+
return 'succeeded';
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (status.success.code === MotionMasterMessage.Status.SystemIdentification.Success.Code.UNSPECIFIED) {
|
|
241
|
+
return 'succeeded';
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return 'running';
|
|
246
|
+
},
|
|
247
|
+
circuloEncoderMagnetDistance: (status: MotionMasterMessage.Status.ICirculoEncoderMagnetDistance) => {
|
|
248
|
+
if (typeof status.distance === 'number' || typeof status.position === 'number') {
|
|
249
|
+
return 'succeeded';
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return 'failed';
|
|
253
|
+
},
|
|
254
|
+
circuloEncoderNarrowAngleCalibrationProcedure: (status: MotionMasterMessage.Status.ICirculoEncoderNarrowAngleCalibrationProcedure) => {
|
|
255
|
+
if (status.error) {
|
|
256
|
+
return 'failed';
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (status.success) {
|
|
260
|
+
if (status.success.code === MotionMasterMessage.Status.CirculoEncoderNarrowAngleCalibrationProcedure.Success.Code.STOPPED) {
|
|
261
|
+
return 'failed';
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (status.success.code === MotionMasterMessage.Status.CirculoEncoderNarrowAngleCalibrationProcedure.Success.Code.DONE) {
|
|
265
|
+
return 'succeeded';
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if (status.success === MotionMasterMessage.Status.CirculoEncoderNarrowAngleCalibrationProcedure.Success.Code.UNSPECIFIED) {
|
|
269
|
+
return 'succeeded';
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return 'running';
|
|
274
|
+
},
|
|
275
|
+
deviceCia402State: (status: MotionMasterMessage.Status.IDeviceCiA402State) => {
|
|
276
|
+
if (status.error) {
|
|
277
|
+
return 'failed';
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return 'succeeded';
|
|
281
|
+
},
|
|
282
|
+
systemLog: (status: MotionMasterMessage.Status.ISystemLog) => {
|
|
283
|
+
if (status.content) {
|
|
284
|
+
return 'succeeded';
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return 'failed';
|
|
288
|
+
},
|
|
289
|
+
deviceSiiRestore: (status: MotionMasterMessage.Status.IDeviceSiiRestore) => {
|
|
290
|
+
if (status.error) {
|
|
291
|
+
return 'failed';
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (status.success) {
|
|
295
|
+
if (status.success.code === MotionMasterMessage.Status.DeviceSiiRestore.Success.Code.DONE) {
|
|
296
|
+
return 'succeeded';
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (status.success.code === MotionMasterMessage.Status.DeviceSiiRestore.Success.Code.UNSPECIFIED) {
|
|
300
|
+
return 'succeeded';
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return 'running';
|
|
305
|
+
},
|
|
306
|
+
openLoopFieldControl: (status: MotionMasterMessage.Status.IOpenLoopFieldControl) => {
|
|
307
|
+
if (status.error) {
|
|
308
|
+
return 'failed';
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if (status.success) {
|
|
312
|
+
if (status.success.code === MotionMasterMessage.Status.OpenLoopFieldControl.Success.Code.DONE) {
|
|
313
|
+
return 'succeeded';
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if (status.success.code === MotionMasterMessage.Status.OpenLoopFieldControl.Success.Code.UNSPECIFIED) {
|
|
317
|
+
return 'succeeded';
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return 'running';
|
|
322
|
+
},
|
|
323
|
+
fullAutoTuning: (status: MotionMasterMessage.Status.IFullAutoTuning) => {
|
|
324
|
+
if (status.error) {
|
|
325
|
+
return 'failed';
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
if (status.success) {
|
|
329
|
+
if (status.success.code === MotionMasterMessage.Status.FullAutoTuning.Success.Code.POSITION_STOPPED ||
|
|
330
|
+
status.success.code === MotionMasterMessage.Status.FullAutoTuning.Success.Code.VELOCITY_STOPPED) {
|
|
331
|
+
return 'failed';
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if (status.success.code === MotionMasterMessage.Status.FullAutoTuning.Success.Code.POSITION_DONE ||
|
|
335
|
+
status.success.code === MotionMasterMessage.Status.FullAutoTuning.Success.Code.VELOCITY_DONE) {
|
|
336
|
+
return 'succeeded';
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
if (status.success === MotionMasterMessage.Status.FullAutoTuning.Success.Code.UNSPECIFIED) {
|
|
340
|
+
return 'succeeded';
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
return 'running';
|
|
345
|
+
},
|
|
346
|
+
circuloEncoderConfiguration: (status: MotionMasterMessage.Status.ICirculoEncoderConfiguration) => {
|
|
347
|
+
if (status.error) {
|
|
348
|
+
return 'failed';
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (status.success) {
|
|
352
|
+
if (status.success.code === MotionMasterMessage.Status.CirculoEncoderConfiguration.Success.Code.DONE) {
|
|
353
|
+
return 'succeeded'
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (status.success.code === MotionMasterMessage.Status.CirculoEncoderConfiguration.Success.Code.UNSPECIFIED) {
|
|
357
|
+
return 'succeeded'
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return 'running';
|
|
362
|
+
},
|
|
363
|
+
osCommand: (status: MotionMasterMessage.Status.IOsCommand) => {
|
|
364
|
+
if (status.error) {
|
|
365
|
+
return 'failed';
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
if (status.success) {
|
|
369
|
+
if (status.success.code === MotionMasterMessage.Status.OsCommand.Success.Code.DONE) {
|
|
370
|
+
return 'succeeded';
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (status.success.code === MotionMasterMessage.Status.OsCommand.Success.Code.UNSPECIFIED) {
|
|
374
|
+
return 'succeeded';
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
return 'running';
|
|
379
|
+
},
|
|
380
|
+
};
|