Am Donnerstag, 1. Januar 2009 schrieben Sie: > On 01/01/2009 04:42 AM, you wrote: > > The usage of the electrical/outputs nodes is somewhat messy: > > I agree. > > > dme.cxx interprets it as boolean, anything other than 0 is "on" > > adf.cxx interprets it as "kind of boolean", anything below 1.0 is "off" > > navradio.cxx thinks, everything greater than 1.0 is "on" > > turn_indicator.cxx normalizes its value relative to 12.0 > > And some others don't normalize, but act like 8.0 is sufficient, > which probably means that 12.0 is "normal". > > > Thats why I initialized the properties to the given values. From my > > perspective, a normalized property should be better than a absolute value > > to cope with different bus voltages. > > I agree that using a "voltage-norm" property, normalized to the > interval [0,1] is a desirable goal. But how do we get there? > > I like to think about things from the users' point of view, > which means, in this case, asking what is best for the fleet > as a whole. It would be good for the fleet to have a standard > set of well-behaved instruments that can be used in many > aircraft. So how do we do this, without redesigning the > electrical bus in each airplane, i.e. rewriting a gazillion > lines of poorly-documented XML, nasal, and c++? > > Here's a possibly-constructive suggestion. After reading your > note, I started thinking that maybe we could add one property, > something like "voltage-bus-is-normalized-to" and set it to > 1.0 for some aircraft and 12 or 28 in some others. > > I'm not sure, but I'm hoping that something like that would > permit the construction of a _compatible_ set of instruments. > > Comments? Suggestions?
Hi John I am moving this to the flightgear-devel list so we have a bigger chance of getting some valueable comments or suggestions ;-) First a tiny abstract of what's going on: John suggested to me a patch for the SenecaII defining the values in /systems/electrical/outputs/* to be of value 12 and type double. I rejected his request, because I think this hides the "creative" way instruments interpret this value. For example: - dme.cxx interprets it as boolean, anything other than 0 is "on" - adf.cxx interprets it as "kind of boolean", anything below 1.0 is "off" - navradio.cxx thinks, everything greater than 1.0 is "on" - turn_indicator.cxx normalizes its value relative to 12.0 We both agree on having some kind of "normalized" supply property as a [0..1] interval should be the most flexible way of defining power for an instrument and let the instrument itself decide how to interprete this value. We don't think, the current implementation matches the quality standard of FlightGear (remember: let's do things right) Changing the current implementation might break many instruments and aircraft and has to be carefully thought of. Being backward compatible is mandatory when touching this issue. Please find attached a patch as a proof of concept that has been in my head for a while now. Here is a short description of what it does: Check if /systems/electrical/outputs/dme exists (but don't create) If yes: use this node's value for guessing if power is available (for b.c.) If not: check if /instrumentation/dme/supply-voltage-norm exists If yes: check if this node's value is greater than the value of /instrumentation/dme/supply-voltage-min If no: assume power is available. It's now the responsibility of the electrical system (or the aircraft config file) to provide a value to the /instrumentation/dme/supply-voltage-norm node. It is independent of the absolute voltage of the system itself or the operating voltage of the instrument. I'd be happy to refine this concept and provide a patch for the Instruments using the old /systems/electrical/output properties if the community agrees on that idea. Happy and peaceful 2009 to everybody. Torsten
Index: dme.cxx =================================================================== RCS file: /var/cvs/FlightGear-0.9/source/src/Instrumentation/dme.cxx,v retrieving revision 1.20 diff -u -p -r1.20 dme.cxx --- dme.cxx 25 Dec 2008 23:11:44 -0000 1.20 +++ dme.cxx 1 Jan 2009 20:19:24 -0000 @@ -69,7 +69,18 @@ DME::init () _latitude_node = fgGetNode("/position/latitude-deg", true); _altitude_node = fgGetNode("/position/altitude-ft", true); _serviceable_node = node->getChild("serviceable", 0, true); - _electrical_node = fgGetNode("/systems/electrical/outputs/dme", true); + _electrical_node = fgGetNode("/systems/electrical/outputs/dme", false); + if( _electrical_node != NULL ) { + SG_LOG(SG_COCKPIT, SG_WARN, "dme is using deprecated electrical output node, please update to dme-norm"); + _electrical_norm_node = NULL; + } else { + _electrical_norm_node = node->getChild("supply-voltage-norm", false); + _electrical_min_node = node->getChild("min-supply-voltage-norm", false); + if( _electrical_norm_node == NULL ) { + SG_LOG(SG_COCKPIT, SG_WARN, "no supply voltage defined for dme, assuming dme allways on."); + } + + } SGPropertyNode *fnode = node->getChild("frequencies", 0, true); _source_node = fnode->getChild("source", 0, true); _frequency_node = fnode->getChild("selected-mhz", 0, true); @@ -79,6 +90,29 @@ DME::init () _time_node = node->getChild("indicated-time-min", 0, true); } +/* + Check if the device has (electrical) power for operation. + Be backwards compatible to old /systems/electrical/outputs/dme property +*/ +bool +DME::hasPower() +{ + // backward compatibility + if( _electrical_node != NULL ) + return _electrical_node->getBoolValue(); + + if( _electrical_norm_node != NULL ) { + // return true, if power-norm is greater than minimum required power + double min = 0.8; + if( _electrical_min_node != NULL ) + min = _electrical_min_node->getDoubleValue(); + return _electrical_norm_node->getDoubleValue() > min; + } + + // nothing defined, assume power is on + return true; +} + void DME::update (double delta_time_sec) { @@ -114,7 +148,7 @@ DME::update (double delta_time_sec) // If it's off, don't bother. if (!_serviceable_node->getBoolValue() || - !_electrical_node->getBoolValue() || + !hasPower() || !_transmitter_valid) { _last_distance_nm = 0; _in_range_node->setBoolValue(false); Index: dme.hxx =================================================================== RCS file: /var/cvs/FlightGear-0.9/source/src/Instrumentation/dme.hxx,v retrieving revision 1.8 diff -u -p -r1.8 dme.hxx --- dme.hxx 26 Dec 2008 12:28:05 -0000 1.8 +++ dme.hxx 1 Jan 2009 20:19:24 -0000 @@ -46,12 +46,15 @@ private: void search (double frequency, double longitude_rad, double latitude_rad, double altitude_m); + bool hasPower(); SGPropertyNode_ptr _longitude_node; SGPropertyNode_ptr _latitude_node; SGPropertyNode_ptr _altitude_node; SGPropertyNode_ptr _serviceable_node; SGPropertyNode_ptr _electrical_node; + SGPropertyNode_ptr _electrical_norm_node; + SGPropertyNode_ptr _electrical_min_node; SGPropertyNode_ptr _source_node; SGPropertyNode_ptr _frequency_node;
------------------------------------------------------------------------------
_______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel