remoterigs-raspberrypi 0.1.2 → 0.1.4
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/index.js +3 -1
- package/package.json +1 -1
- package/src/common/signalr.js +10 -11
- package/src/common/webrtc-streamer-wrapper.js +9 -9
- package/src/component/component.js +1 -1
- package/src/models/models.js +2 -2
- package/src/rig.js +5 -2
- package/src/server.js +11 -25
- package/src/src/common/code.js +62 -0
- package/src/src/common/debug.js +77 -0
- package/src/src/common/signalr.js +188 -0
- package/src/src/common/webrtc-streamer-wrapper.js +483 -0
- package/src/src/component/component.js +358 -0
- package/src/src/component/input/input.js +26 -0
- package/src/src/component/pin/pin.js +92 -0
- package/src/src/component/property/property.js +32 -0
- package/src/src/component/status/status-number.js +7 -0
- package/src/src/component/status/status-state.js +27 -0
- package/src/src/component/status/status.js +41 -0
- package/src/src/models/models.js +1045 -0
- package/src/src/rig.js +68 -0
- package/src/src/server.js +73 -0
package/src/src/rig.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import Component from './component/component.js';
|
|
2
|
+
import Debug from './common/debug.js';
|
|
3
|
+
import SignalR from './common/signalr.js';
|
|
4
|
+
import { StatusModel, StatusType, RigModelLoadedModel } from './models/models.js';
|
|
5
|
+
export default class Rig {
|
|
6
|
+
constructor(rigModel) {
|
|
7
|
+
this.rig = rigModel;
|
|
8
|
+
this.components = new Array();
|
|
9
|
+
for (var i = 0; i < this.rig.logSettings.length; i++) {
|
|
10
|
+
var text = "logSettingType: " + Debug.GetStringValue(this.rig.logSettings[i].logSettingType);
|
|
11
|
+
if (this.rig.logSettings[i].parameter1 != undefined) {
|
|
12
|
+
text += " / parameter1: " + this.rig.logSettings[i].parameter1;
|
|
13
|
+
}
|
|
14
|
+
Debug.LogAlways("#" + this.rig.logSettings[i].id + " log setting", text, true);
|
|
15
|
+
}
|
|
16
|
+
Debug.LogAlways(this.GetName(), "rig instance created & log settings loaded", true);
|
|
17
|
+
}
|
|
18
|
+
CreateComponents() {
|
|
19
|
+
Debug.LogAlways(this.GetName(), "creating components for rig (" + this.rig.rigModelViewModel.components.length + " component(s))", true);
|
|
20
|
+
for (var i = 0; i < this.rig.rigModelViewModel.components.length; i++) {
|
|
21
|
+
try {
|
|
22
|
+
this.components.push(new Component(this, this.rig.rigModelViewModel.components[i], this.rig.clientRTCConfigurationViewModel, null));
|
|
23
|
+
}
|
|
24
|
+
catch (ex) {
|
|
25
|
+
Debug.Error(this.GetName(), "FAILED TO CREATE CHILD COMPONENT: " + ex);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
Debug.LogAlways(this.GetName(), "rig components created", true);
|
|
29
|
+
}
|
|
30
|
+
Init() {
|
|
31
|
+
for (var i = 0; i < this.components.length; i++) {
|
|
32
|
+
this.components[i].Init();
|
|
33
|
+
}
|
|
34
|
+
Debug.LogAlways(this.GetName(), "rig 'init' functions executed", true);
|
|
35
|
+
}
|
|
36
|
+
Shutdown() {
|
|
37
|
+
for (var i = 0; i < this.components.length; i++) {
|
|
38
|
+
this.components[i].Shutdown();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
SendCurrent() {
|
|
42
|
+
var tStatusModel = new StatusModel();
|
|
43
|
+
tStatusModel.type = StatusType.RigModelLoaded;
|
|
44
|
+
var tRigLoadedModel = new RigModelLoadedModel();
|
|
45
|
+
tRigLoadedModel.rigId = this.rig.id;
|
|
46
|
+
tRigLoadedModel.rigModelVersion = this.rig.rigModelViewModel.version;
|
|
47
|
+
tStatusModel.value = tRigLoadedModel;
|
|
48
|
+
SignalR.UpdateStatus(tStatusModel);
|
|
49
|
+
for (var i = 0; i < this.components.length; i++) {
|
|
50
|
+
this.components[i].SendCurrent();
|
|
51
|
+
}
|
|
52
|
+
Debug.LogAlways(this.GetName(), "rig current status send to server", true);
|
|
53
|
+
}
|
|
54
|
+
ProcessKeyEvent(event) {
|
|
55
|
+
for (var i = 0; i < this.components.length; i++) {
|
|
56
|
+
this.components[i].ProcessKeyEvent(event);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
PutWebRTCMessage(message) {
|
|
60
|
+
for (var i = 0; i < this.components.length; i++) {
|
|
61
|
+
this.components[i].PutWebRTCMessage(message);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
GetName() {
|
|
65
|
+
return "#" + this.rig.id + " " + this.rig.name;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=rig.js.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// require
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import Debug from './common/debug.js';
|
|
4
|
+
import SignalR from './common/signalr.js';
|
|
5
|
+
import { config } from 'process';
|
|
6
|
+
export default class Server {
|
|
7
|
+
static { this.signalr = ""; }
|
|
8
|
+
static { this.rig = null; }
|
|
9
|
+
static { this.rig_uniquecode = ""; }
|
|
10
|
+
constructor() {
|
|
11
|
+
//this.OnExit = this.OnExit.bind(this);
|
|
12
|
+
//this.OnSigInt = this.OnSigInt.bind(this);
|
|
13
|
+
//this.OnSigTerm = this.OnSigTerm.bind(this);
|
|
14
|
+
Debug.SetErrorCallback(() => {
|
|
15
|
+
if (Server.rig != null) {
|
|
16
|
+
Debug.LogAlways(this.GetName(), "ERROR SHUTDOWN!", true);
|
|
17
|
+
this.Shutdown();
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
Start(configPath) {
|
|
22
|
+
//this.InitHandlers();
|
|
23
|
+
if (configPath == undefined || configPath == "" || config == null) {
|
|
24
|
+
Debug.Error(this.GetName(), "config file path is missing");
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
fs.readFile(configPath, 'utf8', (error, data) => {
|
|
28
|
+
if (error != undefined) {
|
|
29
|
+
Debug.Error(this.GetName(), 'error reading config: ' + error);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
this.Load(JSON.parse(data));
|
|
34
|
+
}
|
|
35
|
+
catch (parseError) {
|
|
36
|
+
Debug.Error(this.GetName(), 'error parsing config: ' + parseError);
|
|
37
|
+
}
|
|
38
|
+
this.SetupVariables();
|
|
39
|
+
SignalR.StartConnection(Server.rig_uniquecode);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
Load(config) {
|
|
43
|
+
// Server
|
|
44
|
+
if (config.server.url != undefined) {
|
|
45
|
+
Server.serverurl = config.server.url;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
Debug.Error(this.GetName(), "server ip address is not defined in config.json");
|
|
49
|
+
}
|
|
50
|
+
// rig
|
|
51
|
+
if (config.rig?.uniquecode != undefined) {
|
|
52
|
+
Server.rig_uniquecode = config.rig.uniquecode;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
Debug.Error(this.GetName(), "rig unique code is not defined in config.json");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
Shutdown() {
|
|
59
|
+
if (Server.rig != null) {
|
|
60
|
+
Debug.LogAlways(this.GetName(), "SHUTDOWN", true);
|
|
61
|
+
Server.rig.Shutdown();
|
|
62
|
+
SignalR.StopConnection();
|
|
63
|
+
Server.rig = null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
SetupVariables() {
|
|
67
|
+
Server.signalr = Server.serverurl + "/righub";
|
|
68
|
+
}
|
|
69
|
+
GetName() {
|
|
70
|
+
return "server";
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=server.js.map
|