motion-master-client 0.0.409 → 0.0.410

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/src/api.js CHANGED
@@ -49,6 +49,7 @@ function clearClient(reason) {
49
49
  log(`Clearing client (${reason}).`);
50
50
  dataMonitoringMap.forEach((monitoring) => monitoring.stop());
51
51
  dataMonitoringMap.clear();
52
+ signalGeneratorRepeatMap.clear();
52
53
  client.closeSockets();
53
54
  client = undefined;
54
55
  }
@@ -111,6 +112,13 @@ function createDefaultDataMonitoringParameterIds(deviceRef) {
111
112
  // the device's UI PDO mapping (or the default if unavailable). Collects data continuously — can consume
112
113
  // significant memory if left running. Stopped and cleared on disconnect.
113
114
  const dataMonitoringMap = new Map();
115
+ // The signals of the SetSignalGeneratorParameters oneof, derived from the generated message class so that
116
+ // the list stays in sync with motion-master.proto.
117
+ const signalGeneratorSignalKeys = Object.keys(types_1.MotionMasterMessage.Request.SetSignalGeneratorParameters.prototype).filter((key) => key !== 'deviceAddress' && key !== 'toJSON');
118
+ // Whether the signal last configured through set-signal-generator-parameters repeats, keyed by device id.
119
+ // A repeating signal runs until it is stopped and never reports completion, so start-signal-generator must
120
+ // not wait for it. Cleared on disconnect.
121
+ const signalGeneratorRepeatMap = new Map();
114
122
  // Enable CORS for all routes and all origins
115
123
  app.use((0, cors_1.default)());
116
124
  // Middleware to parse JSON body
@@ -541,11 +549,117 @@ app.get('/api/devices/:deviceRef/disable-motion-controller', asyncHandler((req,
541
549
  res.status(500).send(status.error);
542
550
  }
543
551
  })));
544
- app.get('/api/devices/:deviceRef/get-ethercat-network-state', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
545
- var _16;
552
+ /**
553
+ * Configures the signal generator; run it afterwards with `start-signal-generator`.
554
+ *
555
+ * The request body mirrors the `SetSignalGeneratorParameters` message: exactly one of the signal properties,
556
+ * holding that signal's configuration.
557
+ *
558
+ * @example curl -X POST "http://localhost:63526/api/devices/0/set-signal-generator-parameters" -H "Content-Type: application/json" -d '{"torqueRamp":{"target":200,"torqueSlope":50,"sustainTime":5000,"masterGenerated":false}}'
559
+ */
560
+ app.post('/api/devices/:deviceRef/set-signal-generator-parameters', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
561
+ var _16, _17, _18;
546
562
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
547
563
  const deviceRefObj = (0, device_1.makeDeviceRefObj)(deviceRef);
548
564
  const requestTimeout = parseInt(((_16 = req.query['request-timeout']) !== null && _16 !== void 0 ? _16 : '3000'));
565
+ const signalConfigs = ((_17 = req.body) !== null && _17 !== void 0 ? _17 : {});
566
+ const signals = signalGeneratorSignalKeys.filter((key) => signalConfigs[key] != null);
567
+ // Motion Master would keep only the last of several signals - a protobuf oneof holds one field - and
568
+ // report NOT_DEFINED for none at all, so reject both here where the message still names the culprit.
569
+ if (signals.length !== 1) {
570
+ res.status(400).send({
571
+ message: `Provide exactly one signal in the request body, received ${signals.length}. Accepted signals: ${signalGeneratorSignalKeys.join(', ')}.`,
572
+ });
573
+ return;
574
+ }
575
+ const signal = signals[0];
576
+ const props = Object.assign(Object.assign({}, deviceRefObj), { [signal]: signalConfigs[signal] });
577
+ const status = yield (0, rxjs_1.lastValueFrom)(client.request.setSignalGeneratorParameters(props, requestTimeout));
578
+ if (status.request !== 'succeeded') {
579
+ res.status(500).send(status.error);
580
+ return;
581
+ }
582
+ // Remember whether this signal repeats, so start-signal-generator knows not to wait for a completion
583
+ // that never comes.
584
+ const device = yield (0, rxjs_1.lastValueFrom)(client.request.resolveDevice(deviceRef));
585
+ signalGeneratorRepeatMap.set(device.id, ((_18 = signalConfigs[signal]) === null || _18 === void 0 ? void 0 : _18.repeat) === true);
586
+ res.send();
587
+ })));
588
+ /**
589
+ * Starts the signal generator configured by `set-signal-generator-parameters`. This turns the motor.
590
+ *
591
+ * A non-repeating signal completes on its own, so the request waits for it and responds with the data
592
+ * collected while it ran as CSV. A repeating signal runs until `stop-signal-generator`, so the request
593
+ * responds as soon as the signal generator has started, with an empty body and no data.
594
+ *
595
+ * @example curl "http://localhost:63526/api/devices/0/start-signal-generator?request-timeout=60000"
596
+ */
597
+ app.get('/api/devices/:deviceRef/start-signal-generator', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
598
+ var _19, _20;
599
+ const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
600
+ const deviceRefObj = (0, device_1.makeDeviceRefObj)(deviceRef);
601
+ const requestTimeout = parseInt(((_19 = req.query['request-timeout']) !== null && _19 !== void 0 ? _19 : '60000'));
602
+ const wait = req.query['wait'] !== undefined ? asBoolean(req.query['wait']) : true;
603
+ const device = yield (0, rxjs_1.lastValueFrom)(client.request.resolveDevice(deviceRef));
604
+ const repeat = req.query['repeat'] !== undefined
605
+ ? asBoolean(req.query['repeat'])
606
+ : (_20 = signalGeneratorRepeatMap.get(device.id)) !== null && _20 !== void 0 ? _20 : false;
607
+ // A repeating signal never reports DONE, so waiting for completion would only ever time out.
608
+ if (repeat || !wait) {
609
+ const status = yield (0, rxjs_1.firstValueFrom)(client.request.startSignalGenerator(Object.assign({}, deviceRefObj), requestTimeout));
610
+ if (status.request === 'failed') {
611
+ res.status(500).send(status.error);
612
+ }
613
+ else {
614
+ res.send();
615
+ }
616
+ return;
617
+ }
618
+ const monitoringParameterIds = yield createDefaultDataMonitoringParameterIds(deviceRef);
619
+ const dataMonitoring = client.createDataMonitoring(monitoringParameterIds, 1000);
620
+ dataMonitoring.start();
621
+ try {
622
+ const statuses = yield (0, rxjs_1.lastValueFrom)(client.request.startSignalGenerator(Object.assign({}, deviceRefObj), requestTimeout).pipe((0, rxjs_1.toArray)()));
623
+ // Warnings are intermediate statuses - the signal generator keeps running with, for example, a reduced
624
+ // velocity - and the response body is the collected data, so surface them in the log instead.
625
+ statuses
626
+ .filter((status) => status.warning)
627
+ .forEach((status) => { var _a; return log(`Signal generator warning on device ${deviceRef}: ${(_a = status.warning) === null || _a === void 0 ? void 0 : _a.message}`); });
628
+ const finalStatus = statuses.at(-1);
629
+ if ((finalStatus === null || finalStatus === void 0 ? void 0 : finalStatus.request) === 'succeeded') {
630
+ res.type('text/csv').send(dataMonitoring.csv);
631
+ }
632
+ else {
633
+ res.status(500).send(finalStatus === null || finalStatus === void 0 ? void 0 : finalStatus.error);
634
+ }
635
+ }
636
+ finally {
637
+ dataMonitoring.stop();
638
+ }
639
+ })));
640
+ /**
641
+ * Stops the running signal generator by sending a Quick Stop command to the device.
642
+ *
643
+ * @example curl "http://localhost:63526/api/devices/0/stop-signal-generator"
644
+ */
645
+ app.get('/api/devices/:deviceRef/stop-signal-generator', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
646
+ var _21;
647
+ const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
648
+ const deviceRefObj = (0, device_1.makeDeviceRefObj)(deviceRef);
649
+ const requestTimeout = parseInt(((_21 = req.query['request-timeout']) !== null && _21 !== void 0 ? _21 : '3000'));
650
+ const status = yield (0, rxjs_1.lastValueFrom)(client.request.stopSignalGenerator(Object.assign({}, deviceRefObj), requestTimeout));
651
+ if (status.request === 'succeeded') {
652
+ res.send();
653
+ }
654
+ else {
655
+ res.status(500).send(status.error);
656
+ }
657
+ })));
658
+ app.get('/api/devices/:deviceRef/get-ethercat-network-state', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
659
+ var _22;
660
+ const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
661
+ const deviceRefObj = (0, device_1.makeDeviceRefObj)(deviceRef);
662
+ const requestTimeout = parseInt(((_22 = req.query['request-timeout']) !== null && _22 !== void 0 ? _22 : '3000'));
549
663
  const status = yield (0, rxjs_1.lastValueFrom)(client.request.getEthercatNetworkState(Object.assign({}, deviceRefObj), requestTimeout));
550
664
  if (status.request === 'succeeded') {
551
665
  res.send({ state: status.state });
@@ -555,11 +669,11 @@ app.get('/api/devices/:deviceRef/get-ethercat-network-state', asyncHandler((req,
555
669
  }
556
670
  })));
