104 SGPropertyNode_ptr cfg )
106 simgear::PropertyList cfg_props = cfg->getChildren(
"property");
107 for( simgear::PropertyList::iterator it = cfg_props.begin();
108 it != cfg_props.end();
111 SGPropertyNode_ptr prop = prop_root->getNode((*it)->getStringValue(),
true);
112 SGPropertyNode* val = (*it)->getNode(
"_attr_/value");
116 prop->setDoubleValue( val->getDoubleValue() );
120 (*it)->removeChild(
"_attr_", 0);
128 _name(
"unnamed autopilot"),
134 componentForge[
"pid-controller"] = new CreateAndConfigureFunctor<PIDController,Component>();
135 componentForge[
"pi-simple-controller"] = new CreateAndConfigureFunctor<PISimpleController,Component>();
136 componentForge[
"predict-simple"] = new CreateAndConfigureFunctor<Predictor,Component>();
137 componentForge[
"filter"] = new CreateAndConfigureFunctor<DigitalFilter,Component>();
138 componentForge[
"logic"] = new CreateAndConfigureFunctor<Logic,Component>();
139 componentForge[
"flipflop"] = new CreateAndConfigureFunctor<FlipFlop,Component>();
140 componentForge[
"state-machine"] = new StateMachineFunctor();
144 configNode = rootNode;
150 SGPropertyNode_ptr prop_root_node = rootNode->getChild(
"property-root");
151 if( !prop_root_node )
152 prop_root_node = configNode->getChild(
"property-root");
154 SGPropertyNode_ptr prop_root =
155 fgGetNode(prop_root_node ? prop_root_node->getStringValue() :
"/",
true);
166 int count = configNode->nChildren();
167 for(
int i = 0;
i < count; ++
i )
169 SGPropertyNode_ptr node = configNode->getChild(
i);
170 string childName = node->getNameString();
171 if( childName ==
"property"
172 || childName ==
"property-root" )
176 SG_LOG(SG_AUTOPILOT, SG_BULK,
"unhandled element <" << childName <<
">");
181 if( component->subsystemId().length() == 0 ) {
182 std::ostringstream buf;
183 buf <<
"unnamed_component_" <<
i;
186 double updateInterval = node->getDoubleValue(
"update-interval-secs", 0.0 );
188 SG_LOG( SG_AUTOPILOT, SG_DEBUG,
"adding autopilot component \"" << childName <<
"\" as \"" << component->subsystemId() <<
"\" with interval=" << updateInterval );
212 if( component == NULL )
return;
215 const auto originalName =
string{component->subsystemId()};
216 std::string
name = originalName;
218 name =
"unnamed_autopilot";
221 for(
unsigned int i = 0; get_subsystem(
name) !=
nullptr;
i++ ) {
222 std::ostringstream buf;
223 buf << component->subsystemId() <<
"_" <<
i;
227 if (!originalName.empty() && (
name != originalName)) {
228 SG_LOG( SG_AUTOPILOT, SG_DEV_WARN,
"Duplicate autopilot component " << originalName <<
", renamed to " <<
name );
231 set_subsystem(
name, component, updateInterval );
void fgTie(const char *name, V(*getter)(), void(*setter)(V)=0, bool useDefault=true)
Tie a property to a pair of simple functions.