motion-master-client 0.0.65 → 0.0.67

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 CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "motion-master-client",
3
- "version": "0.0.65",
3
+ "version": "0.0.67",
4
4
  "type": "commonjs",
5
5
  "description": "A library and CLI program used for communicating with Motion Master.",
6
6
  "dependencies": {
7
+ "commander": "^11.1.0",
7
8
  "fast-deep-equal": "^3.1.3",
8
9
  "lodash": "^4.17.21",
9
10
  "papaparse": "^5.4.1",
@@ -11,7 +12,8 @@
11
12
  "roarr": "^7.15.0",
12
13
  "rxjs": "^7.8.1",
13
14
  "semver": "^7.5.1",
14
- "uuid": "^9.0.0"
15
+ "uuid": "^9.0.0",
16
+ "ws": "^8.13.0"
15
17
  },
16
18
  "peerDependencies": {
17
19
  "tslib": "2.5.3"
package/src/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/src/cli.js ADDED
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const commander_1 = require("commander");
5
+ const index_1 = require("./index");
6
+ const rxjs_1 = require("rxjs");
7
+ const fs_1 = require("fs");
8
+ const pkg = require("../package.json");
9
+ Object.assign(globalThis, { WebSocket: require('ws') });
10
+ let client;
11
+ let opts;
12
+ let deviceRefObj;
13
+ function getClient() {
14
+ if (!client) {
15
+ opts = commander_1.program.opts();
16
+ deviceRefObj = (0, index_1.makeDeviceRefObj)(opts['deviceRef']);
17
+ client = (0, index_1.createMotionMasterClient)(opts['hostname']);
18
+ }
19
+ return client;
20
+ }
21
+ function logStringified(status) {
22
+ console.log(JSON.stringify(status, null, 2));
23
+ }
24
+ commander_1.program
25
+ .name('motion-master-client')
26
+ .description('CLI to Motion Master API')
27
+ .version(pkg.version)
28
+ .addOption(new commander_1.Option('-s, --hostname <value>', 'connect to a running Motion Master process (e.g., localhost, 192.168.123.456, oblac-drives-76d3c210.local)')
29
+ .default('localhost'))
30
+ .addOption(new commander_1.Option('-f, --format <value>', 'print the output in a format such as CSV, JSON, and so on')
31
+ .choices(['csv']))
32
+ .addOption(new commander_1.Option('-p, --pretty-print', 'print the output in a more readable form, which is useful for requests that involve progress')
33
+ .default(false)
34
+ .conflicts('format'))
35
+ .addOption(new commander_1.Option('-d, --device-ref <value>', 'position, address, or serial number')
36
+ .default(0, '0 position represents the first device in a network chain')
37
+ .argParser((value) => {
38
+ const n = Number(value);
39
+ return isNaN(n) ? value : n;
40
+ }))
41
+ .addOption(new commander_1.Option('-m, --message-id <value>', 'the message ID, which uniquely identifies the request, will be generated by the client library if not specified'))
42
+ .addOption(new commander_1.Option('-t, --request-timeout <value>', 'after sending a request, how long will the client wait for Motion Master to send the status message back')
43
+ .argParser((value) => {
44
+ const n = Number(value);
45
+ if (!Number.isInteger(n)) {
46
+ throw new Error(`The request timeout option must be an integer. The provided value is: ${value}`);
47
+ }
48
+ return n;
49
+ }));
50
+ const getSystemVersionCommand = new commander_1.Command('getSystemVersion').action(() => getClient().whenReady().then(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
51
+ var _a;
52
+ const status = yield (0, rxjs_1.lastValueFrom)(client.request.getSystemVersion((_a = opts['requestTimeout']) !== null && _a !== void 0 ? _a : 3000, opts['messageId']));
53
+ if (opts['prettyPrint']) {
54
+ console.log(status === null || status === void 0 ? void 0 : status.version);
55
+ }
56
+ else {
57
+ logStringified(status);
58
+ }
59
+ })).finally(() => client.closeSockets()));
60
+ const getDeviceInfoCommand = new commander_1.Command('getDeviceInfo').action(() => getClient().whenReady().then(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
61
+ var _b, _c;
62
+ const status = yield (0, rxjs_1.lastValueFrom)(client.request.getDeviceInfo((_b = opts['requestTimeout']) !== null && _b !== void 0 ? _b : 5000, opts['messageId']));
63
+ if (opts['format'] === 'csv') {
64
+ console.log(['deviceAddress', 'type', 'position', 'alias'].join(','));
65
+ (_c = status === null || status === void 0 ? void 0 : status.devices) === null || _c === void 0 ? void 0 : _c.forEach((device) => console.log([device.deviceAddress, device.type, device.position, device.alias].join(',')));
66
+ }
67
+ else {
68
+ logStringified(status);
69
+ }
70
+ })).finally(() => client.closeSockets()));
71
+ const getDeviceParameterInfoCommand = new commander_1.Command('getDeviceParameterInfo').action(() => getClient().whenReady().then(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
72
+ var _d, _e;
73
+ const status = yield (0, rxjs_1.lastValueFrom)(client.request.getDeviceParameterInfo(Object.assign({}, deviceRefObj), (_d = opts['requestTimeout']) !== null && _d !== void 0 ? _d : 10000, opts['messageId']));
74
+ if (opts['format'] === 'csv') {
75
+ console.log(['index', 'subindex', 'name', 'unit', 'group', 'readAccess', 'writeAccess', 'min', 'max', 'valueType'].join(','));
76
+ (_e = status.parameters) === null || _e === void 0 ? void 0 : _e.forEach((p) => console.log([p.index, p.subindex, p.name, p.unit, p.group, p.readAccess, p.writeAccess, p.min, p.max, p.valueType].join(',')));
77
+ }
78
+ else {
79
+ logStringified(status);
80
+ }
81
+ })).finally(() => client.closeSockets()));
82
+ const getDeviceParameterValuesCommand = new commander_1.Command('getDeviceParameterValues')
83
+ .addOption(new commander_1.Option('--load-from-cache', 'load parameter values from the Motion Master cache').default(false))
84
+ .addOption(new commander_1.Option('--send-progress', 'send progress while retrieving the parameter values from the device').default(false))
85
+ .addArgument(new commander_1.Argument('<parameterIds...>', 'space-separated list of parameter ids, e.g. 0x2030:01 0x2110:0C'))
86
+ .action((ids, { loadFromCache, sendProgress }) => {
87
+ const parameters = ids.reduce((arr, id) => {
88
+ const [index, subindex] = (0, index_1.splitParameterId)(id.trim());
89
+ arr.push({ index, subindex, loadFromCache });
90
+ return arr;
91
+ }, []);
92
+ getClient().onceReady$.pipe((0, rxjs_1.mergeMap)(() => { var _a; return client.request.getDeviceParameterValues(Object.assign(Object.assign({}, deviceRefObj), { parameters, sendProgress }), (_a = opts['requestTimeout']) !== null && _a !== void 0 ? _a : 30000, opts['messageId']); })).subscribe({
93
+ next: (status) => {
94
+ var _a;
95
+ if (opts['format'] === 'csv') {
96
+ console.log(['index', 'subindex', 'typeValue', 'intValue', 'uintValue', 'floatValue', 'stringValue', 'rawValue'].join(','));
97
+ (_a = status.parameterValues) === null || _a === void 0 ? void 0 : _a.forEach((p) => console.log([p.index, p.subindex, p === null || p === void 0 ? void 0 : p.typeValue, p.intValue, p.uintValue, p.floatValue, p.stringValue, p.rawValue].join(',')));
98
+ }
99
+ else {
100
+ logStringified(status);
101
+ }
102
+ },
103
+ complete: () => client.closeSockets(),
104
+ });
105
+ });
106
+ const getDeviceFileCommand = new commander_1.Command('getDeviceFile')
107
+ .addArgument(new commander_1.Argument('<name>', 'name of the file to retrieve'))
108
+ .action((name) => {
109
+ getClient().whenReady().then(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
110
+ var _a;
111
+ const status = yield (0, rxjs_1.lastValueFrom)(client.request.getDeviceFile(Object.assign(Object.assign({}, deviceRefObj), { name }), (_a = opts['requestTimeout']) !== null && _a !== void 0 ? _a : 5000, opts['messageId']));
112
+ if (opts['prettyPrint']) {
113
+ if (status.content) {
114
+ console.log((0, index_1.decodeTextContent)(status.content));
115
+ }
116
+ else {
117
+ console.log(`No content for '${name}'`);
118
+ }
119
+ }
120
+ else {
121
+ logStringified(status);
122
+ }
123
+ })).finally(() => client.closeSockets());
124
+ });
125
+ const setDeviceFileCommand = new commander_1.Command('setDeviceFile')
126
+ .addArgument(new commander_1.Argument('<name>', 'name of the file to write to the device'))
127
+ .addArgument(new commander_1.Argument('<srcPath>', 'path to a file on your computer to read the content from and write to the device'))
128
+ .addOption(new commander_1.Option('--overwrite', 'overwrite the existing file on the device with the same name').default(false))
129
+ .action((name, srcPath, { overwrite }) => {
130
+ const content = Buffer.from((0, fs_1.readFileSync)(srcPath, { encoding: 'utf-8' }), 'utf-8');
131
+ getClient().whenReady().then(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
132
+ var _a;
133
+ const status = yield (0, rxjs_1.lastValueFrom)(client.request.setDeviceFile(Object.assign(Object.assign({}, deviceRefObj), { name, content, overwrite }), (_a = opts['requestTimeout']) !== null && _a !== void 0 ? _a : 5000, opts['messageId']));
134
+ logStringified(status);
135
+ })).finally(() => client.closeSockets());
136
+ });
137
+ const startOffsetDetectionCommand = new commander_1.Command('startOffsetDetection').action(() => {
138
+ getClient().onceReady$.pipe((0, rxjs_1.mergeMap)(() => { var _a; return client.request.startOffsetDetection(Object.assign({}, deviceRefObj), (_a = opts['requestTimeout']) !== null && _a !== void 0 ? _a : 60000, opts['messageId']); })).subscribe({
139
+ next: (status) => {
140
+ var _a, _b, _c, _d;
141
+ if (opts['prettyPrint']) {
142
+ const step = index_1.MotionMasterMessage.Status.OffsetDetection.Progress.Code[(_b = (_a = status.progress) === null || _a === void 0 ? void 0 : _a.code) !== null && _b !== void 0 ? _b : 0];
143
+ console.log(`${step} (${(_d = (_c = status.progress) === null || _c === void 0 ? void 0 : _c.percentage) !== null && _d !== void 0 ? _d : 0}%)`);
144
+ }
145
+ else {
146
+ logStringified(status);
147
+ }
148
+ },
149
+ complete: () => client.closeSockets(),
150
+ });
151
+ });
152
+ commander_1.program
153
+ .addCommand(getSystemVersionCommand)
154
+ .addCommand(getDeviceInfoCommand)
155
+ .addCommand(getDeviceParameterInfoCommand)
156
+ .addCommand(getDeviceParameterValuesCommand)
157
+ .addCommand(getDeviceFileCommand)
158
+ .addCommand(setDeviceFileCommand)
159
+ .addCommand(startOffsetDetectionCommand);
160
+ commander_1.program.parse();
161
+ //# sourceMappingURL=cli.js.map
package/src/cli.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../../libs/motion-master-client/src/cli.ts"],"names":[],"mappings":";;;AAAA,yCAA6E;AAC7E,mCAAiK;AACjK,+BAA+C;AAC/C,2BAAkC;AAClC,uCAAuC;AAEvC,MAAM,C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AAI,EAAE,CAAC,MAAM,EAAE,EAAE;;YACf,IAAI,IAAI,CAAC,aAAa,CAAC,EAAE;gBACvB,MAAM,IAAI,GAAG,2BAAmB,CAAC,MAAM,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAA,MAAA,MAAM,CAAC,QAAQ,0CAAE,IAAI,mCAAI,CAAC,CAAC,CAAC;gBAClG,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,KAAK,MAAA,MAAA,MAAM,CAAC,QAAQ,0CAAE,UAAU,mCAAI,CAAC,IAAI,CAAC,CAAA;aAC9D;iBAAM;gBACL,cAAc,CAAC,MAAM,CAAC,CAAC;aACxB;QACH,CAAC;QACD,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,EAAE;KACtC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,mBAAO;KACJ,UAAU,CAAC,uBAAuB,CAAC;KACnC,UAAU,CAAC,oBAAoB,CAAC;KAChC,UAAU,CAAC,6BAA6B,CAAC;KACzC,UAAU,CAAC,+BAA+B,CAAC;KAC3C,UAAU,CAAC,oBAAoB,CAAC;KAChC,UAAU,CAAC,oBAAoB,CAAC;KAChC,UAAU,CAAC,2BAA2B,CAAC,CAAC;AAE3C,mBAAO,CAAC,KAAK,EAAE,CAAC"}
package/src/index.d.ts CHANGED
@@ -17,6 +17,7 @@ export * from './lib/motion-master-req-res-web-socket';
17
17
  export * from './lib/motion-master-req-res-worker-socket';
