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
This commit is contained in:
parent
bed15f5315
commit
598d46529f
2 changed files with 7 additions and 5 deletions
|
@ -334,14 +334,15 @@ bool RSFlipFlopImplementation::getState( double dt, DigitalComponent::InputMap i
|
||||||
|
|
||||||
bool ClockedFlipFlopImplementation::getState( double dt, DigitalComponent::InputMap input, bool & q )
|
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 c = input.get_value("clock");
|
||||||
bool raisingEdge = c && !_clock;
|
bool raisingEdge = c && !_clock;
|
||||||
|
|
||||||
_clock = c;
|
_clock = c;
|
||||||
|
|
||||||
|
if( RSFlipFlopImplementation::getState( dt, input, q ) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
|
||||||
if( !raisingEdge ) return false; //signal no change
|
if( !raisingEdge ) return false; //signal no change
|
||||||
return onRaisingEdge( input, q );
|
return onRaisingEdge( input, q );
|
||||||
}
|
}
|
||||||
|
@ -452,7 +453,7 @@ void FlipFlop::update( bool firstTime, double dt )
|
||||||
|
|
||||||
q0 = q = get_output();
|
q0 = q = get_output();
|
||||||
|
|
||||||
if( _implementation->getState( dt, _input, q ) ) {
|
if( _implementation->getState( dt, _input, q ) && q0 != q ) {
|
||||||
set_output( q );
|
set_output( q );
|
||||||
|
|
||||||
if(_debug) {
|
if(_debug) {
|
||||||
|
|
|
@ -44,7 +44,8 @@ void Logic::set_output( bool value )
|
||||||
bool Logic::get_output() const
|
bool Logic::get_output() const
|
||||||
{
|
{
|
||||||
OutputMap::const_iterator it = _output.begin();
|
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 )
|
void Logic::update( bool firstTime, double dt )
|
||||||
|
|
Loading…
Reference in a new issue