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) {
|
||||
|
||||
Reference in New Issue
Block a user