557
671
  app.get('/api/devices/:deviceRef/set-ethercat-network-state/:state', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
558
- var _17, _18;
672
+ var _23, _24;
559
673
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
560
674
  const deviceRefObj = (0, device_1.makeDeviceRefObj)(deviceRef);
561
- const state = (_17 = types_1.MotionMasterMessage.Request.SetEthercatNetworkState.State[req.params['state'].toUpperCase()]) !== null && _17 !== void 0 ? _17 : types_1.MotionMasterMessage.Request.SetEthercatNetworkState.State.UNSPECIFIED;
562
- const requestTimeout = parseInt(((_18 = req.query['request-timeout']) !== null && _18 !== void 0 ? _18 : '3000'));
675
+ const state = (_23 = types_1.MotionMasterMessage.Request.SetEthercatNetworkState.State[req.params['state'].toUpperCase()]) !== null && _23 !== void 0 ? _23 : types_1.MotionMasterMessage.Request.SetEthercatNetworkState.State.UNSPECIFIED;
676
+ const requestTimeout = parseInt(((_24 = req.query['request-timeout']) !== null && _24 !== void 0 ? _24 : '3000'));
563
677
  const status = yield (0, rxjs_1.lastValueFrom)(client.request.setEthercatNetworkState(Object.assign(Object.assign({}, deviceRefObj), { state }), requestTimeout));
564
678
  if (status.request === 'succeeded') {
565
679
  res.send();
@@ -569,15 +683,15 @@ app.get('/api/devices/:deviceRef/set-ethercat-network-state/:state', asyncHandle
569
683
  }
570
684
  })));
571
685
  app.get('/api/devices/:deviceRef/start-system-identification', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
572
- var _19, _20, _21, _22, _23;
686
+ var _25, _26, _27, _28, _29;
573
687
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
574
688
  const deviceRefObj = (0, device_1.makeDeviceRefObj)(deviceRef);
575
- const durationSeconds = parseFloat(((_19 = req.query['duration-seconds']) !== null && _19 !== void 0 ? _19 : '3.0'));
576
- const torqueAmplitude = parseInt(((_20 = req.query['torque-amplitude']) !== null && _20 !== void 0 ? _20 : '300'));
577
- const startFrequency = parseInt(((_21 = req.query['start-frequency']) !== null && _21 !== void 0 ? _21 : '2'));
578
- const endFrequency = parseInt(((_22 = req.query['end-frequency']) !== null && _22 !== void 0 ? _22 : '60'));
689
+ const durationSeconds = parseFloat(((_25 = req.query['duration-seconds']) !== null && _25 !== void 0 ? _25 : '3.0'));
690
+ const torqueAmplitude = parseInt(((_26 = req.query['torque-amplitude']) !== null && _26 !== void 0 ? _26 : '300'));
691
+ const startFrequency = parseInt(((_27 = req.query['start-frequency']) !== null && _27 !== void 0 ? _27 : '2'));
692
+ const endFrequency = parseInt(((_28 = req.query['end-frequency']) !== null && _28 !== void 0 ? _28 : '60'));
579
693
  const nextGenSysId = asBoolean(req.query['next-gen-sys-id']);
580
- const requestTimeout = parseInt(((_23 = req.query['request-timeout']) !== null && _23 !== void 0 ? _23 : '30000'));
694
+ const requestTimeout = parseInt(((_29 = req.query['request-timeout']) !== null && _29 !== void 0 ? _29 : '30000'));
581
695
  const props = Object.assign(Object.assign({}, deviceRefObj), { durationSeconds,
582
696
  torqueAmplitude,
583
697
  startFrequency,
@@ -593,9 +707,9 @@ app.get('/api/devices/:deviceRef/start-system-identification', asyncHandler((req
593
707
  }
594
708
  })));
595
709
  app.get('/api/devices/:deviceRef/set-modes-of-operation/:modesOfOperation', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
596
- var _24;
710
+ var _30;
597
711
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
598
- const modesOfOperation = parseInt((_24 = req.params['modesOfOperation']) !== null && _24 !== void 0 ? _24 : '0');
712
+ const modesOfOperation = parseInt((_30 = req.params['modesOfOperation']) !== null && _30 !== void 0 ? _30 : '0');
599
713
  yield (0, rxjs_1.lastValueFrom)(client.request.setModesOfOperation(deviceRef, modesOfOperation));
600
714
  res.send();
601
715
  })));
@@ -606,9 +720,9 @@ app.get('/api/devices/:deviceRef/transition-to-cia402-state/:state', asyncHandle
606
720
  res.send();
607
721
  })));
608
722
  app.get('/api/devices/:deviceRef/cia402-state', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
609
- var _25;
723
+ var _31;
610
724
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
611
- const requestTimeout = parseInt(((_25 = req.query['request-timeout']) !== null && _25 !== void 0 ? _25 : '5000'));
725
+ const requestTimeout = parseInt(((_31 = req.query['request-timeout']) !== null && _31 !== void 0 ? _31 : '5000'));
612
726
  const state = yield (0, rxjs_1.lastValueFrom)(client.request.getCia402State(deviceRef, requestTimeout));
613
727
  res.send({ state });
614
728
  })));
@@ -619,10 +733,10 @@ app.get('/api/devices/:deviceRef/cia402-state', asyncHandler((req, res) => tslib
619
733
  * @example curl "http://localhost:63526/api/devices/0/when-target-reached?monitoring-interval=1000&request-timeout=5000"
620
734
  */
621
735
  app.get('/api/devices/:deviceRef/when-target-reached', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
622
- var _26, _27;
736
+ var _32, _33;
623
737
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
624
- const monitoringInterval = parseInt(((_26 = req.query['monitoring-interval']) !== null && _26 !== void 0 ? _26 : '10000'));
625
- const requestTimeout = parseInt(((_27 = req.query['request-timeout']) !== null && _27 !== void 0 ? _27 : '5000'));
738
+ const monitoringInterval = parseInt(((_32 = req.query['monitoring-interval']) !== null && _32 !== void 0 ? _32 : '10000'));
739
+ const requestTimeout = parseInt(((_33 = req.query['request-timeout']) !== null && _33 !== void 0 ? _33 : '5000'));
626
740
  yield client.whenTargetReached(deviceRef, monitoringInterval, requestTimeout);
627
741
  res.send({ targetReached: true });
628
742
  })));
@@ -633,11 +747,11 @@ app.get('/api/devices/:deviceRef/when-target-reached', asyncHandler((req, res) =
633
747
  * @example curl "http://localhost:63526/api/devices/0/when-cia402-state-reached/OPERATION_ENABLED?monitoring-interval=10000&request-timeout=60000"
634
748
  */
635
749
  app.get('/api/devices/:deviceRef/when-cia402-state-reached/:state', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
636
- var _28, _29;
750
+ var _34, _35;
637
751
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
638
752
  const state = req.params['state'];
639
- const monitoringInterval = parseInt(((_28 = req.query['monitoring-interval']) !== null && _28 !== void 0 ? _28 : '10000'));
640
- const requestTimeout = parseInt(((_29 = req.query['request-timeout']) !== null && _29 !== void 0 ? _29 : '60000'));
753
+ const monitoringInterval = parseInt(((_34 = req.query['monitoring-interval']) !== null && _34 !== void 0 ? _34 : '10000'));
754
+ const requestTimeout = parseInt(((_35 = req.query['request-timeout']) !== null && _35 !== void 0 ? _35 : '60000'));
641
755
  yield client.whenCia402StateReached(deviceRef, state, monitoringInterval, requestTimeout);
642
756
  res.send();
643
757
  })));