18
18
  export * from './lib/operators';
19
19
  export * from './lib/options';
20
+ export * from './lib/os-command';
20
21
  export * from './lib/parameter';
21
22
  export * from './lib/request-status-resolver';
22
23
  export * from './lib/system-log-line';
package/src/index.js CHANGED
@@ -20,6 +20,7 @@ tslib_1.__exportStar(require("./lib/motion-master-req-res-web-socket"), exports)
20
20
  tslib_1.__exportStar(require("./lib/motion-master-req-res-worker-socket"), exports);
21
21
  tslib_1.__exportStar(require("./lib/operators"), exports);
22
22
  tslib_1.__exportStar(require("./lib/options"), exports);
23
+ tslib_1.__exportStar(require("./lib/os-command"), exports);
23
24
  tslib_1.__exportStar(require("./lib/parameter"), exports);
24
25
  tslib_1.__exportStar(require("./lib/request-status-resolver"), exports);
25
26
  tslib_1.__exportStar(require("./lib/system-log-line"), exports);
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/motion-master-client/src/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B;AAC7B,4DAAkC;AAClC,gEAAsC;AACtC,iEAAuC;AACvC,uDAA6B;AAC7B,qEAA2C;AAC3C,kEAAwC;AACxC,iEAAuC;AACvC,qEAA2C;AAC3C,6EAAmD;AACnD,6EAAmD;AACnD,iFAAuD;AACvD,oFAA0D;AAC1D,6EAAmD;AACnD,6EAAmD;AACnD,iFAAuD;AACvD,oFAA0D;AAC1D,0DAAgC;AAChC,wDAA8B;AAC9B,0DAAgC;AAChC,wEAA8C;AAC9C,gEAAsC;AACtC,sDAA4B;AAC5B,qDAA2B;AAC3B,qDAA2B;AAC3B,kFAAwD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/motion-master-client/src/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B;AAC7B,4DAAkC;AAClC,gEAAsC;AACtC,iEAAuC;AACvC,uDAA6B;AAC7B,qEAA2C;AAC3C,kEAAwC;AACxC,iEAAuC;AACvC,qEAA2C;AAC3C,6EAAmD;AACnD,6EAAmD;AACnD,iFAAuD;AACvD,oFAA0D;AAC1D,6EAAmD;AACnD,6EAAmD;AACnD,iFAAuD;AACvD,oFAA0D;AAC1D,0DAAgC;AAChC,wDAA8B;AAC9B,2DAAiC;AACjC,0DAAgC;AAChC,wEAA8C;AAC9C,gEAAsC;AACtC,sDAA4B;AAC5B,qDAA2B;AAC3B,qDAA2B;AAC3B,kFAAwD"}
@@ -0,0 +1,16 @@
1
+ export declare enum EncoderRegisterAddress {
2
+ STATUS0 = 118,
3
+ STATUS1 = 119,
4
+ OUT_ZERO_OUT_MSB = 17
5
+ }
6
+ export interface EncoderRegisterError {
7
+ name: string;
8
+ error: string;
9
+ description: string;
10
+ remedy: string;
11
+ fullDescription: string;
12
+ }
13
+ export declare const encoderRegisterErrors: {
14
+ [key: number]: EncoderRegisterError;
15
+ }[];
16
+ export declare function mapEncoderRegisterValueToErrors(registerValue: number, statusIndex: 0 | 1): EncoderRegisterError[];
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapEncoderRegisterValueToErrors = exports.encoderRegisterErrors = exports.EncoderRegisterAddress = void 0;
4
+ var EncoderRegisterAddress;
5
+ (function (EncoderRegisterAddress) {
6
+ EncoderRegisterAddress[EncoderRegisterAddress["STATUS0"] = 118] = "STATUS0";
7
+ EncoderRegisterAddress[EncoderRegisterAddress["STATUS1"] = 119] = "STATUS1";
8
+ EncoderRegisterAddress[EncoderRegisterAddress["OUT_ZERO_OUT_MSB"] = 17] = "OUT_ZERO_OUT_MSB";
9
+ })(EncoderRegisterAddress = exports.EncoderRegisterAddress || (exports.EncoderRegisterAddress = {}));
10
+ ;
11
+ ;
12
+ exports.encoderRegisterErrors = [
13
+ {
14
+ 1: {
15
+ name: "AM_MIN",
16
+ error: "Signal error: poor level (master track)",
17
+ description: "Magnetic field strength is too low for encoder operation.",
18
+ remedy: "Check positioning of the encoder ring.",
19
+ fullDescription: "An encoder magnetic ring is too far from the encoder chip or isn't detected. Check the mechanical assembly. In some rare cases can be provoked by demagnetized ring or field strength drop due to high temperatures. A magnetic ring is too far from the encoder chip. Check the mechanical assembly."
20
+ },
21
+ 2: {
22
+ name: "AM_MAX",
23
+ error: "Signal error: clipping (master track)",
24
+ description: "Magnetic field strength is too high.",
25
+ remedy: "Check mechanical assembly and external fields.",
26
+ fullDescription: "The outer track of the encoder chip detects too strong a field. Typically, it can't be generated by the magnetic ring itself at normal conditions. Please check the influence of external fields, especially brakes. A magnetic ring is too close to the encoder chip. Check the mechanical assembly."
27
+ },
28
+ 4: {
29
+ name: "AN_MIN",
30
+ error: "Signal error: poor level (nonius track)",
31
+ description: "Magnetic field strength is too low for encoder operation.",
32
+ remedy: "Check positioning of the encoder ring.",
33
+ fullDescription: "An encoder magnetic ring is too far from the encoder chip or isn't detected. Check the mechanical assembly. In some rare cases can be provoked by demagnetized ring or field strength drop due to high temperatures."
34
+ },
35
+ 8: {
36
+ name: "AN_MAX",
37
+ error: "Signal error: clipping (nonius track)",
38
+ description: "Magnetic field strength is too high.",
39
+ remedy: "Check mechanical assembly and external fields.",
40
+ fullDescription: "The inner track of the encoder chip detects too strong a field. Typically, it can't be generated by the magnetic ring itself at normal conditions. Please check the influence of external fields, especially brakes."
41
+ },
42
+ 16: {
43
+ name: "STUP",
44
+ error: "Startup iC-MU",
45
+ description: "Encoder startup error. Can appear during Multiturn configuration.",
46
+ remedy: "Power cycle the drive.",
47
+ fullDescription: "Encoder initialization error. The typical reason is: not saved Multiturn Counter configuration. Connect the multiturn battery, check the battery voltage, configure the multiturn bits in OBLAC Drives, configure internal encoder and save changes. Power cycle the drive. If the error is always present, contact support."
48
+ },
49
+ },
50
+ {
51
+ 2: {
52
+ name: "FRQ_CNV",
53
+ error: "Excessive signal frequency for internal 12 Bit converter",
54
+ description: "Encoder maximum speed was exceeded.",
55
+ remedy: "",
56
+ fullDescription: "Encoder maximum speed was exceeded. Circulo 7 - 12000 RPM or Circulo 9 - 6000 RPM"
57
+ },
58
+ 4: {
59
+ name: "FRQ_ABZ",
60
+ error: "Excessive signal frequency for ABZ-converter",
61
+ description: "Encoder maximum speed was exceeded.",
62
+ remedy: "",
63
+ fullDescription: "Encoder maximum speed was exceeded. Circulo 7 - 12000 RPM or Circulo 9 - 6000 RPM"
64
+ },
65
+ 8: {
66
+ name: "NON_CTR",
67
+ error: "Period counter consistency error: counted period <-> calculated Nonius position",
68
+ description: "Internal Encoder calibration parameters are outdated or non-existing.",
69
+ remedy: "Please calibrate the internal encoder.",
70
+ fullDescription: "The absolute position value can't be computed reliably at the current position. This can be caused by: encoder wasn't calibrated, change of encoder mechanics, severe thermal expansion or magnetic target damage. Run diagnostics and repeat the calibration procedure. If this error prevents you from performing calibration - disable it or contact support."
71
+ },
72
+ 16: {
73
+ name: "MT_CTR",
74
+ error: "Multiturn data consistency error: counted multiturn <-> external MT data",
75
+ description: "Multiturn Counter synchronization error.",
76
+ remedy: "Check MT configuration, connect a battery. Power cycle the drive.",
77
+ fullDescription: "Can happen because of not saved Multiturn Counter configuration. Connect the multiturn battery, check the battery voltage, configure the multiturn bits in OBLAC Drives, configure internal encoder and save changes. If the error is still present, please contact support."
78
+ },
79
+ 32: {
80
+ name: "MT_ERR",
81
+ error: "Multiturn communication error: MTD line not 1 when trying to read MT data, MTD line is not 0 right after the last clock pulse, or SSI error bit active on MT interface",
82
+ description: "Multiturn Counter communication error.",
83
+ remedy: "Check MT configuration, connect a battery. Power cycle the drive.",
84
+ fullDescription: "The Multiturn counter is in error state. Connect the multiturn battery, check the battery voltage, configure the multiturn bits in OBLAC Drives, configure internal encoder and save changes. Power cycle the drive. If the error is still present, please contact support."
85
+ },
86
+ 64: {
87
+ name: "EPR_ERR",
88
+ error: "I2C communication error: No EEPROM or I2C communication error",
89
+ description: "Encoder EEPROM memory communication error.",
90
+ remedy: "Power Cycle the drive.",
91
+ fullDescription: "Communication with the EEPROM memory of the chip is distorted. Power Cycle the drive. If this can't be reset, there is a hardware problem. Please contact support."
92
+ },
93
+ 128: {
94
+ name: "",
95
+ error: "Invalid check sum internal RAM",
96
+ description: "Invalid check sum internal RAM",
97
+ remedy: "",
98
+ fullDescription: ""
99
+ },
100
+ }
101
+ ];
102
+ function mapEncoderRegisterValueToErrors(registerValue, statusIndex) {
103
+ const errors = [];
104
+ let i = 1;
105
+ while (i < 256) {
106
+ if ((registerValue & i) === i) {
107
+ const error = exports.encoderRegisterErrors[statusIndex][i];
108
+ if (error) {
109
+ errors.push(error);
110
+ }
111
+ }
112
+ i *= 2;
113
+ }
114
+ return errors;
115
+ }
116
+ exports.mapEncoderRegisterValueToErrors = mapEncoderRegisterValueToErrors;
117
+ //# sourceMappingURL=encoder-register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoder-register.js","sourceRoot":"","sources":["../../../../../libs/motion-master-client/src/lib/encoder-register.ts"],"names":[],"mappings":";;;AAAA,IAAY,sBAIX;AAJD,WAAY,sBAAsB;IAChC,2EAAc,CAAA;IACd,2EAAc,CAAA;IACd,4FAAuB,CAAA;AACzB,CAAC,EAJW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAIjC;AAAA,CAAC;AAQD,CAAC;AAEW,QAAA,qBAAqB,GAA8C;IAC9E;QACE,CAAC,EAAE;YACD,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,yCAAyC;YAChD,WAAW,EAAE,2DAA2D;YACxE,MAAM,EAAE,wCAAwC;YAChD,eAAe,EAAE,uSAAuS;SACzT;QACD,CAAC,EAAE;YACD,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,uCAAuC;YAC9C,WAAW,EAAE,sCAAsC;YACnD,MAAM,EAAE,gDAAgD;YACxD,eAAe,EAAE,uSAAuS;SACzT;QACD,CAAC,EAAE;YACD,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,yCAAyC;YAChD,WAAW,EAAE,2DAA2D;YACxE,MAAM,EAAE,wCAAwC;YAChD,eAAe,EAAE,sNAAsN;SACxO;QACD,CAAC,EAAE;YACD,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,uCAAuC;YAC9C,WAAW,EAAE,sCAAsC;YACnD,MAAM,EAAE,gDAAgD;YACxD,eAAe,EAAE,sNAAsN;SACxO;QACD,EAAE,EAAE;YACF,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,eAAe;YACtB,WAAW,EAAE,mEAAmE;YAChF,MAAM,EAAE,wBAAwB;YAChC,eAAe,EAAE,8TAA8T;SAChV;KACF;IACD;QACE,CAAC,EAAE;YACD,IAAI,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AAC,KAAK,CAAC,EAAE;YAC7B,MAAM,KAAK,GAAG,6BAAqB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;YACpD,IAAI,KAAK,EAAE;gBACT,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACpB;SACF;QACD,CAAC,IAAI,CAAC,CAAC;KACR;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAbD,0EAaC"}
@@ -11,8 +11,27 @@ export declare class MotionMasterPubSubWebSocket implements MotionMasterPubSubSo
11
11
  private webSocket$?;
