-
Notifications
You must be signed in to change notification settings - Fork 1
/
states.js
134 lines (129 loc) · 3.69 KB
/
states.js
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
const { numberOfPresentationSlots, numberOfMediaPlayerSlots } = require('./constants')
var choices = require('./choices')
exports.generateCaptureStates = function () {
var cchoices = choices.getChoicesForCapture()
var states = new Object()
for (var i = cchoices.length - 1; i >= 0; i--) {
var ci = cchoices[i].id
states[ci] = false
}
return states
}
exports.generateDisplayStates = function () {
var dchoices = choices.getChoicesForDisplay()
var states = new Object()
for (var i = dchoices.length - 1; i >= 0; i--) {
var di = dchoices[i].id
states[di] = new Object()
states[di].loaded = false
states[di].displayed = false
}
return states
}
exports.generateSlotStates = function () {
var schoices = choices.getChoicesForSlot()
var states = new Object()
for (var i = numberOfPresentationSlots - 1; i >= 0; i--) {
const si = schoices[i].id
states[si] = new Object()
states[si].exists = false
states[si].opened = false
}
return states
}
function doUpdateDisplayStates(states, data) {
const key = 'Display' + (data.displayIndex + 1)
for (const k in states) {
states[k].displayed = false
if (key === k) {
states[key].displayed = true
}
}
states.DisplayTest.displayed = data.displayTest
states.Freeze.displayed = data.displayFreeze
states.Blackout.displayed = data.displayBlack
}
exports.updateStates = function (states, data) {
// DisplayTest
states.DisplayTest.loaded = true
// Freeze
states.Freeze.loaded = true
// Blackout
states.Blackout.loaded = true
for (var i = data.isLoaded.length; i > 0; i--) {
var key = 'Display' + i
states[key].loaded = data.isLoaded[i - 1]
}
doUpdateDisplayStates(states, data)
}
exports.updateDisplayStates = function (states, data) {
doUpdateDisplayStates(states, data)
}
exports.updateCaptureStates = function (states, index) {
const key = 'Capture' + (index + 1)
for (const k in states) {
if (key === k) {
states[k] = true
} else {
states[k] = false
}
}
}
exports.uploadLoadStates = function (states, index) {
const key = 'Display' + (index + 1)
for (const k in states) {
if (key === k) {
states[key].loaded = true
}
}
}
exports.updateUnloadStates = function (states, index) {
const key = 'Display' + (index + 1)
for (const k in states) {
if (key === k) {
states[key].loaded = false
}
}
}
exports.updateSlotStates = function (states, data) {
for (var i = numberOfPresentationSlots; i > 0; i--) {
const si = 'Slot' + i
states[si].exists = data.exists[i - 1]
states[si].opened = data.opened[i - 1]
}
}
exports.generateMediaSlotStates = function () {
var schoices = choices.getChoicesForMediaPlayer()
var states = new Object()
states['any_media_loaded'] = new Object()
states['any_media_loaded'].loaded = false
for (var i = numberOfMediaPlayerSlots - 1; i >= 0; i--) {
const si = schoices[i].id
states[si] = new Object()
states[si].playing = false
states[si].loaded = false
}
return states
}
exports.updateMediaPlayerState = function (mediaPlayerState, data) {
mediaPlayerState.playing = data.Media_playback_state == 'playing'
mediaPlayerState.paused = data.Media_playback_state == 'paused'
mediaPlayerState.loop_on = data.Media_player_loop_status == 'on'
mediaPlayerState.fade_on = data.Media_player_fade_status == 'on'
mediaPlayerState.slots['any_media_loaded'].loaded = false
// Slots
for (var i = numberOfMediaPlayerSlots; i > 0; i--) {
const si = 'Load_MediaPlayer#' + i
if (data.Media_playing == i) {
mediaPlayerState.slots[si].playing = true
} else {
mediaPlayerState.slots[si].playing = false
}
if (data.Media_loaded == i) {
mediaPlayerState.slots[si].loaded = true
mediaPlayerState.slots['any_media_loaded'].loaded = true
} else {
mediaPlayerState.slots[si].loaded = false
}
}
}