@synapticon/motion-master-client 2.2.2 → 6.0.0-alpha.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/api-error.d.ts +25 -0
- package/dist/api-error.js +52 -0
- package/dist/client.d.ts +20 -0
- package/dist/client.js +37 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +8 -0
- package/dist/eni.d.ts +197 -0
- package/dist/eni.js +61 -0
- package/dist/generated/Api.d.ts +1886 -0
- package/dist/generated/Api.js +1293 -0
- package/dist/generated/data-contracts.d.ts +2282 -0
- package/dist/generated/data-contracts.js +12 -0
- package/dist/generated/http-client.d.ts +60 -0
- package/dist/generated/http-client.js +171 -0
- package/dist/hex.d.ts +2 -0
- package/dist/hex.js +20 -0
- package/dist/index.d.ts +13 -7
- package/dist/index.js +20 -22
- package/dist/lan.d.ts +4 -0
- package/dist/lan.js +59 -0
- package/dist/mmpd.d.ts +53 -0
- package/dist/mmpd.js +322 -0
- package/dist/sdo.d.ts +17 -0
- package/dist/sdo.js +219 -0
- package/dist/web-socket-connection.d.ts +70 -0
- package/dist/web-socket-connection.js +237 -0
- package/dist/wire-time.d.ts +2 -0
- package/dist/wire-time.js +18 -0
- package/package.json +29 -39
- package/.vscode/launch.json +0 -23
- package/README.md +0 -118
- package/box.config.json +0 -7
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -1433
- package/dist/cli.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/motion-master-client-web-socket-connection.d.ts +0 -43
- package/dist/motion-master-client-web-socket-connection.d.ts.map +0 -1
- package/dist/motion-master-client-web-socket-connection.js +0 -91
- package/dist/motion-master-client-web-socket-connection.js.map +0 -1
- package/dist/motion-master-client.d.ts +0 -105
- package/dist/motion-master-client.d.ts.map +0 -1
- package/dist/motion-master-client.js +0 -348
- package/dist/motion-master-client.js.map +0 -1
- package/dist/motion-master-notification-subscribe-data.d.ts +0 -8
- package/dist/motion-master-notification-subscribe-data.d.ts.map +0 -1
- package/dist/motion-master-notification-subscribe-data.js +0 -3
- package/dist/motion-master-notification-subscribe-data.js.map +0 -1
- package/dist/motion-master-notification-web-socket-connection.d.ts +0 -56
- package/dist/motion-master-notification-web-socket-connection.d.ts.map +0 -1
- package/dist/motion-master-notification-web-socket-connection.js +0 -115
- package/dist/motion-master-notification-web-socket-connection.js.map +0 -1
- package/dist/motion-master-notification.d.ts +0 -31
- package/dist/motion-master-notification.d.ts.map +0 -1
- package/dist/motion-master-notification.js +0 -44
- package/dist/motion-master-notification.js.map +0 -1
- package/dist/util.d.ts +0 -16
- package/dist/util.d.ts.map +0 -1
- package/dist/util.js +0 -24
- package/dist/util.js.map +0 -1
- package/licenses.format.json +0 -4
- package/motion-master-client.config.json +0 -7
- package/smm_data_dic.json +0 -1213
- package/src/cli.ts +0 -1361
- package/src/index.ts +0 -7
- package/src/motion-master-client-web-socket-connection.ts +0 -104
- package/src/motion-master-client.ts +0 -468
- package/src/motion-master-notification-subscribe-data.ts +0 -7
- package/src/motion-master-notification-web-socket-connection.ts +0 -143
- package/src/motion-master-notification.ts +0 -51
- package/src/util.ts +0 -22
- package/test.sh +0 -122
- package/tsconfig.json +0 -63
- package/tslint.json +0 -118
package/dist/cli.js
DELETED
|
@@ -1,1433 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
14
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
-
function step(op) {
|
|
17
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
-
while (_) try {
|
|
19
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
20
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
-
switch (op[0]) {
|
|
22
|
-
case 0: case 1: t = op; break;
|
|
23
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
-
default:
|
|
27
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
-
if (t[2]) _.ops.pop();
|
|
32
|
-
_.trys.pop(); continue;
|
|
33
|
-
}
|
|
34
|
-
op = body.call(thisArg, _);
|
|
35
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
-
};
|
|
42
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
var commander_1 = __importDefault(require("commander"));
|
|
44
|
-
var fs_1 = __importDefault(require("fs"));
|
|
45
|
-
var path_1 = __importDefault(require("path"));
|
|
46
|
-
var rxjs_1 = require("rxjs");
|
|
47
|
-
var operators_1 = require("rxjs/operators");
|
|
48
|
-
var string_decoder_1 = require("string_decoder");
|
|
49
|
-
var util_1 = __importDefault(require("util"));
|
|
50
|
-
var uuid_1 = require("uuid");
|
|
51
|
-
var yaml_1 = __importDefault(require("yaml"));
|
|
52
|
-
var zeromq_1 = __importDefault(require("zeromq"));
|
|
53
|
-
var motion_master_client_1 = require("./motion-master-client");
|
|
54
|
-
var motion_master_notification_1 = require("./motion-master-notification");
|
|
55
|
-
var util_2 = require("./util");
|
|
56
|
-
var ExitStatus;
|
|
57
|
-
(function (ExitStatus) {
|
|
58
|
-
ExitStatus[ExitStatus["SUCCESS"] = 0] = "SUCCESS";
|
|
59
|
-
ExitStatus[ExitStatus["UNCAUGHT_EXCEPTION"] = 1] = "UNCAUGHT_EXCEPTION";
|
|
60
|
-
ExitStatus[ExitStatus["UNHANDLED_REJECTION"] = 2] = "UNHANDLED_REJECTION";
|
|
61
|
-
ExitStatus[ExitStatus["TIMEOUT"] = 3] = "TIMEOUT";
|
|
62
|
-
ExitStatus[ExitStatus["INCORRECT_PARAMETER_FORMAT"] = 4] = "INCORRECT_PARAMETER_FORMAT";
|
|
63
|
-
})(ExitStatus || (ExitStatus = {}));
|
|
64
|
-
// tslint:disable: no-var-requires
|
|
65
|
-
var debug = require('debug')('motion-master-client');
|
|
66
|
-
var version = require('../package.json')['version'];
|
|
67
|
-
// tslint:enable-next-line: no-var-requires
|
|
68
|
-
process.on('uncaughtException', function (err) {
|
|
69
|
-
console.error('Caught exception: ' + err);
|
|
70
|
-
process.exit(ExitStatus.UNCAUGHT_EXCEPTION);
|
|
71
|
-
});
|
|
72
|
-
process.on('unhandledRejection', function (reason) {
|
|
73
|
-
console.error('Unhandled rejection reason: ', reason);
|
|
74
|
-
process.exit(ExitStatus.UNHANDLED_REJECTION);
|
|
75
|
-
});
|
|
76
|
-
var inspectOptions = {
|
|
77
|
-
showHidden: false,
|
|
78
|
-
depth: null,
|
|
79
|
-
colors: true,
|
|
80
|
-
maxArrayLength: null,
|
|
81
|
-
compact: false,
|
|
82
|
-
};
|
|
83
|
-
// map to cache device parameter info per device
|
|
84
|
-
var deviceParameterInfoMap = new Map();
|
|
85
|
-
var motionMasterClient = new motion_master_client_1.MotionMasterClient();
|
|
86
|
-
var motionMasterNotification = new motion_master_notification_1.MotionMasterNotification();
|
|
87
|
-
var config = {
|
|
88
|
-
pingSystemInterval: 150,
|
|
89
|
-
motionMasterHeartbeatTimeoutDue: 1000,
|
|
90
|
-
serverEndpoint: 'tcp://127.0.0.1:62524',
|
|
91
|
-
notificationEndpoint: 'tcp://127.0.0.1:62525',
|
|
92
|
-
identity: uuid_1.v4(),
|
|
93
|
-
};
|
|
94
|
-
//
|
|
95
|
-
// program and commands
|
|
96
|
-
//
|
|
97
|
-
commander_1.default
|
|
98
|
-
.version(version)
|
|
99
|
-
.option('-c, --config <path>', 'path to JSON config file to read and replace the default values with')
|
|
100
|
-
.option('-d, --device-address <address>', 'device address (uint32) generated by Motion Master - takes precedence over device position', parseOptionValueAsInt)
|
|
101
|
-
.option('-f, --output-format <json|yaml>', 'if left unspecified the output format is the default colored message inspect')
|
|
102
|
-
.option('-p, --device-position <position>', 'used when device address is not specified', parseOptionValueAsInt, 0);
|
|
103
|
-
commander_1.default
|
|
104
|
-
.command('request <type> [args...]')
|
|
105
|
-
.option('-i, --interval <value>', 'sending interval in microseconds', parseOptionValueAsInt, 1 * 1000 * 1000)
|
|
106
|
-
.on('--help', function () {
|
|
107
|
-
var types = Object.keys(util_2.MotionMasterMessage.Request).slice(8).map(function (type) { return type.charAt(0).toLowerCase() + type.slice(1); });
|
|
108
|
-
console.log('');
|
|
109
|
-
console.log('Request <type>s:');
|
|
110
|
-
console.log(' ' + types.join('\n '));
|
|
111
|
-
})
|
|
112
|
-
.action(requestAction);
|
|
113
|
-
commander_1.default
|
|
114
|
-
.command('upload [params...]')
|
|
115
|
-
.option('-s, --send-progress')
|
|
116
|
-
.action(uploadAction);
|
|
117
|
-
commander_1.default
|
|
118
|
-
.command('download [paramValues...]')
|
|
119
|
-
.action(downloadAction);
|
|
120
|
-
commander_1.default
|
|
121
|
-
.command('getDeviceFileContent <filename>')
|
|
122
|
-
.action(getDeviceFileContentAction);
|
|
123
|
-
commander_1.default
|
|
124
|
-
.command('getDeviceLogContent')
|
|
125
|
-
.action(getDeviceLogContentAction);
|
|
126
|
-
commander_1.default
|
|
127
|
-
.command('getCoggingTorqueDataContent')
|
|
128
|
-
.action(getCoggingTorqueDataContent);
|
|
129
|
-
commander_1.default
|
|
130
|
-
.command('startCoggingTorqueRecording')
|
|
131
|
-
.option('-s, --skip-auto-tuning')
|
|
132
|
-
.action(startCoggingTorqueRecordingAction);
|
|
133
|
-
commander_1.default
|
|
134
|
-
.command('startOffsetDetection')
|
|
135
|
-
.action(startOffsetDetectionAction);
|
|
136
|
-
commander_1.default
|
|
137
|
-
.command('startPlantIdentification <durationSeconds> <torqueAmplitude> <startFrequency> <endFrequency> <cutoffFrequency>')
|
|
138
|
-
.action(startPlantIdentificationAction);
|
|
139
|
-
commander_1.default
|
|
140
|
-
.command('startSystemIdentification <durationSeconds> <torqueAmplitude> <startFrequency> <endFrequency>')
|
|
141
|
-
.action(startSystemIdentificationAction);
|
|
142
|
-
commander_1.default
|
|
143
|
-
.command('startCirculoEncoderNarrowAngleCalibrationProcedure <encoderOrdinal>')
|
|
144
|
-
.action(startCirculoEncoderNarrowAngleCalibrationProcedureAction);
|
|
145
|
-
commander_1.default
|
|
146
|
-
.command('monitor <topic> [params...]')
|
|
147
|
-
.option('-i, --interval <value>', 'sending interval in microseconds', parseOptionValueAsInt, 1 * 1000 * 1000)
|
|
148
|
-
.action(monitorAction);
|
|
149
|
-
// parse command line arguments and execute the command action
|
|
150
|
-
commander_1.default.parse(process.argv);
|
|
151
|
-
//
|
|
152
|
-
// command action functions
|
|
153
|
-
//
|
|
154
|
-
function requestAction(type, args, cmd) {
|
|
155
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
156
|
-
var deviceAddress, messageId, _a, parameters, deviceParameterInfo_1, parameterValues, name_1, filepath, name_2, content, overwrite, name_3, filepath, firmwarePackageContent, skipSiiInstallation, getDeviceLog, skipAutoTuning, durationSeconds, torqueAmplitude, startFrequency, endFrequency, cutoffFrequency, durationSeconds, torqueAmplitude, startFrequency, endFrequency, computeAutoTuningGainsType, controllerType, settlingTime, positionDamping, alphaMult, order, lb, ub, computeAutoTuningGains, velocityLoopBandwidth, velocityDamping, computeAutoTuningGains, target, setMotionControllerParameters, controllerType, filter, signalGeneratorType, setSignalGeneratorParameters, target, sustainTime, target, sustainTime, repeat, target, profileVelocity, profileAcceleration, profileDeceleration, sustainTime, target, profileVelocity, profileAcceleration, profileDeceleration, sustainTime, repeat, target, profileVelocity, profileAcceleration, profileDeceleration, sustainTime, repeat, amplitude, frequency, repeat, target, sustainTime, target, sustainTime, repeat, target, profileAcceleration, profileDeceleration, sustainTime, target, profileAcceleration, profileDeceleration, sustainTime, repeat, target, profileAcceleration, profileDeceleration, sustainTime, repeat, amplitude, frequency, repeat, target, sustainTime, target, sustainTime, repeat, target, torqueSlope, sustainTime, target, torqueSlope, sustainTime, repeat, target, torqueSlope, sustainTime, repeat, amplitude, frequency, repeat, parameters, getDeviceParameterValues, topic, startMonitoringRequestId, state, timeoutMs, encoderOrdinal, ringRevision, encoderOrdinal, state, devicePosition, filepath, firmwarePackageContent, properties, tuningType, controllerType, tuningType, controllerType, encoderOrdinal, timeoutMs, filepath, command;
|
|
157
|
-
return __generator(this, function (_b) {
|
|
158
|
-
switch (_b.label) {
|
|
159
|
-
case 0:
|
|
160
|
-
connectToMotionMaster(cmd.parent);
|
|
161
|
-
return [4 /*yield*/, getCommandDeviceAddressAsync(cmd.parent)];
|
|
162
|
-
case 1:
|
|
163
|
-
deviceAddress = _b.sent();
|
|
164
|
-
messageId = uuid_1.v4();
|
|
165
|
-
printOnMessageReceived(messageId, cmd.parent.outputFormat);
|
|
166
|
-
_a = type;
|
|
167
|
-
switch (_a) {
|
|
168
|
-
case 'pingSystem': return [3 /*break*/, 2];
|
|
169
|
-
case 'getSystemVersion': return [3 /*break*/, 3];
|
|
170
|
-
case 'getDeviceInfo': return [3 /*break*/, 4];
|
|
171
|
-
case 'getDeviceParameterInfo': return [3 /*break*/, 5];
|
|
172
|
-
case 'getDeviceParameterValues': return [3 /*break*/, 6];
|
|
173
|
-
case 'getMultiDeviceParameterValues': return [3 /*break*/, 7];
|
|
174
|
-
case 'setDeviceParameterValues': return [3 /*break*/, 8];
|
|
175
|
-
case 'setMultiDeviceParameterValues': return [3 /*break*/, 10];
|
|
176
|
-
case 'getDeviceFileList': return [3 /*break*/, 11];
|
|
177
|
-
case 'getDeviceFile': return [3 /*break*/, 12];
|
|
178
|
-
case 'setDeviceFile': return [3 /*break*/, 13];
|
|
179
|
-
case 'deleteDeviceFile': return [3 /*break*/, 14];
|
|
180
|
-
case 'resetDeviceFault': return [3 /*break*/, 15];
|
|
181
|
-
case 'stopDevice': return [3 /*break*/, 16];
|
|
182
|
-
case 'startDeviceFirmwareInstallation': return [3 /*break*/, 17];
|
|
183
|
-
case 'getDeviceLog': return [3 /*break*/, 18];
|
|
184
|
-
case 'startCoggingTorqueRecording': return [3 /*break*/, 19];
|
|
185
|
-
case 'getCoggingTorqueData': return [3 /*break*/, 20];
|
|
186
|
-
case 'startOffsetDetection': return [3 /*break*/, 21];
|
|
187
|
-
case 'startPlantIdentification': return [3 /*break*/, 22];
|
|
188
|
-
case 'startSystemIdentification': return [3 /*break*/, 23];
|
|
189
|
-
case 'computeAutoTuningGains': return [3 /*break*/, 24];
|
|
190
|
-
case 'setMotionControllerParameters': return [3 /*break*/, 25];
|
|
191
|
-
case 'enableMotionController': return [3 /*break*/, 26];
|
|
192
|
-
case 'disableMotionController': return [3 /*break*/, 27];
|
|
193
|
-
case 'setSignalGeneratorParameters': return [3 /*break*/, 28];
|
|
194
|
-
case 'startSignalGenerator': return [3 /*break*/, 29];
|
|
195
|
-
case 'stopSignalGenerator': return [3 /*break*/, 30];
|
|
196
|
-
case 'startMonitoringDeviceParameterValues': return [3 /*break*/, 31];
|
|
197
|
-
case 'stopMonitoringDeviceParameterValues': return [3 /*break*/, 32];
|
|
198
|
-
case 'getEthercatNetworkState': return [3 /*break*/, 33];
|
|
199
|
-
case 'setEthercatNetworkState': return [3 /*break*/, 34];
|
|
200
|
-
case 'startNarrowAngleCalibration': return [3 /*break*/, 35];
|
|
201
|
-
case 'setSystemClientTimeout': return [3 /*break*/, 36];
|
|
202
|
-
case 'getCirculoEncoderMagnetDistance': return [3 /*break*/, 37];
|
|
203
|
-
case 'startCirculoEncoderNarrowAngleCalibrationProcedure': return [3 /*break*/, 38];
|
|
204
|
-
case 'getDeviceCia402State': return [3 /*break*/, 39];
|
|
205
|
-
case 'setDeviceCia402State': return [3 /*break*/, 40];
|
|
206
|
-
case 'getSystemLog': return [3 /*break*/, 41];
|
|
207
|
-
case 'startDeviceSiiRestore': return [3 /*break*/, 42];
|
|
208
|
-
case 'startOpenLoopFieldControl': return [3 /*break*/, 43];
|
|
209
|
-
case 'computeFullAutoTuningGains': return [3 /*break*/, 44];
|
|
210
|
-
case 'startFullAutoTuning': return [3 /*break*/, 45];
|
|
211
|
-
case 'stopFullAutoTuning': return [3 /*break*/, 46];
|
|
212
|
-
case 'startCirculoEncoderConfiguration': return [3 /*break*/, 47];
|
|
213
|
-
case 'startOsCommand': return [3 /*break*/, 48];
|
|
214
|
-
}
|
|
215
|
-
return [3 /*break*/, 49];
|
|
216
|
-
case 2:
|
|
217
|
-
{
|
|
218
|
-
motionMasterClient.requestPingSystem(messageId);
|
|
219
|
-
process.exit(ExitStatus.SUCCESS);
|
|
220
|
-
return [3 /*break*/, 50];
|
|
221
|
-
}
|
|
222
|
-
_b.label = 3;
|
|
223
|
-
case 3:
|
|
224
|
-
{
|
|
225
|
-
exitOnMessageReceived(messageId);
|
|
226
|
-
motionMasterClient.requestGetSystemVersion(messageId);
|
|
227
|
-
return [3 /*break*/, 50];
|
|
228
|
-
}
|
|
229
|
-
_b.label = 4;
|
|
230
|
-
case 4:
|
|
231
|
-
{
|
|
232
|
-
exitOnMessageReceived(messageId);
|
|
233
|
-
motionMasterClient.requestGetDeviceInfo(messageId);
|
|
234
|
-
return [3 /*break*/, 50];
|
|
235
|
-
}
|
|
236
|
-
_b.label = 5;
|
|
237
|
-
case 5:
|
|
238
|
-
{
|
|
239
|
-
exitOnMessageReceived(messageId);
|
|
240
|
-
motionMasterClient.requestGetDeviceParameterInfo(deviceAddress, messageId);
|
|
241
|
-
return [3 /*break*/, 50];
|
|
242
|
-
}
|
|
243
|
-
_b.label = 6;
|
|
244
|
-
case 6:
|
|
245
|
-
{
|
|
246
|
-
exitOnMessageReceived(messageId);
|
|
247
|
-
parameters = args.map(paramToIndexSubindex);
|
|
248
|
-
validateParameters(parameters);
|
|
249
|
-
motionMasterClient.requestGetDeviceParameterValues(deviceAddress, parameters, false, messageId);
|
|
250
|
-
return [3 /*break*/, 50];
|
|
251
|
-
}
|
|
252
|
-
_b.label = 7;
|
|
253
|
-
case 7:
|
|
254
|
-
{
|
|
255
|
-
throw new Error("Request \"" + type + "\" is not yet implemented");
|
|
256
|
-
}
|
|
257
|
-
_b.label = 8;
|
|
258
|
-
case 8:
|
|
259
|
-
exitOnMessageReceived(messageId);
|
|
260
|
-
return [4 /*yield*/, getDeviceParameterInfoAsync(deviceAddress)];
|
|
261
|
-
case 9:
|
|
262
|
-
deviceParameterInfo_1 = _b.sent();
|
|
263
|
-
parameterValues = args.map(function (paramValue) { return paramToIndexSubIndexValue(paramValue, deviceParameterInfo_1); });
|
|
264
|
-
motionMasterClient.requestSetDeviceParameterValues(deviceAddress, parameterValues, messageId);
|
|
265
|
-
return [3 /*break*/, 50];
|
|
266
|
-
case 10:
|
|
267
|
-
{
|
|
268
|
-
throw new Error("Request \"" + type + "\" is not yet implemented");
|
|
269
|
-
}
|
|
270
|
-
_b.label = 11;
|
|
271
|
-
case 11:
|
|
272
|
-
{
|
|
273
|
-
exitOnMessageReceived(messageId);
|
|
274
|
-
motionMasterClient.requestGetDeviceFileList(deviceAddress, messageId);
|
|
275
|
-
return [3 /*break*/, 50];
|
|
276
|
-
}
|
|
277
|
-
_b.label = 12;
|
|
278
|
-
case 12:
|
|
279
|
-
{
|
|
280
|
-
exitOnMessageReceived(messageId);
|
|
281
|
-
name_1 = args[0];
|
|
282
|
-
motionMasterClient.requestGetDeviceFile(deviceAddress, name_1, messageId);
|
|
283
|
-
return [3 /*break*/, 50];
|
|
284
|
-
}
|
|
285
|
-
_b.label = 13;
|
|
286
|
-
case 13:
|
|
287
|
-
{
|
|
288
|
-
exitOnMessageReceived(messageId);
|
|
289
|
-
filepath = args[0];
|
|
290
|
-
name_2 = path_1.default.basename(filepath);
|
|
291
|
-
content = fs_1.default.readFileSync(filepath);
|
|
292
|
-
overwrite = true;
|
|
293
|
-
motionMasterClient.requestSetDeviceFile(deviceAddress, name_2, content, overwrite, messageId);
|
|
294
|
-
return [3 /*break*/, 50];
|
|
295
|
-
}
|
|
296
|
-
_b.label = 14;
|
|
297
|
-
case 14:
|
|
298
|
-
{
|
|
299
|
-
exitOnMessageReceived(messageId);
|
|
300
|
-
name_3 = args[0];
|
|
301
|
-
motionMasterClient.requestDeleteDeviceFile(deviceAddress, name_3, messageId);
|
|
302
|
-
return [3 /*break*/, 50];
|
|
303
|
-
}
|
|
304
|
-
_b.label = 15;
|
|
305
|
-
case 15:
|
|
306
|
-
{
|
|
307
|
-
exitOnMessageReceived(messageId);
|
|
308
|
-
motionMasterClient.requestResetDeviceFault(deviceAddress, messageId);
|
|
309
|
-
return [3 /*break*/, 50];
|
|
310
|
-
}
|
|
311
|
-
_b.label = 16;
|
|
312
|
-
case 16:
|
|
313
|
-
{
|
|
314
|
-
motionMasterClient.requestStopDevice(deviceAddress, messageId);
|
|
315
|
-
process.exit(ExitStatus.SUCCESS);
|
|
316
|
-
return [3 /*break*/, 50];
|
|
317
|
-
}
|
|
318
|
-
_b.label = 17;
|
|
319
|
-
case 17:
|
|
320
|
-
{
|
|
321
|
-
exitOnMessageReceived(messageId, 120000, util_2.MotionMasterMessage.Status.DeviceFirmwareInstallation.Success.Code.DONE);
|
|
322
|
-
filepath = args[0];
|
|
323
|
-
firmwarePackageContent = fs_1.default.readFileSync(filepath);
|
|
324
|
-
skipSiiInstallation = parseInt(args[1], 10) !== 0;
|
|
325
|
-
motionMasterClient.requestStartDeviceFirmwareInstallation(deviceAddress, firmwarePackageContent, skipSiiInstallation, messageId);
|
|
326
|
-
return [3 /*break*/, 50];
|
|
327
|
-
}
|
|
328
|
-
_b.label = 18;
|
|
329
|
-
case 18:
|
|
330
|
-
{
|
|
331
|
-
exitOnMessageReceived(messageId);
|
|
332
|
-
getDeviceLog = { deviceAddress: deviceAddress };
|
|
333
|
-
motionMasterClient.sendRequest({ getDeviceLog: getDeviceLog }, messageId);
|
|
334
|
-
return [3 /*break*/, 50];
|
|
335
|
-
}
|
|
336
|
-
_b.label = 19;
|
|
337
|
-
case 19:
|
|
338
|
-
{
|
|
339
|
-
exitOnMessageReceived(messageId, 300000, util_2.MotionMasterMessage.Status.CoggingTorqueRecording.Success.Code.DONE);
|
|
340
|
-
skipAutoTuning = parseInt(args[0], 10) !== 0;
|
|
341
|
-
motionMasterClient.requestStartCoggingTorqueRecording(deviceAddress, skipAutoTuning, messageId);
|
|
342
|
-
return [3 /*break*/, 50];
|
|
343
|
-
}
|
|
344
|
-
_b.label = 20;
|
|
345
|
-
case 20:
|
|
346
|
-
{
|
|
347
|
-
exitOnMessageReceived(messageId);
|
|
348
|
-
motionMasterClient.requestGetCoggingTorqueData(deviceAddress, messageId);
|
|
349
|
-
return [3 /*break*/, 50];
|
|
350
|
-
}
|
|
351
|
-
_b.label = 21;
|
|
352
|
-
case 21:
|
|
353
|
-
{
|
|
354
|
-
exitOnMessageReceived(messageId, 180000, util_2.MotionMasterMessage.Status.OffsetDetection.Success.Code.DONE);
|
|
355
|
-
motionMasterClient.requestStartOffsetDetection(deviceAddress, messageId);
|
|
356
|
-
return [3 /*break*/, 50];
|
|
357
|
-
}
|
|
358
|
-
_b.label = 22;
|
|
359
|
-
case 22:
|
|
360
|
-
{
|
|
361
|
-
exitOnMessageReceived(messageId, 60000, util_2.MotionMasterMessage.Status.PlantIdentification.Success.Code.DONE);
|
|
362
|
-
durationSeconds = parseFloat(args[0]);
|
|
363
|
-
torqueAmplitude = parseInt(args[1], 10);
|
|
364
|
-
startFrequency = parseInt(args[2], 10);
|
|
365
|
-
endFrequency = parseInt(args[3], 10);
|
|
366
|
-
cutoffFrequency = parseInt(args[4], 10);
|
|
367
|
-
motionMasterClient.requestStartPlantIdentification(deviceAddress, durationSeconds, torqueAmplitude, startFrequency, endFrequency, cutoffFrequency, messageId);
|
|
368
|
-
return [3 /*break*/, 50];
|
|
369
|
-
}
|
|
370
|
-
_b.label = 23;
|
|
371
|
-
case 23:
|
|
372
|
-
{
|
|
373
|
-
exitOnMessageReceived(messageId, 60000, util_2.MotionMasterMessage.Status.SystemIdentification.Success.Code.DONE);
|
|
374
|
-
durationSeconds = parseFloat(args[0]);
|
|
375
|
-
torqueAmplitude = parseInt(args[1], 10);
|
|
376
|
-
startFrequency = parseFloat(args[2]);
|
|
377
|
-
endFrequency = parseFloat(args[3]);
|
|
378
|
-
motionMasterClient.requestStartSystemIdentification(deviceAddress, durationSeconds, torqueAmplitude, startFrequency, endFrequency, messageId);
|
|
379
|
-
return [3 /*break*/, 50];
|
|
380
|
-
}
|
|
381
|
-
_b.label = 24;
|
|
382
|
-
case 24:
|
|
383
|
-
{
|
|
384
|
-
computeAutoTuningGainsType = args[0];
|
|
385
|
-
switch (computeAutoTuningGainsType) {
|
|
386
|
-
case 'positionParameters': {
|
|
387
|
-
exitOnMessageReceived(messageId, 10000, util_2.MotionMasterMessage.Status.AutoTuning.Success.Code.POSITION_DONE);
|
|
388
|
-
controllerType = parseInt(args[1], 10);
|
|
389
|
-
settlingTime = parseFloat(args[2]);
|
|
390
|
-
positionDamping = parseFloat(args[3]);
|
|
391
|
-
alphaMult = parseInt(args[4], 10);
|
|
392
|
-
order = parseInt(args[5], 10);
|
|
393
|
-
lb = parseFloat(args[6]);
|
|
394
|
-
ub = parseFloat(args[7]);
|
|
395
|
-
computeAutoTuningGains = {
|
|
396
|
-
deviceAddress: deviceAddress,
|
|
397
|
-
positionParameters: {
|
|
398
|
-
controllerType: controllerType,
|
|
399
|
-
settlingTime: settlingTime,
|
|
400
|
-
positionDamping: positionDamping,
|
|
401
|
-
alphaMult: alphaMult,
|
|
402
|
-
order: order,
|
|
403
|
-
lb: lb,
|
|
404
|
-
ub: ub,
|
|
405
|
-
},
|
|
406
|
-
};
|
|
407
|
-
motionMasterClient.sendRequest({ computeAutoTuningGains: computeAutoTuningGains }, messageId);
|
|
408
|
-
break;
|
|
409
|
-
}
|
|
410
|
-
case 'velocityParameters': {
|
|
411
|
-
exitOnMessageReceived(messageId, 10000, util_2.MotionMasterMessage.Status.AutoTuning.Success.Code.VELOCITY_DONE);
|
|
412
|
-
velocityLoopBandwidth = parseFloat(args[1]);
|
|
413
|
-
velocityDamping = parseFloat(args[2]);
|
|
414
|
-
computeAutoTuningGains = {
|
|
415
|
-
deviceAddress: deviceAddress,
|
|
416
|
-
velocityParameters: {
|
|
417
|
-
velocityLoopBandwidth: velocityLoopBandwidth,
|
|
418
|
-
velocityDamping: velocityDamping,
|
|
419
|
-
},
|
|
420
|
-
};
|
|
421
|
-
motionMasterClient.sendRequest({ computeAutoTuningGains: computeAutoTuningGains }, messageId);
|
|
422
|
-
break;
|
|
423
|
-
}
|
|
424
|
-
default: {
|
|
425
|
-
throw new Error("Unknown compute auto-tuning gains type: " + computeAutoTuningGainsType);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
return [3 /*break*/, 50];
|
|
429
|
-
}
|
|
430
|
-
_b.label = 25;
|
|
431
|
-
case 25:
|
|
432
|
-
{
|
|
433
|
-
target = parseInt(args[0], 10);
|
|
434
|
-
setMotionControllerParameters = {
|
|
435
|
-
deviceAddress: deviceAddress,
|
|
436
|
-
target: target,
|
|
437
|
-
};
|
|
438
|
-
motionMasterClient.sendRequest({ setMotionControllerParameters: setMotionControllerParameters }, messageId);
|
|
439
|
-
process.exit(ExitStatus.SUCCESS);
|
|
440
|
-
return [3 /*break*/, 50];
|
|
441
|
-
}
|
|
442
|
-
_b.label = 26;
|
|
443
|
-
case 26:
|
|
444
|
-
{
|
|
445
|
-
exitOnMessageReceived(messageId);
|
|
446
|
-
controllerType = parseInt(args[0], 10);
|
|
447
|
-
filter = parseInt(args[1], 10) !== 0;
|
|
448
|
-
motionMasterClient.requestEnableMotionController(deviceAddress, controllerType, filter, messageId);
|
|
449
|
-
return [3 /*break*/, 50];
|
|
450
|
-
}
|
|
451
|
-
_b.label = 27;
|
|
452
|
-
case 27:
|
|
453
|
-
{
|
|
454
|
-
motionMasterClient.requestDisableMotionController(deviceAddress, messageId);
|
|
455
|
-
process.exit(ExitStatus.SUCCESS);
|
|
456
|
-
return [3 /*break*/, 50];
|
|
457
|
-
}
|
|
458
|
-
_b.label = 28;
|
|
459
|
-
case 28:
|
|
460
|
-
{
|
|
461
|
-
signalGeneratorType = args[0];
|
|
462
|
-
setSignalGeneratorParameters = { deviceAddress: deviceAddress };
|
|
463
|
-
switch (signalGeneratorType) {
|
|
464
|
-
case 'positionStepResponse': {
|
|
465
|
-
target = parseInt(args[1], 10);
|
|
466
|
-
sustainTime = parseInt(args[2], 10);
|
|
467
|
-
setSignalGeneratorParameters.positionStepResponse = {
|
|
468
|
-
target: target,
|
|
469
|
-
sustainTime: sustainTime,
|
|
470
|
-
};
|
|
471
|
-
break;
|
|
472
|
-
}
|
|
473
|
-
case 'positionAdvancedStepResponse': {
|
|
474
|
-
target = parseInt(args[1], 10);
|
|
475
|
-
sustainTime = parseInt(args[2], 10);
|
|
476
|
-
repeat = parseInt(args[3], 10) !== 0;
|
|
477
|
-
setSignalGeneratorParameters.positionAdvancedStepResponse = {
|
|
478
|
-
target: target,
|
|
479
|
-
sustainTime: sustainTime,
|
|
480
|
-
repeat: repeat,
|
|
481
|
-
};
|
|
482
|
-
break;
|
|
483
|
-
}
|
|
484
|
-
case 'positionRamp': {
|
|
485
|
-
target = parseInt(args[1], 10);
|
|
486
|
-
profileVelocity = parseInt(args[2], 10);
|
|
487
|
-
profileAcceleration = parseInt(args[3], 10);
|
|
488
|
-
profileDeceleration = parseInt(args[4], 10);
|
|
489
|
-
sustainTime = parseInt(args[5], 10);
|
|
490
|
-
setSignalGeneratorParameters.positionRamp = {
|
|
491
|
-
target: target,
|
|
492
|
-
profileVelocity: profileVelocity,
|
|
493
|
-
profileAcceleration: profileAcceleration,
|
|
494
|
-
profileDeceleration: profileDeceleration,
|
|
495
|
-
sustainTime: sustainTime,
|
|
496
|
-
};
|
|
497
|
-
break;
|
|
498
|
-
}
|
|
499
|
-
case 'positionTrapezoidal': {
|
|
500
|
-
target = parseInt(args[1], 10);
|
|
501
|
-
profileVelocity = parseInt(args[2], 10);
|
|
502
|
-
profileAcceleration = parseInt(args[3], 10);
|
|
503
|
-
profileDeceleration = parseInt(args[4], 10);
|
|
504
|
-
sustainTime = parseInt(args[5], 10);
|
|
505
|
-
repeat = parseInt(args[6], 10) !== 0;
|
|
506
|
-
setSignalGeneratorParameters.positionTrapezoidal = {
|
|
507
|
-
target: target,
|
|
508
|
-
profileVelocity: profileVelocity,
|
|
509
|
-
profileAcceleration: profileAcceleration,
|
|
510
|
-
profileDeceleration: profileDeceleration,
|
|
511
|
-
sustainTime: sustainTime,
|
|
512
|
-
repeat: repeat,
|
|
513
|
-
};
|
|
514
|
-
break;
|
|
515
|
-
}
|
|
516
|
-
case 'positionBidirectional': {
|
|
517
|
-
target = parseInt(args[1], 10);
|
|
518
|
-
profileVelocity = parseInt(args[2], 10);
|
|
519
|
-
profileAcceleration = parseInt(args[3], 10);
|
|
520
|
-
profileDeceleration = parseInt(args[4], 10);
|
|
521
|
-
sustainTime = parseInt(args[5], 10);
|
|
522
|
-
repeat = parseInt(args[6], 10) !== 0;
|
|
523
|
-
setSignalGeneratorParameters.positionBidirectional = {
|
|
524
|
-
target: target,
|
|
525
|
-
profileVelocity: profileVelocity,
|
|
526
|
-
profileAcceleration: profileAcceleration,
|
|
527
|
-
profileDeceleration: profileDeceleration,
|
|
528
|
-
sustainTime: sustainTime,
|
|
529
|
-
repeat: repeat,
|
|
530
|
-
};
|
|
531
|
-
break;
|
|
532
|
-
}
|
|
533
|
-
case 'positionSineWave': {
|
|
534
|
-
amplitude = parseInt(args[1], 10);
|
|
535
|
-
frequency = parseFloat(args[2]);
|
|
536
|
-
repeat = parseInt(args[3], 10) !== 0;
|
|
537
|
-
setSignalGeneratorParameters.positionSineWave = {
|
|
538
|
-
amplitude: amplitude,
|
|
539
|
-
frequency: frequency,
|
|
540
|
-
repeat: repeat,
|
|
541
|
-
};
|
|
542
|
-
break;
|
|
543
|
-
}
|
|
544
|
-
case 'velocityStepResponse': {
|
|
545
|
-
target = parseInt(args[1], 10);
|
|
546
|
-
sustainTime = parseInt(args[2], 10);
|
|
547
|
-
setSignalGeneratorParameters.velocityStepResponse = {
|
|
548
|
-
target: target,
|
|
549
|
-
sustainTime: sustainTime,
|
|
550
|
-
};
|
|
551
|
-
break;
|
|
552
|
-
}
|
|
553
|
-
case 'velocityAdvancedStepResponse': {
|
|
554
|
-
target = parseInt(args[1], 10);
|
|
555
|
-
sustainTime = parseInt(args[2], 10);
|
|
556
|
-
repeat = parseInt(args[3], 10) !== 0;
|
|
557
|
-
setSignalGeneratorParameters.velocityAdvancedStepResponse = {
|
|
558
|
-
target: target,
|
|
559
|
-
sustainTime: sustainTime,
|
|
560
|
-
repeat: repeat,
|
|
561
|
-
};
|
|
562
|
-
break;
|
|
563
|
-
}
|
|
564
|
-
case 'velocityRamp': {
|
|
565
|
-
target = parseInt(args[1], 10);
|
|
566
|
-
profileAcceleration = parseInt(args[2], 10);
|
|
567
|
-
profileDeceleration = parseInt(args[3], 10);
|
|
568
|
-
sustainTime = parseInt(args[4], 10);
|
|
569
|
-
setSignalGeneratorParameters.velocityRamp = {
|
|
570
|
-
target: target,
|
|
571
|
-
profileAcceleration: profileAcceleration,
|
|
572
|
-
profileDeceleration: profileDeceleration,
|
|
573
|
-
sustainTime: sustainTime,
|
|
574
|
-
};
|
|
575
|
-
break;
|
|
576
|
-
}
|
|
577
|
-
case 'velocityTrapezoidal': {
|
|
578
|
-
target = parseInt(args[1], 10);
|
|
579
|
-
profileAcceleration = parseInt(args[2], 10);
|
|
580
|
-
profileDeceleration = parseInt(args[3], 10);
|
|
581
|
-
sustainTime = parseInt(args[4], 10);
|
|
582
|
-
repeat = parseInt(args[5], 10) !== 0;
|
|
583
|
-
setSignalGeneratorParameters.velocityTrapezoidal = {
|
|
584
|
-
target: target,
|
|
585
|
-
profileAcceleration: profileAcceleration,
|
|
586
|
-
profileDeceleration: profileDeceleration,
|
|
587
|
-
sustainTime: sustainTime,
|
|
588
|
-
repeat: repeat,
|
|
589
|
-
};
|
|
590
|
-
break;
|
|
591
|
-
}
|
|
592
|
-
case 'velocityBidirectional': {
|
|
593
|
-
target = parseInt(args[1], 10);
|
|
594
|
-
profileAcceleration = parseInt(args[2], 10);
|
|
595
|
-
profileDeceleration = parseInt(args[3], 10);
|
|
596
|
-
sustainTime = parseInt(args[4], 10);
|
|
597
|
-
repeat = parseInt(args[5], 10) !== 0;
|
|
598
|
-
setSignalGeneratorParameters.velocityBidirectional = {
|
|
599
|
-
target: target,
|
|
600
|
-
profileAcceleration: profileAcceleration,
|
|
601
|
-
profileDeceleration: profileDeceleration,
|
|
602
|
-
sustainTime: sustainTime,
|
|
603
|
-
repeat: repeat,
|
|
604
|
-
};
|
|
605
|
-
break;
|
|
606
|
-
}
|
|
607
|
-
case 'velocitySineWave': {
|
|
608
|
-
amplitude = parseInt(args[1], 10);
|
|
609
|
-
frequency = parseFloat(args[2]);
|
|
610
|
-
repeat = parseInt(args[3], 10) !== 0;
|
|
611
|
-
setSignalGeneratorParameters.velocitySineWave = {
|
|
612
|
-
amplitude: amplitude,
|
|
613
|
-
frequency: frequency,
|
|
614
|
-
repeat: repeat,
|
|
615
|
-
};
|
|
616
|
-
break;
|
|
617
|
-
}
|
|
618
|
-
case 'torqueStepResponse': {
|
|
619
|
-
target = parseInt(args[1], 10);
|
|
620
|
-
sustainTime = parseInt(args[2], 10);
|
|
621
|
-
setSignalGeneratorParameters.torqueStepResponse = {
|
|
622
|
-
target: target,
|
|
623
|
-
sustainTime: sustainTime,
|
|
624
|
-
};
|
|
625
|
-
break;
|
|
626
|
-
}
|
|
627
|
-
case 'torqueAdvancedStepResponse': {
|
|
628
|
-
target = parseInt(args[1], 10);
|
|
629
|
-
sustainTime = parseInt(args[2], 10);
|
|
630
|
-
repeat = parseInt(args[3], 10) !== 0;
|
|
631
|
-
setSignalGeneratorParameters.torqueAdvancedStepResponse = {
|
|
632
|
-
target: target,
|
|
633
|
-
sustainTime: sustainTime,
|
|
634
|
-
repeat: repeat,
|
|
635
|
-
};
|
|
636
|
-
break;
|
|
637
|
-
}
|
|
638
|
-
case 'torqueRamp': {
|
|
639
|
-
target = parseInt(args[1], 10);
|
|
640
|
-
torqueSlope = parseInt(args[2], 10);
|
|
641
|
-
sustainTime = parseInt(args[3], 10);
|
|
642
|
-
setSignalGeneratorParameters.torqueRamp = {
|
|
643
|
-
target: target,
|
|
644
|
-
torqueSlope: torqueSlope,
|
|
645
|
-
sustainTime: sustainTime,
|
|
646
|
-
};
|
|
647
|
-
break;
|
|
648
|
-
}
|
|
649
|
-
case 'torqueTrapezoidal': {
|
|
650
|
-
target = parseInt(args[1], 10);
|
|
651
|
-
torqueSlope = parseInt(args[2], 10);
|
|
652
|
-
sustainTime = parseInt(args[3], 10);
|
|
653
|
-
repeat = parseInt(args[4], 10) !== 0;
|
|
654
|
-
setSignalGeneratorParameters.torqueTrapezoidal = {
|
|
655
|
-
target: target,
|
|
656
|
-
torqueSlope: torqueSlope,
|
|
657
|
-
sustainTime: sustainTime,
|
|
658
|
-
repeat: repeat,
|
|
659
|
-
};
|
|
660
|
-
break;
|
|
661
|
-
}
|
|
662
|
-
case 'torqueBidirectional': {
|
|
663
|
-
target = parseInt(args[1], 10);
|
|
664
|
-
torqueSlope = parseInt(args[2], 10);
|
|
665
|
-
sustainTime = parseInt(args[3], 10);
|
|
666
|
-
repeat = parseInt(args[4], 10) !== 0;
|
|
667
|
-
setSignalGeneratorParameters.torqueBidirectional = {
|
|
668
|
-
target: target,
|
|
669
|
-
torqueSlope: torqueSlope,
|
|
670
|
-
sustainTime: sustainTime,
|
|
671
|
-
repeat: repeat,
|
|
672
|
-
};
|
|
673
|
-
break;
|
|
674
|
-
}
|
|
675
|
-
case 'torqueSineWave': {
|
|
676
|
-
amplitude = parseInt(args[1], 10);
|
|
677
|
-
frequency = parseFloat(args[2]);
|
|
678
|
-
repeat = parseInt(args[3], 10) !== 0;
|
|
679
|
-
setSignalGeneratorParameters.torqueSineWave = {
|
|
680
|
-
amplitude: amplitude,
|
|
681
|
-
frequency: frequency,
|
|
682
|
-
repeat: repeat,
|
|
683
|
-
};
|
|
684
|
-
break;
|
|
685
|
-
}
|
|
686
|
-
default: {
|
|
687
|
-
throw new Error("Unknown set signal generator parameters type: " + signalGeneratorType);
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
motionMasterClient.sendRequest({ setSignalGeneratorParameters: setSignalGeneratorParameters }, messageId);
|
|
691
|
-
process.exit(ExitStatus.SUCCESS);
|
|
692
|
-
return [3 /*break*/, 50];
|
|
693
|
-
}
|
|
694
|
-
_b.label = 29;
|
|
695
|
-
case 29:
|
|
696
|
-
{
|
|
697
|
-
exitOnMessageReceived(messageId, 2147483647, util_2.MotionMasterMessage.Status.SignalGenerator.Success.Code.DONE);
|
|
698
|
-
motionMasterClient.requestStartSignalGenerator(deviceAddress, messageId);
|
|
699
|
-
return [3 /*break*/, 50];
|
|
700
|
-
}
|
|
701
|
-
_b.label = 30;
|
|
702
|
-
case 30:
|
|
703
|
-
{
|
|
704
|
-
motionMasterClient.requestStopSignalGenerator(deviceAddress, messageId);
|
|
705
|
-
process.exit(ExitStatus.SUCCESS);
|
|
706
|
-
return [3 /*break*/, 50];
|
|
707
|
-
}
|
|
708
|
-
_b.label = 31;
|
|
709
|
-
case 31:
|
|
710
|
-
{
|
|
711
|
-
parameters = args.slice(1).map(paramToIndexSubindex);
|
|
712
|
-
validateParameters(parameters);
|
|
713
|
-
getDeviceParameterValues = { deviceAddress: deviceAddress, parameters: parameters };
|
|
714
|
-
topic = args[0];
|
|
715
|
-
requestStartMonitoringDeviceParameterValues({ getDeviceParameterValues: getDeviceParameterValues, interval: cmd.interval, topic: topic });
|
|
716
|
-
return [3 /*break*/, 50];
|
|
717
|
-
}
|
|
718
|
-
_b.label = 32;
|
|
719
|
-
case 32:
|
|
720
|
-
{
|
|
721
|
-
startMonitoringRequestId = args[0];
|
|
722
|
-
motionMasterClient.requestStopMonitoringDeviceParameterValues(startMonitoringRequestId, messageId);
|
|
723
|
-
process.exit(ExitStatus.SUCCESS);
|
|
724
|
-
return [3 /*break*/, 50];
|
|
725
|
-
}
|
|
726
|
-
_b.label = 33;
|
|
727
|
-
case 33:
|
|
728
|
-
{
|
|
729
|
-
exitOnMessageReceived(messageId);
|
|
730
|
-
motionMasterClient.requestGetEthercatNetworkState(deviceAddress, messageId);
|
|
731
|
-
return [3 /*break*/, 50];
|
|
732
|
-
}
|
|
733
|
-
_b.label = 34;
|
|
734
|
-
case 34:
|
|
735
|
-
{
|
|
736
|
-
exitOnMessageReceived(messageId);
|
|
737
|
-
state = parseInt(args[0], 10);
|
|
738
|
-
motionMasterClient.requestSetEthercatNetworkState(deviceAddress, state, messageId);
|
|
739
|
-
return [3 /*break*/, 50];
|
|
740
|
-
}
|
|
741
|
-
_b.label = 35;
|
|
742
|
-
case 35:
|
|
743
|
-
{
|
|
744
|
-
exitOnMessageReceived(messageId, 180000, util_2.MotionMasterMessage.Status.NarrowAngleCalibration.Success.Code.DONE);
|
|
745
|
-
motionMasterClient.requestStartNarrowAngleCalibration(deviceAddress);
|
|
746
|
-
return [3 /*break*/, 50];
|
|
747
|
-
}
|
|
748
|
-
_b.label = 36;
|
|
749
|
-
case 36:
|
|
750
|
-
{
|
|
751
|
-
timeoutMs = parseInt(args[0], 10);
|
|
752
|
-
motionMasterClient.requestSetSystemClientTimeout(timeoutMs, messageId);
|
|
753
|
-
process.exit(ExitStatus.SUCCESS);
|
|
754
|
-
return [3 /*break*/, 50];
|
|
755
|
-
}
|
|
756
|
-
_b.label = 37;
|
|
757
|
-
case 37:
|
|
758
|
-
{
|
|
759
|
-
exitOnMessageReceived(messageId);
|
|
760
|
-
encoderOrdinal = parseInt(args[0], 10);
|
|
761
|
-
ringRevision = parseInt(args[1], 10);
|
|
762
|
-
motionMasterClient.requestGetCirculoEncoderMagnetDistance(deviceAddress, encoderOrdinal, ringRevision, messageId);
|
|
763
|
-
return [3 /*break*/, 50];
|
|
764
|
-
}
|
|
765
|
-
_b.label = 38;
|
|
766
|
-
case 38:
|
|
767
|
-
{
|
|
768
|
-
exitOnMessageReceived(messageId, 60000, util_2.MotionMasterMessage.Status.CirculoEncoderNarrowAngleCalibrationProcedure.Success.Code.DONE);
|
|
769
|
-
encoderOrdinal = parseInt(args[0], 10);
|
|
770
|
-
motionMasterClient.requestStartCirculoEncoderNarrowAngleCalibrationProcedure(deviceAddress, encoderOrdinal, messageId);
|
|
771
|
-
return [3 /*break*/, 50];
|
|
772
|
-
}
|
|
773
|
-
_b.label = 39;
|
|
774
|
-
case 39:
|
|
775
|
-
{
|
|
776
|
-
exitOnMessageReceived(messageId);
|
|
777
|
-
motionMasterClient.requestGetDeviceCia402State(deviceAddress, messageId);
|
|
778
|
-
return [3 /*break*/, 50];
|
|
779
|
-
}
|
|
780
|
-
_b.label = 40;
|
|
781
|
-
case 40:
|
|
782
|
-
{
|
|
783
|
-
exitOnMessageReceived(messageId);
|
|
784
|
-
state = parseInt(args[0], 10);
|
|
785
|
-
motionMasterClient.requestSetDeviceCia402State(deviceAddress, state, messageId);
|
|
786
|
-
return [3 /*break*/, 50];
|
|
787
|
-
}
|
|
788
|
-
_b.label = 41;
|
|
789
|
-
case 41:
|
|
790
|
-
{
|
|
791
|
-
exitOnMessageReceived(messageId);
|
|
792
|
-
motionMasterClient.requestGetSystemLog(messageId);
|
|
793
|
-
return [3 /*break*/, 50];
|
|
794
|
-
}
|
|
795
|
-
_b.label = 42;
|
|
796
|
-
case 42:
|
|
797
|
-
{
|
|
798
|
-
exitOnMessageReceived(messageId, 120000, util_2.MotionMasterMessage.Status.DeviceSiiRestore.Success.Code.DONE);
|
|
799
|
-
devicePosition = parseInt(args[0], 10);
|
|
800
|
-
filepath = args[1];
|
|
801
|
-
firmwarePackageContent = fs_1.default.readFileSync(filepath);
|
|
802
|
-
motionMasterClient.requestStartDeviceSiiRestore(devicePosition, firmwarePackageContent, messageId);
|
|
803
|
-
return [3 /*break*/, 50];
|
|
804
|
-
}
|
|
805
|
-
_b.label = 43;
|
|
806
|
-
case 43:
|
|
807
|
-
{
|
|
808
|
-
exitOnMessageReceived(messageId, 2147483647, util_2.MotionMasterMessage.Status.OpenLoopFieldControl.Success.Code.DONE);
|
|
809
|
-
properties = {
|
|
810
|
-
deviceAddress: deviceAddress,
|
|
811
|
-
angle: parseInt(args[0], 10),
|
|
812
|
-
velocity: parseInt(args[1], 10),
|
|
813
|
-
acceleration: parseInt(args[2], 10),
|
|
814
|
-
torque: parseInt(args[3], 10),
|
|
815
|
-
torqueSpeed: parseInt(args[4], 10),
|
|
816
|
-
};
|
|
817
|
-
motionMasterClient.requestStartOpenLoopFieldControl(properties, messageId);
|
|
818
|
-
return [3 /*break*/, 50];
|
|
819
|
-
}
|
|
820
|
-
_b.label = 44;
|
|
821
|
-
case 44:
|
|
822
|
-
{
|
|
823
|
-
tuningType = parseInt(args[0], 10);
|
|
824
|
-
controllerType = args[1] // UNSPECIFIED (0), PI_P (1), P_PI (2)
|
|
825
|
-
? parseInt(args[1], 10)
|
|
826
|
-
: util_2.MotionMasterMessage.Request.ComputeFullAutoTuningGains.ControllerType.UNSPECIFIED;
|
|
827
|
-
switch (tuningType) {
|
|
828
|
-
case 0: {
|
|
829
|
-
exitOnMessageReceived(messageId, 10000, util_2.MotionMasterMessage.Status.FullAutoTuning.Success.Code.POSITION_DONE);
|
|
830
|
-
motionMasterClient.requestComputeFullAutoTuningGains(deviceAddress, tuningType, controllerType, messageId);
|
|
831
|
-
break;
|
|
832
|
-
}
|
|
833
|
-
case 1: {
|
|
834
|
-
exitOnMessageReceived(messageId, 10000, util_2.MotionMasterMessage.Status.FullAutoTuning.Success.Code.VELOCITY_DONE);
|
|
835
|
-
motionMasterClient.requestComputeFullAutoTuningGains(deviceAddress, tuningType, controllerType, messageId);
|
|
836
|
-
break;
|
|
837
|
-
}
|
|
838
|
-
default: {
|
|
839
|
-
throw new Error("Unknown compute auto-tuning gains type: " + tuningType);
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
return [3 /*break*/, 50];
|
|
843
|
-
}
|
|
844
|
-
_b.label = 45;
|
|
845
|
-
case 45:
|
|
846
|
-
{
|
|
847
|
-
tuningType = parseInt(args[0], 10);
|
|
848
|
-
controllerType = args[1] // UNSPECIFIED (0), PI_P (1), P_PI (2)
|
|
849
|
-
? parseInt(args[1], 10)
|
|
850
|
-
: util_2.MotionMasterMessage.Request.StartFullAutoTuning.ControllerType.UNSPECIFIED;
|
|
851
|
-
switch (tuningType) {
|
|
852
|
-
case 0: {
|
|
853
|
-
exitOnMessageReceived(messageId, 10000, util_2.MotionMasterMessage.Status.FullAutoTuning.Success.Code.POSITION_DONE);
|
|
854
|
-
motionMasterClient.requestStartFullAutoTuning(deviceAddress, tuningType, controllerType, messageId);
|
|
855
|
-
break;
|
|
856
|
-
}
|
|
857
|
-
case 1: {
|
|
858
|
-
exitOnMessageReceived(messageId, 10000, util_2.MotionMasterMessage.Status.FullAutoTuning.Success.Code.VELOCITY_DONE);
|
|
859
|
-
motionMasterClient.requestStartFullAutoTuning(deviceAddress, tuningType, controllerType, messageId);
|
|
860
|
-
break;
|
|
861
|
-
}
|
|
862
|
-
default: {
|
|
863
|
-
throw new Error("Unknown start auto-tuning type: " + tuningType);
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
return [3 /*break*/, 50];
|
|
867
|
-
}
|
|
868
|
-
_b.label = 46;
|
|
869
|
-
case 46:
|
|
870
|
-
{
|
|
871
|
-
motionMasterClient.requestStopFullAutoTuning(deviceAddress, messageId);
|
|
872
|
-
return [3 /*break*/, 50];
|
|
873
|
-
}
|
|
874
|
-
_b.label = 47;
|
|
875
|
-
case 47:
|
|
876
|
-
{
|
|
877
|
-
exitOnMessageReceived(messageId, 60000, util_2.MotionMasterMessage.Status.CirculoEncoderConfiguration.Success.Code.DONE);
|
|
878
|
-
encoderOrdinal = parseInt(args[0], 10);
|
|
879
|
-
motionMasterClient.requestStartCirculoEncoderConfiguration(deviceAddress, encoderOrdinal, messageId);
|
|
880
|
-
return [3 /*break*/, 50];
|
|
881
|
-
}
|
|
882
|
-
_b.label = 48;
|
|
883
|
-
case 48:
|
|
884
|
-
{
|
|
885
|
-
exitOnMessageReceived(messageId, 60000, util_2.MotionMasterMessage.Status.OsCommand.Success.Code.DONE);
|
|
886
|
-
timeoutMs = parseInt(args[0], 10);
|
|
887
|
-
filepath = args[1];
|
|
888
|
-
command = fs_1.default.readFileSync(filepath);
|
|
889
|
-
motionMasterClient.requestStartOsCommand(deviceAddress, timeoutMs, command, messageId);
|
|
890
|
-
return [3 /*break*/, 50];
|
|
891
|
-
}
|
|
892
|
-
_b.label = 49;
|
|
893
|
-
case 49:
|
|
894
|
-
{
|
|
895
|
-
throw new Error("Request \"" + type + "\" doesn't exist");
|
|
896
|
-
}
|
|
897
|
-
_b.label = 50;
|
|
898
|
-
case 50: return [2 /*return*/];
|
|
899
|
-
}
|
|
900
|
-
});
|
|
901
|
-
});
|
|
902
|
-
}
|
|
903
|
-
function uploadAction(params, cmd) {
|
|
904
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
905
|
-
var deviceAddress, sendProgress, messageId, parameters, getDeviceParameterValues;
|
|
906
|
-
return __generator(this, function (_a) {
|
|
907
|
-
switch (_a.label) {
|
|
908
|
-
case 0:
|
|
909
|
-
connectToMotionMaster(cmd.parent);
|
|
910
|
-
return [4 /*yield*/, getCommandDeviceAddressAsync(cmd.parent)];
|
|
911
|
-
case 1:
|
|
912
|
-
deviceAddress = _a.sent();
|
|
913
|
-
sendProgress = cmd.sendProgress;
|
|
914
|
-
messageId = uuid_1.v4();
|
|
915
|
-
printOnMessageReceived(messageId, cmd.parent.outputFormat);
|
|
916
|
-
exitOnMessageReceived(messageId);
|
|
917
|
-
parameters = params.map(paramToIndexSubindex);
|
|
918
|
-
validateParameters(parameters);
|
|
919
|
-
getDeviceParameterValues = { deviceAddress: deviceAddress, parameters: parameters, sendProgress: sendProgress };
|
|
920
|
-
motionMasterClient.sendRequest({ getDeviceParameterValues: getDeviceParameterValues }, messageId);
|
|
921
|
-
return [2 /*return*/];
|
|
922
|
-
}
|
|
923
|
-
});
|
|
924
|
-
});
|
|
925
|
-
}
|
|
926
|
-
function downloadAction(paramValues, cmd) {
|
|
927
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
928
|
-
var deviceAddress, messageId, deviceParameterInfo, parameterValues, setDeviceParameterValues;
|
|
929
|
-
return __generator(this, function (_a) {
|
|
930
|
-
switch (_a.label) {
|
|
931
|
-
case 0:
|
|
932
|
-
connectToMotionMaster(cmd.parent);
|
|
933
|
-
return [4 /*yield*/, getCommandDeviceAddressAsync(cmd.parent)];
|
|
934
|
-
case 1:
|
|
935
|
-
deviceAddress = _a.sent();
|
|
936
|
-
messageId = uuid_1.v4();
|
|
937
|
-
printOnMessageReceived(messageId, cmd.parent.outputFormat);
|
|
938
|
-
exitOnMessageReceived(messageId);
|
|
939
|
-
return [4 /*yield*/, getDeviceParameterInfoAsync(deviceAddress)];
|
|
940
|
-
case 2:
|
|
941
|
-
deviceParameterInfo = _a.sent();
|
|
942
|
-
parameterValues = paramValues.map(function (paramValue) { return paramToIndexSubIndexValue(paramValue, deviceParameterInfo); });
|
|
943
|
-
setDeviceParameterValues = { deviceAddress: deviceAddress, parameterValues: parameterValues };
|
|
944
|
-
motionMasterClient.sendRequest({ setDeviceParameterValues: setDeviceParameterValues }, messageId);
|
|
945
|
-
return [2 /*return*/];
|
|
946
|
-
}
|
|
947
|
-
});
|
|
948
|
-
});
|
|
949
|
-
}
|
|
950
|
-
function getDeviceFileContentAction(name, cmd) {
|
|
951
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
952
|
-
var deviceAddress, messageId, getDeviceFile;
|
|
953
|
-
return __generator(this, function (_a) {
|
|
954
|
-
switch (_a.label) {
|
|
955
|
-
case 0:
|
|
956
|
-
connectToMotionMaster(cmd.parent);
|
|
957
|
-
return [4 /*yield*/, getCommandDeviceAddressAsync(cmd.parent)];
|
|
958
|
-
case 1:
|
|
959
|
-
deviceAddress = _a.sent();
|
|
960
|
-
messageId = uuid_1.v4();
|
|
961
|
-
motionMasterClient.selectMessage(messageId).pipe(operators_1.first()).subscribe(function (message) {
|
|
962
|
-
if (message && message.status && message.status.deviceFile) {
|
|
963
|
-
var error = message.status.deviceFile.error;
|
|
964
|
-
if (error) {
|
|
965
|
-
throw new Error(error.code + ": " + error.message);
|
|
966
|
-
}
|
|
967
|
-
else {
|
|
968
|
-
var content = message.status.deviceFile.content;
|
|
969
|
-
if (content) {
|
|
970
|
-
var contentDecoded = new string_decoder_1.StringDecoder('utf-8').write(Buffer.from(content));
|
|
971
|
-
console.log(contentDecoded);
|
|
972
|
-
process.exit(ExitStatus.SUCCESS);
|
|
973
|
-
}
|
|
974
|
-
else {
|
|
975
|
-
throw new Error('Device file content is empty');
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
else {
|
|
980
|
-
throw new Error('The received message is not "deviceFile"');
|
|
981
|
-
}
|
|
982
|
-
});
|
|
983
|
-
getDeviceFile = { deviceAddress: deviceAddress, name: name };
|
|
984
|
-
motionMasterClient.sendRequest({ getDeviceFile: getDeviceFile }, messageId);
|
|
985
|
-
return [2 /*return*/];
|
|
986
|
-
}
|
|
987
|
-
});
|
|
988
|
-
});
|
|
989
|
-
}
|
|
990
|
-
function getDeviceLogContentAction(cmd) {
|
|
991
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
992
|
-
var deviceAddress, messageId, getDeviceLog;
|
|
993
|
-
return __generator(this, function (_a) {
|
|
994
|
-
switch (_a.label) {
|
|
995
|
-
case 0:
|
|
996
|
-
connectToMotionMaster(cmd.parent);
|
|
997
|
-
return [4 /*yield*/, getCommandDeviceAddressAsync(cmd.parent)];
|
|
998
|
-
case 1:
|
|
999
|
-
deviceAddress = _a.sent();
|
|
1000
|
-
messageId = uuid_1.v4();
|
|
1001
|
-
motionMasterClient.selectMessage(messageId).pipe(operators_1.first()).subscribe(function (message) {
|
|
1002
|
-
if (message && message.status && message.status.deviceLog) {
|
|
1003
|
-
var error = message.status.deviceLog.error;
|
|
1004
|
-
if (error) {
|
|
1005
|
-
throw new Error(error.code + ": " + error.message);
|
|
1006
|
-
}
|
|
1007
|
-
else {
|
|
1008
|
-
var content = message.status.deviceLog.content;
|
|
1009
|
-
if (content) {
|
|
1010
|
-
var contentDecoded = new string_decoder_1.StringDecoder('utf-8').write(Buffer.from(content));
|
|
1011
|
-
console.log(contentDecoded);
|
|
1012
|
-
process.exit(ExitStatus.SUCCESS);
|
|
1013
|
-
}
|
|
1014
|
-
else {
|
|
1015
|
-
throw new Error('Device log content is empty');
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
|
-
else {
|
|
1020
|
-
throw new Error('The received message is not "deviceLog"');
|
|
1021
|
-
}
|
|
1022
|
-
});
|
|
1023
|
-
getDeviceLog = { deviceAddress: deviceAddress };
|
|
1024
|
-
motionMasterClient.sendRequest({ getDeviceLog: getDeviceLog }, messageId);
|
|
1025
|
-
return [2 /*return*/];
|
|
1026
|
-
}
|
|
1027
|
-
});
|
|
1028
|
-
});
|
|
1029
|
-
}
|
|
1030
|
-
function getCoggingTorqueDataContent(cmd) {
|
|
1031
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1032
|
-
var deviceAddress, messageId, getCoggingTorqueData;
|
|
1033
|
-
return __generator(this, function (_a) {
|
|
1034
|
-
switch (_a.label) {
|
|
1035
|
-
case 0:
|
|
1036
|
-
connectToMotionMaster(cmd.parent);
|
|
1037
|
-
return [4 /*yield*/, getCommandDeviceAddressAsync(cmd.parent)];
|
|
1038
|
-
case 1:
|
|
1039
|
-
deviceAddress = _a.sent();
|
|
1040
|
-
messageId = uuid_1.v4();
|
|
1041
|
-
motionMasterClient.selectMessage(messageId).pipe(operators_1.first()).subscribe(function (message) {
|
|
1042
|
-
if (message && message.status && message.status.coggingTorqueData) {
|
|
1043
|
-
var error = message.status.coggingTorqueData.error;
|
|
1044
|
-
if (error) {
|
|
1045
|
-
throw new Error(error.code + ": " + error.message);
|
|
1046
|
-
}
|
|
1047
|
-
else {
|
|
1048
|
-
var table = message.status.coggingTorqueData.table;
|
|
1049
|
-
if (table && table.data) {
|
|
1050
|
-
console.log(table.data.join(', '));
|
|
1051
|
-
process.exit(ExitStatus.SUCCESS);
|
|
1052
|
-
}
|
|
1053
|
-
else {
|
|
1054
|
-
throw new Error('Cogging torque table content data is empty');
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
else {
|
|
1059
|
-
throw new Error('The received message is not "coggingTorqueData"');
|
|
1060
|
-
}
|
|
1061
|
-
});
|
|
1062
|
-
getCoggingTorqueData = { deviceAddress: deviceAddress };
|
|
1063
|
-
motionMasterClient.sendRequest({ getCoggingTorqueData: getCoggingTorqueData }, messageId);
|
|
1064
|
-
return [2 /*return*/];
|
|
1065
|
-
}
|
|
1066
|
-
});
|
|
1067
|
-
});
|
|
1068
|
-
}
|
|
1069
|
-
function startOffsetDetectionAction(cmd) {
|
|
1070
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1071
|
-
var messageId, deviceAddress, startOffsetDetection;
|
|
1072
|
-
return __generator(this, function (_a) {
|
|
1073
|
-
switch (_a.label) {
|
|
1074
|
-
case 0:
|
|
1075
|
-
connectToMotionMaster(cmd.parent);
|
|
1076
|
-
messageId = uuid_1.v4();
|
|
1077
|
-
printOnMessageReceived(messageId, cmd.parent.outputFormat);
|
|
1078
|
-
exitOnMessageReceived(messageId, 180000, util_2.MotionMasterMessage.Status.OffsetDetection.Success.Code.DONE);
|
|
1079
|
-
return [4 /*yield*/, getCommandDeviceAddressAsync(cmd.parent)];
|
|
1080
|
-
case 1:
|
|
1081
|
-
deviceAddress = _a.sent();
|
|
1082
|
-
startOffsetDetection = { deviceAddress: deviceAddress };
|
|
1083
|
-
motionMasterClient.sendRequest({ startOffsetDetection: startOffsetDetection }, messageId);
|
|
1084
|
-
return [2 /*return*/];
|
|
1085
|
-
}
|
|
1086
|
-
});
|
|
1087
|
-
});
|
|
1088
|
-
}
|
|
1089
|
-
function startCoggingTorqueRecordingAction(cmd) {
|
|
1090
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1091
|
-
var messageId, deviceAddress, skipAutoTuning, startCoggingTorqueRecording;
|
|
1092
|
-
return __generator(this, function (_a) {
|
|
1093
|
-
switch (_a.label) {
|
|
1094
|
-
case 0:
|
|
1095
|
-
connectToMotionMaster(cmd.parent);
|
|
1096
|
-
messageId = uuid_1.v4();
|
|
1097
|
-
printOnMessageReceived(messageId, cmd.parent.outputFormat);
|
|
1098
|
-
exitOnMessageReceived(messageId, 300000, util_2.MotionMasterMessage.Status.CoggingTorqueRecording.Success.Code.DONE);
|
|
1099
|
-
return [4 /*yield*/, getCommandDeviceAddressAsync(cmd.parent)];
|
|
1100
|
-
case 1:
|
|
1101
|
-
deviceAddress = _a.sent();
|
|
1102
|
-
skipAutoTuning = cmd.skipAutoTuning;
|
|
1103
|
-
startCoggingTorqueRecording = { deviceAddress: deviceAddress, skipAutoTuning: skipAutoTuning };
|
|
1104
|
-
motionMasterClient.sendRequest({ startCoggingTorqueRecording: startCoggingTorqueRecording }, messageId);
|
|
1105
|
-
return [2 /*return*/];
|
|
1106
|
-
}
|
|
1107
|
-
});
|
|
1108
|
-
});
|
|
1109
|
-
}
|
|
1110
|
-
function startPlantIdentificationAction(durationSeconds, torqueAmplitude, startFrequency, endFrequency, cutoffFrequency, cmd) {
|
|
1111
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1112
|
-
var deviceAddress, messageId, startPlantIdentification;
|
|
1113
|
-
return __generator(this, function (_a) {
|
|
1114
|
-
switch (_a.label) {
|
|
1115
|
-
case 0:
|
|
1116
|
-
connectToMotionMaster(cmd.parent);
|
|
1117
|
-
return [4 /*yield*/, getCommandDeviceAddressAsync(cmd.parent)];
|
|
1118
|
-
case 1:
|
|
1119
|
-
deviceAddress = _a.sent();
|
|
1120
|
-
messageId = uuid_1.v4();
|
|
1121
|
-
printOnMessageReceived(messageId, cmd.parent.outputFormat);
|
|
1122
|
-
exitOnMessageReceived(messageId, 60000, util_2.MotionMasterMessage.Status.PlantIdentification.Success.Code.DONE);
|
|
1123
|
-
durationSeconds = parseFloat(durationSeconds);
|
|
1124
|
-
torqueAmplitude = parseInt(torqueAmplitude, 10);
|
|
1125
|
-
startFrequency = parseInt(startFrequency, 10);
|
|
1126
|
-
endFrequency = parseInt(endFrequency, 10);
|
|
1127
|
-
cutoffFrequency = parseInt(cutoffFrequency, 10);
|
|
1128
|
-
startPlantIdentification = {
|
|
1129
|
-
deviceAddress: deviceAddress,
|
|
1130
|
-
durationSeconds: durationSeconds,
|
|
1131
|
-
torqueAmplitude: torqueAmplitude,
|
|
1132
|
-
startFrequency: startFrequency,
|
|
1133
|
-
endFrequency: endFrequency,
|
|
1134
|
-
cutoffFrequency: cutoffFrequency,
|
|
1135
|
-
};
|
|
1136
|
-
motionMasterClient.sendRequest({ startPlantIdentification: startPlantIdentification }, messageId);
|
|
1137
|
-
return [2 /*return*/];
|
|
1138
|
-
}
|
|
1139
|
-
});
|
|
1140
|
-
});
|
|
1141
|
-
}
|
|
1142
|
-
function startSystemIdentificationAction(durationSeconds, torqueAmplitude, startFrequency, endFrequency, cmd) {
|
|
1143
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1144
|
-
var deviceAddress, messageId, startSystemIdentification;
|
|
1145
|
-
return __generator(this, function (_a) {
|
|
1146
|
-
switch (_a.label) {
|
|
1147
|
-
case 0:
|
|
1148
|
-
connectToMotionMaster(cmd.parent);
|
|
1149
|
-
return [4 /*yield*/, getCommandDeviceAddressAsync(cmd.parent)];
|
|
1150
|
-
case 1:
|
|
1151
|
-
deviceAddress = _a.sent();
|
|
1152
|
-
messageId = uuid_1.v4();
|
|
1153
|
-
printOnMessageReceived(messageId, cmd.parent.outputFormat);
|
|
1154
|
-
exitOnMessageReceived(messageId, 60000, util_2.MotionMasterMessage.Status.SystemIdentification.Success.Code.DONE);
|
|
1155
|
-
durationSeconds = parseFloat(durationSeconds);
|
|
1156
|
-
torqueAmplitude = parseInt(torqueAmplitude, 10);
|
|
1157
|
-
startFrequency = parseFloat(startFrequency);
|
|
1158
|
-
endFrequency = parseFloat(endFrequency);
|
|
1159
|
-
startSystemIdentification = {
|
|
1160
|
-
deviceAddress: deviceAddress,
|
|
1161
|
-
durationSeconds: durationSeconds,
|
|
1162
|
-
torqueAmplitude: torqueAmplitude,
|
|
1163
|
-
startFrequency: startFrequency,
|
|
1164
|
-
endFrequency: endFrequency,
|
|
1165
|
-
};
|
|
1166
|
-
motionMasterClient.sendRequest({ startSystemIdentification: startSystemIdentification }, messageId);
|
|
1167
|
-
return [2 /*return*/];
|
|
1168
|
-
}
|
|
1169
|
-
});
|
|
1170
|
-
});
|
|
1171
|
-
}
|
|
1172
|
-
function startCirculoEncoderNarrowAngleCalibrationProcedureAction(encoderOrdinal, cmd) {
|
|
1173
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1174
|
-
var deviceAddress, messageId, startCirculoEncoderNarrowAngleCalibrationProcedure;
|
|
1175
|
-
return __generator(this, function (_a) {
|
|
1176
|
-
switch (_a.label) {
|
|
1177
|
-
case 0:
|
|
1178
|
-
connectToMotionMaster(cmd.parent);
|
|
1179
|
-
return [4 /*yield*/, getCommandDeviceAddressAsync(cmd.parent)];
|
|
1180
|
-
case 1:
|
|
1181
|
-
deviceAddress = _a.sent();
|
|
1182
|
-
messageId = uuid_1.v4();
|
|
1183
|
-
printOnMessageReceived(messageId, cmd.parent.outputFormat);
|
|
1184
|
-
exitOnMessageReceived(messageId, 60000, util_2.MotionMasterMessage.Status.CirculoEncoderNarrowAngleCalibrationProcedure.Success.Code.DONE);
|
|
1185
|
-
encoderOrdinal = parseInt(encoderOrdinal, 10);
|
|
1186
|
-
startCirculoEncoderNarrowAngleCalibrationProcedure = {
|
|
1187
|
-
deviceAddress: deviceAddress,
|
|
1188
|
-
encoderOrdinal: encoderOrdinal,
|
|
1189
|
-
};
|
|
1190
|
-
motionMasterClient.sendRequest({ startCirculoEncoderNarrowAngleCalibrationProcedure: startCirculoEncoderNarrowAngleCalibrationProcedure }, messageId);
|
|
1191
|
-
return [2 /*return*/];
|
|
1192
|
-
}
|
|
1193
|
-
});
|
|
1194
|
-
});
|
|
1195
|
-
}
|
|
1196
|
-
function monitorAction(topic, params, cmd) {
|
|
1197
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1198
|
-
var deviceAddress, parameters, getDeviceParameterValues;
|
|
1199
|
-
return __generator(this, function (_a) {
|
|
1200
|
-
switch (_a.label) {
|
|
1201
|
-
case 0:
|
|
1202
|
-
connectToMotionMaster(cmd.parent);
|
|
1203
|
-
return [4 /*yield*/, getCommandDeviceAddressAsync(cmd.parent)];
|
|
1204
|
-
case 1:
|
|
1205
|
-
deviceAddress = _a.sent();
|
|
1206
|
-
parameters = params.map(paramToIndexSubindex);
|
|
1207
|
-
getDeviceParameterValues = { deviceAddress: deviceAddress, parameters: parameters };
|
|
1208
|
-
requestStartMonitoringDeviceParameterValues({ getDeviceParameterValues: getDeviceParameterValues, interval: cmd.interval, topic: topic });
|
|
1209
|
-
return [2 /*return*/];
|
|
1210
|
-
}
|
|
1211
|
-
});
|
|
1212
|
-
});
|
|
1213
|
-
}
|
|
1214
|
-
//
|
|
1215
|
-
// helper functions
|
|
1216
|
-
//
|
|
1217
|
-
function connectToMotionMaster(cmd) {
|
|
1218
|
-
if (cmd.config) {
|
|
1219
|
-
var contents = fs_1.default.readFileSync(cmd.config, { encoding: 'utf8' });
|
|
1220
|
-
var json = JSON.parse(contents);
|
|
1221
|
-
Object.assign(config, json);
|
|
1222
|
-
}
|
|
1223
|
-
// ping Motion Master in regular intervals
|
|
1224
|
-
var pingSystemInterval = rxjs_1.interval(config.pingSystemInterval);
|
|
1225
|
-
pingSystemInterval.subscribe(function () { return motionMasterClient.sendRequest({ pingSystem: {} }); });
|
|
1226
|
-
// connect to server endpoint
|
|
1227
|
-
var serverSocket = zeromq_1.default.socket('dealer');
|
|
1228
|
-
debug("Using identity for ZeroMQ DEALER socket: " + config.identity);
|
|
1229
|
-
serverSocket.identity = config.identity;
|
|
1230
|
-
serverSocket.connect(config.serverEndpoint);
|
|
1231
|
-
debug("Connected to ZeroMQ DEALER socket server endpoint: " + config.serverEndpoint);
|
|
1232
|
-
// feed data coming from Motion Master to MotionMasterClient
|
|
1233
|
-
serverSocket.on('message', function (data) {
|
|
1234
|
-
motionMasterClient.input$.next(util_2.decodeMotionMasterMessage(data));
|
|
1235
|
-
});
|
|
1236
|
-
// send data fed from MotionMasterClient to Motion Master
|
|
1237
|
-
motionMasterClient.output$.subscribe(function (message) {
|
|
1238
|
-
// log outgoing messages and skip ping messages
|
|
1239
|
-
if (!(message && message.request && message.request.pingSystem)) {
|
|
1240
|
-
debug(util_1.default.inspect(message, inspectOptions));
|
|
1241
|
-
}
|
|
1242
|
-
serverSocket.send(Buffer.from(util_2.encodeMotionMasterMessage(message)));
|
|
1243
|
-
});
|
|
1244
|
-
// connnect to notification endpoint
|
|
1245
|
-
var notificationSocket = zeromq_1.default.socket('sub').connect(config.notificationEndpoint);
|
|
1246
|
-
debug("Connected to ZeroMQ SUB socket notification endpoint: " + config.notificationEndpoint);
|
|
1247
|
-
// subscribe to all topics
|
|
1248
|
-
notificationSocket.subscribe('');
|
|
1249
|
-
// exit process when a heartbeat message is not received for more than the time specified
|
|
1250
|
-
motionMasterClient.selectMessageStatus('systemPong').pipe(operators_1.timeout(config.motionMasterHeartbeatTimeoutDue)).subscribe({
|
|
1251
|
-
error: function (err) {
|
|
1252
|
-
console.error(err.name + ": Heartbeat message not received for more than " + config.motionMasterHeartbeatTimeoutDue + " ms. Check if Motion Master process is running.");
|
|
1253
|
-
process.exit(ExitStatus.TIMEOUT);
|
|
1254
|
-
},
|
|
1255
|
-
});
|
|
1256
|
-
// feed notification data coming from Motion Master to MotionMasterNotification
|
|
1257
|
-
notificationSocket.on('message', function (topic, message) {
|
|
1258
|
-
motionMasterNotification.input$.next({ topic: topic.toString(), messages: [util_2.decodeMotionMasterMessage(message)] });
|
|
1259
|
-
});
|
|
1260
|
-
}
|
|
1261
|
-
function requestStartMonitoringDeviceParameterValues(startMonitoringDeviceParameterValues) {
|
|
1262
|
-
var messageId = uuid_1.v4();
|
|
1263
|
-
motionMasterNotification.selectMessagesByTopic(startMonitoringDeviceParameterValues.topic || '').subscribe(function (messages) {
|
|
1264
|
-
var timestamp = Date.now();
|
|
1265
|
-
var topic = startMonitoringDeviceParameterValues.topic;
|
|
1266
|
-
console.log(util_1.default.inspect({ timestamp: timestamp, topic: topic, messages: messages }, inspectOptions));
|
|
1267
|
-
});
|
|
1268
|
-
motionMasterClient.sendRequest({ startMonitoringDeviceParameterValues: startMonitoringDeviceParameterValues }, messageId);
|
|
1269
|
-
}
|
|
1270
|
-
function getDeviceParameterInfoAsync(deviceAddress) {
|
|
1271
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1272
|
-
var getDeviceParameterInfo, messageId, deviceParameterInfo;
|
|
1273
|
-
return __generator(this, function (_a) {
|
|
1274
|
-
switch (_a.label) {
|
|
1275
|
-
case 0:
|
|
1276
|
-
if (!deviceAddress) {
|
|
1277
|
-
return [2 /*return*/, null];
|
|
1278
|
-
}
|
|
1279
|
-
if (deviceParameterInfoMap.has(deviceAddress)) {
|
|
1280
|
-
return [2 /*return*/, deviceParameterInfoMap.get(deviceAddress)]; // retrieve from cache
|
|
1281
|
-
}
|
|
1282
|
-
getDeviceParameterInfo = { deviceAddress: deviceAddress };
|
|
1283
|
-
messageId = uuid_1.v4();
|
|
1284
|
-
motionMasterClient.sendRequest({ getDeviceParameterInfo: getDeviceParameterInfo }, messageId);
|
|
1285
|
-
return [4 /*yield*/, motionMasterClient.selectMessage(messageId).pipe(operators_1.first(), operators_1.map(function (message) { return message && message.status ? message.status.deviceParameterInfo : null; })).toPromise()];
|
|
1286
|
-
case 1:
|
|
1287
|
-
deviceParameterInfo = _a.sent();
|
|
1288
|
-
deviceParameterInfoMap.set(deviceAddress, deviceParameterInfo); // cache
|
|
1289
|
-
return [2 /*return*/, deviceParameterInfo];
|
|
1290
|
-
}
|
|
1291
|
-
});
|
|
1292
|
-
});
|
|
1293
|
-
}
|
|
1294
|
-
function paramToIndexSubindex(paramValue) {
|
|
1295
|
-
var _a = paramValue.split(':'), indexStr = _a[0], subindexStr = _a[1];
|
|
1296
|
-
var index = parseInt(indexStr, 16);
|
|
1297
|
-
var subindex = parseInt(subindexStr, 10) || 0;
|
|
1298
|
-
return { index: index, subindex: subindex };
|
|
1299
|
-
}
|
|
1300
|
-
function paramToIndexSubIndexValue(paramValue, deviceParameterInfo) {
|
|
1301
|
-
var _a = paramValue.split('='), param = _a[0], value = _a[1];
|
|
1302
|
-
var _b = paramToIndexSubindex(param), index = _b.index, subindex = _b.subindex;
|
|
1303
|
-
var parameterValue = { index: index, subindex: subindex };
|
|
1304
|
-
if (deviceParameterInfo) {
|
|
1305
|
-
if (deviceParameterInfo.parameters) {
|
|
1306
|
-
var parameter = deviceParameterInfo.parameters.find(function (p) { return p.index === index && p.subindex === subindex; });
|
|
1307
|
-
if (parameter) {
|
|
1308
|
-
var VT = util_2.MotionMasterMessage.Status.DeviceParameterInfo.Parameter.ValueType;
|
|
1309
|
-
switch (parameter.valueType) {
|
|
1310
|
-
case VT.UNSPECIFIED:
|
|
1311
|
-
case VT.INTEGER8:
|
|
1312
|
-
case VT.INTEGER16:
|
|
1313
|
-
case VT.INTEGER32: {
|
|
1314
|
-
parameterValue.intValue = parseInt(value, 10);
|
|
1315
|
-
break;
|
|
1316
|
-
}
|
|
1317
|
-
case VT.BOOLEAN:
|
|
1318
|
-
case VT.UNSIGNED8:
|
|
1319
|
-
case VT.UNSIGNED16:
|
|
1320
|
-
case VT.UNSIGNED32: {
|
|
1321
|
-
parameterValue.uintValue = parseInt(value, 10);
|
|
1322
|
-
break;
|
|
1323
|
-
}
|
|
1324
|
-
case VT.REAL32: {
|
|
1325
|
-
parameterValue.floatValue = parseFloat(value);
|
|
1326
|
-
break;
|
|
1327
|
-
}
|
|
1328
|
-
case VT.VISIBLE_STRING:
|
|
1329
|
-
case VT.OCTET_STRING:
|
|
1330
|
-
case VT.UNICODE_STRING:
|
|
1331
|
-
case VT.TIME_OF_DAY: {
|
|
1332
|
-
parameterValue.stringValue = value;
|
|
1333
|
-
break;
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
1338
|
-
}
|
|
1339
|
-
return parameterValue;
|
|
1340
|
-
}
|
|
1341
|
-
function validateParameters(parameters) {
|
|
1342
|
-
var error = null;
|
|
1343
|
-
if (parameters.some(function (p) { return p.index === 0; })) {
|
|
1344
|
-
error = new Error('Parameter with index 0 is requested.');
|
|
1345
|
-
}
|
|
1346
|
-
if (parameters.some(function (p) { return isNaN(p.index) || isNaN(p.subindex); })) {
|
|
1347
|
-
error = new Error('Parameter with unparsable index or subindex is requested.');
|
|
1348
|
-
}
|
|
1349
|
-
if (error) {
|
|
1350
|
-
error.message += '\nExample of correct formats: "0x2002 0x100A:0 0x2003:4".';
|
|
1351
|
-
console.error(error.name + ": " + error.message);
|
|
1352
|
-
console.error(util_1.default.inspect(parameters, inspectOptions));
|
|
1353
|
-
process.exit(ExitStatus.INCORRECT_PARAMETER_FORMAT);
|
|
1354
|
-
}
|
|
1355
|
-
}
|
|
1356
|
-
function getCommandDeviceAddressAsync(cmd) {
|
|
1357
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1358
|
-
var device;
|
|
1359
|
-
return __generator(this, function (_a) {
|
|
1360
|
-
switch (_a.label) {
|
|
1361
|
-
case 0:
|
|
1362
|
-
if (!cmd.deviceAddress) return [3 /*break*/, 1];
|
|
1363
|
-
return [2 /*return*/, cmd.deviceAddress];
|
|
1364
|
-
case 1:
|
|
1365
|
-
if (!Number.isInteger(cmd.devicePosition)) return [3 /*break*/, 3];
|
|
1366
|
-
return [4 /*yield*/, motionMasterClient.selectDeviceAtPosition(cmd.devicePosition).toPromise()];
|
|
1367
|
-
case 2:
|
|
1368
|
-
device = _a.sent();
|
|
1369
|
-
if (device) {
|
|
1370
|
-
return [2 /*return*/, device.deviceAddress];
|
|
1371
|
-
}
|
|
1372
|
-
else {
|
|
1373
|
-
console.warn("WARNING: Cannot get device at position " + cmd.devicePosition + " or device list is empty.");
|
|
1374
|
-
return [2 /*return*/, null];
|
|
1375
|
-
}
|
|
1376
|
-
return [3 /*break*/, 4];
|
|
1377
|
-
case 3: return [2 /*return*/, null];
|
|
1378
|
-
case 4: return [2 /*return*/];
|
|
1379
|
-
}
|
|
1380
|
-
});
|
|
1381
|
-
});
|
|
1382
|
-
}
|
|
1383
|
-
function exitOnMessageReceived(messageId, due, exitOnSuccessCode) {
|
|
1384
|
-
if (due === void 0) { due = 10000; }
|
|
1385
|
-
motionMasterClient.selectMessage(messageId).pipe(operators_1.first(function (message) {
|
|
1386
|
-
if (exitOnSuccessCode === undefined) {
|
|
1387
|
-
return true;
|
|
1388
|
-
}
|
|
1389
|
-
else {
|
|
1390
|
-
if (message && message.status) {
|
|
1391
|
-
var key = Object.keys(message.status)[0];
|
|
1392
|
-
var status_1 = message.status[key];
|
|
1393
|
-
if (status_1 && ((status_1.success && status_1.success.code === exitOnSuccessCode) || status_1.error)) {
|
|
1394
|
-
return true;
|
|
1395
|
-
}
|
|
1396
|
-
}
|
|
1397
|
-
return false;
|
|
1398
|
-
}
|
|
1399
|
-
}), operators_1.timeout(due)).subscribe({
|
|
1400
|
-
next: function () {
|
|
1401
|
-
debug("Exit on message received " + messageId);
|
|
1402
|
-
process.exit(ExitStatus.SUCCESS);
|
|
1403
|
-
},
|
|
1404
|
-
error: function (err) {
|
|
1405
|
-
console.error(err.name + ": Status message " + messageId + " not received for more than " + due + " ms.");
|
|
1406
|
-
process.exit(ExitStatus.TIMEOUT);
|
|
1407
|
-
},
|
|
1408
|
-
});
|
|
1409
|
-
}
|
|
1410
|
-
function printOnMessageReceived(messageId, outputFormat) {
|
|
1411
|
-
if (outputFormat === void 0) { outputFormat = 'inspect'; }
|
|
1412
|
-
motionMasterClient.selectMessage(messageId).subscribe(function (message) {
|
|
1413
|
-
var timestamp = Date.now();
|
|
1414
|
-
var outputObj = { timestamp: timestamp, message: message };
|
|
1415
|
-
switch (outputFormat) {
|
|
1416
|
-
case 'json': {
|
|
1417
|
-
console.log(JSON.stringify(outputObj));
|
|
1418
|
-
break;
|
|
1419
|
-
}
|
|
1420
|
-
case 'yaml': {
|
|
1421
|
-
console.log(yaml_1.default.stringify(outputObj));
|
|
1422
|
-
break;
|
|
1423
|
-
}
|
|
1424
|
-
default: {
|
|
1425
|
-
console.log(util_1.default.inspect(outputObj, inspectOptions));
|
|
1426
|
-
}
|
|
1427
|
-
}
|
|
1428
|
-
});
|
|
1429
|
-
}
|
|
1430
|
-
function parseOptionValueAsInt(value) {
|
|
1431
|
-
return parseInt(value, 10);
|
|
1432
|
-
}
|
|
1433
|
-
//# sourceMappingURL=cli.js.map
|