12
12
  private _url?;
13
13
  get url(): string | undefined;
14
+ /**
15
+ * Open a WebSocket connection on the provided URL.
16
+ */
14
17
  open(url: string): void;
18
+ /**
19
+ * Close WebSocket connection.
20
+ */
15
21
  close(): void;
22
+ /**
23
+ * Reopen will recreate the WebSocket connection if the current connection is not open.
24
+ */
16
25
  reopen(): void;
26
+ /**
27
+ * Create WebSocket connection.
28
+ *
29
+ * Every message received on this socket will be deserialized into a tuple of topic and Motion Master Message.
30
+ *
31
+ * Bytes of the received data:
32
+ * - The 1st byte contains the length of the topic string.
33
+ * - The 2nd byte and subsequent bytes up to the length of the topic string contain the topic.
34
+ * - Bytes following the length of the topic and the topic itself contain the encoded proto message.
35
+ */
17
36
  private createWebSocket;
18
37
  }
@@ -15,6 +15,9 @@ class MotionMasterPubSubWebSocket {
15
15
  get url() {
16
16
  return this._url;
17
17
  }
18
+ /**
19
+ * Open a WebSocket connection on the provided URL.
20
+ */
18
21
  open(url) {
19
22
  this._url = url;
20
23
  this.webSocket$ = this.createWebSocket(url);
@@ -25,15 +28,31 @@ class MotionMasterPubSubWebSocket {
25
28
  },
26
29
  });