@@ -647,7 +761,7 @@ app.get('/api/devices/:deviceRef/save-config', asyncHandler((req, res) => tslib_
647
761
  res.send();
648
762
  })));
649
763
  app.put('/api/devices/:deviceRef/load-config', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
650
- var _30, _31;
764
+ var _36, _37;
651
765
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
652
766
  let content;
653
767
  if (Buffer.isBuffer(req.body)) {
@@ -657,21 +771,21 @@ app.put('/api/devices/:deviceRef/load-config', asyncHandler((req, res) => tslib_
657
771
  content = new Uint8Array(Buffer.from(req.body, 'utf-8'));
658
772
  }
659
773
  else {
660
- const contentType = (_30 = req.headers['content-type']) !== null && _30 !== void 0 ? _30 : '';
774
+ const contentType = (_36 = req.headers['content-type']) !== null && _36 !== void 0 ? _36 : '';
661
775
  throw new Error(`Unsupported body type for load-config: ${typeof req.body} (Content-Type: ${contentType})`);
662
776
  }
663
777
  const refresh = asBoolean(req.query['refresh']);
664
- const strategy = (_31 = req.query['strategy']) !== null && _31 !== void 0 ? _31 : 'replace';
778
+ const strategy = (_37 = req.query['strategy']) !== null && _37 !== void 0 ? _37 : 'replace';
665
779
  yield (0, rxjs_1.lastValueFrom)(client.request.loadConfig(deviceRef, content, strategy, { count: 20, delay: 500 }, refresh));
666
780
  res.send();
667
781
  })));
668
782
  app.get('/api/devices/:deviceRef/compute-auto-tuning-gains/velocity', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
669
- var _32, _33, _34;
783
+ var _38, _39, _40;
670
784
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
671
785
  const deviceRefObj = (0, device_1.makeDeviceRefObj)(deviceRef);
672
- const velocityLoopBandwidth = parseFloat(((_32 = req.query['velocity-loop-bandwidth']) !== null && _32 !== void 0 ? _32 : '5'));
673
- const velocityDamping = parseFloat(((_33 = req.query['velocity-damping']) !== null && _33 !== void 0 ? _33 : '0.7'));
674
- const requestTimeout = parseInt(((_34 = req.query['request-timeout']) !== null && _34 !== void 0 ? _34 : '120000'));
786
+ const velocityLoopBandwidth = parseFloat(((_38 = req.query['velocity-loop-bandwidth']) !== null && _38 !== void 0 ? _38 : '5'));
787
+ const velocityDamping = parseFloat(((_39 = req.query['velocity-damping']) !== null && _39 !== void 0 ? _39 : '0.7'));
788
+ const requestTimeout = parseInt(((_40 = req.query['request-timeout']) !== null && _40 !== void 0 ? _40 : '120000'));
675
789
  const velocityParameters = { velocityLoopBandwidth, velocityDamping };
676
790
  const status = yield (0, rxjs_1.lastValueFrom)(client.request.computeAutoTuningGains(Object.assign(Object.assign({}, deviceRefObj), { velocityParameters }), requestTimeout));
677
791
  if (status.request === 'succeeded') {
@@ -682,17 +796,17 @@ app.get('/api/devices/:deviceRef/compute-auto-tuning-gains/velocity', asyncHandl
682
796
  }
683
797
  })));
684
798
  app.get('/api/devices/:deviceRef/compute-auto-tuning-gains/position', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
685
- var _35, _36, _37, _38, _39, _40, _41, _42, _43;
799
+ var _41, _42, _43, _44, _45, _46, _47, _48, _49;
686
800
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
687
801
  const deviceRefObj = (0, device_1.makeDeviceRefObj)(deviceRef);
688
- const controllerType = (_36 = types_1.MotionMasterMessage.Request.ComputeAutoTuningGains.PositionParameters.ControllerType[((_35 = req.query['controller-type']) !== null && _35 !== void 0 ? _35 : 'UNSPECIFIED')]) !== null && _36 !== void 0 ? _36 : types_1.MotionMasterMessage.Request.ComputeAutoTuningGains.PositionParameters.ControllerType.UNSPECIFIED;
689
- const settlingTime = parseFloat(((_37 = req.query['settling-time']) !== null && _37 !== void 0 ? _37 : '0.2'));
690
- const positionDamping = parseFloat(((_38 = req.query['position-damping']) !== null && _38 !== void 0 ? _38 : '1'));
691
- const alphaMult = parseInt(((_39 = req.query['alpha-mult']) !== null && _39 !== void 0 ? _39 : '1'));
692
- const order = parseInt(((_40 = req.query['order']) !== null && _40 !== void 0 ? _40 : '0'));
693
- const lb = parseInt(((_41 = req.query['lb']) !== null && _41 !== void 0 ? _41 : '1'));
694
- const ub = parseInt(((_42 = req.query['ub']) !== null && _42 !== void 0 ? _42 : '1001'));
695
- const requestTimeout = parseInt(((_43 = req.query['request-timeout']) !== null && _43 !== void 0 ? _43 : '120000'));
802
+ const controllerType = (_42 = types_1.MotionMasterMessage.Request.ComputeAutoTuningGains.PositionParameters.ControllerType[((_41 = req.query['controller-type']) !== null && _41 !== void 0 ? _41 : 'UNSPECIFIED')]) !== null && _42 !== void 0 ? _42 : types_1.MotionMasterMessage.Request.ComputeAutoTuningGains.PositionParameters.ControllerType.UNSPECIFIED;
803
+ const settlingTime = parseFloat(((_43 = req.query['settling-time']) !== null && _43 !== void 0 ? _43 : '0.2'));
804
+ const positionDamping = parseFloat(((_44 = req.query['position-damping']) !== null && _44 !== void 0 ? _44 : '1'));
805
+ const alphaMult = parseInt(((_45 = req.query['alpha-mult']) !== null && _45 !== void 0 ? _45 : '1'));
806
+ const order = parseInt(((_46 = req.query['order']) !== null && _46 !== void 0 ? _46 : '0'));
807
+ const lb = parseInt(((_47 = req.query['lb']) !== null && _47 !== void 0 ? _47 : '1'));
808
+ const ub = parseInt(((_48 = req.query['ub']) !== null && _48 !== void 0 ? _48 : '1001'));
809
+ const requestTimeout = parseInt(((_49 = req.query['request-timeout']) !== null && _49 !== void 0 ? _49 : '120000'));
696
810
  const positionParameters = { controllerType, settlingTime, positionDamping, alphaMult, order, lb, ub };
697
811
  const status = yield (0, rxjs_1.lastValueFrom)(client.request.computeAutoTuningGains(Object.assign(Object.assign({}, deviceRefObj), { positionParameters }), requestTimeout));
698
812
  if (status.request === 'succeeded') {
@@ -703,15 +817,15 @@ app.get('/api/devices/:deviceRef/compute-auto-tuning-gains/position', asyncHandl
703
817
  }
704
818
  })));
705
819
  app.get('/api/devices/:deviceRef/start-open-loop-field-control', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
706
- var _44, _45, _46, _47, _48, _49;
820
+ var _50, _51, _52, _53, _54, _55;
707
821
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
708
822
  const deviceRefObj = (0, device_1.makeDeviceRefObj)(deviceRef);
709
- const angle = parseInt(((_44 = req.query['angle']) !== null && _44 !== void 0 ? _44 : '360'));
710
- const velocity = parseInt(((_45 = req.query['velocity']) !== null && _45 !== void 0 ? _45 : '5'));
711
- const acceleration = parseInt(((_46 = req.query['acceleration']) !== null && _46 !== void 0 ? _46 : '1000'));
712
- const torque = parseInt(((_47 = req.query['torque']) !== null && _47 !== void 0 ? _47 : '1000'));
713
- const torqueSpeed = parseInt(((_48 = req.query['torqueSpeed']) !== null && _48 !== void 0 ? _48 : '10000'));
714
- const requestTimeout = parseInt(((_49 = req.query['request-timeout']) !== null && _49 !== void 0 ? _49 : '120000'));
823
+ const angle = parseInt(((_50 = req.query['angle']) !== null && _50 !== void 0 ? _50 : '360'));
824
+ const velocity = parseInt(((_51 = req.query['velocity']) !== null && _51 !== void 0 ? _51 : '5'));
825
+ const acceleration = parseInt(((_52 = req.query['acceleration']) !== null && _52 !== void 0 ? _52 : '1000'));
826
+ const torque = parseInt(((_53 = req.query['torque']) !== null && _53 !== void 0 ? _53 : '1000'));
827
+ const torqueSpeed = parseInt(((_54 = req.query['torqueSpeed']) !== null && _54 !== void 0 ? _54 : '10000'));
828
+ const requestTimeout = parseInt(((_55 = req.query['request-timeout']) !== null && _55 !== void 0 ? _55 : '120000'));
715
829
  const status = yield (0, rxjs_1.lastValueFrom)(client.request.startOpenLoopFieldControl(Object.assign(Object.assign({}, deviceRefObj), { angle, velocity, acceleration, torque, torqueSpeed }), requestTimeout));
716
830
  if (status.request === 'succeeded') {
717
831
  res.send();
@@ -721,17 +835,17 @@ app.get('/api/devices/:deviceRef/start-open-loop-field-control', asyncHandler((r
721
835
  }
722
836
  })));
