Added basic control panel
This commit is contained in:
36
dist/Unity/UnityWebSocket.js
vendored
36
dist/Unity/UnityWebSocket.js
vendored
@@ -20,8 +20,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
||||
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
@@ -47,9 +47,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UnityWebSocket = void 0;
|
||||
exports.CameraUnityStateColors = exports.UnityWebSocket = void 0;
|
||||
var ws_1 = require("ws");
|
||||
var Utils_1 = require("../Utils");
|
||||
var Status_1 = require("../Status");
|
||||
var PREFIX = '[Unity]';
|
||||
var UnityWebSocket = /** @class */ (function () {
|
||||
function UnityWebSocket(Main) {
|
||||
@@ -71,6 +72,7 @@ var UnityWebSocket = /** @class */ (function () {
|
||||
this.disconnected = false;
|
||||
this.restartRequested = false;
|
||||
this._Main = Main;
|
||||
this.updateStatus();
|
||||
}
|
||||
UnityWebSocket.prototype.handle = function (command) {
|
||||
var args = [];
|
||||
@@ -150,11 +152,27 @@ var UnityWebSocket = /** @class */ (function () {
|
||||
UnityWebSocket.prototype.broadcastState = function () {
|
||||
this._Main.WebServer.socket.emit('unityWebSocketState', this.getState());
|
||||
};
|
||||
UnityWebSocket.prototype.updateStatus = function () {
|
||||
if (this.state != 'CONNECTED') {
|
||||
this._Main.Status.update(Status_1.StatusType.CameraUnityStream, exports.CameraUnityStateColors[this.state], this.message, {
|
||||
reboot: this.state === 'FAILED',
|
||||
});
|
||||
}
|
||||
else {
|
||||
var status_1 = !this.parameters.zedReady
|
||||
? 'Waiting for ZED stream'
|
||||
: this.message;
|
||||
this._Main.Status.update(Status_1.StatusType.CameraUnityStream, this.parameters.zedReady ? Status_1.State.Green : Status_1.State.Yellow, status_1, {
|
||||
reboot: this.parameters.zedReady,
|
||||
});
|
||||
}
|
||||
};
|
||||
UnityWebSocket.prototype.setInfo = function (message, error, state) {
|
||||
if (state === void 0) { state = 'FAILED'; }
|
||||
this.message = message;
|
||||
this.error = error;
|
||||
this.state = state;
|
||||
this.updateStatus();
|
||||
this.broadcastState();
|
||||
if (error != null)
|
||||
this._Main.Twilio.sendError('UnityWebSocket', error);
|
||||
@@ -204,6 +222,7 @@ var UnityWebSocket = /** @class */ (function () {
|
||||
? 2
|
||||
: null });
|
||||
});
|
||||
this.updateStatus();
|
||||
this.broadcastState();
|
||||
break;
|
||||
case 'response_camera_frame':
|
||||
@@ -302,7 +321,10 @@ var UnityWebSocket = /** @class */ (function () {
|
||||
};
|
||||
UnityWebSocket.prototype.startFetchClocks = function () {
|
||||
var _this = this;
|
||||
this.socket.send(JSON.stringify({ type: 'set_heartbeat_auto_send', autoSend: false }));
|
||||
this.socket.send(JSON.stringify({
|
||||
type: 'set_heartbeat_auto_send',
|
||||
autoSend: false,
|
||||
}));
|
||||
this.heartbeatClock = setInterval(function () {
|
||||
if (_this.socket == null ||
|
||||
_this.socket.readyState !== ws_1.WebSocket.OPEN)
|
||||
@@ -327,4 +349,10 @@ var UnityWebSocket = /** @class */ (function () {
|
||||
return UnityWebSocket;
|
||||
}());
|
||||
exports.UnityWebSocket = UnityWebSocket;
|
||||
exports.CameraUnityStateColors = {
|
||||
CONNECTED: Status_1.State.Green,
|
||||
DISCONNECTED: Status_1.State.Gray,
|
||||
CONNECTING: Status_1.State.Yellow,
|
||||
FAILED: Status_1.State.Red,
|
||||
};
|
||||
//# sourceMappingURL=UnityWebSocket.js.map
|
||||
Reference in New Issue
Block a user