From 6893327431a9d06c363a6cb00acccc0b171a4a49 Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Mon, 28 Jun 2010 18:15:36 +0200 Subject: [PATCH] Fix two bugs in the new autopilot code - Respect the global inverted flag in the get_output() method - Emit debug output only on a state change --- src/Autopilot/flipflop.cxx | 9 +++++---- src/Autopilot/logic.cxx | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) 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 )