723
837
  app.get('/api/devices/:deviceRef/start-full-auto-tuning/velocity', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
724
- var _50, _51, _52, _53;
838
+ var _56, _57, _58, _59;
725
839
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
726
840
  const deviceRefObj = (0, device_1.makeDeviceRefObj)(deviceRef);
727
841
  const type = types_1.MotionMasterMessage.Request.StartFullAutoTuning.Type.VELOCITY;
728
- const requestTimeout = parseInt(((_50 = req.query['request-timeout']) !== null && _50 !== void 0 ? _50 : '60000'));
842
+ const requestTimeout = parseInt(((_56 = req.query['request-timeout']) !== null && _56 !== void 0 ? _56 : '60000'));
729
843
  const props = Object.assign(Object.assign({}, deviceRefObj), { type });
730
844
  const status = yield (0, rxjs_1.lastValueFrom)(client.request.startFullAutoTuning(props, requestTimeout));
731
845
  if (status.request === 'succeeded') {
732
- const dampingRatio = (_51 = status.dampingRatio) !== null && _51 !== void 0 ? _51 : 0;
733
- const settlingTime = (_52 = status.settlingTime) !== null && _52 !== void 0 ? _52 : 0;
734
- const bandwidth = (_53 = status.bandwidth) !== null && _53 !== void 0 ? _53 : 0;
846
+ const dampingRatio = (_57 = status.dampingRatio) !== null && _57 !== void 0 ? _57 : 0;
847
+ const settlingTime = (_58 = status.settlingTime) !== null && _58 !== void 0 ? _58 : 0;
848
+ const bandwidth = (_59 = status.bandwidth) !== null && _59 !== void 0 ? _59 : 0;
735
849
  const pidObj = {};
736
850
  for (let subidx = 1; subidx < 5; subidx++) {
737
851
  pidObj[(0, parameter_1.makeParameterId)(0x2011, subidx)] = yield client.request.upload(deviceRef, 0x2011, subidx);
@@ -746,17 +860,17 @@ app.get('/api/devices/:deviceRef/start-full-auto-tuning/velocity', asyncHandler(
746
860
  }
747
861
  })));
748
862
  app.get('/api/devices/:deviceRef/start-full-auto-tuning/position/:controllerType', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
749
- var _54, _55, _56, _57;
863
+ var _60, _61, _62, _63;
750
864
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
751
865
  const deviceRefObj = (0, device_1.makeDeviceRefObj)(deviceRef);
752
866
  const type = types_1.MotionMasterMessage.Request.StartFullAutoTuning.Type.POSITION;
753
867
  let controllerType = types_1.MotionMasterMessage.Request.StartFullAutoTuning.ControllerType[req.params['controllerType'].toUpperCase()] || types_1.MotionMasterMessage.Request.StartFullAutoTuning.ControllerType.UNSPECIFIED;
754
- const requestTimeout = parseInt(((_54 = req.query['request-timeout']) !== null && _54 !== void 0 ? _54 : '60000'));
868
+ const requestTimeout = parseInt(((_60 = req.query['request-timeout']) !== null && _60 !== void 0 ? _60 : '60000'));
755
869
  const status = yield (0, rxjs_1.lastValueFrom)(client.request.startFullAutoTuning(Object.assign(Object.assign({}, deviceRefObj), { type, controllerType }), requestTimeout));
756
870
  if (status.request === 'succeeded') {
757
- const dampingRatio = (_55 = status.dampingRatio) !== null && _55 !== void 0 ? _55 : 0;
758
- const settlingTime = (_56 = status.settlingTime) !== null && _56 !== void 0 ? _56 : 0;
759
- const bandwidth = (_57 = status.bandwidth) !== null && _57 !== void 0 ? _57 : 0;
871
+ const dampingRatio = (_61 = status.dampingRatio) !== null && _61 !== void 0 ? _61 : 0;
872
+ const settlingTime = (_62 = status.settlingTime) !== null && _62 !== void 0 ? _62 : 0;
873
+ const bandwidth = (_63 = status.bandwidth) !== null && _63 !== void 0 ? _63 : 0;
760
874
  const pidObj = {};
761
875
  for (let subidx = 1; subidx < 9; subidx++) {
762
876
  pidObj[(0, parameter_1.makeParameterId)(0x2012, subidx)] = yield client.request.upload(deviceRef, 0x2012, subidx);
@@ -771,10 +885,10 @@ app.get('/api/devices/:deviceRef/start-full-auto-tuning/position/:controllerType
771
885
  }
772
886
  })));
773
887
  app.get('/api/devices/:deviceRef/stop-full-auto-tuning', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
774
- var _58;
888
+ var _64;
775
889
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
776
890
  const deviceRefObj = (0, device_1.makeDeviceRefObj)(deviceRef);
777
- const requestTimeout = parseInt(((_58 = req.query['request-timeout']) !== null && _58 !== void 0 ? _58 : '10000'));
891
+ const requestTimeout = parseInt(((_64 = req.query['request-timeout']) !== null && _64 !== void 0 ? _64 : '10000'));
778
892
  const status = yield (0, rxjs_1.lastValueFrom)(client.request.stopFullAutoTuning(deviceRefObj, requestTimeout));
779
893
  if (status.request == 'succeeded') {
780
894
  res.send();
@@ -793,9 +907,9 @@ app.get('/api/devices/:deviceRef/set-halt-bit/:value', asyncHandler((req, res) =
793
907
  * @example curl "http://localhost:63500/api/devices/0/run-torque-profile?target=100&holding-duration=3000&skip-quick-stop=false&target-reach-timeout=5000&slope=50&window=30&window-time=1"
794
908
  */
795
909
  app.get('/api/devices/:deviceRef/run-torque-profile', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
796
- var _59, _60;
910
+ var _65, _66;
797
911
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
798
- const target = parseInt(((_59 = req.query['target']) !== null && _59 !== void 0 ? _59 : '100'));
912
+ const target = parseInt(((_65 = req.query['target']) !== null && _65 !== void 0 ? _65 : '100'));
799
913
  const holdingDuration = parseInt(req.query['holding-duration']) || undefined;
800
914
  const skipQuickStop = req.query['skip-quick-stop'] !== undefined ? asBoolean(req.query['skip-quick-stop']) : true;
801
915
  const targetReachTimeout = parseInt(req.query['target-reach-timeout']) || undefined;
@@ -803,7 +917,7 @@ app.get('/api/devices/:deviceRef/run-torque-profile', asyncHandler((req, res) =>
803
917
  res.status(400).send('target-reach-timeout is required when skip-quick-stop is false');
804
918
  return;
805
919
  }
806
- const slope = parseInt(((_60 = req.query['slope']) !== null && _60 !== void 0 ? _60 : '50'));
920
+ const slope = parseInt(((_66 = req.query['slope']) !== null && _66 !== void 0 ? _66 : '50'));
807
921
  const windowStr = req.query['window'];
808
922
  const window = windowStr ? parseInt(windowStr) : undefined;
809
923
  const windowTimeStr = req.query['window-time'];
@@ -835,11 +949,11 @@ app.get('/api/devices/:deviceRef/run-torque-profile', asyncHandler((req, res) =>
835
949
  * @example curl "http://localhost:63500/api/devices/0/run-velocity-profile?acceleration=5000&target=1000&deceleration=5000&holding-duration=2000&skip-quick-stop=false&target-reach-timeout=5000&window=10&window-time=1"
836
950
  */
837
951
  app.get('/api/devices/:deviceRef/run-velocity-profile', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
838
- var _61, _62, _63;
952
+ var _67, _68, _69;
839
953
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
840
- const acceleration = parseInt(((_61 = req.query['acceleration']) !== null && _61 !== void 0 ? _61 : '1000'));
841
- const target = parseInt(((_62 = req.query['target']) !== null && _62 !== void 0 ? _62 : '1000'));
842
- const deceleration = parseInt(((_63 = req.query['deceleration']) !== null && _63 !== void 0 ? _63 : '1000'));
954
+ const acceleration = parseInt(((_67 = req.query['acceleration']) !== null && _67 !== void 0 ? _67 : '1000'));
955
+ const target = parseInt(((_68 = req.query['target']) !== null && _68 !== void 0 ? _68 : '1000'));
956
+ const deceleration = parseInt(((_69 = req.query['deceleration']) !== null && _69 !== void 0 ? _69 : '1000'));
843
957
  const holdingDuration = parseInt(req.query['holding-duration']) || undefined;
844
958
  const skipQuickStop = req.query['skip-quick-stop'] !== undefined ? asBoolean(req.query['skip-quick-stop']) : true;
845
959
  const targetReachTimeout = parseInt(req.query['target-reach-timeout']) || undefined;
@@ -879,11 +993,11 @@ app.get('/api/devices/:deviceRef/run-velocity-profile', asyncHandler((req, res)
879
993
  * @example curl "http://localhost:63500/api/devices/0/run-position-profile?acceleration=5000&target=10000&deceleration=5000&holding-duration=2000&relative=true&skip-quick-stop=false&target-reach-timeout=5000&velocity=2000&window=10&window-time=1"
880
994
  */
881
995
  app.get('/api/devices/:deviceRef/run-position-profile', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
882
- var _64, _65, _66, _67;
996
+ var _70, _71, _72, _73;
883
997
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
884
- const acceleration = parseInt(((_64 = req.query['acceleration']) !== null && _64 !== void 0 ? _64 : '1000'));
885
- const target = parseInt(((_65 = req.query['target']) !== null && _65 !== void 0 ? _65 : '1000'));
886
- const deceleration = parseInt(((_66 = req.query['deceleration']) !== null && _66 !== void 0 ? _66 : '1000'));
998
+ const acceleration = parseInt(((_70 = req.query['acceleration']) !== null && _70 !== void 0 ? _70 : '1000'));
999
+ const target = parseInt(((_71 = req.query['target']) !== null && _71 !== void 0 ? _71 : '1000'));
1000
+ const deceleration = parseInt(((_72 = req.query['deceleration']) !== null && _72 !== void 0 ? _72 : '1000'));
887
1001
  const holdingDuration = parseInt(req.query['holding-duration']) || undefined;
888
1002
  const relative = asBoolean(req.query['relative']);
889
1003
  const skipQuickStop = req.query['skip-quick-stop'] !== undefined ? asBoolean(req.query['skip-quick-stop']) : true;
@@ -892,7 +1006,7 @@ app.get('/api/devices/:deviceRef/run-position-profile', asyncHandler((req, res)
892
1006
  res.status(400).send('target-reach-timeout is required when skip-quick-stop is false');
893
1007
  return;
894
1008
  }
895
- const velocity = parseInt(((_67 = req.query['velocity']) !== null && _67 !== void 0 ? _67 : '100'));
1009
+ const velocity = parseInt(((_73 = req.query['velocity']) !== null && _73 !== void 0 ? _73 : '100'));
896
1010
  const windowStr = req.query['window'];
897
1011
  const window = windowStr ? parseInt(windowStr) : undefined;
898
1012
  const windowTimeStr = req.query['window-time'];
@@ -934,14 +1048,14 @@ app.get('/api/devices/:deviceRef/force-on-demand-parameters-update', asyncHandle
934
1048
  res.send();
935
1049
  })));
936
1050
  app.get('/api/devices/:deviceRef/start-circulo-encoder-narrow-angle-calibration', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
937
- var _68, _69, _70;
1051
+ var _74, _75, _76;
938
1052
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
939
1053
  const deviceRefObj = (0, device_1.makeDeviceRefObj)(deviceRef);
940
- const encoderOrdinal = parseInt(((_68 = req.query['encoder-ordinal']) !== null && _68 !== void 0 ? _68 : '1'));
1054
+ const encoderOrdinal = parseInt(((_74 = req.query['encoder-ordinal']) !== null && _74 !== void 0 ? _74 : '1'));
941
1055
  const activateHealthMonitoring = asBoolean(req.query['activate-health-monitoring']);
942
1056
  const measurementOnly = asBoolean(req.query['measurement-only']);
943
- const externalEncoderType = parseInt(((_69 = req.query['external-encoder-type']) !== null && _69 !== void 0 ? _69 : '0'));
944
- const requestTimeout = parseInt(((_70 = req.query['request-timeout']) !== null && _70 !== void 0 ? _70 : '120000'));
1057
+ const externalEncoderType = parseInt(((_75 = req.query['external-encoder-type']) !== null && _75 !== void 0 ? _75 : '0'));
1058
+ const requestTimeout = parseInt(((_76 = req.query['request-timeout']) !== null && _76 !== void 0 ? _76 : '120000'));
945
1059
  const statuses = yield (0, rxjs_1.lastValueFrom)(client.request
946
1060
  .startCirculoEncoderNarrowAngleCalibrationProcedure(Object.assign(Object.assign({}, deviceRefObj), { encoderOrdinal, activateHealthMonitoring, measurementOnly, externalEncoderType }), requestTimeout)
947
1061
  .pipe((0, rxjs_1.toArray)()));
@@ -991,13 +1105,13 @@ app.get('/api/devices/:deviceRef/start-circulo-encoder-narrow-angle-calibration'
991
1105
  }
992
1106
  })));
993
1107
  app.get('/api/devices/:deviceRef/start-circulo-encoder-configuration', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
994
- var _71, _72, _73, _74;
1108
+ var _77, _78, _79, _80;
995
1109
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
996
1110
  const deviceRefObj = (0, device_1.makeDeviceRefObj)(deviceRef);
997
- const encoderOrdinal = parseInt(((_71 = req.query['encoder-ordinal']) !== null && _71 !== void 0 ? _71 : '1'));
998
- const batteryModeMaxAcceleration = parseInt(((_72 = req.query['battery-mode-max-acceleration']) !== null && _72 !== void 0 ? _72 : '0'));
999
- const externalCirculoType = parseInt(((_73 = req.query['external-circulo-type']) !== null && _73 !== void 0 ? _73 : '0'));
1000
- const requestTimeout = parseInt(((_74 = req.query['request-timeout']) !== null && _74 !== void 0 ? _74 : '30000'));
1111
+ const encoderOrdinal = parseInt(((_77 = req.query['encoder-ordinal']) !== null && _77 !== void 0 ? _77 : '1'));
1112
+ const batteryModeMaxAcceleration = parseInt(((_78 = req.query['battery-mode-max-acceleration']) !== null && _78 !== void 0 ? _78 : '0'));
1113
+ const externalCirculoType = parseInt(((_79 = req.query['external-circulo-type']) !== null && _79 !== void 0 ? _79 : '0'));
1114
+ const requestTimeout = parseInt(((_80 = req.query['request-timeout']) !== null && _80 !== void 0 ? _80 : '30000'));
1001
1115
  const status = yield (0, rxjs_1.lastValueFrom)(client.request.startCirculoEncoderConfiguration(Object.assign(Object.assign({}, deviceRefObj), { encoderOrdinal, batteryModeMaxAcceleration, externalCirculoType }), requestTimeout));
1002
1116
  if (status.request === 'succeeded') {
1003
1117
  res.send();
@@ -1007,9 +1121,9 @@ app.get('/api/devices/:deviceRef/start-circulo-encoder-configuration', asyncHand
1007
1121
  }
1008
1122
  })));
1009
1123
  app.get('/api/devices/:deviceRef/check-circulo-encoder-errors', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1010
- var _75;
1124
+ var _81;
1011
1125
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
1012
- const encoderOrdinal = parseInt(((_75 = req.query['encoder-ordinal']) !== null && _75 !== void 0 ? _75 : '1'));
1126
+ const encoderOrdinal = parseInt(((_81 = req.query['encoder-ordinal']) !== null && _81 !== void 0 ? _81 : '1'));
1013
1127
  const result = yield (0, rxjs_1.lastValueFrom)(client.request.checkCirculoEncoderErrors(deviceRef, encoderOrdinal));
1014
1128
  res.send(result);
1015
1129
  })));
@@ -1019,12 +1133,12 @@ app.get('/api/devices/:deviceRef/start-integro-encoder-calibration', asyncHandle
1019
1133
  res.send();
1020
1134
  })));
