1 contributor
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
var main_loop_id = 0;
var loop_check_functions_max_index = 0;
var loop_check_functions = [];
var device = [nil, nil];
var deviceClass = {};
var init_main_loop = func {
loop_check_functions = [
pfdCursors,
checkTrafficProximity,
checkMarkerBaecon,
device[0] == nil ? void : func { moveMap (0) },
checkRollAcquisition,
checkPitchAcquisition,
pfdCursors,
computeAltitudeDiff,
computeAirspeedDiff,
device[1] == nil ? void : func { moveMap(1) },
checkAlerts,
];
loop_check_functions_max_index = size(loop_check_functions);
}
var main_loop = func () {
getData();
FLCcomputation();
loop_check_functions[main_loop_id]();
main_loop_id += 1;
if (main_loop_id == loop_check_functions_max_index) main_loop_id = 0;
settimer(main_loop, 0);
}
var setListeners = func {
setlistener('/instrumentation/nav/nav-id',
func (n) {
var val = n.getValue();
device[0].display.updateNAV({'nav-id': 1, val: val});
device[0].display.updateNAV({'nav-id': 1, val: val});
}, 1, 2);
setlistener('/instrumentation/nav[1]/nav-id',
func (n) {
var val = n.getValue();
device[0].display.updateNAV({'nav-id': 2, val: val});
device[1].display.updateNAV({'nav-id': 2, val: val});
}, 1, 2);
setlistener('/instrumentation/zkv1000/radios/nav-tune',
func (n) {
var val = n.getValue();
setNavTune();
device[0].display.updateNAV({tune: val});
device[1].display.updateNAV({tune: val});
}, 1, 2);
setlistener('/instrumentation/zkv1000/radios/comm-tune',
func (n) {
var val = n.getValue();
setCommTune();
device[0].display.updateCOMM({tune: val});
device[1].display.updateCOMM({tune: val});
}, 1, 2);
setlistener('/instrumentation/zkv1000/afcs/heading-bug-deg',
func (n) {
var val = n.getValue();
if (val != nil) {
device[0].display.updateHDG(val);
device[1].display.updateHDG(val);
}
}, 0, 2);
setlistener('/instrumentation/zkv1000/device[0]/knobs/CRS',
func (n) {
var val = n.getValue();
if (val != nil) {
device[0].display.updateCRS();
device[1].display.updateCRS();
}
}, 0, 2);
setlistener('/instrumentation/zkv1000/afcs/selected-alt-ft',
func (n) {
var val = n.getValue();
if (val != nil) {
if (! device[0].display.screenElements['SelectedALT'].getVisible()) {
device[0].display.screenElements['SelectedALT'].show();
device[0].display.screenElements['SelectedALT-text'].show();
device[0].display.screenElements['SelectedALT-symbol'].show();
device[0].display.screenElements['SelectedALT-bug'].show();
device[0].display.screenElements['SelectedALT-bg'].show();
}
device[0].display.updateSelectedALT();
}
}, 0, 2);
setlistener('/gear/gear/wow',
func device[0].display.updateXPDR(),
0, 0);
}
var deviceClass = {
new: func (d) {
var m = { parents: [ deviceClass ] };
m.role = d ? 'MFD' : 'PFD';
m.node = zkv.getNode('device[' ~ d ~ ']', 1);
m.display = displayClass.new(m, m.role);
m.display.showInitProgress(m.role);
m.buttons = buttonsClass.new(m.node);
m.knobs = knobsClass.new(m.node);
m.softkeys = softkeysClass.new(m, m.node, m.role);
m.display.loadsvg();
m.display.loadGroup({
hide : [
'Failures',
'SoftKeysTexts',
'PFD-Widgets',
'COMM',
'XPDR-TIME',
'NAV',
'FlightInstruments',
'VDI',
'OMI',
],
clip : 'PitchScale',
});
zkv.getNode(m.role ~ 'init').setIntValue(0);
m.setstatus(d + 1);
msg(m.role ~ ' switched on!');
return m;
},
status: 0,
role: '',
setstatus: func (s) {
if (s == 1) {
}
elsif (s == 2) {
me.rootmenu = 12;
me.node.getNode('mfd-title',1).setValue('TOPO');
}
me.status = s;
me.node.getNode('status', 1).setIntValue(s);
},
MFD: func {
m.rootmenu = 12;
m.newstatus(2);
m.node.getNode('mfd-title',1).setValue('TOPO');
},
MENUkeyItems: {},
set_MENUkeyItems: func {
me.MENUkeyItems = {
'MAIN MENU': [
[['ROUTE MANAGER'], func { me.MENUsoftkey('ROUTE MANAGER') }],
[['GENERAL OPTIONS'], func { me.MENUsoftkey('GENERAL OPTIONS') }],
],
'ROUTE MANAGER': [
[[sprintf('%sACTIVATE ROUTE MANAGER', getprop('/autopilot/route-manager/active') ? 'DES' : ''), ' '],
func {
getprop('/autopilot/route-manager/route/num') or return;
setprop('/autopilot/route-manager/current-wp', 0);
var v = getprop('/autopilot/route-manager/active');
setprop('/autopilot/route-manager/active', !v);
me.mud.node.getNode('line[' ~ me.mud.selected.first_line ~ ']').setValue(sprintf('%sACTIVATE ROUTE MANAGER', v ? '' : 'DES'));
}],
[['SEARCH AIRPORT'], void],
[['SEARCH NAVAID'], void],
[['SEARCH FIX'], void],
[['BACK'], func { me.MENUsoftkey('MAIN MENU') }],
],
'BACKLIGHT LEVEL': [
[['HIGH'], func { setprop('/instrumentation/zkv1000/emission', 1.0) }],
[['MEDIUM HIGH'], func { setprop('/instrumentation/zkv1000/emission', 0.6) }],
[['MEDIUM LOW'], func { setprop('/instrumentation/zkv1000/emission', 0.4) }],
[['LOW'], func { setprop('/instrumentation/zkv1000/emission', 0.2) }],
[[' ', 'BACK'], func { me.MENUsoftkey('GENERAL OPTIONS') }],
],
'GENERAL OPTIONS': [
[['ADJUST BACKLIGHT'], func { me.MENUsoftkey('BACKLIGHT LEVEL') }],
[['MAX NAVAIDS SHOW'], void],
],
};
},
};
var powerOn = func {
device[0] = deviceClass.new(0);
device[1] = deviceClass.new(1);
settimer(setListeners, 5);
}