From 3a6315031e8f82e958cc5465ed687d3ed8c91216 Mon Sep 17 00:00:00 2001 From: mfranz Date: Wed, 6 May 2009 18:49:06 +0000 Subject: [PATCH] door.setpos(): stop movement before setting absolute value timer: stop and save/restore on reset --- Nasal/aircraft.nas | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Nasal/aircraft.nas b/Nasal/aircraft.nas index 5882f57be..076a2ddbf 100644 --- a/Nasal/aircraft.nas +++ b/Nasal/aircraft.nas @@ -62,6 +62,7 @@ var door = { }, # door.setpos(double) -> set ./position-norm without movement setpos: func(pos) { + me.stop(); me.positionN.setValue(pos); me.target = pos < 0.5; me; @@ -428,6 +429,14 @@ var timer = { m.interval = res; m.loopid = 0; m.running = 0; + m.reinitL = setlistener("/sim/signals/reinit", func(n) { + if (n.getValue()) { + m.stop(); + m.total = m.node.getValue(); + } else { + m.node.setDoubleValue(m.total); + } + }); if (save) { data.add(m.node); m.saveL = setlistener("/sim/signals/save", func m._save_()); @@ -438,13 +447,15 @@ var timer = { }, del: func { me.stop(); + removelistener(me.reinitL); if (me.saveL != nil) removelistener(me.saveL); }, start: func { me.running and return; me.last_systime = me.systimeN.getValue(); - me.interval != nil and me._loop_(me.loopid); + if (me.interval != nil) + me._loop_(me.loopid); me.running = 1; me; }, @@ -922,6 +933,7 @@ var wind_speed_from = func(azimuth) { } + # returns true airspeed for given indicated airspeed [kt] and altitude [m] # var kias_to_ktas = func(kias, altitude) {