remoterigs-raspberrypi 0.1.3 → 0.1.5

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 CHANGED
@@ -1,3 +1,5 @@
1
1
  import Server from './src/server.js';
2
2
  var server = new Server();
3
- server.Start();
3
+ const configPath = process.argv[2];
4
+
5
+ server.Start(configPath);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "remoterigs-raspberrypi",
3
3
  "type": "module",
4
- "version": "0.1.3",
4
+ "version": "0.1.5",
5
5
  "main": "./index.js",
6
6
  "files": [
7
7
  "index.js",
@@ -15,7 +15,6 @@
15
15
  "dependencies": {
16
16
  "@microsoft/signalr": "^8.0.7",
17
17
  "axios": "^1.13.2",
18
- "pigpio": "^3.3.1",
19
- "webrtc-streamer": "^0.8.14-6-g6774b68"
18
+ "pigpio": "^3.3.1"
20
19
  }
21
20
  }
@@ -1,8 +1,8 @@
1
- import { exec } from "child_process";
2
1
  import * as signalR from '@microsoft/signalr';
3
2
  import Server from './../server.js';
4
3
  import Debug from './debug.js';
5
4
  import Rig from '../rig.js';
5
+ import { exec } from "child_process";
6
6
  import { LogSettingType, CommandType, StatusType } from '../models/models.js';
7
7
  export default class SignalR {
8
8
  static { this.hubConnection = null; }
@@ -47,7 +47,7 @@ export default class SignalR {
47
47
  SignalR.SignIn(uniquecode);
48
48
  break;
49
49
  case CommandType.RigShutdown:
50
- Debug.LogAlways("Raspberry Pi", "SHUTTING DOWN!", true);
50
+ Debug.LogAlways("Raspberry Pi", "SHUTTING DOWN! (received command)", true);
51
51
  exec("shutdown now");
52
52
  break;
53
53
  }
@@ -115,17 +115,16 @@ export default class SignalR {
115
115
  SignalR.hubConnection.invoke('SignIn', uniquecode)
116
116
  .then((rigClientViewModel) => {
117
117
  if (rigClientViewModel.rigModelViewModel == undefined) {
118
- Debug.LogAlways(SignalR.GetName(), "SignIn failed!! GUID: " + uniquecode, true);
118
+ Debug.LogAlways(SignalR.GetName(), "sign in to server failed! GUID: " + uniquecode, true);
119
119
  }
120
120
  else {
121
- Debug.LogAlways(SignalR.GetName(), "SignIn successful", true);
121
+ Debug.LogAlways(SignalR.GetName(), "sign in to server successful", true);
122
+ Debug.LogAlways(SignalR.GetName(), "rig #" + rigClientViewModel.id + " '" + rigClientViewModel.name + "'", true);
123
+ Debug.LogAlways(SignalR.GetName(), "rig model #" + rigClientViewModel.rigModelViewModel.id + " '" + rigClientViewModel.rigModelViewModel.name + "'", true);
122
124
  Server.rig = new Rig(rigClientViewModel);
123
125
  Server.rig.CreateComponents();
124
- Debug.LogAlways(SignalR.GetName(), "Rig components loaded", true);
125
126
  Server.rig.Init();
126
- Debug.LogAlways(SignalR.GetName(), "Rig 'Init' functions executed", true);
127
127
  Server.rig.SendCurrent();
128
- Debug.LogAlways(SignalR.GetName(), "Rig current status send", true);
129
128
  }
130
129
  })
131
130
  .catch((err) => {
@@ -133,7 +132,7 @@ export default class SignalR {
133
132
  });
134
133
  }
135
134
  else {
136
- Debug.Error(SignalR.GetName(), "outgoing SignIn: no hub connection");
135
+ Debug.Error(SignalR.GetName(), "sign in canceled: no hub connection");
137
136
  }
138
137
  }
139
138
  static UpdateStatus(pStatusModel) {
package/src/rig.js CHANGED
@@ -13,10 +13,10 @@ export default class Rig {
13
13
  }
14
14
  Debug.LogAlways("#" + this.rig.logSettings[i].id + " log setting", text, true);
15
15
  }
16
- Debug.LogAlways(this.GetName(), "Rig instance '" + this.rig.name + "' created", true);
16
+ Debug.LogAlways(this.GetName(), "rig instance created & log settings loaded", true);
17
17
  }
