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:
89
dist/Unity/UnityRunner.js
vendored
89
dist/Unity/UnityRunner.js
vendored
@@ -104,6 +104,52 @@ var UnityRunner = /** @class */ (function () {
|
||||
else
|
||||
console.log(PREFIX, message !== null && message !== void 0 ? message : error);
|
||||
};
|
||||
UnityRunner.prototype.stop = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var quitSucceeded;
|
||||
var _this = this;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
if (this.process == null)
|
||||
return [2 /*return*/];
|
||||
this.restartTriggered = true;
|
||||
if (this._Main.UnityWebSocket.state === 'CONNECTED') {
|
||||
this._Main.UnityWebSocket.quitApplication();
|
||||
this.setInfo('Requested quit through WebSocket...', null, 'STARTING');
|
||||
}
|
||||
else {
|
||||
this.process.kill('SIGTERM');
|
||||
this.setInfo('Requested quit through SIGTERM...', null, 'STARTING');
|
||||
}
|
||||
return [4 /*yield*/, new Promise(function (resolve) {
|
||||
var timeout = setTimeout(function () {
|
||||
clearInterval(c);
|
||||
resolve(false);
|
||||
}, 5000);
|
||||
var c = setInterval(function () {
|
||||
if (_this.process != null &&
|
||||
!_this.process.killed &&
|
||||
_this.process.exitCode == null)
|
||||
return;
|
||||
clearTimeout(timeout);
|
||||
clearInterval(c);
|
||||
resolve(true);
|
||||
});
|
||||
})];
|
||||
case 1:
|
||||
quitSucceeded = _a.sent();
|
||||
if (!quitSucceeded)
|
||||
this.process.kill('SIGKILL');
|
||||
this.setInfo('Stopped', null, 'STOPPED');
|
||||
this._Main.UnityWebSocket.disconnect();
|
||||
this._Main.WebServer.Calibration.hasCalibrationImage = false;
|
||||
this.startTime = -1;
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
UnityRunner.prototype.restart = function () {
|
||||
return __awaiter(this, arguments, void 0, function (instant) {
|
||||
if (instant === void 0) { instant = false; }
|
||||
@@ -112,42 +158,41 @@ var UnityRunner = /** @class */ (function () {
|
||||
case 0:
|
||||
if (this.restartTriggered)
|
||||
return [2 /*return*/];
|
||||
clearInterval(this.statusClock);
|
||||
this._Main.WebServer.Calibration.hasCalibrationImage = false;
|
||||
this._Main.UnityWebSocket.disconnect();
|
||||
this.restartTriggered = true;
|
||||
clearInterval(this.statusClock);
|
||||
this.startTime = -1;
|
||||
this.broadcastState();
|
||||
if (!!instant) return [3 /*break*/, 2];
|
||||
return [4 /*yield*/, (0, Utils_1.delay)(2000)];
|
||||
case 1:
|
||||
_a.sent();
|
||||
_a.label = 2;
|
||||
case 2:
|
||||
if (this.output.current.length > 0) {
|
||||
this.output.last = __spreadArray([], this.output.current, true);
|
||||
this.output.current = [];
|
||||
}
|
||||
if (instant)
|
||||
this.setInfo('Process will restart shortly...', null, 'STOPPED');
|
||||
if (!(this.process != null)) return [3 /*break*/, 3];
|
||||
this.process.kill('SIGTERM');
|
||||
return [4 /*yield*/, (0, Utils_1.delay)(3000)];
|
||||
case 2:
|
||||
_a.sent();
|
||||
if (!this.process.killed && this.process.exitCode === null) {
|
||||
this.process.kill('SIGKILL');
|
||||
console.log(PREFIX, 'Sent SIGKILL to process.');
|
||||
}
|
||||
_a.label = 3;
|
||||
return [4 /*yield*/, this.stop()];
|
||||
case 3:
|
||||
this.startTime = -1;
|
||||
if (!!instant) return [3 /*break*/, 5];
|
||||
_a.sent();
|
||||
if (!instant) return [3 /*break*/, 6];
|
||||
return [4 /*yield*/, (0, Utils_1.delay)(1000)];
|
||||
case 4:
|
||||
_a.sent();
|
||||
this.setInfo('Process will restart shortly...', null, 'STOPPED');
|
||||
return [4 /*yield*/, (0, Utils_1.delay)(2000)];
|
||||
case 5:
|
||||
_a.sent();
|
||||
return [3 /*break*/, 8];
|
||||
case 6:
|
||||
this.message = 'Reconnecting in 10 seconds...';
|
||||
this.broadcastState();
|
||||
return [4 /*yield*/, (0, Utils_1.delay)(10000)];
|
||||
case 4:
|
||||
case 7:
|
||||
_a.sent();
|
||||
_a.label = 5;
|
||||
case 5: return [4 /*yield*/, this.start()];
|
||||
case 6:
|
||||
_a.label = 8;
|
||||
case 8: return [4 /*yield*/, this.start()];
|
||||
case 9:
|
||||
_a.sent();
|
||||
return [2 /*return*/];
|
||||
}
|
||||
@@ -214,7 +259,7 @@ var UnityRunner = /** @class */ (function () {
|
||||
this.process.on('exit', function (code, signal) {
|
||||
if (_this.restartTriggered)
|
||||
return;
|
||||
_this.setInfo('Process exited', "Process exited with code ".concat(code, " and signal ").concat(signal), 'STOPPED');
|
||||
_this.setInfo('Process exited', "Process exited with code ".concat(code, " and signal ").concat(signal), 'PROBLEM');
|
||||
_this.restart();
|
||||
});
|
||||
this.process.on('error', function (err) {
|
||||
|
||||
2
dist/Unity/UnityRunner.js.map
vendored
2
dist/Unity/UnityRunner.js.map
vendored
File diff suppressed because one or more lines are too long
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');
|
||||
|
||||
2
dist/Unity/UnityWebSocket.js.map
vendored
2
dist/Unity/UnityWebSocket.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user