From: Torsten Dreyer Date: Mon, 28 Jun 2010 16:15:36 +0000 (+0200) Subject: Fix three bugs in the new autopilot code X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=598d46529fb9865a9e47390072ccfde795a2c1d1;p=flightgear.git Fix three bugs in the new autopilot code - Respect the global inverted flag in the get_output() method - Check the clock state before processing the static R/S inputs - Emit debug output only on a state change --- diff --git a/src/Autopilot/flipflop.cxx b/src/Autopilot/flipflop.cxx index c82981849..076b2db48 100644 --- a/src/Autopilot/flipflop.cxx +++ b/src/Autopilot/flipflop.cxx @@ -334,14 +334,15 @@ bool RSFlipFlopImplementation::getState( double dt, DigitalComponent::InputMap i bool ClockedFlipFlopImplementation::getState( double dt, DigitalComponent::InputMap input, bool & q ) { - if( RSFlipFlopImplementation::getState( dt, input, q ) ) - return true; - bool c = input.get_value("clock"); bool raisingEdge = c && !_clock; _clock = c; + if( RSFlipFlopImplementation::getState( dt, input, q ) ) + return true; + + if( !raisingEdge ) return false; //signal no change return onRaisingEdge( input, q ); } @@ -452,7 +453,7 @@ void FlipFlop::update( bool firstTime, double dt ) q0 = q = get_output(); - if( _implementation->getState( dt, _input, q ) ) { + if( _implementation->getState( dt, _input, q ) && q0 != q ) { set_output( q ); if(_debug) { diff --git a/src/Autopilot/logic.cxx b/src/Autopilot/logic.cxx index 0b5895511..1400b6fb8 100644 --- a/src/Autopilot/logic.cxx +++ b/src/Autopilot/logic.cxx @@ -44,7 +44,8 @@ void Logic::set_output( bool value ) bool Logic::get_output() const { OutputMap::const_iterator it = _output.begin(); - return it != _output.end() ? (*it).second->getValue() : false; + bool q = it != _output.end() ? (*it).second->getValue() : false; + return _inverted ? !q : q; } void Logic::update( bool firstTime, double dt )