Autopilot components: Switch to using the subsystem name.
The _name, get_name(), and set_name() variables and functions have been removed. The Component::get_name() function is now handled by Subsystem::subsystemId(), and Component::set_name() replaced by SGSubsystem::set_name(). The Component::_name variable is replaced by SGSubsystem::_subsystemId.
This commit is contained in:
parent
332c240b38
commit
0eb8716d45
8 changed files with 15 additions and 28 deletions
|
@ -168,15 +168,14 @@ Autopilot::Autopilot( SGPropertyNode_ptr rootNode, SGPropertyNode_ptr configNode
|
|||
}
|
||||
|
||||
Component * component = (*componentForge[childName])(*prop_root, *node);
|
||||
if( component->get_name().length() == 0 ) {
|
||||
if( component->subsystemId().length() == 0 ) {
|
||||
std::ostringstream buf;
|
||||
buf << "unnamed_component_" << i;
|
||||
component->set_name( buf.str() );
|
||||
}
|
||||
|
||||
double updateInterval = node->getDoubleValue( "update-interval-secs", 0.0 );
|
||||
|
||||
SG_LOG( SG_AUTOPILOT, SG_DEBUG, "adding autopilot component \"" << childName << "\" as \"" << component->get_name() << "\" with interval=" << updateInterval );
|
||||
SG_LOG( SG_AUTOPILOT, SG_DEBUG, "adding autopilot component \"" << childName << "\" as \"" << component->subsystemId() << "\" with interval=" << updateInterval );
|
||||
add_component(component,updateInterval);
|
||||
}
|
||||
}
|
||||
|
@ -203,14 +202,14 @@ void Autopilot::add_component( Component * component, double updateInterval )
|
|||
if( component == NULL ) return;
|
||||
|
||||
// check for duplicate name
|
||||
std::string name = component->get_name();
|
||||
std::string name = component->subsystemId();
|
||||
for( unsigned i = 0; get_subsystem( name.c_str() ) != NULL; i++ ) {
|
||||
std::ostringstream buf;
|
||||
buf << component->get_name() << "_" << i;
|
||||
buf << component->subsystemId() << "_" << i;
|
||||
name = buf.str();
|
||||
}
|
||||
if( name != component->get_name() )
|
||||
SG_LOG( SG_AUTOPILOT, SG_WARN, "Duplicate autopilot component " << component->get_name() << ", renamed to " << name );
|
||||
if( name != component->subsystemId() )
|
||||
SG_LOG( SG_AUTOPILOT, SG_WARN, "Duplicate autopilot component " << component->subsystemId() << ", renamed to " << name );
|
||||
|
||||
set_subsystem( name.c_str(), component, updateInterval );
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ bool Component::configure( SGPropertyNode& cfg_node,
|
|||
{
|
||||
if ( cfg_name == "name" )
|
||||
{
|
||||
_name = cfg_node.getStringValue();
|
||||
set_name(cfg_node.getStringValue());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -102,18 +102,6 @@ public:
|
|||
virtual bool configure( SGPropertyNode& prop_root,
|
||||
SGPropertyNode& cfg );
|
||||
|
||||
/**
|
||||
* @brief getter for the name property
|
||||
* @return the name of the component
|
||||
*/
|
||||
inline const std::string& get_name() const { return _name; }
|
||||
|
||||
/**
|
||||
* @brief setter for the name property
|
||||
* @param name the name of the component
|
||||
*/
|
||||
inline void set_name( const std::string & name ) { _name = name; }
|
||||
|
||||
/**
|
||||
* @brief check if this component is enabled as configured in the
|
||||
* <enable> section
|
||||
|
|
|
@ -814,17 +814,17 @@ void DigitalFilter::update( bool firstTime, double dt)
|
|||
switch( _initializeTo ) {
|
||||
|
||||
case INITIALIZE_INPUT:
|
||||
SG_LOG(SG_AUTOPILOT,SG_DEBUG, "First time initialization of " << get_name() << " to " << _valueInput.get_value() );
|
||||
SG_LOG(SG_AUTOPILOT,SG_DEBUG, "First time initialization of " << subsystemId() << " to " << _valueInput.get_value() );
|
||||
_implementation->initialize( _valueInput.get_value() );
|
||||
break;
|
||||
|
||||
case INITIALIZE_OUTPUT:
|
||||
SG_LOG(SG_AUTOPILOT,SG_DEBUG, "First time initialization of " << get_name() << " to " << get_output_value() );
|
||||
SG_LOG(SG_AUTOPILOT,SG_DEBUG, "First time initialization of " << subsystemId() << " to " << get_output_value() );
|
||||
_implementation->initialize( get_output_value() );
|
||||
break;
|
||||
|
||||
default:
|
||||
SG_LOG(SG_AUTOPILOT,SG_DEBUG, "First time initialization of " << get_name() << " to (uninitialized)" );
|
||||
SG_LOG(SG_AUTOPILOT,SG_DEBUG, "First time initialization of " << subsystemId() << " to (uninitialized)" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -463,7 +463,7 @@ bool FlipFlop::configure( SGPropertyNode& cfg_node,
|
|||
void FlipFlop::update( bool firstTime, double dt )
|
||||
{
|
||||
if( _implementation == NULL ) {
|
||||
SG_LOG( SG_AUTOPILOT, SG_ALERT, "No flip-flop implementation for " << get_name() << endl );
|
||||
SG_LOG( SG_AUTOPILOT, SG_ALERT, "No flip-flop implementation for " << subsystemId() << endl );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -475,7 +475,7 @@ void FlipFlop::update( bool firstTime, double dt )
|
|||
set_output( q );
|
||||
|
||||
if(_debug) {
|
||||
cout << "updating flip-flop \"" << get_name() << "\"" << endl;
|
||||
cout << "updating flip-flop \"" << subsystemId() << "\"" << endl;
|
||||
cout << "prev. Output:" << q0 << endl;
|
||||
for( InputMap::const_iterator it = _input.begin(); it != _input.end(); ++it )
|
||||
cout << "Input \"" << (*it).first << "\":" << (*it).second->test() << endl;
|
||||
|
|
|
@ -63,7 +63,7 @@ void Logic::update( bool firstTime, double dt )
|
|||
if( a != q ) {
|
||||
using std::endl;
|
||||
using std::cout;
|
||||
cout << "updating logic \"" << get_name() << "\"" << endl;
|
||||
cout << "updating logic \"" << subsystemId() << "\"" << endl;
|
||||
cout << "prev. Output:" << q << endl;
|
||||
cout << "new Output:" << a << endl;
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ void PIDController::update( bool firstTime, double dt )
|
|||
elapsedTime = 0.0;
|
||||
|
||||
if( Ts > SGLimitsd::min()) {
|
||||
if( _debug ) cout << "Updating " << get_name()
|
||||
if( _debug ) cout << "Updating " << subsystemId()
|
||||
<< " Ts " << Ts << endl;
|
||||
|
||||
double y_n = _valueInput.get_value();
|
||||
|
|
|
@ -62,7 +62,7 @@ void PISimpleController::update( bool firstTime, double dt )
|
|||
_int_sum = 0.0;
|
||||
}
|
||||
|
||||
if ( _debug ) std::cout << "Updating " << get_name() << std::endl;
|
||||
if ( _debug ) std::cout << "Updating " << subsystemId() << std::endl;
|
||||
double y_n = _valueInput.get_value();
|
||||
double r_n = _referenceInput.get_value();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue