Hi Csaba,

no problem. I've attached a nasal script to put in whatever aircraft you want. In this script you'll find several listeners linked to several properties that can be modified using instrument-failures.xml or system-failures.xml.

Then open the Equipment -> Instrument failures dialog and uncheck Airspeed Indicator, then Apply, you will see in the terminal that all the listeners have been triggered, which is not not correct.

After the patch have been applied, reopen the dialog, uncheck again airspeed indicator, then you'll find that only the listener linked to "/instrumentation/airspeed-indicator/serviceable" will be fired, as it should be.

I've grep'ed in FG sources to find out if copy_from_pui has an other caller than applyValues but it is not the case, and it is not public (AFAIK C++ ;)), so I think that the change is quite safe. Anyway you may think the problem is deeper... in listeners code for example, but my knowledge about FG sources is not great enough to check in this place :D.

regards
seb

Csaba Halász wrote :
On Fri, Feb 20, 2009 at 8:46 AM, Sébastien MARQUE <seb.mar...@free.fr> wrote:
actually I already use a listener that only fires then the value really
change. I've looked in Nasal scripting wiki page and globals.nas to be
sure, and tried the other possible values for the fourth argument of
setlistener, with no more succes, that's why I looked in FG sources. If
changes in sources can't be applied or don't have the expected effects
I've got an other workaround, but it is quite an ugly one.

If the "listeners that only fire on real change" don't work then it is
a bug that should be fixed. Can you give instructions how to reproduce
this problem?
Not that I have anything against your patch, looks harmless enough :)

var init_failures = func {
    foreach (var f; keys(failure)) {
        #props.globals.getNode(f ~ "/serviceable", 1).setBoolValue(1);
        setlistener(f ~ "/serviceable", failure[f]);
    }
    print("Init failures system... OK");
}

var keep_serviceable = func (s) {
    setprop(s ~ "/serviceable", 1);
}

var failure = {
    "/instrumentation/airspeed-indicator" : func {
        #keep_serviceable("/instrumentation/airspeed-indicator");
        props.globals.getNode("/instrumentation/aliases/airspeed").unalias();
        print("airspeed indicator failure");
        shake_airspeed_indicator();
    },
    #"/instrumentation/attitude-indicator" : func {
    #   print("attitude indicator failure");
    #},
    "/instrumentation/altimeter" : func { 
        props.globals.getNode("/instrumentation/aliases/altitude").unalias();
        print("altimeter failure");
    },
    "/instrumentation/turn-indicator" : func { 
        props.globals.getNode("/instrumentation/aliases/turn-rate").unalias();
        print("turn indicator failure"); 
    },
    "/instrumentation/slip-skid-ball" : func { 
        props.globals.getNode("/instrumentation/aliases/turn-rate").unalias();
        print("slip-skid ball failure"); 
    },
    "/instrumentation/heading-indicator" : func { 
        props.globals.getNode("/instrumentation/aliases/heading").unalias();
        print("heading indicator failure"); 
    },
    "/instrumentation/vertical-speed-indicator" : func { 
        
props.globals.getNode("/instrumentation/aliases/vertical-speed").unalias();
        print("vertical speed indicator failure"); 
    },
    "/systems/static" : func {
        getprop("/systems/static/serviceable") == 0 or return;
        # we still need the calculated values by FG to compute indicated values
        keep_serviceable("/systems/static");
        props.globals.getNode("/instrumentation/aliases/airspeed").unalias();
        props.globals.getNode("/instrumentation/aliases/altitude").unalias();
        
props.globals.getNode("/instrumentation/aliases/vertical-speed").unalias();
        
props.globals.getNode("/instrumentation/aliases/vertical-speed").setValue(0.0);
        compute_airspeed();
        print("static failure"); 
    },
    "/systems/pitot" : func { 
        # FG seems to already compute a correct indicated airspeed 
        # already for this case
        print("pitot failure"); 
    },
    "/systems/vacuum" : func { 
        props.globals.getNode("/instrumentation/aliases/heading").unalias();
        print("vacuum failure"); 
    }
};

var internal_airspeed = 
props.globals.getNode("/instrumentation/airspeed-indicator/indicated-speed-kt");
var indicated_airpeed = 
props.globals.getNode("/instrumentation/aliases/airspeed");
var compute_airspeed = func {
    # workaround waiting for better calculation, 
    # I think it should be dependant of environment pressure (altitude?).
    indicated_airpeed.setValue(1.1 * internal_airspeed.getValue());
    settimer(compute_airspeed, 0);
}

var shake_airspeed_indicator = func {
    indicated_airpeed.setValue((2.5 - (rand() * 5)) + 
internal_airspeed.getValue());
    settimer(shake_airspeed_indicator, 0.1);
}
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to