Lots of changes
- ✅ Feedback van dataSensor array - ✅ dataSliders min/max and unit - ✅ Camera before Unity - ✅ Restart knop buiten service mode - ✅ Operator phonenumber button - ✅ Gracefull shutdown - ✅ Out of service control
This commit is contained in:
84
dist/Unity/UnityWebSocket.js
vendored
84
dist/Unity/UnityWebSocket.js
vendored
@@ -1,4 +1,15 @@
|
||||
"use strict";
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
@@ -51,7 +62,9 @@ var UnityWebSocket = /** @class */ (function () {
|
||||
zedPath: '',
|
||||
zedReady: false,
|
||||
zedFPS: '-',
|
||||
parameters: [],
|
||||
outOfService: null,
|
||||
sliders: [],
|
||||
sensors: [],
|
||||
};
|
||||
this.disconnected = false;
|
||||
this.restartRequested = false;
|
||||
@@ -66,22 +79,54 @@ var UnityWebSocket = /** @class */ (function () {
|
||||
case 'parameterValue':
|
||||
var sliderIndex = args[0];
|
||||
var percentage = args[1];
|
||||
if (this.parameters.parameters[sliderIndex] == undefined)
|
||||
this.setSliderValue(sliderIndex, percentage);
|
||||
break;
|
||||
case 'enableOutOfService':
|
||||
var enableCallback = args[0];
|
||||
if (typeof enableCallback !== 'function')
|
||||
return;
|
||||
this.parameters.parameters[sliderIndex].outputValue =
|
||||
percentage;
|
||||
if (this.socket == null ||
|
||||
this.socket.readyState !== ws_1.WebSocket.OPEN)
|
||||
this.setOutOfService(true);
|
||||
enableCallback({ succeed: true });
|
||||
break;
|
||||
case 'disableOutOfService':
|
||||
var disableCallback = args[0];
|
||||
if (typeof disableCallback !== 'function')
|
||||
return;
|
||||
this.socket.send(JSON.stringify({
|
||||
type: 'set_slider_value',
|
||||
sliderIndex: sliderIndex,
|
||||
sliderValue: percentage,
|
||||
}));
|
||||
this.broadcastState();
|
||||
this.setOutOfService(false);
|
||||
disableCallback({ succeed: true });
|
||||
break;
|
||||
}
|
||||
};
|
||||
UnityWebSocket.prototype.quitApplication = function () {
|
||||
if (this.socket == null || this.socket.readyState !== ws_1.WebSocket.OPEN)
|
||||
return;
|
||||
this.socket.send(JSON.stringify({
|
||||
type: 'quit_application',
|
||||
}));
|
||||
};
|
||||
UnityWebSocket.prototype.setSliderValue = function (sliderIndex, sliderValue) {
|
||||
if (this.socket == null || this.socket.readyState !== ws_1.WebSocket.OPEN)
|
||||
return;
|
||||
this.socket.send(JSON.stringify({
|
||||
type: 'set_slider_value',
|
||||
sliderIndex: sliderIndex,
|
||||
sliderValue: sliderValue,
|
||||
}));
|
||||
if (this.parameters.sliders[sliderIndex] == undefined)
|
||||
return;
|
||||
this.parameters.sliders[sliderIndex].outputValue = sliderValue;
|
||||
this.broadcastState();
|
||||
};
|
||||
UnityWebSocket.prototype.setOutOfService = function (state) {
|
||||
if (this.socket == null || this.socket.readyState !== ws_1.WebSocket.OPEN)
|
||||
return;
|
||||
this.socket.send(JSON.stringify({
|
||||
type: 'set_out_of_service',
|
||||
showOutOfService: state,
|
||||
}));
|
||||
this.parameters.outOfService = true;
|
||||
this.broadcastState();
|
||||
};
|
||||
UnityWebSocket.prototype.broadcastState = function () {
|
||||
this._Main.WebServer.socket.emit('unityWebSocketState', this.getState());
|
||||
};
|
||||
@@ -101,6 +146,7 @@ var UnityWebSocket = /** @class */ (function () {
|
||||
clearInterval(this.calibrationImageClock);
|
||||
};
|
||||
UnityWebSocket.prototype.handleSocketMessage = function (data) {
|
||||
var _a;
|
||||
var message;
|
||||
try {
|
||||
message = JSON.parse(data.toString());
|
||||
@@ -120,7 +166,17 @@ var UnityWebSocket = /** @class */ (function () {
|
||||
this.parameters.zedReady =
|
||||
message.heartbeat.zedCamera.isZedReady;
|
||||
this.parameters.zedFPS = message.heartbeat.zedCamera.cameraFPS;
|
||||
this.parameters.parameters = message.heartbeat.dataSliders;
|
||||
this.parameters.outOfService =
|
||||
(_a = message.heartbeat.showOutOfService) !== null && _a !== void 0 ? _a : false;
|
||||
this.parameters.sensors = message.heartbeat.dataSensors;
|
||||
this.parameters.sliders = message.heartbeat.dataSliders.map(function (slider) {
|
||||
var _a, _b, _c, _d, _e, _f, _g;
|
||||
return __assign(__assign({}, slider), { min: (_a = slider.min) !== null && _a !== void 0 ? _a : 0, max: (_b = slider.max) !== null && _b !== void 0 ? _b : 1, unit: (_c = slider.unit) !== null && _c !== void 0 ? _c : '%', visualMultiplier: ((_d = slider.min) !== null && _d !== void 0 ? _d : 0) == 0 && ((_e = slider.max) !== null && _e !== void 0 ? _e : 1) == 1
|
||||
? 100
|
||||
: null, decimalPlaces: ((_f = slider.min) !== null && _f !== void 0 ? _f : 0) == 0 && ((_g = slider.max) !== null && _g !== void 0 ? _g : 1) == 1
|
||||
? 0
|
||||
: 2 });
|
||||
});
|
||||
this.broadcastState();
|
||||
break;
|
||||
case 'response_camera_frame':
|
||||
@@ -203,6 +259,8 @@ var UnityWebSocket = /** @class */ (function () {
|
||||
_this.setInfo('Connected', null, 'CONNECTED');
|
||||
});
|
||||
this.socket.on('close', function () {
|
||||
if (_this._Main.UnityRunner.restartTriggered)
|
||||
return;
|
||||
if (_this.restartRequested)
|
||||
return;
|
||||
_this.setInfo('Disconnected', 'Unity was disconnected unexpectedly', 'FAILED');
|
||||
|
||||
Reference in New Issue
Block a user