1021
1135
  app.get('/api/devices/:deviceRef/circulo-encoder-magnet-distance', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1022
- var _76, _77, _78;
1136
+ var _82, _83, _84;
1023
1137
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
1024
1138
  const deviceRefObj = (0, device_1.makeDeviceRefObj)(deviceRef);
1025
- const encoderOrdinal = parseInt(((_76 = req.query['encoder-ordinal']) !== null && _76 !== void 0 ? _76 : '1'));
1026
- const ringRevision = parseInt(((_77 = req.query['ring-revision']) !== null && _77 !== void 0 ? _77 : '0'));
1027
- const requestTimeout = parseInt(((_78 = req.query['request-timeout']) !== null && _78 !== void 0 ? _78 : '5000'));
1139
+ const encoderOrdinal = parseInt(((_82 = req.query['encoder-ordinal']) !== null && _82 !== void 0 ? _82 : '1'));
1140
+ const ringRevision = parseInt(((_83 = req.query['ring-revision']) !== null && _83 !== void 0 ? _83 : '0'));
1141
+ const requestTimeout = parseInt(((_84 = req.query['request-timeout']) !== null && _84 !== void 0 ? _84 : '5000'));
1028
1142
  const status = yield (0, rxjs_1.lastValueFrom)(client.request.getCirculoEncoderMagnetDistance(Object.assign(Object.assign({}, deviceRefObj), { encoderOrdinal, ringRevision }), requestTimeout));
1029
1143
  if (status.request === 'succeeded') {
1030
1144
  res.send({ distance: status.distance, position: status.position });
@@ -1034,7 +1148,7 @@ app.get('/api/devices/:deviceRef/circulo-encoder-magnet-distance', asyncHandler(
1034
1148
  }
1035
1149
  })));
1036
1150
  app.post('/api/devices/:deviceRef/run-os-command', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1037
- var _79, _80, _81, _82;
1151
+ var _85, _86, _87, _88;
1038
1152
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
1039
1153
  const commandQuery = req.query['command'];
1040
1154
  if (!commandQuery) {
@@ -1049,12 +1163,12 @@ app.post('/api/devices/:deviceRef/run-os-command', asyncHandler((req, res) => ts
1049
1163
  return;
1050
1164
  }
1051
1165
  const commandArray = new Uint8Array(command);
1052
- const commandTimeout = parseInt(((_79 = req.query['command-timeout']) !== null && _79 !== void 0 ? _79 : '10000'));
1053
- const responsePollingInterval = parseInt(((_80 = req.query['response-polling-interval']) !== null && _80 !== void 0 ? _80 : '1000'));
1166
+ const commandTimeout = parseInt(((_85 = req.query['command-timeout']) !== null && _85 !== void 0 ? _85 : '10000'));
1167
+ const responsePollingInterval = parseInt(((_86 = req.query['response-polling-interval']) !== null && _86 !== void 0 ? _86 : '1000'));
1054
1168
  const osCommandModeQuery = req.query['os-command-mode'];
1055
1169
  const osCommandMode = osCommandModeQuery !== undefined && asBoolean(osCommandModeQuery)
1056
1170
  ? true
1057
- : (_81 = os_command_1.OsCommandMode[osCommandModeQuery === null || osCommandModeQuery === void 0 ? void 0 : osCommandModeQuery.toUpperCase()]) !== null && _81 !== void 0 ? _81 : false;
1171
+ : (_87 = os_command_1.OsCommandMode[osCommandModeQuery === null || osCommandModeQuery === void 0 ? void 0 : osCommandModeQuery.toUpperCase()]) !== null && _87 !== void 0 ? _87 : false;
1058
1172
  const readFsBuffer = asBoolean(req.query['read-fs-buffer']);
1059
1173
  const fsBufferContent = req.body;
1060
1174
  let fsBufferContentArray = undefined;
@@ -1062,7 +1176,7 @@ app.post('/api/devices/:deviceRef/run-os-command', asyncHandler((req, res) => ts
1062
1176
  fsBufferContentArray = new Uint8Array(fsBufferContent);
1063
1177
  }
1064
1178
  const fsBuffer = fsBufferContentArray !== null && fsBufferContentArray !== void 0 ? fsBufferContentArray : readFsBuffer;
1065
- const fsBufferReadWriteTimeout = parseInt(((_82 = req.query['fs-buffer-read-write-timeout']) !== null && _82 !== void 0 ? _82 : '30000'));
1179
+ const fsBufferReadWriteTimeout = parseInt(((_88 = req.query['fs-buffer-read-write-timeout']) !== null && _88 !== void 0 ? _88 : '30000'));
1066
1180
  const status = yield (0, rxjs_1.lastValueFrom)(client.request.runOsCommand(deviceRef, commandArray, commandTimeout, responsePollingInterval, osCommandMode, fsBuffer, fsBufferReadWriteTimeout));
1067
1181
  if (status.request === 'succeeded') {
1068
1182
  res.send(status);
@@ -1071,11 +1185,29 @@ app.post('/api/devices/:deviceRef/run-os-command', asyncHandler((req, res) => ts
1071
1185
  res.status(500).send(status);
1072
1186
  }
1073
1187
  })));
1188
+ /**
1189
+ * Aborts the OS command in progress and resets the sticky OS command mode, so the next command can run.
1190
+ *
1191
+ * @example curl -X POST "http://localhost:63526/api/devices/0/os-command/abort?command-timeout=10000&response-polling-interval=250"
1192
+ */
1193
+ app.post('/api/devices/:deviceRef/os-command/abort', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1194
+ var _89, _90;
1195
+ const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
1196
+ const commandTimeout = parseInt(((_89 = req.query['command-timeout']) !== null && _89 !== void 0 ? _89 : '10000'));
1197
+ const responsePollingInterval = parseInt(((_90 = req.query['response-polling-interval']) !== null && _90 !== void 0 ? _90 : '250'));
1198
+ const status = yield (0, rxjs_1.lastValueFrom)(client.request.abortOsCommand(deviceRef, commandTimeout, responsePollingInterval));
1199
+ if (status.request === 'succeeded') {
1200
+ res.send(status);
1201
+ }
1202
+ else {
1203
+ res.status(500).send(status);
1204
+ }
1205
+ })));
1074
1206
  app.post('/api/devices/:deviceRef/configure-smm', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1075
- var _83, _84, _85;
1207
+ var _91, _92, _93;
1076
1208
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
1077
- const username = (_83 = req.query['username']) !== null && _83 !== void 0 ? _83 : 'Test';
1078
- const password = (_84 = req.query['password']) !== null && _84 !== void 0 ? _84 : 'SomanetSMM';
1209
+ const username = (_91 = req.query['username']) !== null && _91 !== void 0 ? _91 : 'Test';
1210
+ const password = (_92 = req.query['password']) !== null && _92 !== void 0 ? _92 : 'SomanetSMM';
1079
1211
  let configString;
1080
1212
  if (Buffer.isBuffer(req.body)) {
1081
1213
  // application/octet-stream (or express.raw)
@@ -1086,49 +1218,49 @@ app.post('/api/devices/:deviceRef/configure-smm', asyncHandler((req, res) => tsl
1086
1218
  configString = req.body;
1087
1219
  }
1088
1220
  else {
1089
- const contentType = (_85 = req.headers['content-type']) !== null && _85 !== void 0 ? _85 : '';
1221
+ const contentType = (_93 = req.headers['content-type']) !== null && _93 !== void 0 ? _93 : '';
1090
1222
  throw new Error(`Unsupported body type for configure-smm: ${typeof req.body} (Content-Type: ${contentType})`);
1091
1223
  }
1092
1224
  const safetyParametersReport = yield (0, rxjs_1.lastValueFrom)(client.request.configureSmmFromFile(deviceRef, username, password, configString));
1093
1225
  res.send(safetyParametersReport);
1094
1226
  })));
