... | ... |
@@ -82,8 +82,25 @@ var setListeners = func { |
82 | 82 |
flightdeck[c].map.layers.route.onCurrentWaypointChange(props.globals.getNode('/autopilot/route-manager/current-wp')), |
83 | 83 |
0, 1); |
84 | 84 |
|
85 |
- prop = zkv.getPath() ~ '/serviceable'; |
|
86 |
- data.listeners[prop] = setlistener(prop, func (n) if (!n.getValue()) zkv1000.powerOff, 0, 0); |
|
85 |
+ if (zkv.getChild('serviceable') != nil) { |
|
86 |
+ prop = zkv.getPath() ~ '/serviceable'; |
|
87 |
+ data.listeners[prop] = setlistener(prop, |
|
88 |
+ func (n) { |
|
89 |
+ var type = n.getType(); |
|
90 |
+ if (type == 'BOOL') { |
|
91 |
+ if (n.getBoolValue()) |
|
92 |
+ zkv1000.powerOn(); |
|
93 |
+ else |
|
94 |
+ zkv1000.powerOff(); |
|
95 |
+ } |
|
96 |
+ elsif (type == 'INT' or type == 'LONG' or type == 'FLOAT' or type == 'DOUBLE') { |
|
97 |
+ if (n.getValue() > 12) |
|
98 |
+ zkv1000.powerOn(); |
|
99 |
+ else |
|
100 |
+ zkv1000.powerOff(); |
|
101 |
+ } |
|
102 |
+ }, 0, 0); |
|
103 |
+ } |
|
87 | 104 |
|
88 | 105 |
# the timer isn't necessary anymore |
89 | 106 |
data.timers.listeners.stop(); |
... | ... |
@@ -186,30 +203,57 @@ var deviceClass = { |
186 | 203 |
return m; |
187 | 204 |
}, |
188 | 205 |
off: func { |
206 |
+ var name = me.name; |
|
189 | 207 |
foreach (var timer; keys(me.timers)) { |
190 | 208 |
me.timers[timer].stop(); |
191 | 209 |
delete(me.timers, timer); |
192 | 210 |
} |
193 | 211 |
foreach (var member; keys(me)) { |
194 |
- if (contains(me[member], 'off')) me[class].off(); |
|
212 |
+ if (member == 'parents') |
|
213 |
+ continue; |
|
214 |
+ if (contains(me[member], 'parents')) { |
|
215 |
+ if (contains(me[member].parents[0], 'new') |
|
216 |
+ and typeof(me[member].parents[0].new) == 'func') { |
|
217 |
+ if (contains(me[member].parents[0], 'removeAllChildren') |
|
218 |
+ and !contains(me[member].parents[0], 'setVisible')) # this one is a props node, but not canvas |
|
219 |
+ me[member].removeAllChildren(); |
|
220 |
+ elsif (contains(me[member].parents[0], 'off') |
|
221 |
+ and typeof(me[member].parents[0].off) == 'func') |
|
222 |
+ me[member].off(); |
|
223 |
+ } |
|
224 |
+ } |
|
225 |
+ } |
|
226 |
+ foreach (var member; keys(me)) { |
|
227 |
+ if (member == 'parents') |
|
228 |
+ continue; |
|
195 | 229 |
delete(me, member); |
196 | 230 |
} |
231 |
+ zkv.getNode(name).setValue('status', 0); |
|
232 |
+ msg(name ~ ' switched off'); |
|
197 | 233 |
}, |
198 | 234 |
}; |
199 | 235 |
|
200 | 236 |
var powerOff = func { |
201 |
- foreach (var listener; keys(data.listeners)) |
|
237 |
+ foreach (var listener; keys(data.listeners)) { |
|
238 |
+ if (listener == '/instrumentation/zkv1000/serviceable') |
|
239 |
+ continue; |
|
202 | 240 |
removelistener(data.listeners[listener]); |
241 |
+ delete(data.listeners, listener); |
|
242 |
+ } |
|
203 | 243 |
|
204 | 244 |
foreach (var timer; keys(data.timers)) { |
205 | 245 |
data.timers[timer].stop(); |
246 |
+ if (timer == '20Hz' or timer == '1Hz') |
|
247 |
+ continue; |
|
206 | 248 |
delete(data.timers, timer); |
207 | 249 |
} |
208 | 250 |
|
251 |
+ foreach (var k; keys(autopilot)) |
|
252 |
+ delete(autopilot, k); |
|
253 |
+ |
|
209 | 254 |
foreach (var name; keys(flightdeck)) { |
210 | 255 |
flightdeck[name].off(); |
211 |
- delete(flightdeck, name); |
|
212 |
- setprop(zkv.getPath() ~ '/' ~ name ~ '/status', 0); |
|
256 |
+ flightdeck[name] = nil; |
|
213 | 257 |
} |
214 | 258 |
} |
215 | 259 |
|
... | ... |
@@ -219,22 +263,26 @@ var powerOn = func { |
219 | 263 |
return; |
220 | 264 |
} |
221 | 265 |
|
222 |
- if (contains(data.listeners, 'autopower')) |
|
223 |
- removelistener(data.listeners.autopower); |
|
266 |
+ if (contains(data.listeners, '/instrumentation/zkv1000/serviceable')) { |
|
267 |
+ removelistener(data.listeners['/instrumentation/zkv1000/serviceable']); |
|
268 |
+ delete(data.listeners, '/instrumentation/zkv1000/serviceable'); |
|
269 |
+ } |
|
224 | 270 |
|
225 | 271 |
foreach (var freq; keys(data.timers)) |
226 | 272 |
data.timers[freq].start(); |
227 | 273 |
|
228 | 274 |
foreach (var name; keys(flightdeck)) |
229 | 275 |
if (zkv.getNode(name) != nil) |
276 |
+ if (zkv.getNode(name).getValue('status') == nil or zkv.getNode(name).getValue('status') == 0) |
|
230 | 277 |
# thread.newthread(func { |
231 | 278 |
flightdeck[name] = deviceClass.new(name); |
232 | 279 |
# }); |
233 | 280 |
|
234 |
- autopilot = APClass.new(); |
|
281 |
+ if (! contains(autopilot, 'parents')) |
|
282 |
+ autopilot = APClass.new(); |
|
235 | 283 |
|
236 | 284 |
if (! contains(data.timers, 'listeners')) { |
237 |
- data.timers.listeners = maketimer(5, setListeners); |
|
285 |
+ data.timers.listeners = maketimer(1, setListeners); |
|
238 | 286 |
data.timers.listeners.singleShot = 1; |
239 | 287 |
data.timers.listeners.start(); |
240 | 288 |
} |
... | ... |
@@ -306,12 +306,33 @@ var displayClass = { |
306 | 306 |
#}}} |
307 | 307 |
|
308 | 308 |
off: func { |
309 |
- foreach(var timer; keys(me.timers2)) { |
|
310 |
- me.timers2[timer].stop(); |
|
311 |
- delete(me.timers2, timer); |
|
309 |
+ me.parents[0]._updateRadio = func; # because of the settimers... |
|
310 |
+ me.parents[0].updateEIS = func; |
|
311 |
+ foreach(var timer; keys(me.timers)) { |
|
312 |
+ me.timers[timer].stop(); |
|
313 |
+ delete(me.timers, timer); |
|
312 | 314 |
} |
313 |
- me.screen.del(); |
|
314 |
- me.display.del(); |
|
315 |
+ foreach (var e; keys(me.screenElements)) { |
|
316 |
+ if (typeof(me.screenElements[e]) != 'nil') |
|
317 |
+ me.screenElements[e].hide(); |
|
318 |
+ delete(me.screenElements, e); |
|
319 |
+ } |
|
320 |
+ foreach (var e; keys(me.screenElements)) { |
|
321 |
+ if (typeof(me.screenElements[e]) != 'nil') |
|
322 |
+ me.screenElements[e].hide(); |
|
323 |
+ delete(me.screenElements, e); |
|
324 |
+ } |
|
325 |
+ foreach (var e; keys(me.screenElements)) { |
|
326 |
+ if (typeof(me.screenElements[e]) != 'nil') |
|
327 |
+ me.screenElements[e].hide(); |
|
328 |
+ delete(me.screenElements, e); |
|
329 |
+ } |
|
330 |
+ me.screen.setVisible(0); |
|
331 |
+ settimer(func { |
|
332 |
+ me.screen.removeAllChildren(); |
|
333 |
+ me.screen.del(); |
|
334 |
+ me.display.del(); |
|
335 |
+ }, 0.1); |
|
315 | 336 |
}, |
316 | 337 |
|
317 | 338 |
# temporary Widget Display for HDG and CRS modification {{{ |
... | ... |
@@ -78,6 +78,13 @@ var mapClass = { |
78 | 78 |
|
79 | 79 |
return m; |
80 | 80 |
}, |
81 |
+ off: func { |
|
82 |
+ me.mapOrientation.setVisible(0); |
|
83 |
+ foreach (var layer; keys(me.layers)) { |
|
84 |
+ me.layers[layer].off(); |
|
85 |
+ delete(me.layers, layer); |
|
86 |
+ } |
|
87 |
+ }, |
|
81 | 88 |
changeZoom : func (d = 0) { |
82 | 89 |
me.device.data.zoom = math.max(2, math.min(19, me.device.data.zoom + d)); |
83 | 90 |
me.device.data['range-nm'] = me.device.display.display.get('view[1]') / 2 * 84.53 * math.cos(data.lat) / math.pow(2, me.device.data.zoom); |
... | ... |
@@ -403,6 +403,10 @@ var MapNavaids = { |
403 | 403 |
|
404 | 404 |
return m; |
405 | 405 |
}, |
406 |
+ off: func { |
|
407 |
+ me._group.setVisible(0); |
|
408 |
+ me._group.removeAllChildren(); |
|
409 |
+ }, |
|
406 | 410 |
update : func { |
407 | 411 |
me._group._node.getNode('ref-lat', 1).setDoubleValue(data.lat); |
408 | 412 |
me._group._node.getNode('ref-lon', 1).setDoubleValue(data.lon); |
... | ... |
@@ -219,6 +219,11 @@ var MapRoute = { |
219 | 219 |
|
220 | 220 |
return m; |
221 | 221 |
}, |
222 |
+ off: func { |
|
223 |
+ me.setVisible(0); |
|
224 |
+ me.group.setVisible(0); |
|
225 |
+ me.group.removeAllChildren(); |
|
226 |
+ }, |
|
222 | 227 |
update: func { |
223 | 228 |
me.visibility != 0 or return; |
224 | 229 |
me.group._node |
... | ... |
@@ -96,6 +96,10 @@ var MapTcas = { |
96 | 96 |
return m; |
97 | 97 |
}, |
98 | 98 |
|
99 |
+ off: func { |
|
100 |
+ me.setVisible(0); |
|
101 |
+ }, |
|
102 |
+ |
|
99 | 103 |
update : func() { |
100 | 104 |
if (me.device.data.tcas == 0) |
101 | 105 |
return; |
... | ... |
@@ -34,6 +34,12 @@ var MapTiles = { |
34 | 34 |
return m; |
35 | 35 |
}, |
36 | 36 |
|
37 |
+ off: func { |
|
38 |
+ me.group.setVisible(0); |
|
39 |
+ me.group.removeAllChildren(); |
|
40 |
+ me.group.del(); |
|
41 |
+ }, |
|
42 |
+ |
|
37 | 43 |
setVisible : func (v) { |
38 | 44 |
if (v != me.visibility) { |
39 | 45 |
me.visibility = v; |
... | ... |
@@ -8,6 +8,11 @@ var pageClass = { |
8 | 8 |
return m; |
9 | 9 |
}, |
10 | 10 |
|
11 |
+ off: func { |
|
12 |
+ me.del(); |
|
13 |
+ me.page.removeAllChildren(); |
|
14 |
+ }, |
|
15 |
+ |
|
11 | 16 |
del : func (id = nil) { |
12 | 17 |
if (id != nil and typeof(id) == 'scalar') { |
13 | 18 |
delete(me.state, id); |