27
30
  }
31
+ /**
32
+ * Close WebSocket connection.
33
+ */
28
34
  close() {
29
35
  var _a;
30
36
  (_a = this.webSocket$) === null || _a === void 0 ? void 0 : _a.complete();
31
37
  }
38
+ /**
39
+ * Reopen will recreate the WebSocket connection if the current connection is not open.
40
+ */
32
41
  reopen() {
33
42
  if (this.url && this.opened$.value === false) {
34
43
  this.open(this.url);
35
44
  }
36
45
  }
46
+ /**
47
+ * Create WebSocket connection.
48
+ *
49
+ * Every message received on this socket will be deserialized into a tuple of topic and Motion Master Message.
50
+ *
51
+ * Bytes of the received data:
52
+ * - The 1st byte contains the length of the topic string.
53
+ * - The 2nd byte and subsequent bytes up to the length of the topic string contain the topic.
54
+ * - Bytes following the length of the topic and the topic itself contain the encoded proto message.
55
+ */
37
56
  createWebSocket(url) {
38
57
  const decoder = new TextDecoder('utf-8');
39
58
  const webSocketConfig = {
@@ -1 +1 @@
1
- {"version":3,"file":"motion-master-pub-sub-web-socket.js","sourceRoot":"","sources":["../../../../../libs/motion-master-client/src/lib/motion-master-pub-sub-web-socket.ts"],"names":[],"mappings":";;;AAAA,+BAAgD;AAChD,8CAAqF;AACrF,qCAAkC;AAElC,mCAAoE;AACpE,iCAAkE;AAElE,MAAa,2BAA2B;IAAxC;QAEW,YAAO,GAAG,IAAI,sBAAe,CAAU,KAAK,CAAC,CAAC;QAE9C,WAAM,GAAG,IAAI,cAAO,EAAqC,CAAC;QAE1D,UAAK,GAAG,IAAI,cAAO,EAAkC,CAAC;IA+DjE,CAAC;IAzDC,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,IAAI,CAAC,GAAW;QACd,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAEhB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;QAE5C,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;YACxB,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;YACvC,KAAK,EAAE,GAAG,EAAE;gBACV,oDAAoD;YACtD,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED,KAAK;;QACH,MAAA,IAAI,CAAC,UAAU,0CAAE,QAAQ,EAAE,CAAC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AAG,EAAE;oBACT,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBACxB,eAAM,CAAC,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAC,CAAC;gBAC1C,CAAC;aACF;YACD,GAAG;SACJ,CAAC;QAEF,OAAO,IAAA,qBAAS,EAAC,eAAe,CAAC,CAAC;IACpC,CAAC;CAEF;AArED,kEAqEC"}
1
+ {"version":3,"file":"motion-master-pub-sub-web-socket.js","sourceRoot":"","sources":["../../../../../libs/motion-master-client/src/lib/motion-master-pub-sub-web-socket.ts"],"names":[],"mappings":";;;AAAA,+BAAgD;AAChD,8CAAqF;AACrF,qCAAkC;AAElC,mCAAoE;AACpE,iCAAkE;AAElE,MAAa,2BAA2B;IAAxC;QAEW,YAAO,GAAG,IAAI,sBAAe,CAAU,KAAK,CAAC,CAAC;QAE9C,WAAM,GAAG,IAAI,cAAO,EAAqC,CAAC;QAE1D,UAAK,GAAG,IAAI,cAAO,EAAkC,CAAC;IAkFjE,CAAC;IA5EC,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,GAAW;QACd,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAEhB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;QAE5C,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;YACxB,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;YACvC,KAAK,EAAE,GAAG,EAAE;gBACV,oDAAoD;YACtD,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK;;QACH,MAAA,IAAI,CAAC,UAAU,0CAAE,QAAQ,EAAE,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,IAAI,IAAI,CAAC,GAAG,IAAI,IAAI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