1095
1227
  app.post('/api/devices/:deviceRef/update-smm-software', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1096
- var _86, _87, _88, _89, _90, _91, _92;
1228
+ var _94, _95, _96, _97, _98, _99, _100;
1097
1229
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
1098
- const username = (_86 = req.query['username']) !== null && _86 !== void 0 ? _86 : 'Test';
1099
- const password = (_87 = req.query['password']) !== null && _87 !== void 0 ? _87 : 'SomanetSMM';
1100
- const crc = parseInt(((_88 = req.query['crc']) !== null && _88 !== void 0 ? _88 : ''), 16);
1230
+ const username = (_94 = req.query['username']) !== null && _94 !== void 0 ? _94 : 'Test';
1231
+ const password = (_95 = req.query['password']) !== null && _95 !== void 0 ? _95 : 'SomanetSMM';
1232
+ const crc = parseInt(((_96 = req.query['crc']) !== null && _96 !== void 0 ? _96 : ''), 16);
1101
1233
  // Validate CRC
1102
1234
  if (Number.isNaN(crc)) {
1103
1235
  res.status(400).send('Invalid CRC format. Expected hexadecimal string.');
1104
1236
  return;
1105
1237
  }
1106
1238
  // Get optional parameters from query string
1107
- const chunkSize = parseInt(((_89 = req.query['chunkSize']) !== null && _89 !== void 0 ? _89 : '1000'));
1108
- const commandTimeout = parseInt(((_90 = req.query['commandTimeout']) !== null && _90 !== void 0 ? _90 : '30000'));
1109
- const responsePollingInterval = parseInt(((_91 = req.query['responsePollingInterval']) !== null && _91 !== void 0 ? _91 : '1000'));
1110
- const fsBufferReadWriteTimeout = parseInt(((_92 = req.query['fsBufferReadWriteTimeout']) !== null && _92 !== void 0 ? _92 : '120000'));
1239
+ const chunkSize = parseInt(((_97 = req.query['chunkSize']) !== null && _97 !== void 0 ? _97 : '1000'));
1240
+ const commandTimeout = parseInt(((_98 = req.query['commandTimeout']) !== null && _98 !== void 0 ? _98 : '30000'));
1241
+ const responsePollingInterval = parseInt(((_99 = req.query['responsePollingInterval']) !== null && _99 !== void 0 ? _99 : '1000'));
1242
+ const fsBufferReadWriteTimeout = parseInt(((_100 = req.query['fsBufferReadWriteTimeout']) !== null && _100 !== void 0 ? _100 : '120000'));
1111
1243
  // Create buffer from request body
1112
1244
  const buffer = new Uint8Array(req.body);
1113
1245
  yield (0, rxjs_1.lastValueFrom)(client.request.updateSmmSoftware(deviceRef, username, password, buffer, crc, chunkSize, commandTimeout, responsePollingInterval, fsBufferReadWriteTimeout));
1114
1246
  res.send();
1115
1247
  })));
1116
1248
  app.post('/api/devices/:deviceRef/update-smm-software-to-encrypted', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1117
- var _93, _94, _95, _96, _97, _98, _99;
1249
+ var _101, _102, _103, _104, _105, _106, _107;
1118
1250
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
1119
- const username = (_93 = req.query['username']) !== null && _93 !== void 0 ? _93 : 'Test';
1120
- const password = (_94 = req.query['password']) !== null && _94 !== void 0 ? _94 : 'SomanetSMM';
1121
- const crc = parseInt(((_95 = req.query['crc']) !== null && _95 !== void 0 ? _95 : ''), 16);
1251
+ const username = (_101 = req.query['username']) !== null && _101 !== void 0 ? _101 : 'Test';
1252
+ const password = (_102 = req.query['password']) !== null && _102 !== void 0 ? _102 : 'SomanetSMM';
1253
+ const crc = parseInt(((_103 = req.query['crc']) !== null && _103 !== void 0 ? _103 : ''), 16);
1122
1254
  // Validate CRC
1123
1255
  if (Number.isNaN(crc)) {
1124
1256
  res.status(400).send('Invalid CRC format. Expected hexadecimal string.');
1125
1257
  return;
1126
1258
  }
1127
1259
  // Get optional parameters from query string
1128
- const chunkSize = parseInt(((_96 = req.query['chunkSize']) !== null && _96 !== void 0 ? _96 : '1000'));
1129
- const commandTimeout = parseInt(((_97 = req.query['commandTimeout']) !== null && _97 !== void 0 ? _97 : '30000'));
1130
- const responsePollingInterval = parseInt(((_98 = req.query['responsePollingInterval']) !== null && _98 !== void 0 ? _98 : '1000'));
1131
- const fsBufferReadWriteTimeout = parseInt(((_99 = req.query['fsBufferReadWriteTimeout']) !== null && _99 !== void 0 ? _99 : '120000'));
1260
+ const chunkSize = parseInt(((_104 = req.query['chunkSize']) !== null && _104 !== void 0 ? _104 : '1000'));
1261
+ const commandTimeout = parseInt(((_105 = req.query['commandTimeout']) !== null && _105 !== void 0 ? _105 : '30000'));
1262
+ const responsePollingInterval = parseInt(((_106 = req.query['responsePollingInterval']) !== null && _106 !== void 0 ? _106 : '1000'));
1263
+ const fsBufferReadWriteTimeout = parseInt(((_107 = req.query['fsBufferReadWriteTimeout']) !== null && _107 !== void 0 ? _107 : '120000'));
1132
1264
  // Create buffer from request body
1133
1265
  const buffer = new Uint8Array(req.body);
1134
1266
  yield (0, rxjs_1.lastValueFrom)(client.request.updateSmmSoftwareToEncrypted(deviceRef, username, password, buffer, crc, chunkSize, commandTimeout, responsePollingInterval, fsBufferReadWriteTimeout));
@@ -1141,16 +1273,16 @@ app.get('/api/devices/:deviceRef/write-circulo-integrated-encoder-config-bin-fil
1141
1273
  res.send(status);
1142
1274
  })));
1143
1275
  app.get('/api/devices/:deviceRef/run-chirp-signal', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1144
- var _100, _101, _102, _103, _104, _105, _106, _107;
1145
- const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
1146
- const hrdStreamingDuration = parseInt(((_100 = req.query['hrd-streaming-duration']) !== null && _100 !== void 0 ? _100 : '4000'));
1147
- const modesOfOperation = parseInt(((_101 = req.query['modes-of-operation']) !== null && _101 !== void 0 ? _101 : '10'));
1148
- const signalType = parseInt(((_102 = req.query['signal-type']) !== null && _102 !== void 0 ? _102 : '0'));
1149
- const startFrequency = parseInt(((_103 = req.query['start-frequency']) !== null && _103 !== void 0 ? _103 : '2000'));
1150
- const startProcedure = parseInt(((_104 = req.query['start-procedure']) !== null && _104 !== void 0 ? _104 : '2'));
1151
- const targetAmplitude = parseInt(((_105 = req.query['target-amplitude']) !== null && _105 !== void 0 ? _105 : '300'));
1152
- const targetFrequency = parseInt(((_106 = req.query['target-frequency']) !== null && _106 !== void 0 ? _106 : '100000'));
1153
- const transitionTime = parseInt(((_107 = req.query['transition-time']) !== null && _107 !== void 0 ? _107 : '3000'));
1276
+ var _108, _109, _110, _111, _112, _113, _114, _115;
1277
+ const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
1278
+ const hrdStreamingDuration = parseInt(((_108 = req.query['hrd-streaming-duration']) !== null && _108 !== void 0 ? _108 : '4000'));
1279
+ const modesOfOperation = parseInt(((_109 = req.query['modes-of-operation']) !== null && _109 !== void 0 ? _109 : '10'));
1280
+ const signalType = parseInt(((_110 = req.query['signal-type']) !== null && _110 !== void 0 ? _110 : '0'));
1281
+ const startFrequency = parseInt(((_111 = req.query['start-frequency']) !== null && _111 !== void 0 ? _111 : '2000'));
1282
+ const startProcedure = parseInt(((_112 = req.query['start-procedure']) !== null && _112 !== void 0 ? _112 : '2'));
1283
+ const targetAmplitude = parseInt(((_113 = req.query['target-amplitude']) !== null && _113 !== void 0 ? _113 : '300'));
1284
+ const targetFrequency = parseInt(((_114 = req.query['target-frequency']) !== null && _114 !== void 0 ? _114 : '100000'));
1285
+ const transitionTime = parseInt(((_115 = req.query['transition-time']) !== null && _115 !== void 0 ? _115 : '3000'));
1154
1286
  const options = {
1155
1287
  hrdStreamingDuration,
1156
1288
  modesOfOperation,
@@ -1171,18 +1303,18 @@ app.get('/api/devices/:deviceRef/run-chirp-signal', asyncHandler((req, res) => t
1171
1303
  }
1172
1304
  })));
