]> git.mxchange.org Git - flightgear.git/commitdiff
Fix three bugs in the new autopilot code
authorTorsten Dreyer <Torsten@t3r.de>
Mon, 28 Jun 2010 16:15:36 +0000 (18:15 +0200)
committerTorsten Dreyer <Torsten@t3r.de>
Mon, 28 Jun 2010 16:20:30 +0000 (18:20 +0200)
- 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

src/Autopilot/flipflop.cxx
src/Autopilot/logic.cxx

index c829818499585a6d6f4809b335ef01d6326499d8..076b2db48eae542ecdeba2013170a8d3bb36acb2 100644 (file)
@@ -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) {
index 0b5895511ba0009abace8d47bf68f4785b7c0389..1400b6fb890d928935c35a54cbf8e6594fb73707 100644 (file)
@@ -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 )