motion-master-client 0.0.22 → 0.0.23
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/package.json +16 -2
- package/src/index.js +29 -0
- package/src/index.js.map +1 -0
- package/src/lib/cia402.d.ts +182 -0
- package/src/lib/cia402.js +392 -0
- package/src/lib/cia402.js.map +1 -0
- package/src/lib/config-file.d.ts +13 -0
- package/src/lib/config-file.js +50 -0
- package/src/lib/config-file.js.map +1 -0
- package/src/lib/device-log-line.d.ts +5 -0
- package/src/lib/device-log-line.js +3 -0
- package/src/lib/device-log-line.js.map +1 -0
- package/src/lib/device-parameter.d.ts +56 -0
- package/src/lib/device-parameter.js +39 -0
- package/src/lib/device-parameter.js.map +1 -0
- package/src/lib/device.d.ts +9 -0
- package/src/lib/device.js +3 -0
- package/src/lib/device.js.map +1 -0
- package/src/lib/hardware-description.d.ts +41 -0
- package/src/lib/hardware-description.js +94 -0
- package/src/lib/hardware-description.js.map +1 -0
- package/src/lib/logger.d.ts +1 -0
- package/src/lib/logger.js +8 -0
- package/src/lib/logger.js.map +1 -0
- package/src/lib/monitoring-config.d.ts +6 -0
- package/src/lib/monitoring-config.js +3 -0
- package/src/lib/monitoring-config.js.map +1 -0
- package/src/lib/{monitoring-entry.ts → monitoring-entry.d.ts} +4 -5
- package/src/lib/monitoring-entry.js +3 -0
- package/src/lib/monitoring-entry.js.map +1 -0
- package/src/lib/motion-master-client.d.ts +52 -0
- package/src/lib/motion-master-client.js +151 -0
- package/src/lib/motion-master-client.js.map +1 -0
- package/src/lib/motion-master-pub-sub-client.d.ts +16 -0
- package/src/lib/motion-master-pub-sub-client.js +68 -0
- package/src/lib/motion-master-pub-sub-client.js.map +1 -0
- package/src/lib/motion-master-pub-sub-socket.d.ts +34 -0
- package/src/lib/motion-master-pub-sub-socket.js +3 -0
- package/src/lib/motion-master-pub-sub-socket.js.map +1 -0
- package/src/lib/motion-master-pub-sub-web-socket.d.ts +14 -0
- package/src/lib/motion-master-pub-sub-web-socket.js +67 -0
- package/src/lib/motion-master-pub-sub-web-socket.js.map +1 -0
- package/src/lib/motion-master-pub-sub-worker-socket.d.ts +14 -0
- package/src/lib/motion-master-pub-sub-worker-socket.js +42 -0
- package/src/lib/motion-master-pub-sub-worker-socket.js.map +1 -0
- package/src/lib/motion-master-req-res-client.d.ts +920 -0
- package/src/lib/motion-master-req-res-client.js +1680 -0
- package/src/lib/motion-master-req-res-client.js.map +1 -0
- package/src/lib/motion-master-req-res-socket.d.ts +52 -0
- package/src/lib/motion-master-req-res-socket.js +3 -0
- package/src/lib/motion-master-req-res-socket.js.map +1 -0
- package/src/lib/motion-master-req-res-web-socket.d.ts +24 -0
- package/src/lib/motion-master-req-res-web-socket.js +99 -0
- package/src/lib/motion-master-req-res-web-socket.js.map +1 -0
- package/src/lib/motion-master-req-res-worker-socket.d.ts +20 -0
- package/src/lib/motion-master-req-res-worker-socket.js +69 -0
- package/src/lib/motion-master-req-res-worker-socket.js.map +1 -0
- package/src/lib/operators.d.ts +18 -0
- package/src/lib/operators.js +76 -0
- package/src/lib/operators.js.map +1 -0
- package/src/lib/options.d.ts +10 -0
- package/src/lib/options.js +14 -0
- package/src/lib/options.js.map +1 -0
- package/src/lib/parameter.d.ts +72 -0
- package/src/lib/parameter.js +119 -0
- package/src/lib/parameter.js.map +1 -0
- package/src/lib/product-id-range.d.ts +7 -0
- package/src/lib/product-id-range.js +12 -0
- package/src/lib/product-id-range.js.map +1 -0
- package/src/lib/request-status-resolver.d.ts +4 -0
- package/src/lib/request-status-resolver.js +345 -0
- package/src/lib/request-status-resolver.js.map +1 -0
- package/src/lib/system-log-line.d.ts +9 -0
- package/src/lib/system-log-line.js +3 -0
- package/src/lib/system-log-line.js.map +1 -0
- package/src/lib/{types.ts → types.d.ts} +143 -74
- package/src/lib/types.js +28 -0
- package/src/lib/types.js.map +1 -0
- package/src/lib/urls.d.ts +3 -0
- package/src/lib/urls.js +10 -0
- package/src/lib/urls.js.map +1 -0
- package/src/lib/util.d.ts +40 -0
- package/src/lib/util.js +316 -0
- package/src/lib/util.js.map +1 -0
- package/.babelrc +0 -3
- package/.eslintrc.json +0 -18
- package/jest.config.ts +0 -16
- package/motion-master.proto +0 -1822
- package/project.json +0 -45
- package/src/lib/cia402.spec.ts +0 -77
- package/src/lib/cia402.ts +0 -414
- package/src/lib/config-file.spec.ts +0 -114
- package/src/lib/config-file.ts +0 -63
- package/src/lib/device-log-line.ts +0 -5
- package/src/lib/device-parameter.spec.ts +0 -85
- package/src/lib/device-parameter.ts +0 -79
- package/src/lib/device.ts +0 -10
- package/src/lib/hardware-description.spec.ts +0 -253
- package/src/lib/hardware-description.ts +0 -129
- package/src/lib/logger.ts +0 -5
- package/src/lib/monitoring-config.ts +0 -6
- package/src/lib/motion-master-client.ts +0 -221
- package/src/lib/motion-master-pub-sub-client.ts +0 -95
- package/src/lib/motion-master-pub-sub-socket.ts +0 -40
- package/src/lib/motion-master-pub-sub-web-socket.ts +0 -78
- package/src/lib/motion-master-pub-sub-worker-socket.ts +0 -51
- package/src/lib/motion-master-req-res-client.spec.ts +0 -740
- package/src/lib/motion-master-req-res-client.ts +0 -2120
- package/src/lib/motion-master-req-res-socket.ts +0 -62
- package/src/lib/motion-master-req-res-web-socket.ts +0 -124
- package/src/lib/motion-master-req-res-worker-socket.ts +0 -87
- package/src/lib/operators.ts +0 -90
- package/src/lib/options.ts +0 -12
- package/src/lib/parameter.spec.ts +0 -160
- package/src/lib/parameter.ts +0 -170
- package/src/lib/product-id-range.ts +0 -8
- package/src/lib/request-status-resolver.ts +0 -403
- package/src/lib/system-log-line.ts +0 -9
- package/src/lib/urls.ts +0 -6
- package/src/lib/util.ts +0 -305
- package/tsconfig.json +0 -23
- package/tsconfig.lib.json +0 -10
- package/tsconfig.spec.json +0 -20
- package/typedoc.json +0 -10
- /package/src/{index.ts → index.d.ts} +0 -0
|
@@ -1,43 +1,26 @@
|
|
|
1
1
|
import { motionmaster } from "./motion-master.proto";
|
|
2
|
-
|
|
3
2
|
export import MotionMasterMessage = motionmaster.MotionMasterMessage;
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5
3
|
export import IMotionMasterMessage = motionmaster.IMotionMasterMessage;
|
|
6
|
-
|
|
7
4
|
export type StatusKey = keyof MotionMasterMessage.IStatus;
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
| 'running';
|
|
13
|
-
|
|
14
|
-
export class RequestError extends Error { }
|
|
15
|
-
|
|
16
|
-
export type ParameterAddress = [number, number]; // index, subindex
|
|
5
|
+
export type RequestStatus = 'succeeded' | 'failed' | 'running';
|
|
6
|
+
export declare class RequestError extends Error {
|
|
7
|
+
}
|
|
8
|
+
export type ParameterAddress = [number, number];
|
|
17
9
|
export type ParameterTypeValue = Omit<MotionMasterMessage.Request.SetDeviceParameterValues.IParameterValue, 'index' | 'subindex'>;
|
|
18
10
|
export type ParameterTypeValueKey = keyof ParameterTypeValue;
|
|
19
11
|
export type ParameterValueType = string | number | Uint8Array;
|
|
20
|
-
export type ParameterAddressValue = [number, number, ParameterValueType, ParameterTypeValueKey?];
|
|
21
|
-
export type DeviceParameterAddressValue = [DeviceRef, number, number, ParameterValueType, ParameterTypeValueKey?];
|
|
12
|
+
export type ParameterAddressValue = [number, number, ParameterValueType, ParameterTypeValueKey?];
|
|
13
|
+
export type DeviceParameterAddressValue = [DeviceRef, number, number, ParameterValueType, ParameterTypeValueKey?];
|
|
22
14
|
export type DeviceParameterIds = string[] | [DeviceRef, number, number][];
|
|
23
|
-
|
|
24
15
|
export type DeviceRefObj = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
deviceAddress?: (number | null);
|
|
17
|
+
deviceSerialNumber?: (string | null);
|
|
18
|
+
devicePosition?: (number | null);
|
|
28
19
|
};
|
|
29
|
-
|
|
30
20
|
export type DeviceRef = number | string;
|
|
31
|
-
|
|
32
|
-
export type ParameterInfoAndValue = MotionMasterMessage.Status.DeviceParameterInfo.IParameter
|
|
33
|
-
& MotionMasterMessage.Status.DeviceParameterValues.IParameterValue;
|
|
34
|
-
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
21
|
+
export type ParameterInfoAndValue = MotionMasterMessage.Status.DeviceParameterInfo.IParameter & MotionMasterMessage.Status.DeviceParameterValues.IParameterValue;
|
|
36
22
|
export import EthercatNetworkState = MotionMasterMessage.Request.SetEthercatNetworkState.State;
|
|
37
|
-
|
|
38
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
39
23
|
export import ControllerType = MotionMasterMessage.Request.EnableMotionController.ControllerType;
|
|
40
|
-
|
|
41
24
|
export type GetDeviceParameterInfoRequest = MotionMasterMessage.Request.IGetDeviceParameterInfo & DeviceRefObj;
|
|
42
25
|
export type GetDeviceParameterValuesRequest = MotionMasterMessage.Request.IGetDeviceParameterValues & DeviceRefObj;
|
|
43
26
|
export type GetMultiDeviceParameterValuesRequest = MotionMasterMessage.Request.IGetMultiDeviceParameterValues;
|
|
@@ -81,53 +64,139 @@ export type StopFullAutoTuningRequest = MotionMasterMessage.Request.IStopFullAut
|
|
|
81
64
|
export type StartCirculoEncoderConfigurationRequest = MotionMasterMessage.Request.IStartCirculoEncoderConfiguration & DeviceRefObj;
|
|
82
65
|
export type StopCirculoEncoderNarrowAngleCalibrationProcedureRequest = MotionMasterMessage.Request.IStopCirculoEncoderNarrowAngleCalibrationProcedure & DeviceRefObj;
|
|
83
66
|
export type StartOsCommandRequest = MotionMasterMessage.Request.IStartOsCommand & DeviceRefObj;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
export type
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
export type
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
export type
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
export type
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
export type
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
export type
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
export type
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
67
|
+
export type SystemVersionStatus = MotionMasterMessage.Status.ISystemVersion & {
|
|
68
|
+
request: RequestStatus;
|
|
69
|
+
messageId?: string;
|
|
70
|
+
};
|
|
71
|
+
export type DeviceInfoStatus = MotionMasterMessage.Status.IDeviceInfo & {
|
|
72
|
+
request: RequestStatus;
|
|
73
|
+
messageId?: string;
|
|
74
|
+
};
|
|
75
|
+
export type DeviceParameterInfoStatus = MotionMasterMessage.Status.IDeviceParameterInfo & {
|
|
76
|
+
request: RequestStatus;
|
|
77
|
+
messageId?: string;
|
|
78
|
+
};
|
|
79
|
+
export type DeviceParameterValuesStatus = MotionMasterMessage.Status.IDeviceParameterValues & {
|
|
80
|
+
request: RequestStatus;
|
|
81
|
+
messageId?: string;
|
|
82
|
+
};
|
|
83
|
+
export type MultiDeviceParameterValuesStatus = MotionMasterMessage.Status.IMultiDeviceParameterValues & {
|
|
84
|
+
request: RequestStatus;
|
|
85
|
+
messageId?: string;
|
|
86
|
+
};
|
|
87
|
+
export type DeviceFileListStatus = MotionMasterMessage.Status.IDeviceFileList & {
|
|
88
|
+
request: RequestStatus;
|
|
89
|
+
messageId?: string;
|
|
90
|
+
};
|
|
91
|
+
export type DeviceFileStatus = MotionMasterMessage.Status.IDeviceFile & {
|
|
92
|
+
request: RequestStatus;
|
|
93
|
+
messageId?: string;
|
|
94
|
+
};
|
|
95
|
+
export type DeviceFaultResetStatus = MotionMasterMessage.Status.IDeviceFaultReset & {
|
|
96
|
+
request: RequestStatus;
|
|
97
|
+
messageId?: string;
|
|
98
|
+
};
|
|
99
|
+
export type DeviceStopStatus = MotionMasterMessage.Status.IDeviceStop & {
|
|
100
|
+
request: RequestStatus;
|
|
101
|
+
messageId?: string;
|
|
102
|
+
};
|
|
103
|
+
export type DeviceFirmwareInstallationStatus = MotionMasterMessage.Status.IDeviceFirmwareInstallation & {
|
|
104
|
+
request: RequestStatus;
|
|
105
|
+
messageId?: string;
|
|
106
|
+
};
|
|
107
|
+
export type DeviceLogStatus = MotionMasterMessage.Status.IDeviceLog & {
|
|
108
|
+
request: RequestStatus;
|
|
109
|
+
messageId?: string;
|
|
110
|
+
};
|
|
111
|
+
export type CoggingTorqueRecordingStatus = MotionMasterMessage.Status.ICoggingTorqueRecording & {
|
|
112
|
+
request: RequestStatus;
|
|
113
|
+
messageId?: string;
|
|
114
|
+
};
|
|
115
|
+
export type CoggingTorqueDataStatus = MotionMasterMessage.Status.ICoggingTorqueData & {
|
|
116
|
+
request: RequestStatus;
|
|
117
|
+
messageId?: string;
|
|
118
|
+
};
|
|
119
|
+
export type OffsetDetectionStatus = MotionMasterMessage.Status.IOffsetDetection & {
|
|
120
|
+
request: RequestStatus;
|
|
121
|
+
messageId?: string;
|
|
122
|
+
};
|
|
123
|
+
export type PlantIdentificationStatus = MotionMasterMessage.Status.IPlantIdentification & {
|
|
124
|
+
request: RequestStatus;
|
|
125
|
+
messageId?: string;
|
|
126
|
+
};
|
|
127
|
+
export type AutoTuningStatus = MotionMasterMessage.Status.IAutoTuning & {
|
|
128
|
+
request: RequestStatus;
|
|
129
|
+
messageId?: string;
|
|
130
|
+
};
|
|
131
|
+
export type MotionControllerStatus = MotionMasterMessage.Status.IMotionController & {
|
|
132
|
+
request: RequestStatus;
|
|
133
|
+
messageId?: string;
|
|
134
|
+
};
|
|
135
|
+
export type SignalGeneratorStatus = MotionMasterMessage.Status.ISignalGenerator & {
|
|
136
|
+
request: RequestStatus;
|
|
137
|
+
messageId?: string;
|
|
138
|
+
};
|
|
139
|
+
export type MonitoringParameterValuesStatus = MotionMasterMessage.Status.IMonitoringParameterValues & {
|
|
140
|
+
request: RequestStatus;
|
|
141
|
+
messageId?: string;
|
|
142
|
+
};
|
|
143
|
+
export type EthercatNetworkStateStatus = MotionMasterMessage.Status.IEthercatNetworkState & {
|
|
144
|
+
request: RequestStatus;
|
|
145
|
+
messageId?: string;
|
|
146
|
+
};
|
|
147
|
+
export type NarrowAngleCalibrationStatus = MotionMasterMessage.Status.INarrowAngleCalibration & {
|
|
148
|
+
request: RequestStatus;
|
|
149
|
+
messageId?: string;
|
|
150
|
+
};
|
|
151
|
+
export type SystemIdentificationStatus = MotionMasterMessage.Status.ISystemIdentification & {
|
|
152
|
+
request: RequestStatus;
|
|
153
|
+
messageId?: string;
|
|
154
|
+
};
|
|
155
|
+
export type CirculoEncoderMagnetDistanceStatus = MotionMasterMessage.Status.ICirculoEncoderMagnetDistance & {
|
|
156
|
+
request: RequestStatus;
|
|
157
|
+
messageId?: string;
|
|
158
|
+
};
|
|
159
|
+
export type CirculoEncoderNarrowAngleCalibrationProcedureStatus = MotionMasterMessage.Status.ICirculoEncoderNarrowAngleCalibrationProcedure & {
|
|
160
|
+
request: RequestStatus;
|
|
161
|
+
messageId?: string;
|
|
162
|
+
};
|
|
163
|
+
export type DeviceCiA402StateStatus = MotionMasterMessage.Status.IDeviceCiA402State & {
|
|
164
|
+
request: RequestStatus;
|
|
165
|
+
messageId?: string;
|
|
166
|
+
};
|
|
167
|
+
export type SystemLogStatus = MotionMasterMessage.Status.ISystemLog & {
|
|
168
|
+
request: RequestStatus;
|
|
169
|
+
messageId?: string;
|
|
170
|
+
};
|
|
171
|
+
export type DeviceSiiRestoreStatus = MotionMasterMessage.Status.IDeviceSiiRestore & {
|
|
172
|
+
request: RequestStatus;
|
|
173
|
+
messageId?: string;
|
|
174
|
+
};
|
|
175
|
+
export type OpenLoopFieldControlStatus = MotionMasterMessage.Status.IOpenLoopFieldControl & {
|
|
176
|
+
request: RequestStatus;
|
|
177
|
+
messageId?: string;
|
|
178
|
+
};
|
|
179
|
+
export type FullAutoTuningStatus = MotionMasterMessage.Status.IFullAutoTuning & {
|
|
180
|
+
request: RequestStatus;
|
|
181
|
+
messageId?: string;
|
|
182
|
+
};
|
|
183
|
+
export type CirculoEncoderConfigurationStatus = MotionMasterMessage.Status.ICirculoEncoderConfiguration & {
|
|
184
|
+
request: RequestStatus;
|
|
185
|
+
messageId?: string;
|
|
186
|
+
};
|
|
187
|
+
export type OsCommandStatus = MotionMasterMessage.Status.IOsCommand & {
|
|
188
|
+
request: RequestStatus;
|
|
189
|
+
messageId?: string;
|
|
190
|
+
};
|
|
118
191
|
export import ValueType = MotionMasterMessage.Status.DeviceParameterInfo.Parameter.ValueType;
|
|
119
|
-
|
|
120
|
-
export function
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
export enum RestoreDefaultParametersType {
|
|
129
|
-
RESTORE_ALL_DEFAULT_PARAMETERS = 1,
|
|
130
|
-
RESTORE_MANUFACTURER_DEFAULT_PARAMETERS = 4,
|
|
192
|
+
export declare function isArrayOfDeviceSerialNumbers(ids: DeviceParameterIds): ids is string[];
|
|
193
|
+
export declare function isObjectOfDeviceSerialNumberToValues(ids: {
|
|
194
|
+
[deviceParameterId: string]: ParameterValueType;
|
|
195
|
+
} | DeviceParameterAddressValue[]): ids is {
|
|
196
|
+
[deviceParameterId: string]: ParameterValueType;
|
|
197
|
+
};
|
|
198
|
+
export declare enum RestoreDefaultParametersType {
|
|
199
|
+
RESTORE_ALL_DEFAULT_PARAMETERS = 1,
|
|
200
|
+
RESTORE_MANUFACTURER_DEFAULT_PARAMETERS = 4
|
|
131
201
|
}
|
|
132
|
-
|
|
133
202
|
export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
package/src/lib/types.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RestoreDefaultParametersType = exports.isObjectOfDeviceSerialNumberToValues = exports.isArrayOfDeviceSerialNumbers = exports.ValueType = exports.ControllerType = exports.EthercatNetworkState = exports.RequestError = exports.MotionMasterMessage = void 0;
|
|
4
|
+
const motion_master_proto_1 = require("./motion-master.proto");
|
|
5
|
+
exports.MotionMasterMessage = motion_master_proto_1.motionmaster.MotionMasterMessage;
|
|
6
|
+
class RequestError extends Error {
|
|
7
|
+
}
|
|
8
|
+
exports.RequestError = RequestError;
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10
|
+
exports.EthercatNetworkState = exports.MotionMasterMessage.Request.SetEthercatNetworkState.State;
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
12
|
+
exports.ControllerType = exports.MotionMasterMessage.Request.EnableMotionController.ControllerType;
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
|
+
exports.ValueType = exports.MotionMasterMessage.Status.DeviceParameterInfo.Parameter.ValueType;
|
|
15
|
+
function isArrayOfDeviceSerialNumbers(ids) {
|
|
16
|
+
return ids.length > 0 && typeof ids[0] === 'string';
|
|
17
|
+
}
|
|
18
|
+
exports.isArrayOfDeviceSerialNumbers = isArrayOfDeviceSerialNumbers;
|
|
19
|
+
function isObjectOfDeviceSerialNumberToValues(ids) {
|
|
20
|
+
return !Array.isArray(ids);
|
|
21
|
+
}
|
|
22
|
+
exports.isObjectOfDeviceSerialNumberToValues = isObjectOfDeviceSerialNumberToValues;
|
|
23
|
+
var RestoreDefaultParametersType;
|
|
24
|
+
(function (RestoreDefaultParametersType) {
|
|
25
|
+
RestoreDefaultParametersType[RestoreDefaultParametersType["RESTORE_ALL_DEFAULT_PARAMETERS"] = 1] = "RESTORE_ALL_DEFAULT_PARAMETERS";
|
|
26
|
+
RestoreDefaultParametersType[RestoreDefaultParametersType["RESTORE_MANUFACTURER_DEFAULT_PARAMETERS"] = 4] = "RESTORE_MANUFACTURER_DEFAULT_PARAMETERS";
|
|
27
|
+
})(RestoreDefaultParametersType = exports.RestoreDefaultParametersType || (exports.RestoreDefaultParametersType = {}));
|
|
28
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../libs/motion-master-client/src/lib/types.ts"],"names":[],"mappings":";;;AAAA,+DAAqD;AAEvC,QAAA,mBAAmB,GAAG,kCAAY,CAAC,mBAAmB,CAAC;AAWrE,MAAa,YAAa,SAAQ,KAAK;CAAI;AAA3C,oCAA2C;AAqB3C,6DAA6D;AAC/C,QAAA,oBAAoB,GAAG,2BAAmB,CAAC,OAAO,CAAC,uBAAuB,CAAC,KAAK,CAAC;AAE/F,6DAA6D;AAC/C,QAAA,cAAc,GAAG,2BAAmB,CAAC,OAAO,CAAC,sBAAsB,CAAC,cAAc,CAAC;AA8EjG,6DAA6D;AAC/C,QAAA,SAAS,GAAG,2BAAmB,CAAC,MAAM,CAAC,mBAAmB,CAAC,SAAS,CAAC,SAAS,CAAC;AAE7F,SAAgB,4BAA4B,CAAC,GAAuB;IAClE,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC;AACtD,CAAC;AAFD,oEAEC;AAED,SAAgB,oCAAoC,CAAC,GAAwF;IAC3I,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAFD,oFAEC;AAED,IAAY,4BAGX;AAHD,WAAY,4BAA4B;IACtC,mIAAkC,CAAA;IAClC,qJAA2C,CAAA;AAC7C,CAAC,EAHW,4BAA4B,GAA5B,oCAA4B,KAA5B,oCAA4B,QAGvC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const firmwarePackageBaseUrl = "https://synapticon.s3.amazonaws.com/somanet-software/releases/";
|
|
2
|
+
export declare const listFirmwarePackagesUrl = "https://pc27e3jixd.execute-api.us-east-1.amazonaws.com/default/listFirmwarePackages";
|
|
3
|
+
export declare function getFirmwarePackageUrl(filename: string): string;
|
package/src/lib/urls.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFirmwarePackageUrl = exports.listFirmwarePackagesUrl = exports.firmwarePackageBaseUrl = void 0;
|
|
4
|
+
exports.firmwarePackageBaseUrl = 'https://synapticon.s3.amazonaws.com/somanet-software/releases/';
|
|
5
|
+
exports.listFirmwarePackagesUrl = 'https://pc27e3jixd.execute-api.us-east-1.amazonaws.com/default/listFirmwarePackages';
|
|
6
|
+
function getFirmwarePackageUrl(filename) {
|
|
7
|
+
return exports.firmwarePackageBaseUrl + filename;
|
|
8
|
+
}
|
|
9
|
+
exports.getFirmwarePackageUrl = getFirmwarePackageUrl;
|
|
10
|
+
//# sourceMappingURL=urls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urls.js","sourceRoot":"","sources":["../../../../../libs/motion-master-client/src/lib/urls.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG,gEAAgE,CAAC;AAC1F,QAAA,uBAAuB,GAAG,qFAAqF,CAAC;AAE7H,SAAgB,qBAAqB,CAAC,QAAgB;IACpD,OAAO,8BAAsB,GAAG,QAAQ,CAAC;AAC3C,CAAC;AAFD,sDAEC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { DeviceLogLine } from "./device-log-line";
|
|
2
|
+
import { Parameter, ParameterIndexSubindex } from "./parameter";
|
|
3
|
+
import { SystemLogLine } from "./system-log-line";
|
|
4
|
+
import { DeviceRef, DeviceRefObj, IMotionMasterMessage, MotionMasterMessage, ParameterAddressValue, ParameterTypeValue, ParameterTypeValueKey, ParameterValueType, ValueType } from "./types";
|
|
5
|
+
export declare function getParameterTypeValueDefault(key: ParameterTypeValueKey): 0 | Uint8Array | "";
|
|
6
|
+
export declare function getParameterTypeValue(parameter: MotionMasterMessage.Status.DeviceParameterValues.IParameterValue): ParameterTypeValueKey | undefined;
|
|
7
|
+
export declare function getParameterValue(parameter: MotionMasterMessage.Status.DeviceParameterValues.IParameterValue): ParameterValueType;
|
|
8
|
+
export declare function makeDeviceRefObj(deviceRef: DeviceRef): DeviceRefObj;
|
|
9
|
+
export declare function parseSystemLogLine(line: string): SystemLogLine | undefined;
|
|
10
|
+
export declare function parseSystemLogContent(content: string): SystemLogLine[];
|
|
11
|
+
export declare function parseDeviceLog(line: string): DeviceLogLine | undefined;
|
|
12
|
+
export declare function parseDeviceLogContent(content: string): DeviceLogLine[];
|
|
13
|
+
export declare function mapParameterTypeValueToObject(type: keyof ParameterTypeValue, value: number | string): ParameterTypeValue;
|
|
14
|
+
export declare function createPlainObjectFromMotionMasterMessage(motionMasterMessage: MotionMasterMessage): {
|
|
15
|
+
[k: string]: any;
|
|
16
|
+
};
|
|
17
|
+
export declare function convertMotionMasterMessageToLoggerContext(motionMasterMessage: IMotionMasterMessage, namespace?: string): {
|
|
18
|
+
namespace: string;
|
|
19
|
+
motionMasterMessage: IMotionMasterMessage;
|
|
20
|
+
type: string | undefined;
|
|
21
|
+
name: string | undefined;
|
|
22
|
+
};
|
|
23
|
+
export declare function decodeTextContent(content: Uint8Array): string;
|
|
24
|
+
export declare function isRxPdoIndex(index: number): boolean;
|
|
25
|
+
export declare function isTxPdoIndex(index: number): boolean;
|
|
26
|
+
export declare function filterRxPdoParameters<T extends ParameterIndexSubindex>(parameters: T[], excludeSubIndex000?: boolean): T[];
|
|
27
|
+
export declare function filterTxPdoParameters<T extends ParameterIndexSubindex>(parameters: T[], excludeSubIndex000?: boolean): T[];
|
|
28
|
+
export declare function fillPdoParametersWithMappingEntries(parameters: Parameter[], entriesPerPdo?: number): Parameter[];
|
|
29
|
+
export declare function mapParameterToPdoSubItemValue(parameter: Parameter): number;
|
|
30
|
+
export declare function mapValueTypeToBitSize(valueType: ValueType): number;
|
|
31
|
+
export declare const valueTypeToParameterTypeValueKeyMap: Map<ValueType, "intValue" | "uintValue" | "floatValue" | "stringValue" | "rawValue">;
|
|
32
|
+
export declare function isValidDeviceRefObj(obj: DeviceRefObj): boolean;
|
|
33
|
+
export declare function createPdoParameterValues(parameters: Array<{
|
|
34
|
+
index: number;
|
|
35
|
+
subindex: number;
|
|
36
|
+
typeValue?: ParameterTypeValueKey;
|
|
37
|
+
}>, values: Array<ParameterValueType>): ParameterAddressValue[];
|
|
38
|
+
export declare function resolveAfter(ms: number, value?: unknown): Promise<unknown>;
|
|
39
|
+
export declare function convertRgbToLedColor(value: number): number;
|
|
40
|
+
export declare function createRandomColor(brightness: number): string;
|
package/src/lib/util.js
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRandomColor = exports.convertRgbToLedColor = exports.resolveAfter = exports.createPdoParameterValues = exports.isValidDeviceRefObj = exports.valueTypeToParameterTypeValueKeyMap = exports.mapValueTypeToBitSize = exports.mapParameterToPdoSubItemValue = exports.fillPdoParametersWithMappingEntries = exports.filterTxPdoParameters = exports.filterRxPdoParameters = exports.isTxPdoIndex = exports.isRxPdoIndex = exports.decodeTextContent = exports.convertMotionMasterMessageToLoggerContext = exports.createPlainObjectFromMotionMasterMessage = exports.mapParameterTypeValueToObject = exports.parseDeviceLogContent = exports.parseDeviceLog = exports.parseSystemLogContent = exports.parseSystemLogLine = exports.makeDeviceRefObj = exports.getParameterValue = exports.getParameterTypeValue = exports.getParameterTypeValueDefault = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const types_1 = require("./types");
|
|
6
|
+
function getParameterTypeValueDefault(key) {
|
|
7
|
+
if (key === 'floatValue' || key === 'intValue' || key === 'uintValue') {
|
|
8
|
+
return 0;
|
|
9
|
+
}
|
|
10
|
+
else if (key === 'rawValue') {
|
|
11
|
+
return Uint8Array.from([]);
|
|
12
|
+
}
|
|
13
|
+
else if (key === 'stringValue') {
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.getParameterTypeValueDefault = getParameterTypeValueDefault;
|
|
21
|
+
function getParameterTypeValue(parameter) {
|
|
22
|
+
return (types_1.MotionMasterMessage.Status.DeviceParameterValues.ParameterValue.create(parameter)).typeValue;
|
|
23
|
+
}
|
|
24
|
+
exports.getParameterTypeValue = getParameterTypeValue;
|
|
25
|
+
function getParameterValue(parameter) {
|
|
26
|
+
var _a;
|
|
27
|
+
const key = getParameterTypeValue(parameter);
|
|
28
|
+
if (key && key in parameter) {
|
|
29
|
+
return (_a = parameter[key]) !== null && _a !== void 0 ? _a : getParameterTypeValueDefault(key);
|
|
30
|
+
}
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
exports.getParameterValue = getParameterValue;
|
|
34
|
+
function makeDeviceRefObj(deviceRef) {
|
|
35
|
+
if (typeof deviceRef === 'number') {
|
|
36
|
+
if (deviceRef <= 0xFFFF) {
|
|
37
|
+
return { devicePosition: deviceRef };
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return { deviceAddress: deviceRef };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return { deviceSerialNumber: deviceRef };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.makeDeviceRefObj = makeDeviceRefObj;
|
|
48
|
+
// TODO: Write unit tests.
|
|
49
|
+
function parseSystemLogLine(line) {
|
|
50
|
+
const re = /(\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\.\d{1,3})\s\((.+)\)\s\[(.+)\](.+:\d+)(.+?)\|(.*)/s;
|
|
51
|
+
const result = re.exec(line);
|
|
52
|
+
if (result) {
|
|
53
|
+
return {
|
|
54
|
+
line,
|
|
55
|
+
date: new Date(result[1]),
|
|
56
|
+
uptime: result[2].trim(),
|
|
57
|
+
id: result[3].trim(),
|
|
58
|
+
file: result[4].trim(),
|
|
59
|
+
level: result[5].trim(),
|
|
60
|
+
message: result[6],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
exports.parseSystemLogLine = parseSystemLogLine;
|
|
66
|
+
// TODO: Write unit tests.
|
|
67
|
+
function parseSystemLogContent(content) {
|
|
68
|
+
const re = /(\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\.\d{1,3}.+?)(?=\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\.\d{1,3}|$)/gs;
|
|
69
|
+
return content.split(re)
|
|
70
|
+
.filter((l) => l !== '')
|
|
71
|
+
.map((v) => parseSystemLogLine(v))
|
|
72
|
+
.filter((l) => l !== undefined);
|
|
73
|
+
}
|
|
74
|
+
exports.parseSystemLogContent = parseSystemLogContent;
|
|
75
|
+
function parseDeviceLog(line) {
|
|
76
|
+
const re = /^(\d{2}:\d{2}:\d{2}\.\d+)\s(.*)\|(.*)$/gm;
|
|
77
|
+
const result = re.exec(line);
|
|
78
|
+
if (result) {
|
|
79
|
+
return {
|
|
80
|
+
time: result[1].trim(),
|
|
81
|
+
level: result[2].trim(),
|
|
82
|
+
message: result[3].trim(),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
exports.parseDeviceLog = parseDeviceLog;
|
|
88
|
+
function parseDeviceLogContent(content) {
|
|
89
|
+
return content.split('\n')
|
|
90
|
+
.map((v) => parseDeviceLog(v))
|
|
91
|
+
.filter((l) => l !== undefined);
|
|
92
|
+
}
|
|
93
|
+
exports.parseDeviceLogContent = parseDeviceLogContent;
|
|
94
|
+
function mapParameterTypeValueToObject(type, value) {
|
|
95
|
+
var _a, _b;
|
|
96
|
+
const p = {};
|
|
97
|
+
if (type === 'floatValue') {
|
|
98
|
+
p['floatValue'] = typeof value === 'number' ? value : parseFloat(value);
|
|
99
|
+
}
|
|
100
|
+
else if (type === 'intValue') {
|
|
101
|
+
p['intValue'] = typeof value === 'number' ? value : parseInt(value, 10);
|
|
102
|
+
}
|
|
103
|
+
else if (type === 'rawValue') {
|
|
104
|
+
if (typeof value === 'number') {
|
|
105
|
+
p['rawValue'] = Uint8Array.from([value]);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
let bytes = [];
|
|
109
|
+
if (value.startsWith('0x')) {
|
|
110
|
+
bytes = (_b = (_a = value.slice(2).match(/.{1,2}/g)) === null || _a === void 0 ? void 0 : _a.map((h) => parseInt(h, 16))) !== null && _b !== void 0 ? _b : [];
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
bytes = value.split(',').map((c) => c.trim()).map((c) => parseInt(c, 10));
|
|
114
|
+
}
|
|
115
|
+
p['rawValue'] = Uint8Array.from(bytes);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else if (type === 'stringValue') {
|
|
119
|
+
p['stringValue'] = typeof value === 'string' ? value : value.toString();
|
|
120
|
+
}
|
|
121
|
+
else if (type === 'uintValue') {
|
|
122
|
+
p['uintValue'] = typeof value === 'number' ? value : parseInt(value, 10);
|
|
123
|
+
}
|
|
124
|
+
return p;
|
|
125
|
+
}
|
|
126
|
+
exports.mapParameterTypeValueToObject = mapParameterTypeValueToObject;
|
|
127
|
+
// Using bytes fixes: ERROR TypeError: Cannot freeze array buffer views with elements in NgRx
|
|
128
|
+
function createPlainObjectFromMotionMasterMessage(motionMasterMessage) {
|
|
129
|
+
return types_1.MotionMasterMessage.toObject(motionMasterMessage, {
|
|
130
|
+
bytes: Array,
|
|
131
|
+
defaults: true,
|
|
132
|
+
arrays: true,
|
|
133
|
+
objects: true,
|
|
134
|
+
oneofs: true,
|
|
135
|
+
json: true, // Performs additional JSON compatibility conversions, i.e. NaN and Infinity to strings
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
exports.createPlainObjectFromMotionMasterMessage = createPlainObjectFromMotionMasterMessage;
|
|
139
|
+
function convertMotionMasterMessageToLoggerContext(motionMasterMessage, namespace = 'reqResMessage') {
|
|
140
|
+
let type;
|
|
141
|
+
let name;
|
|
142
|
+
if (motionMasterMessage.request) {
|
|
143
|
+
type = 'request';
|
|
144
|
+
name = Object.keys(motionMasterMessage.request).join();
|
|
145
|
+
}
|
|
146
|
+
else if (motionMasterMessage.status) {
|
|
147
|
+
type = 'status';
|
|
148
|
+
name = Object.keys(motionMasterMessage.status).join();
|
|
149
|
+
}
|
|
150
|
+
return { namespace, motionMasterMessage, type, name };
|
|
151
|
+
}
|
|
152
|
+
exports.convertMotionMasterMessageToLoggerContext = convertMotionMasterMessageToLoggerContext;
|
|
153
|
+
function decodeTextContent(content) {
|
|
154
|
+
const decoder = new TextDecoder();
|
|
155
|
+
const buffer = Uint8Array.from(content);
|
|
156
|
+
return decoder.decode(buffer);
|
|
157
|
+
}
|
|
158
|
+
exports.decodeTextContent = decodeTextContent;
|
|
159
|
+
function isRxPdoIndex(index) {
|
|
160
|
+
return (0, lodash_1.inRange)(index, 0x1600, 0x1800);
|
|
161
|
+
}
|
|
162
|
+
exports.isRxPdoIndex = isRxPdoIndex;
|
|
163
|
+
function isTxPdoIndex(index) {
|
|
164
|
+
return (0, lodash_1.inRange)(index, 0x1A00, 0x1C00);
|
|
165
|
+
}
|
|
166
|
+
exports.isTxPdoIndex = isTxPdoIndex;
|
|
167
|
+
function filterRxPdoParameters(parameters, excludeSubIndex000 = false) {
|
|
168
|
+
return parameters.filter((p) => isRxPdoIndex(p.index) && (excludeSubIndex000 ? p.subindex > 0 : true)); // RxPDOs: Index area 0x1600 to 0x17FF
|
|
169
|
+
}
|
|
170
|
+
exports.filterRxPdoParameters = filterRxPdoParameters;
|
|
171
|
+
function filterTxPdoParameters(parameters, excludeSubIndex000 = false) {
|
|
172
|
+
return parameters.filter((p) => isTxPdoIndex(p.index) && (excludeSubIndex000 ? p.subindex > 0 : true)); // TxPDOs: Index area 0x1A00 to 0x1BFF
|
|
173
|
+
}
|
|
174
|
+
exports.filterTxPdoParameters = filterTxPdoParameters;
|
|
175
|
+
function fillPdoParametersWithMappingEntries(parameters, entriesPerPdo = 10) {
|
|
176
|
+
const output = [];
|
|
177
|
+
let i = 0;
|
|
178
|
+
while (i < parameters.length) {
|
|
179
|
+
if (parameters[i].subindex === 0) {
|
|
180
|
+
let j = i;
|
|
181
|
+
while (parameters[j] && (parameters[j].index === parameters[i].index)) {
|
|
182
|
+
output.push(parameters[j]);
|
|
183
|
+
j++;
|
|
184
|
+
}
|
|
185
|
+
let d = j - i;
|
|
186
|
+
while (d <= entriesPerPdo) {
|
|
187
|
+
output.push({
|
|
188
|
+
index: parameters[i].index,
|
|
189
|
+
subindex: d,
|
|
190
|
+
name: parameters[i].name,
|
|
191
|
+
uintValue: 0,
|
|
192
|
+
value: 0,
|
|
193
|
+
valueType: types_1.ValueType.UNSIGNED32,
|
|
194
|
+
group: parameters[i].group,
|
|
195
|
+
typeValue: "uintValue",
|
|
196
|
+
readAccess: true,
|
|
197
|
+
writeAccess: true,
|
|
198
|
+
});
|
|
199
|
+
d++;
|
|
200
|
+
}
|
|
201
|
+
i = j;
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
i++;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return output;
|
|
208
|
+
}
|
|
209
|
+
exports.fillPdoParametersWithMappingEntries = fillPdoParametersWithMappingEntries;
|
|
210
|
+
function mapParameterToPdoSubItemValue(parameter) {
|
|
211
|
+
const { index, subindex } = parameter;
|
|
212
|
+
if (parameter.valueType && parameter.valueType < types_1.ValueType.VISIBLE_STRING) {
|
|
213
|
+
const buffer = new ArrayBuffer(4);
|
|
214
|
+
const view = new DataView(buffer);
|
|
215
|
+
const bitSize = mapValueTypeToBitSize(parameter.valueType);
|
|
216
|
+
view.setUint16(0, index);
|
|
217
|
+
view.setUint8(2, subindex);
|
|
218
|
+
view.setUint8(3, bitSize);
|
|
219
|
+
return view.getUint32(0);
|
|
220
|
+
}
|
|
221
|
+
return 0;
|
|
222
|
+
}
|
|
223
|
+
exports.mapParameterToPdoSubItemValue = mapParameterToPdoSubItemValue;
|
|
224
|
+
function mapValueTypeToBitSize(valueType) {
|
|
225
|
+
switch (valueType) {
|
|
226
|
+
case types_1.ValueType.UNSPECIFIED:
|
|
227
|
+
return 0;
|
|
228
|
+
case types_1.ValueType.BOOLEAN:
|
|
229
|
+
return 1;
|
|
230
|
+
case types_1.ValueType.INTEGER8:
|
|
231
|
+
case types_1.ValueType.UNSIGNED8:
|
|
232
|
+
return 8;
|
|
233
|
+
case types_1.ValueType.INTEGER16:
|
|
234
|
+
case types_1.ValueType.UNSIGNED16:
|
|
235
|
+
return 16;
|
|
236
|
+
case types_1.ValueType.INTEGER32:
|
|
237
|
+
case types_1.ValueType.UNSIGNED32:
|
|
238
|
+
case types_1.ValueType.REAL32:
|
|
239
|
+
return 32;
|
|
240
|
+
}
|
|
241
|
+
throw new Error(`Non-numeric value type "${valueType}" (data types with variable length) cannot be mapped to bit size. You will have to get this info from ESI.`);
|
|
242
|
+
}
|
|
243
|
+
exports.mapValueTypeToBitSize = mapValueTypeToBitSize;
|
|
244
|
+
exports.valueTypeToParameterTypeValueKeyMap = new Map([
|
|
245
|
+
[types_1.ValueType.BOOLEAN, 'uintValue'],
|
|
246
|
+
[types_1.ValueType.INTEGER8, 'intValue'],
|
|
247
|
+
[types_1.ValueType.INTEGER16, 'intValue'],
|
|
248
|
+
[types_1.ValueType.INTEGER32, 'intValue'],
|
|
249
|
+
[types_1.ValueType.UNSIGNED8, 'uintValue'],
|
|
250
|
+
[types_1.ValueType.UNSIGNED16, 'uintValue'],
|
|
251
|
+
[types_1.ValueType.UNSIGNED32, 'uintValue'],
|
|
252
|
+
[types_1.ValueType.REAL32, 'floatValue'],
|
|
253
|
+
[types_1.ValueType.VISIBLE_STRING, 'stringValue'],
|
|
254
|
+
[types_1.ValueType.OCTET_STRING, 'stringValue'],
|
|
255
|
+
[types_1.ValueType.UNICODE_STRING, 'stringValue'],
|
|
256
|
+
]);
|
|
257
|
+
function isValidDeviceRefObj(obj) {
|
|
258
|
+
return Number.isFinite(Number(obj.deviceAddress))
|
|
259
|
+
|| (typeof obj.devicePosition === 'number' && obj.devicePosition >= 0)
|
|
260
|
+
|| typeof obj.deviceSerialNumber === 'string';
|
|
261
|
+
}
|
|
262
|
+
exports.isValidDeviceRefObj = isValidDeviceRefObj;
|
|
263
|
+
function createPdoParameterValues(parameters, values) {
|
|
264
|
+
const output = parameters.map((parameter, i, arr) => {
|
|
265
|
+
const { index, subindex, typeValue } = parameter;
|
|
266
|
+
let value = values[i];
|
|
267
|
+
if (subindex === 0) {
|
|
268
|
+
value = arr.reduce((n, p, j) => (p.index === index && p.subindex > 0 && values[j]) ? n + 1 : n, 0);
|
|
269
|
+
}
|
|
270
|
+
return [index, subindex, value, typeValue];
|
|
271
|
+
});
|
|
272
|
+
for (let i = 0; i < output.length - 1; i++) {
|
|
273
|
+
const [, subindex1, value1] = output[i];
|
|
274
|
+
if (subindex1 > 0 && value1 === 0) {
|
|
275
|
+
let j = i + 1;
|
|
276
|
+
let [, subindex2, value2] = output[j];
|
|
277
|
+
while (subindex2 > subindex1 && output[j]) {
|
|
278
|
+
if (typeof value2 === 'number' && value2 > 0) {
|
|
279
|
+
output[i][2] = value2;
|
|
280
|
+
output[j][2] = 0;
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
if (output[++j]) {
|
|
284
|
+
[, subindex2, value2] = output[j];
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return output;
|
|
290
|
+
}
|
|
291
|
+
exports.createPdoParameterValues = createPdoParameterValues;
|
|
292
|
+
function resolveAfter(ms, value) {
|
|
293
|
+
return new Promise(function (resolve) {
|
|
294
|
+
setTimeout(resolve.bind(null, value), ms);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
exports.resolveAfter = resolveAfter;
|
|
298
|
+
function convertRgbToLedColor(value) {
|
|
299
|
+
const r = (value >> 16) & 0xFF;
|
|
300
|
+
const g = (value >> 8) & 0xFF;
|
|
301
|
+
const b = value & 0xFF;
|
|
302
|
+
const ledColorValue = (g << 16) | (r << 8) | b;
|
|
303
|
+
return ledColorValue;
|
|
304
|
+
}
|
|
305
|
+
exports.convertRgbToLedColor = convertRgbToLedColor;
|
|
306
|
+
function createRandomColor(brightness) {
|
|
307
|
+
function randomChannel(brightness) {
|
|
308
|
+
const r = 255 - brightness;
|
|
309
|
+
const n = 0 | ((Math.random() * r) + brightness);
|
|
310
|
+
const s = n.toString(16);
|
|
311
|
+
return (s.length == 1) ? '0' + s : s;
|
|
312
|
+
}
|
|
313
|
+
return '#' + randomChannel(brightness) + randomChannel(brightness) + randomChannel(brightness);
|
|
314
|
+
}
|
|
315
|
+
exports.createRandomColor = createRandomColor;
|
|
316
|
+
//# sourceMappingURL=util.js.map
|