-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariables.js
More file actions
63 lines (51 loc) · 1.79 KB
/
Copy pathvariables.js
File metadata and controls
63 lines (51 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
module.exports = async function (self) {
const slots = self.state.slots || [];
const sources = self.state.sources || [];
const machineName = self.state.machineName || {};
let allVariables = [
{
variableId: 'router_connection_online',
name: 'Router Connection Online'
},
{
variableId: 'source_count',
name: 'Source Count'
},
{
variableId: 'router_machine_name',
name: 'Router Machine Name'
},
{
variableId: 'router_machine_real_name',
name: 'Router Real Machine Name'
},
{
variableId: 'router_machine_override_name',
name: 'Router Machine Name Override'
},
...slots.map(o => ({
variableId: `slot_${o.code}_locked`,
name: `Slot ${o.slotName} Lock Status`
})), ...slots.map(o => ({
variableId: `slot_${o.code}`,
name: `Slot ${o.slotName} Source`
}))]
self.setVariableDefinitions(allVariables);
let values = {};
values.router_connection_online = self.state.connectionOk === true ? 'Online' : 'Offline';
values.source_count = sources.length;
values.router_machine_real_name = machineName.real || '';
values.router_machine_override_name = machineName.override || '';
values.router_machine_name = machineName.override || machineName.real || '';
for(let i = 0; i < slots.length; i++) {
let o = slots[i];
values[`slot_${o.code}`] = o.sourceName || '';
values[`slot_${o.code}_locked`] = o.isLocked ? 'Locked' : 'Unlocked';
}
self.setVariableValues(values);
// [
// { variableId: 'variable1', name: 'My first variable' },
// { variableId: 'variable2', name: 'My second variable' },
// { variableId: 'variable3', name: 'Another variable' },
// ])
}