1173
1305
  app.get('/api/devices/:deviceRef/start-limited-range-system-identification', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1174
- var _108, _109, _110, _111, _112, _113, _114;
1306
+ var _116, _117, _118, _119, _120, _121, _122;
1175
1307
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
1176
- const hrdStreamingDuration = parseInt(((_108 = req.query['hrd-streaming-duration']) !== null && _108 !== void 0 ? _108 : '3200'));
1308
+ const hrdStreamingDuration = parseInt(((_116 = req.query['hrd-streaming-duration']) !== null && _116 !== void 0 ? _116 : '3200'));
1177
1309
  const modesOfOperation = cia402_1.ModesOfOperation.CYCLIC_SYNC_POSITION_MODE;
1178
- const rangeLimit = parseInt(((_109 = req.query['range-limit']) !== null && _109 !== void 0 ? _109 : '10000'));
1179
- const rangeLimitMin = parseInt(((_110 = req.query['range-limit-min']) !== null && _110 !== void 0 ? _110 : '1000'));
1310
+ const rangeLimit = parseInt(((_117 = req.query['range-limit']) !== null && _117 !== void 0 ? _117 : '10000'));
1311
+ const rangeLimitMin = parseInt(((_118 = req.query['range-limit-min']) !== null && _118 !== void 0 ? _118 : '1000'));
1180
1312
  const signalType = os_command_1.SystemIdentificationOsCommandSignalType.LINEAR_WITH_CONSTANT_AMPLITUDE;
1181
- const startFrequency = parseInt(((_111 = req.query['start-frequency']) !== null && _111 !== void 0 ? _111 : '1000'));
1313
+ const startFrequency = parseInt(((_119 = req.query['start-frequency']) !== null && _119 !== void 0 ? _119 : '1000'));
1182
1314
  const startProcedure = os_command_1.SystemIdentificationOsCommandStartProcedure.WAIT_FOR_HRD_STREAMING_TO_START;
1183
- const targetAmplitude = parseInt(((_112 = req.query['target-amplitude']) !== null && _112 !== void 0 ? _112 : '300'));
1184
- const targetFrequency = parseInt(((_113 = req.query['target-frequency']) !== null && _113 !== void 0 ? _113 : '10000'));
1185
- const transitionTime = parseInt(((_114 = req.query['transition-time']) !== null && _114 !== void 0 ? _114 : '3000'));
1315
+ const targetAmplitude = parseInt(((_120 = req.query['target-amplitude']) !== null && _120 !== void 0 ? _120 : '300'));
1316
+ const targetFrequency = parseInt(((_121 = req.query['target-frequency']) !== null && _121 !== void 0 ? _121 : '10000'));
1317
+ const transitionTime = parseInt(((_122 = req.query['transition-time']) !== null && _122 !== void 0 ? _122 : '3000'));
1186
1318
  const options = {
1187
1319
  hrdStreamingDuration,
1188
1320
  modesOfOperation,
@@ -1225,15 +1357,15 @@ app.get('/api/motion-composer/stop', asyncHandler((_req, res) => tslib_1.__await
1225
1357
  res.send();
1226
1358
  })));
1227
1359
  app.get('/api/devices/:deviceRef/run-kubler-encoder-register-communication-os-command', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1228
- var _115, _116, _117, _118, _119, _120, _121;
1229
- const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
1230
- const rw = parseInt(((_115 = req.query['rw']) !== null && _115 !== void 0 ? _115 : '0'));
1231
- const registerAddress = parseInt(((_116 = req.query['register-address']) !== null && _116 !== void 0 ? _116 : '0'));
1232
- const registerLength = parseInt(((_117 = req.query['register-length']) !== null && _117 !== void 0 ? _117 : '0'));
1233
- const registerWriteValue = parseInt(((_118 = req.query['register-write-value']) !== null && _118 !== void 0 ? _118 : '0'));
1234
- const commandTimeout = parseInt(((_119 = req.query['command-timeout']) !== null && _119 !== void 0 ? _119 : '10000'));
1235
- const responsePollingInterval = parseInt(((_120 = req.query['response-polling-interval']) !== null && _120 !== void 0 ? _120 : '1000'));
1236
- const osCommandMode = asBoolean(((_121 = req.query['os-command-mode']) !== null && _121 !== void 0 ? _121 : 'false'));
1360
+ var _123, _124, _125, _126, _127, _128, _129;
1361
+ const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
1362
+ const rw = parseInt(((_123 = req.query['rw']) !== null && _123 !== void 0 ? _123 : '0'));
1363
+ const registerAddress = parseInt(((_124 = req.query['register-address']) !== null && _124 !== void 0 ? _124 : '0'));
1364
+ const registerLength = parseInt(((_125 = req.query['register-length']) !== null && _125 !== void 0 ? _125 : '0'));
1365
+ const registerWriteValue = parseInt(((_126 = req.query['register-write-value']) !== null && _126 !== void 0 ? _126 : '0'));
1366
+ const commandTimeout = parseInt(((_127 = req.query['command-timeout']) !== null && _127 !== void 0 ? _127 : '10000'));
1367
+ const responsePollingInterval = parseInt(((_128 = req.query['response-polling-interval']) !== null && _128 !== void 0 ? _128 : '1000'));
1368
+ const osCommandMode = asBoolean(((_129 = req.query['os-command-mode']) !== null && _129 !== void 0 ? _129 : 'false'));
1237
1369
  const status = yield (0, rxjs_1.lastValueFrom)(client.request.runKublerEncoderRegisterCommunicationOsCommand(deviceRef, rw, registerAddress, registerLength, registerWriteValue, commandTimeout, responsePollingInterval, osCommandMode));
1238
1370
  if (status.request === 'succeeded') {
1239
1371
  res.send(status);
@@ -1282,28 +1414,28 @@ app.get('/api/devices/:deviceRef/factory-reset', asyncHandler((req, res) => tsli
1282
1414
  }
1283
1415
  })));
1284
1416
  app.get('/api/devices/:deviceRef/monitoring/start', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1285
- var _122;
1417
+ var _130;
1286
1418
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
1287
1419
  const device = yield (0, rxjs_1.lastValueFrom)(client.request.resolveDevice(deviceRef));
1288
1420
  const monitoringParameterIds = yield createDefaultDataMonitoringParameterIds(deviceRef);
1289
- (_122 = dataMonitoringMap.get(device.id)) === null || _122 === void 0 ? void 0 : _122.stop();
1421
+ (_130 = dataMonitoringMap.get(device.id)) === null || _130 === void 0 ? void 0 : _130.stop();
1290
1422
  const dataMonitoring = client.createDataMonitoring(monitoringParameterIds, 1000);
1291
1423
  dataMonitoring.start();
1292
1424
  dataMonitoringMap.set(device.id, dataMonitoring);
1293
1425
  res.send();
1294
1426
  })));
1295
1427
  app.get('/api/devices/:deviceRef/monitoring/data', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1296
- var _123;
1428
+ var _131;
1297
1429
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
1298
1430
  const device = yield (0, rxjs_1.lastValueFrom)(client.request.resolveDevice(deviceRef));
1299
1431
  const dataMonitoring = dataMonitoringMap.get(device.id);
1300
- res.type('text/csv').send((_123 = dataMonitoring === null || dataMonitoring === void 0 ? void 0 : dataMonitoring.csv) !== null && _123 !== void 0 ? _123 : '');
1432
+ res.type('text/csv').send((_131 = dataMonitoring === null || dataMonitoring === void 0 ? void 0 : dataMonitoring.csv) !== null && _131 !== void 0 ? _131 : '');
1301
1433
  })));
1302
1434
  app.get('/api/devices/:deviceRef/monitoring/stop', asyncHandler((req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1303
- var _124;
1435
+ var _132;
1304
1436
  const deviceRef = (0, device_1.ensureDeviceRef)(req.params['deviceRef']);
1305
1437
  const device = yield (0, rxjs_1.lastValueFrom)(client.request.resolveDevice(deviceRef));
1306
- (_124 = dataMonitoringMap.get(device.id)) === null || _124 === void 0 ? void 0 : _124.stop();
1438
+ (_132 = dataMonitoringMap.get(device.id)) === null || _132 === void 0 ? void 0 : _132.stop();
1307
1439
  res.send();
1308
1440
  })));
1309
1441
  app.listen(port, () => {