node-red-contrib-antenna-genius 0.2.6-beta → 0.3.1
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/Utils.js +72 -55
- package/antenna-genius-activate-antenna.html +14 -13
- package/antenna-genius-activate-antenna.js +43 -16
- package/antenna-genius-antenna-status.html +29 -18
- package/antenna-genius-antenna-status.js +72 -26
- package/antenna-genius-band-labels.html +14 -12
- package/antenna-genius-band-labels.js +47 -15
- package/antenna-genius-server.html +35 -21
- package/antenna-genius-server.js +34 -24
- package/examples/Antenna Genius.json +229 -0
- package/examples/Antenna Genius.png +0 -0
- package/package.json +1 -1
- package/test/Utils.spec.js +141 -0
- package/test/antenna-genius-activate-antenna.spec.js +110 -72
- package/test/antenna-genius-antenna-status.spec.js +163 -106
- package/test/antenna-genius-band-labels.spec.js +137 -103
- package/test/antenna-genius-server.spec.js +51 -31
package/Utils.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
const encode = (
|
|
1
|
+
const encode = (
|
|
2
|
+
protocol = 0,
|
|
3
|
+
method = 0,
|
|
4
|
+
command = 0,
|
|
5
|
+
revision = 0,
|
|
6
|
+
payload = ""
|
|
7
|
+
) => {
|
|
2
8
|
// !llll!bbbbbb!payload
|
|
3
|
-
// llll id the length, in hex of bit header, bbbbbb, and the payload, based on zero.
|
|
9
|
+
// llll id the length, in hex of bit header, bbbbbb, and the payload, based on zero.
|
|
4
10
|
// bbbbbb
|
|
5
11
|
// gscph.protocol = 0xe00000 // 3 bits Protocol version
|
|
6
12
|
// gscph.method = 0x180000 // 2 bits 0 = Unicast request, 1 = Unicast response, 2 = Broadcast request, 3 = Broadcast response
|
|
@@ -8,6 +14,7 @@ const encode = (protocol, method, command, revision, payload) => {
|
|
|
8
14
|
// gscph.revision = 0x00007c // 5 bits Command revision
|
|
9
15
|
// gscph.erro = 0x000003 // 2 bits 0 = No error, 1 = Command error, 2 = Protocol error, 3 = Not defined
|
|
10
16
|
//
|
|
17
|
+
|
|
11
18
|
let a;
|
|
12
19
|
let bitheader;
|
|
13
20
|
|
|
@@ -20,43 +27,53 @@ const encode = (protocol, method, command, revision, payload) => {
|
|
|
20
27
|
//node.warn("dbg01: a ="+a);
|
|
21
28
|
a += revision << 2;
|
|
22
29
|
//node.warn("dbg01: a ="+a.toString(16));
|
|
23
|
-
bitheader =
|
|
24
|
-
commandlength = (
|
|
30
|
+
bitheader = a.toString(16).padStart(6, "0");
|
|
31
|
+
commandlength = (bitheader.length + payload.length + 1)
|
|
32
|
+
.toString(16)
|
|
33
|
+
.padStart(4, "0");
|
|
25
34
|
let ret = "!" + commandlength + "!" + bitheader + "!" + payload;
|
|
26
35
|
|
|
27
36
|
return ret;
|
|
28
37
|
};
|
|
29
38
|
|
|
30
|
-
const decodeheader = (msg) => {
|
|
31
|
-
//Perhaps some code to verify that we acctually got the initial '!', if not discard.
|
|
32
|
-
//Same for the length, verify length in the header to the actual recived length, if no match discard.
|
|
39
|
+
const decodeheader = (msg = "!0007!000000!") => {
|
|
40
|
+
//Perhaps some code to verify that we acctually got the initial '!', if not discard.
|
|
41
|
+
//Same for the length, verify length in the header to the actual recived length, if no match discard.
|
|
33
42
|
//
|
|
34
|
-
msg = msg.toString(
|
|
35
|
-
let response = msg.substring(1).split("!"); //skip first !
|
|
43
|
+
msg = msg.toString("utf8");
|
|
44
|
+
let response = msg.substring(1).split("!"); //skip first !
|
|
36
45
|
|
|
37
46
|
// Header masks
|
|
38
|
-
const gscph_protocol_mask = 0xe00000 // 3 bits Protocol version
|
|
39
|
-
const gscph_method_mask = 0x180000 // 2 bits 0 = Unicast request, 1 = Unicast response, 2 = Broadcast request, 3 = Broadcast response
|
|
40
|
-
const gscph_command_mask =
|
|
41
|
-
const gscph_revision_mask = 0x00007c // 5 bits Command revision
|
|
42
|
-
const gscph_error_mask = 0x000003 // 2 bits 0 = No error, 1 = Command error, 2 = Protocol error, 3 = Not defined
|
|
43
|
-
|
|
44
|
-
let error = gscph_error_mask & parseInt(response[1],16);
|
|
45
|
-
let revision = (gscph_revision_mask & parseInt(response[1],16)) >> 2;
|
|
46
|
-
let command = (gscph_command_mask & parseInt(response[1],16)) >> 7;
|
|
47
|
-
let method = (gscph_method_mask & parseInt(response[1],16)) >> 19;
|
|
48
|
-
let protocol = (gscph_protocol_mask & parseInt(response[1],16)) >> 21;
|
|
47
|
+
const gscph_protocol_mask = 0xe00000; // 3 bits Protocol version
|
|
48
|
+
const gscph_method_mask = 0x180000; // 2 bits 0 = Unicast request, 1 = Unicast response, 2 = Broadcast request, 3 = Broadcast response
|
|
49
|
+
const gscph_command_mask = 0x07ff80; // 12 bits Command number
|
|
50
|
+
const gscph_revision_mask = 0x00007c; // 5 bits Command revision
|
|
51
|
+
const gscph_error_mask = 0x000003; // 2 bits 0 = No error, 1 = Command error, 2 = Protocol error, 3 = Not defined
|
|
52
|
+
|
|
53
|
+
let error = gscph_error_mask & parseInt(response[1], 16);
|
|
54
|
+
let revision = (gscph_revision_mask & parseInt(response[1], 16)) >> 2;
|
|
55
|
+
let command = (gscph_command_mask & parseInt(response[1], 16)) >> 7;
|
|
56
|
+
let method = (gscph_method_mask & parseInt(response[1], 16)) >> 19;
|
|
57
|
+
let protocol = (gscph_protocol_mask & parseInt(response[1], 16)) >> 21;
|
|
49
58
|
let length = response[0];
|
|
50
|
-
let payload = response[2]
|
|
51
|
-
|
|
52
|
-
return {
|
|
59
|
+
let payload = response[2];
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
error: error,
|
|
63
|
+
revision: revision,
|
|
64
|
+
command: command,
|
|
65
|
+
method: method,
|
|
66
|
+
protocol: protocol,
|
|
67
|
+
length: length,
|
|
68
|
+
payload: payload,
|
|
69
|
+
};
|
|
53
70
|
};
|
|
54
71
|
|
|
55
72
|
const decode = (msg) => {
|
|
56
73
|
const header = decodeheader(msg);
|
|
57
74
|
const params = header.payload.split(";");
|
|
58
75
|
let data = {};
|
|
59
|
-
switch(header.command) {
|
|
76
|
+
switch (header.command) {
|
|
60
77
|
case 24:
|
|
61
78
|
data = decode24(params);
|
|
62
79
|
break;
|
|
@@ -70,13 +87,13 @@ const decode = (msg) => {
|
|
|
70
87
|
data = decode412(params);
|
|
71
88
|
break;
|
|
72
89
|
}
|
|
73
|
-
return {...header, ...data};
|
|
90
|
+
return { ...header, ...data };
|
|
74
91
|
};
|
|
75
92
|
|
|
76
93
|
const decode24 = (data) => {
|
|
77
94
|
let msg = {};
|
|
78
95
|
|
|
79
|
-
msg.
|
|
96
|
+
msg.identification = parseInt(data[0]);
|
|
80
97
|
msg.group = parseInt(data[1]);
|
|
81
98
|
msg.name = data[2];
|
|
82
99
|
|
|
@@ -90,10 +107,10 @@ const decode82 = (data) => {
|
|
|
90
107
|
// 2 band.name string Band name (20 characters maximum)
|
|
91
108
|
// 3 band.cutoff.lower int Lower cutoff frequency (0 - 2147483647 hertz)
|
|
92
109
|
// 4 band.cutoff.upper int Upper cutoff frequency (0 - 2147483647 hertz)
|
|
93
|
-
msg.
|
|
94
|
-
msg.
|
|
95
|
-
msg.
|
|
96
|
-
msg.
|
|
110
|
+
msg.index = parseInt(data[0]);
|
|
111
|
+
msg.name = data[1];
|
|
112
|
+
msg.cutoff_lower = parseInt(data[2]);
|
|
113
|
+
msg.cutoff_upper = parseInt(data[3]);
|
|
97
114
|
|
|
98
115
|
return msg;
|
|
99
116
|
};
|
|
@@ -106,13 +123,13 @@ const decode401 = (data) => {
|
|
|
106
123
|
msg.portA_inhibit = parseInt(data[2]);
|
|
107
124
|
msg.portA_antenna = parseInt(data[3]);
|
|
108
125
|
msg.portA_profile = parseInt(data[4]);
|
|
109
|
-
msg.portA_tx = parseInt(data[5]);
|
|
126
|
+
msg.portA_tx = parseInt(data[5]);
|
|
110
127
|
msg.portB_mode = parseInt(data[6]);
|
|
111
128
|
msg.portB_band = parseInt(data[7]);
|
|
112
129
|
msg.portB_inhibit = parseInt(data[8]);
|
|
113
130
|
msg.portB_antenna = parseInt(data[9]);
|
|
114
131
|
msg.portB_profile = parseInt(data[10]);
|
|
115
|
-
msg.portB_tx = parseInt(data[11]);
|
|
132
|
+
msg.portB_tx = parseInt(data[11]);
|
|
116
133
|
msg.stackReach = parseInt(data[12]);
|
|
117
134
|
|
|
118
135
|
return msg;
|
|
@@ -125,30 +142,30 @@ const decode412 = (data) => {
|
|
|
125
142
|
// 1 antenna.name string Antenna name (20 characters maximum)
|
|
126
143
|
// 2 antenna.mode int Antenna mode (1 = RX only, 2 = TX only, 3 = RX and TX)
|
|
127
144
|
// 3 antenna.bands string Hex representation of bands bitfield (2 bytes)
|
|
128
|
-
msg.
|
|
129
|
-
msg.
|
|
130
|
-
msg.
|
|
131
|
-
let parameters = parseInt(data[3],16);
|
|
132
|
-
msg.
|
|
133
|
-
msg.
|
|
134
|
-
msg.
|
|
135
|
-
msg.
|
|
136
|
-
msg.
|
|
137
|
-
msg.
|
|
138
|
-
msg.
|
|
139
|
-
msg.
|
|
140
|
-
msg.
|
|
141
|
-
msg.
|
|
142
|
-
msg.
|
|
143
|
-
msg.
|
|
144
|
-
msg.
|
|
145
|
-
msg.
|
|
146
|
-
msg.
|
|
147
|
-
msg.
|
|
148
|
-
msg.
|
|
145
|
+
msg.index = parseInt(data[0]);
|
|
146
|
+
msg.name = data[1];
|
|
147
|
+
msg.mode = parseInt(data[2]);
|
|
148
|
+
let parameters = parseInt(data[3], 16);
|
|
149
|
+
msg.bands = [];
|
|
150
|
+
msg.bands.push(1 & parameters);
|
|
151
|
+
msg.bands.push(1 & (parameters >> 1));
|
|
152
|
+
msg.bands.push(1 & (parameters >> 2));
|
|
153
|
+
msg.bands.push(1 & (parameters >> 3));
|
|
154
|
+
msg.bands.push(1 & (parameters >> 4));
|
|
155
|
+
msg.bands.push(1 & (parameters >> 5));
|
|
156
|
+
msg.bands.push(1 & (parameters >> 6));
|
|
157
|
+
msg.bands.push(1 & (parameters >> 7));
|
|
158
|
+
msg.bands.push(1 & (parameters >> 8));
|
|
159
|
+
msg.bands.push(1 & (parameters >> 9));
|
|
160
|
+
msg.bands.push(1 & (parameters >> 10));
|
|
161
|
+
msg.bands.push(1 & (parameters >> 11));
|
|
162
|
+
msg.bands.push(1 & (parameters >> 12));
|
|
163
|
+
msg.bands.push(1 & (parameters >> 13));
|
|
164
|
+
msg.bands.push(1 & (parameters >> 14));
|
|
165
|
+
msg.bands.push(1 & (parameters >> 15));
|
|
149
166
|
|
|
150
167
|
return msg;
|
|
151
|
-
}
|
|
168
|
+
};
|
|
152
169
|
|
|
153
170
|
exports.encode = encode;
|
|
154
|
-
exports.decode = decode;
|
|
171
|
+
exports.decode = decode;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
<script type="text/javascript">
|
|
2
|
-
RED.nodes.registerType(
|
|
3
|
-
category:
|
|
4
|
-
color:
|
|
2
|
+
RED.nodes.registerType("antenna-genius-activate-antenna", {
|
|
3
|
+
category: "antenna genius",
|
|
4
|
+
color: "#FFF0F0",
|
|
5
5
|
defaults: {
|
|
6
|
-
name: {value:""},
|
|
7
|
-
server: {value:"", type:"antenna-genius-server"},
|
|
6
|
+
name: { value: "" },
|
|
7
|
+
server: { value: "", type: "antenna-genius-server" },
|
|
8
8
|
},
|
|
9
|
-
inputs:1,
|
|
10
|
-
outputs:0,
|
|
9
|
+
inputs: 1,
|
|
10
|
+
outputs: 0,
|
|
11
11
|
icon: "font-awesome/fa-sliders",
|
|
12
|
-
label: function() {
|
|
13
|
-
return this.name||"antenna-genius-activate-antenna";
|
|
12
|
+
label: function () {
|
|
13
|
+
return this.name || "antenna-genius-activate-antenna";
|
|
14
14
|
},
|
|
15
15
|
paletteLabel: "activate-antenna",
|
|
16
16
|
inputLabels: "Set antenna defined in topic as active",
|
|
@@ -20,11 +20,13 @@
|
|
|
20
20
|
<script type="text/html" data-template-name="antenna-genius-activate-antenna">
|
|
21
21
|
<div class="form-row">
|
|
22
22
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
23
|
-
<input type="text" id="node-input-name" placeholder="Name"
|
|
23
|
+
<input type="text" id="node-input-name" placeholder="Name" />
|
|
24
24
|
</div>
|
|
25
25
|
<div class="form-row">
|
|
26
|
-
<label for="node-input-server"
|
|
27
|
-
|
|
26
|
+
<label for="node-input-server"
|
|
27
|
+
><i class="fa fa-server"></i> Server</label
|
|
28
|
+
>
|
|
29
|
+
<input type="text" id="node-input-server" placeholder="Server" />
|
|
28
30
|
</div>
|
|
29
31
|
</script>
|
|
30
32
|
|
|
@@ -42,5 +44,4 @@ Set the antenna defined in topic as active.
|
|
|
42
44
|
### Details
|
|
43
45
|
|
|
44
46
|
See the `antenna-status` node for more information.
|
|
45
|
-
|
|
46
47
|
</script>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const Utils = require(
|
|
1
|
+
const Utils = require("./Utils");
|
|
2
2
|
|
|
3
3
|
module.exports = (RED) => {
|
|
4
4
|
class AntennaGeniusActivateAntenna {
|
|
@@ -10,31 +10,55 @@ module.exports = (RED) => {
|
|
|
10
10
|
this.bandNameB = "";
|
|
11
11
|
this.server = RED.nodes.getNode(config.server);
|
|
12
12
|
|
|
13
|
+
if(this.server == null) {
|
|
14
|
+
this.status({
|
|
15
|
+
fill: "red",
|
|
16
|
+
shape: "ring",
|
|
17
|
+
text: "disconnected",
|
|
18
|
+
});
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
13
22
|
this.server.updatesEventEmitter.on("connected", () => {
|
|
14
|
-
if(this.server.info.name) {
|
|
15
|
-
this.status({
|
|
23
|
+
if (this.server.info.name) {
|
|
24
|
+
this.status({
|
|
25
|
+
fill: "green",
|
|
26
|
+
shape: "dot",
|
|
27
|
+
text: this.server.info.name,
|
|
28
|
+
});
|
|
16
29
|
}
|
|
17
30
|
});
|
|
18
31
|
|
|
19
|
-
this.server.updatesEventEmitter.on(
|
|
20
|
-
this.status({
|
|
32
|
+
this.server.updatesEventEmitter.on("closed", () => {
|
|
33
|
+
this.status({
|
|
34
|
+
fill: "red",
|
|
35
|
+
shape: "ring",
|
|
36
|
+
text: "disconnected",
|
|
37
|
+
});
|
|
21
38
|
});
|
|
22
39
|
|
|
23
|
-
node.on(
|
|
24
|
-
if(msg.topic) {
|
|
25
|
-
if(this.server.info.name) {
|
|
26
|
-
this.status({
|
|
40
|
+
node.on("input", (msg, send, done) => {
|
|
41
|
+
if (msg.topic) {
|
|
42
|
+
if (this.server.info.name) {
|
|
43
|
+
this.status({
|
|
44
|
+
fill: "green",
|
|
45
|
+
shape: "dot",
|
|
46
|
+
text: this.server.info.name,
|
|
47
|
+
});
|
|
27
48
|
}
|
|
28
|
-
|
|
49
|
+
|
|
29
50
|
let command = Utils.encode(0, 0, 415, 0, msg.topic);
|
|
30
51
|
|
|
31
52
|
this.server.client.write(command);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
53
|
+
} else {
|
|
54
|
+
this.status({
|
|
55
|
+
fill: "red",
|
|
56
|
+
shape: "ring",
|
|
57
|
+
text: "topic is not set",
|
|
58
|
+
});
|
|
35
59
|
this.server.forceUpdate();
|
|
36
60
|
}
|
|
37
|
-
if(done) {
|
|
61
|
+
if (done) {
|
|
38
62
|
done();
|
|
39
63
|
}
|
|
40
64
|
});
|
|
@@ -42,5 +66,8 @@ module.exports = (RED) => {
|
|
|
42
66
|
this.server.connect();
|
|
43
67
|
}
|
|
44
68
|
}
|
|
45
|
-
RED.nodes.registerType(
|
|
46
|
-
|
|
69
|
+
RED.nodes.registerType(
|
|
70
|
+
"antenna-genius-activate-antenna",
|
|
71
|
+
AntennaGeniusActivateAntenna
|
|
72
|
+
);
|
|
73
|
+
};
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
<script type="text/javascript">
|
|
2
|
-
RED.nodes.registerType(
|
|
3
|
-
category:
|
|
4
|
-
color:
|
|
2
|
+
RED.nodes.registerType("antenna-genius-antenna-status", {
|
|
3
|
+
category: "antenna genius",
|
|
4
|
+
color: "#FFF0F0",
|
|
5
5
|
defaults: {
|
|
6
|
-
name: {value:""},
|
|
7
|
-
server: {value:"", type:"antenna-genius-server"},
|
|
8
|
-
antennaNb: {
|
|
6
|
+
name: { value: "" },
|
|
7
|
+
server: { value: "", type: "antenna-genius-server" },
|
|
8
|
+
antennaNb: {
|
|
9
|
+
value: 1,
|
|
10
|
+
required: true,
|
|
11
|
+
validate: RED.validators.number(),
|
|
12
|
+
},
|
|
9
13
|
},
|
|
10
|
-
inputs:0,
|
|
11
|
-
outputs:2,
|
|
14
|
+
inputs: 0,
|
|
15
|
+
outputs: 2,
|
|
12
16
|
icon: "font-awesome/fa-wifi",
|
|
13
|
-
label: function() {
|
|
14
|
-
return this.name||"antenna-genius-antenna-status";
|
|
17
|
+
label: function () {
|
|
18
|
+
return this.name || "antenna-genius-antenna-status";
|
|
15
19
|
},
|
|
16
20
|
paletteLabel: "antenna-status",
|
|
17
21
|
outputLabels: ["Antenna Radio A Status", "Antenna Radio B Status"],
|
|
@@ -21,15 +25,23 @@
|
|
|
21
25
|
<script type="text/html" data-template-name="antenna-genius-antenna-status">
|
|
22
26
|
<div class="form-row">
|
|
23
27
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
24
|
-
<input type="text" id="node-input-name" placeholder="Name"
|
|
28
|
+
<input type="text" id="node-input-name" placeholder="Name" />
|
|
25
29
|
</div>
|
|
26
30
|
<div class="form-row">
|
|
27
|
-
<label for="node-input-server"
|
|
28
|
-
|
|
31
|
+
<label for="node-input-server"
|
|
32
|
+
><i class="fa fa-server"></i> Server</label
|
|
33
|
+
>
|
|
34
|
+
<input type="text" id="node-input-server" placeholder="Server" />
|
|
29
35
|
</div>
|
|
30
36
|
<div class="form-row">
|
|
31
|
-
<label for="node-input-antennaNb"
|
|
32
|
-
|
|
37
|
+
<label for="node-input-antennaNb"
|
|
38
|
+
><i class="fa fa-wifi"></i> Antenna Number</label
|
|
39
|
+
>
|
|
40
|
+
<input
|
|
41
|
+
type="text"
|
|
42
|
+
id="node-input-antennaNb"
|
|
43
|
+
placeholder="Antenna Number"
|
|
44
|
+
/>
|
|
33
45
|
</div>
|
|
34
46
|
</script>
|
|
35
47
|
|
|
@@ -46,7 +58,7 @@ Return Radio A & B status for an antenna.
|
|
|
46
58
|
|
|
47
59
|
Port 1: Status for Radio A antenna.
|
|
48
60
|
|
|
49
|
-
: payload.selected (boolean) : this is the currently selected antenna for Radio A on the current band.
|
|
61
|
+
: payload.selected (boolean) : this is the currently selected antenna for Radio A on the current band.
|
|
50
62
|
|
|
51
63
|
: payload.enabled (boolean) : this antenna can be selected for use by Radio A on the current band.
|
|
52
64
|
|
|
@@ -60,7 +72,7 @@ Port 1: Status for Radio A antenna.
|
|
|
60
72
|
|
|
61
73
|
Port 2: Status for Radio A antenna.
|
|
62
74
|
|
|
63
|
-
: payload.selected (boolean) : this is the currently selected antenna for Radio B on the current band.
|
|
75
|
+
: payload.selected (boolean) : this is the currently selected antenna for Radio B on the current band.
|
|
64
76
|
|
|
65
77
|
: payload.enabled (boolean) : this antenna can be selected for use by Radio B on the current band.
|
|
66
78
|
|
|
@@ -75,5 +87,4 @@ Port 2: Status for Radio A antenna.
|
|
|
75
87
|
### Details
|
|
76
88
|
|
|
77
89
|
A typical workflow is to feed each output to a `button` and then map `payload.name` to the button's `label`, and `payload.background` to the button's `background`. Set the buttons `payload` to `true` and `Topic` to `msg.topic` when clicked and everything is setup to directly feed an `activate-antenna` node.
|
|
78
|
-
|
|
79
90
|
</script>
|
|
@@ -9,91 +9,123 @@ module.exports = (RED) => {
|
|
|
9
9
|
selected: false,
|
|
10
10
|
enabled: false,
|
|
11
11
|
name: "",
|
|
12
|
-
background: ""
|
|
12
|
+
background: "",
|
|
13
13
|
};
|
|
14
14
|
this.radioB = {
|
|
15
15
|
selected: false,
|
|
16
16
|
enabled: false,
|
|
17
17
|
name: "",
|
|
18
|
-
background: ""
|
|
18
|
+
background: "",
|
|
19
19
|
};
|
|
20
20
|
this.server = RED.nodes.getNode(config.server);
|
|
21
21
|
|
|
22
|
+
if(this.server == null) {
|
|
23
|
+
this.status({
|
|
24
|
+
fill: "red",
|
|
25
|
+
shape: "ring",
|
|
26
|
+
text: "disconnected",
|
|
27
|
+
});
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
22
31
|
this.server.updatesEventEmitter.on("connected", () => {
|
|
23
|
-
if(this.server.info.name
|
|
24
|
-
this.status({
|
|
32
|
+
if (this.server.info.name) {
|
|
33
|
+
this.status({
|
|
34
|
+
fill: "green",
|
|
35
|
+
shape: "dot",
|
|
36
|
+
text: this.server.info.name,
|
|
37
|
+
});
|
|
25
38
|
}
|
|
26
39
|
});
|
|
27
40
|
|
|
28
|
-
this.server.updatesEventEmitter.on(
|
|
29
|
-
this.status({
|
|
41
|
+
this.server.updatesEventEmitter.on("closed", () => {
|
|
42
|
+
this.status({
|
|
43
|
+
fill: "red",
|
|
44
|
+
shape: "ring",
|
|
45
|
+
text: "disconnected",
|
|
46
|
+
});
|
|
30
47
|
});
|
|
31
48
|
|
|
32
49
|
this.server.updatesEventEmitter.on("status", (forceUpdate) => {
|
|
33
|
-
|
|
34
50
|
let maxNumberOfAntennas = this.server.status.stackReach * 8;
|
|
35
|
-
if(
|
|
36
|
-
this.
|
|
51
|
+
if (
|
|
52
|
+
this.antennaNumber < 1 ||
|
|
53
|
+
this.antennaNumber > maxNumberOfAntennas ||
|
|
54
|
+
this.antennaNumber > this.server.antennas.length
|
|
55
|
+
) {
|
|
56
|
+
this.status({
|
|
57
|
+
fill: "red",
|
|
58
|
+
shape: "ring",
|
|
59
|
+
text: "antenna number is out of range",
|
|
60
|
+
});
|
|
37
61
|
return;
|
|
38
62
|
}
|
|
39
63
|
|
|
40
64
|
let changed = forceUpdate;
|
|
41
65
|
|
|
42
66
|
// Selected?
|
|
43
|
-
let radioAselected =
|
|
67
|
+
let radioAselected =
|
|
68
|
+
this.antennaNumber == this.server.status.portA_antenna;
|
|
44
69
|
if (radioAselected != this.radioA.selected) {
|
|
45
70
|
changed = true;
|
|
46
71
|
this.radioA.selected = radioAselected;
|
|
47
72
|
}
|
|
48
73
|
|
|
49
|
-
let radioBselected =
|
|
74
|
+
let radioBselected =
|
|
75
|
+
this.antennaNumber == this.server.status.portB_antenna;
|
|
50
76
|
if (radioBselected != this.radioB.selected) {
|
|
51
77
|
changed = true;
|
|
52
78
|
this.radioB.selected = radioBselected;
|
|
53
79
|
}
|
|
54
80
|
|
|
55
81
|
// Enabled?
|
|
56
|
-
let radioAenabled =
|
|
82
|
+
let radioAenabled =
|
|
83
|
+
this.server.antennas[this.antennaNumber - 1].bands[
|
|
84
|
+
this.server.status.portA_band
|
|
85
|
+
] == 1;
|
|
57
86
|
if (radioAenabled != this.radioA.enabled) {
|
|
58
87
|
changed = true;
|
|
59
88
|
this.radioA.enabled = radioAenabled;
|
|
60
89
|
}
|
|
61
90
|
|
|
62
|
-
let radioBenabled =
|
|
91
|
+
let radioBenabled =
|
|
92
|
+
this.server.antennas[this.antennaNumber - 1].bands[
|
|
93
|
+
this.server.status.portB_band
|
|
94
|
+
] == 1;
|
|
63
95
|
if (radioBenabled != this.radioB.enabled) {
|
|
64
96
|
changed = true;
|
|
65
97
|
this.radioB.enabled = radioBenabled;
|
|
66
98
|
}
|
|
67
99
|
|
|
68
100
|
// Get name
|
|
69
|
-
let name = this.server.antennas[this.antennaNumber - 1].
|
|
101
|
+
let name = this.server.antennas[this.antennaNumber - 1].name;
|
|
70
102
|
if (this.radioA.name !== name) {
|
|
71
103
|
changed = true;
|
|
72
104
|
this.radioA.name = this.radioB.name = name;
|
|
73
|
-
this.status({
|
|
105
|
+
this.status({
|
|
106
|
+
fill: "green",
|
|
107
|
+
shape: "dot",
|
|
108
|
+
text: this.server.info.name + " - " + name,
|
|
109
|
+
});
|
|
74
110
|
}
|
|
75
111
|
|
|
76
112
|
if (radioAenabled) {
|
|
77
113
|
if (radioAselected) {
|
|
78
114
|
this.radioA.background = this.server.selectedColor;
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
115
|
+
} else {
|
|
81
116
|
this.radioA.background = this.server.activeColor;
|
|
82
117
|
}
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
118
|
+
} else {
|
|
85
119
|
this.radioA.background = this.server.disabledColor;
|
|
86
120
|
}
|
|
87
121
|
|
|
88
122
|
if (radioBenabled) {
|
|
89
123
|
if (radioBselected) {
|
|
90
124
|
this.radioB.background = this.server.selectedColor;
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
125
|
+
} else {
|
|
93
126
|
this.radioB.background = this.server.activeColor;
|
|
94
127
|
}
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
128
|
+
} else {
|
|
97
129
|
this.radioB.background = this.server.disabledColor;
|
|
98
130
|
}
|
|
99
131
|
|
|
@@ -101,12 +133,26 @@ module.exports = (RED) => {
|
|
|
101
133
|
let radioBTopic = "2;" + this.antennaNumber;
|
|
102
134
|
|
|
103
135
|
if (changed) {
|
|
104
|
-
node.send([
|
|
136
|
+
node.send([
|
|
137
|
+
{
|
|
138
|
+
payload: this.radioA,
|
|
139
|
+
enabled: this.radioA.enabled,
|
|
140
|
+
topic: radioATopic,
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
payload: this.radioB,
|
|
144
|
+
enabled: this.radioB.enabled,
|
|
145
|
+
topic: radioBTopic,
|
|
146
|
+
},
|
|
147
|
+
]);
|
|
105
148
|
}
|
|
106
149
|
});
|
|
107
150
|
|
|
108
151
|
this.server.connect();
|
|
109
152
|
}
|
|
110
153
|
}
|
|
111
|
-
RED.nodes.registerType(
|
|
112
|
-
|
|
154
|
+
RED.nodes.registerType(
|
|
155
|
+
"antenna-genius-antenna-status",
|
|
156
|
+
AntennaGeniusAntennaStatus
|
|
157
|
+
);
|
|
158
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
<script type="text/javascript">
|
|
2
|
-
RED.nodes.registerType(
|
|
3
|
-
category:
|
|
4
|
-
color:
|
|
2
|
+
RED.nodes.registerType("antenna-genius-band-labels", {
|
|
3
|
+
category: "antenna genius",
|
|
4
|
+
color: "#FFF0F0",
|
|
5
5
|
defaults: {
|
|
6
|
-
name: {value:""},
|
|
7
|
-
server: {value:"", type:"antenna-genius-server"},
|
|
6
|
+
name: { value: "" },
|
|
7
|
+
server: { value: "", type: "antenna-genius-server" },
|
|
8
8
|
},
|
|
9
|
-
inputs:0,
|
|
10
|
-
outputs:1,
|
|
9
|
+
inputs: 0,
|
|
10
|
+
outputs: 1,
|
|
11
11
|
icon: "font-awesome/fa-info",
|
|
12
|
-
label: function() {
|
|
13
|
-
return this.name||"antenna-genius-band-labels";
|
|
12
|
+
label: function () {
|
|
13
|
+
return this.name || "antenna-genius-band-labels";
|
|
14
14
|
},
|
|
15
15
|
paletteLabel: "band-labels",
|
|
16
16
|
outputLabels: ["Band Labels"],
|
|
@@ -20,11 +20,13 @@
|
|
|
20
20
|
<script type="text/html" data-template-name="antenna-genius-band-labels">
|
|
21
21
|
<div class="form-row">
|
|
22
22
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
23
|
-
<input type="text" id="node-input-name" placeholder="Name"
|
|
23
|
+
<input type="text" id="node-input-name" placeholder="Name" />
|
|
24
24
|
</div>
|
|
25
25
|
<div class="form-row">
|
|
26
|
-
<label for="node-input-server"
|
|
27
|
-
|
|
26
|
+
<label for="node-input-server"
|
|
27
|
+
><i class="fa fa-server"></i> Server</label
|
|
28
|
+
>
|
|
29
|
+
<input type="text" id="node-input-server" placeholder="Server" />
|
|
28
30
|
</div>
|
|
29
31
|
</script>
|
|
30
32
|
|