18
18
  CreateComponents() {
19
- Debug.LogAlways(this.GetName(), "CreateComponents this.rig.rigModelViewModel.components.length: " + this.rig.rigModelViewModel.components.length, true);
19
+ Debug.LogAlways(this.GetName(), "creating components for rig (" + this.rig.rigModelViewModel.components.length + " component(s))", true);
20
20
  for (var i = 0; i < this.rig.rigModelViewModel.components.length; i++) {
21
21
  try {
22
22
  this.components.push(new Component(this, this.rig.rigModelViewModel.components[i], this.rig.clientRTCConfigurationViewModel, null));
@@ -25,11 +25,13 @@ export default class Rig {
25
25
  Debug.Error(this.GetName(), "FAILED TO CREATE CHILD COMPONENT: " + ex);
26
26
  }
27
27
  }
28
+ Debug.LogAlways(this.GetName(), "rig components created", true);
28
29
  }
29
30
  Init() {
30
31
  for (var i = 0; i < this.components.length; i++) {
31
32
  this.components[i].Init();
32
33
  }
34
+ Debug.LogAlways(this.GetName(), "rig 'init' functions executed", true);
33
35
  }
34
36
  Shutdown() {
35
37
  for (var i = 0; i < this.components.length; i++) {
@@ -47,6 +49,7 @@ export default class Rig {
47
49
  for (var i = 0; i < this.components.length; i++) {
48
50
  this.components[i].SendCurrent();
49
51
  }
52
+ Debug.LogAlways(this.GetName(), "rig current status send to server", true);
50
53
  }
51
54
  ProcessKeyEvent(event) {
52
55
  for (var i = 0; i < this.components.length; i++) {
@@ -59,7 +62,7 @@ export default class Rig {
59
62
  }
60
63
  }
61
64
  GetName() {
62
- return "rig #" + this.rig.id;
65
+ return "#" + this.rig.id + " " + this.rig.name;
63
66
  }
64
67
  }
65
68
  //# sourceMappingURL=rig.js.map
package/src/server.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import fs from 'fs';
3
3
  import Debug from './common/debug.js';
4
4
  import SignalR from './common/signalr.js';
5
+ import { config } from 'process';
5
6
  export default class Server {
6
7
  static { this.signalr = ""; }
7
8
  static { this.rig = null; }
@@ -17,56 +18,41 @@ export default class Server {
17
18
  }
18
19
  });
19
20
  }
20
- Start() {
21
+ Start(configPath) {
21
22
  //this.InitHandlers();
22
- fs.readFile("config.json", 'utf8', (error, data) => {
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) => {
23
28
  if (error != undefined) {
24
- Debug.Error(this.GetName(), 'Error reading config: ' + error);
29
+ Debug.Error(this.GetName(), 'error reading config: ' + error);
25
30
  return;
26
31
  }
27
32
  try {
28
33
  this.Load(JSON.parse(data));
29
34
  }
30
35
  catch (parseError) {
31
- Debug.Error(this.GetName(), 'Error parsing config: ' + parseError);
36
+ Debug.Error(this.GetName(), 'error parsing config: ' + parseError);
32
37
  }
33
38
  this.SetupVariables();
34
39
  SignalR.StartConnection(Server.rig_uniquecode);
35
40
  });
36
41
  }
37
- //private InitHandlers(): void {
38
- // process.on('exit', this.OnExit);
39
- // process.on('SIGINT', this.OnSigInt);
40
- // process.on('SIGTERM', this.OnSigTerm);
41
- //}
42
- //private OnExit(code: any) {
43
- // Debug.LogAlways(this.GetName(), `exit-code: ${code}`);
44
- // this.Shutdown();
45
- //}
46
- //private OnSigInt() {
47
- // Debug.LogAlways(this.GetName(), "SIGINT received (ctrl + c)");
48
- // this.Shutdown();
49
- // process.exit();
50
- //}
51
- //private OnSigTerm() {
52
- // Debug.LogAlways(this.GetName(), "SIGTERM received");
53
- // this.Shutdown();
54
- // process.exit();
55
- //}
56
42
  Load(config) {
57
43
  // Server
58
44
  if (config.server.url != undefined) {
59
45
  Server.serverurl = config.server.url;
60
46
  }
61
47
  else {
62
- Debug.Error(this.GetName(), "Server IP address is not defined in config.json");
48
+ Debug.Error(this.GetName(), "server ip address is not defined in config.json");
63
49
  }
64
50
  // rig
65
51
  if (config.rig?.uniquecode != undefined) {
66
52
  Server.rig_uniquecode = config.rig.uniquecode;
67
53
  }
68
54
  else {
69
- Debug.Error(this.GetName(), "Rig unique code is not defined in config.json");
55
+ Debug.Error(this.GetName(), "rig unique code is not defined in config.json");
70
56
  }
71
57
  }
72
58
  Shutdown() {
@@ -1,8 +1,8 @@
1
- import { exec } from "child_process";
2
1
  import * as signalR from '@microsoft/signalr';
3
2
  import Server from './../server.js';
4
3
  import Debug from './debug.js';
5
4
  import Rig from '../rig.js';
5
+ import { exec } from "child_process";
6
6
  import { LogSettingType, CommandType, StatusType } from '../models/models.js';
7
7
  export default class SignalR {
8
8
  static { this.hubConnection = null; }
@@ -47,7 +47,7 @@ export default class SignalR {
47
47
  SignalR.SignIn(uniquecode);
48
48
  break;
49
49
  case CommandType.RigShutdown:
50
- Debug.LogAlways("Raspberry Pi", "SHUTTING DOWN!", true);
50
+ Debug.LogAlways("Raspberry Pi", "SHUTTING DOWN! (received command)", true);
51
51
  exec("shutdown now");
52
52
  break;
53
53
  }
@@ -115,17 +115,16 @@ export default class SignalR {
115
115
  SignalR.hubConnection.invoke('SignIn', uniquecode)
116
116
  .then((rigClientViewModel) => {
117
117
  if (rigClientViewModel.rigModelViewModel == undefined) {
118
- Debug.LogAlways(SignalR.GetName(), "SignIn failed!! GUID: " + uniquecode, true);
118
+ Debug.LogAlways(SignalR.GetName(), "sign in to server failed! GUID: " + uniquecode, true);
119
119
  }
120
120
  else {
121
- Debug.LogAlways(SignalR.GetName(), "SignIn successful", true);
121
+ Debug.LogAlways(SignalR.GetName(), "sign in to server successful", true);
122
+ Debug.LogAlways(SignalR.GetName(), "rig #" + rigClientViewModel.id + " '" + rigClientViewModel.name + "'", true);
123
+ Debug.LogAlways(SignalR.GetName(), "rig model #" + rigClientViewModel.rigModelViewModel.id + " '" + rigClientViewModel.rigModelViewModel.name + "'", true);
122
124
  Server.rig = new Rig(rigClientViewModel);
123
125
  Server.rig.CreateComponents();
124
- Debug.LogAlways(SignalR.GetName(), "Rig components loaded", true);
125
126
  Server.rig.Init();
126
- Debug.LogAlways(SignalR.GetName(), "Rig 'Init' functions executed", true);
127
127
  Server.rig.SendCurrent();
128
- Debug.LogAlways(SignalR.GetName(), "Rig current status send", true);
129
128
  }
130
129
  })
131
130
  .catch((err) => {
@@ -133,7 +132,7 @@ export default class SignalR {
133
132
  });
134
133
  }
135
134
  else {
136
- Debug.Error(SignalR.GetName(), "outgoing SignIn: no hub connection");
135
+ Debug.Error(SignalR.GetName(), "sign in canceled: no hub connection");
137
136
  }
138
137
  }
139
138
  static UpdateStatus(pStatusModel) {
package/src/src/rig.js CHANGED
@@ -13,10 +13,10 @@ export default class Rig {
13
13
  }
14
14
  Debug.LogAlways("#" + this.rig.logSettings[i].id + " log setting", text, true);
15
15
  }
16
- Debug.LogAlways(this.GetName(), "Rig instance '" + this.rig.name + "' created", true);
16
+ Debug.LogAlways(this.GetName(), "rig instance created & log settings loaded", true);
17
17
  }
18
18
  CreateComponents() {
19
- Debug.LogAlways(this.GetName(), "CreateComponents this.rig.rigModelViewModel.components.length: " + this.rig.rigModelViewModel.components.length, true);
19
+ Debug.LogAlways(this.GetName(), "creating components for rig (" + this.rig.rigModelViewModel.components.length + " component(s))", true);
20
20
  for (var i = 0; i < this.rig.rigModelViewModel.components.length; i++) {
21
21
  try {
22
22
  this.components.push(new Component(this, this.rig.rigModelViewModel.components[i], this.rig.clientRTCConfigurationViewModel, null));
@@ -25,11 +25,13 @@ export default class Rig {
25
25
  Debug.Error(this.GetName(), "FAILED TO CREATE CHILD COMPONENT: " + ex);
26
26
  }
27
27
  }
28
+ Debug.LogAlways(this.GetName(), "rig components created", true);
28
29
  }
29
30
  Init() {
30
31
  for (var i = 0; i < this.components.length; i++) {
31
32
  this.components[i].Init();
32
33
  }
34
+ Debug.LogAlways(this.GetName(), "rig 'init' functions executed", true);
33
35
  }
34
36
  Shutdown() {
35
37
  for (var i = 0; i < this.components.length; i++) {
@@ -47,6 +49,7 @@ export default class Rig {
47
49
  for (var i = 0; i < this.components.length; i++) {
48
50
  this.components[i].SendCurrent();
49
51
  }
52
+ Debug.LogAlways(this.GetName(), "rig current status send to server", true);
50
53
  }
51
54
  ProcessKeyEvent(event) {
52
55
  for (var i = 0; i < this.components.length; i++) {
@@ -59,7 +62,7 @@ export default class Rig {
59
62
  }
60
63
  }
61
64
  GetName() {
62
- return "rig #" + this.rig.id;
65
+ return "#" + this.rig.id + " " + this.rig.name;
63
66
  }
64
67
  }
65
68
  //# sourceMappingURL=rig.js.map
package/src/src/server.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import fs from 'fs';
3
3
  import Debug from './common/debug.js';
4
4
  import SignalR from './common/signalr.js';
5
+ import { config } from 'process';
5
6
  export default class Server {
6
7
  static { this.signalr = ""; }
7
8
  static { this.rig = null; }
@@ -17,56 +18,41 @@ export default class Server {
17
18
  }
18
19
  });
19
20
  }
20
- Start() {
21
+ Start(configPath) {
21
22
  //this.InitHandlers();
22
- fs.readFile("config.json", 'utf8', (error, data) => {
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) => {
23
28
  if (error != undefined) {
24
- Debug.Error(this.GetName(), 'Error reading config: ' + error);
29
+ Debug.Error(this.GetName(), 'error reading config: ' + error);
25
30
  return;
26
31
  }
27
32
  try {
28
33
  this.Load(JSON.parse(data));
29
34
  }
30
35
  catch (parseError) {
31
- Debug.Error(this.GetName(), 'Error parsing config: ' + parseError);
36
+ Debug.Error(this.GetName(), 'error parsing config: ' + parseError);
32
37
  }
33
38
  this.SetupVariables();
34
39
  SignalR.StartConnection(Server.rig_uniquecode);
35
40
  });
36
41
  }
37
- //private InitHandlers(): void {
38
- // process.on('exit', this.OnExit);
39
- // process.on('SIGINT', this.OnSigInt);
40
- // process.on('SIGTERM', this.OnSigTerm);
41
- //}
42
- //private OnExit(code: any) {
43
- // Debug.LogAlways(this.GetName(), `exit-code: ${code}`);
44
- // this.Shutdown();
45
- //}
46
- //private OnSigInt() {
47
- // Debug.LogAlways(this.GetName(), "SIGINT received (ctrl + c)");
48
- // this.Shutdown();
49
- // process.exit();
50
- //}
51
- //private OnSigTerm() {
52
- // Debug.LogAlways(this.GetName(), "SIGTERM received");
53
- // this.Shutdown();
54
- // process.exit();
55
- //}
56
42
  Load(config) {
57
43
  // Server
58
44
  if (config.server.url != undefined) {
59
45
  Server.serverurl = config.server.url;
60
46
  }
61
47
  else {
62
- Debug.Error(this.GetName(), "Server IP address is not defined in config.json");
48
+ Debug.Error(this.GetName(), "server ip address is not defined in config.json");
63
49
  }
64
50
  // rig
65
51
  if (config.rig?.uniquecode != undefined) {
66
52
  Server.rig_uniquecode = config.rig.uniquecode;
67
53
  }
68
54
  else {
69
- Debug.Error(this.GetName(), "Rig unique code is not defined in config.json");
55
+ Debug.Error(this.GetName(), "rig unique code is not defined in config.json");
70
56
  }
71
57
  }
72
58
  Shutdown() {