]> git.mxchange.org Git - flightgear.git/blobdiff - src/Autopilot/flipflop.cxx
toggle fullscreen: also adapt GUI plane when resizing
[flightgear.git] / src / Autopilot / flipflop.cxx
index c829818499585a6d6f4809b335ef01d6326499d8..b22adfa9ae6ab2f90ec9c21a038f0f07ed320a53 100644 (file)
 #include "inputvalue.hxx"
 #include <Main/fg_props.hxx>
 
+using std::map;
+using std::string;
+using std::endl;
+using std::cout;
+
 namespace FGXMLAutopilot {
 
 /**
@@ -267,7 +272,7 @@ public:
    * @brief constructor for a MonoFlopImplementation
    * @param rIsDominant boolean flag to signal if RESET shall be dominant (true) or SET shall be dominant (false)
    */
-  MonoFlopImplementation( bool rIsDominant = true ) : JKFlipFlopImplementation( rIsDominant ) {}
+  MonoFlopImplementation( bool rIsDominant = true ) : JKFlipFlopImplementation( rIsDominant ), _t(0.0) {}
   /**
    * @brief evaluates the output state from the input lines and returns to the stable state 
    * after expiry of the internal timer
@@ -334,14 +339,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,13 +458,13 @@ 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) {
       cout << "updating flip-flop \"" << get_name() << "\"" << endl;
       cout << "prev. Output:" << q0 << endl;
-      for( InputMap::const_iterator it = _input.begin(); it != _input.end(); it++ ) 
+      for( InputMap::const_iterator it = _input.begin(); it != _input.end(); ++it ) 
         cout << "Input \"" << (*it).first << "\":" << (*it).second->test() << endl;
       cout << "new Output:" << q << endl;
     }