30 #include <rtt/RTT.hpp> 31 #include "DeploymentComponent.hpp" 32 #include <rtt/deployment/ComponentLoader.hpp> 33 #include <rtt/extras/Activities.hpp> 34 #include <rtt/extras/SequentialActivity.hpp> 35 #include <rtt/extras/FileDescriptorActivity.hpp> 36 #include <rtt/marsh/PropertyMarshaller.hpp> 37 #include <rtt/marsh/PropertyDemarshaller.hpp> 38 #include <rtt/scripting/Scripting.hpp> 39 #include <rtt/ConnPolicy.hpp> 40 #include <rtt/plugin/PluginLoader.hpp> 42 # if defined(_POSIX_VERSION) 43 # define USE_SIGNALS 1 50 #include <boost/algorithm/string.hpp> 51 #include <rtt/base/OperationCallerBaseInvoker.hpp> 57 #include <rtt/marsh/PropertyLoader.hpp> 59 #undef _POSIX_C_SOURCE 60 #include <sys/types.h> 79 static std::set<string> valid_names;
81 static int got_signal = -1;
84 #if defined(USE_SIGNALS) 86 void ctrl_c_catcher(
int sig)
93 #define ORO_str(s) ORO__str(s) 94 #define ORO__str(s) #s 97 :
RTT::TaskContext(name, Stopped),
98 defaultWaitPeriodPolicy(ORO_WAIT_ABS),
99 autoUnload(
"AutoUnload",
100 "Stop, cleanup and unload all components loaded by the DeploymentComponent when it is destroyed.",
102 validConfig(
"Valid", false),
103 sched_RT(
"ORO_SCHED_RT", ORO_SCHED_RT ),
104 sched_OTHER(
"ORO_SCHED_OTHER", ORO_SCHED_OTHER ),
105 lowest_Priority(
"LowestPriority",
RTT::os::LowestPriority ),
106 highest_Priority(
"HighestPriority",
RTT::os::HighestPriority ),
108 ORO_str(OROCOS_TARGET) ),
111 this->addProperty(
"RTT_COMPONENT_PATH", compPath ).doc(
"Locations to look for components. Use a colon or semi-colon separated list of paths. Defaults to the environment variable with the same name.");
112 this->addProperty(
"DefaultWaitPeriodPolicy", defaultWaitPeriodPolicy ).doc(
"The default value for the wait period policy property for threads of newly created activities (ORO_WAIT_ABS or ORO_WAIT_REL).");
113 this->addProperty( autoUnload );
114 this->addAttribute( target );
116 this->addAttribute( validConfig );
117 this->addAttribute( sched_RT );
118 this->addAttribute( sched_OTHER );
119 this->addAttribute( lowest_Priority );
120 this->addAttribute( highest_Priority );
123 this->addOperation(
"reloadLibrary", &
DeploymentComponent::reloadLibrary,
this, ClientThread).doc(
"Reload a new component library into memory.").arg(
"FilePath",
"The absolute file name of the to be reloaded library. Warning: this is a low-level function only to be used during development/testing.");
124 this->addOperation(
"loadLibrary", &
DeploymentComponent::loadLibrary,
this, ClientThread).doc(
"Load a new library (component, plugin or typekit) into memory.").arg(
"Name",
"The absolute or relative name of the to be loaded library. Warning: this is a low-level function you should only use if import() doesn't work for you.");
125 this->addOperation(
"import", &
DeploymentComponent::import,
this, ClientThread).doc(
"Import all components, plugins and typekits from a given package or directory in the search path.").arg(
"Package",
"The name absolute or relative name of a directory or package.");
126 this->addOperation(
"path", &
DeploymentComponent::path,
this, ClientThread).doc(
"Add additional directories to the component search path without importing them.").arg(
"Paths",
"A colon or semi-colon separated list of paths to search for packages.");
128 this->addOperation(
"loadComponent", &
DeploymentComponent::loadComponent,
this, ClientThread).doc(
"Load a new component instance from a library.").arg(
"Name",
"The name of the to be created component").arg(
"Type",
"The component type, used to lookup the library.");
133 this->provides()->removeOperation(
"loadService");
134 this->addOperation(
"loadService", &
DeploymentComponent::loadService,
this, ClientThread).doc(
"Load a discovered service or plugin in an existing component.").arg(
"Name",
"The name of the component which will receive the service").arg(
"Service",
"The name of the service or plugin.");
135 this->addOperation(
"unloadComponent", &
DeploymentComponent::unloadComponent,
this, ClientThread).doc(
"Unload a loaded component instance.").arg(
"Name",
"The name of the to be created component");
139 this->addOperation(
"loadConfiguration", &
DeploymentComponent::loadConfiguration,
this, ClientThread).doc(
"Load a new XML configuration from a file (identical to loadComponents).").arg(
"File",
"The file which contains the new configuration.");
140 this->addOperation(
"loadConfigurationString", &
DeploymentComponent::loadConfigurationString,
this, ClientThread).doc(
"Load a new XML configuration from a string.").arg(
"Text",
"The string which contains the new configuration.");
143 this->addOperation(
"loadComponents", &
DeploymentComponent::loadComponents,
this, ClientThread).doc(
"Load components listed in an XML configuration file.").arg(
"File",
"The file which contains the new configuration.");
144 this->addOperation(
"configureComponents", &
DeploymentComponent::configureComponents,
this, ClientThread).doc(
"Apply a loaded configuration to the components and configure() them if AutoConf is set.");
150 this->addOperation(
"runScript", &
DeploymentComponent::runScript,
this, ClientThread).doc(
"Runs a script.").arg(
"File",
"An Orocos program script.");
151 this->addOperation(
"kickStart", &
DeploymentComponent::kickStart,
this, ClientThread).doc(
"Calls loadComponents, configureComponents and startComponents in a row.").arg(
"File",
"The file which contains the XML configuration to use.");
152 this->addOperation(
"kickOutAll", &
DeploymentComponent::kickOutAll,
this, ClientThread).doc(
"Calls stopComponents, cleanupComponents and unloadComponents in a row.");
154 this->addOperation(
"kickOutComponent", &
DeploymentComponent::kickOutComponent,
this, ClientThread).doc(
"Calls stopComponents, cleanupComponent and unloadComponent in a row.").arg(
"comp_name",
"component name");
155 this->addOperation(
"kickOut", &
DeploymentComponent::kickOut,
this, ClientThread).doc(
"Calls stopComponents, cleanupComponents and unloadComponents in a row.").arg(
"File",
"The file which contains the name of the components to kickOut (for example, the same used in kickStart).");
157 this->addOperation(
"waitForInterrupt", &
DeploymentComponent::waitForInterrupt,
this, ClientThread).doc(
"This operation waits for the SIGINT signal and then returns. This allows you to wait in a script for ^C.");
158 this->addOperation(
"waitForSignal", &
DeploymentComponent::waitForSignal,
this, ClientThread).doc(
"This operation waits for the signal of the argument and then returns. This allows you to wait in a script for any signal except SIGKILL and SIGSTOP.").arg(
"signal number",
"The signal number to wait for.");
164 this->addOperation(
"connectPeers", cp,
this, ClientThread).doc(
"Connect two Components known to this Component.").arg(
"One",
"The first component.").arg(
"Two",
"The second component.");
166 this->addOperation(
"connectPorts", cp,
this, ClientThread).doc(
"DEPRECATED. Connect the Data Ports of two Components known to this Component.").arg(
"One",
"The first component.").arg(
"Two",
"The second component.");
168 const std::string&,
const std::string&);
170 this->addOperation(
"connectTwoPorts", cp4,
this, ClientThread).doc(
"DEPRECATED. Connect two ports of Components known to this Component.")
171 .arg(
"One",
"The first component.")
172 .arg(
"PortOne",
"The port name of the first component.")
173 .arg(
"Two",
"The second component.")
174 .arg(
"PortTwo",
"The port name of the second component.");
176 .arg(
"component",
"The component which owns 'port'.")
177 .arg(
"port",
"The port to create a stream from or to.")
178 .arg(
"policy",
"The connection policy which serves to describe the stream to be created.");
182 .arg(
"portOne",
"The first port of the connection. Use a dot-separated-path.")
183 .arg(
"portTwo",
"The second port of the connection. Use a dot-separated-path.")
184 .arg(
"policy",
"The connection policy which serves to describe the stream to be created. Use 'ConnPolicy()' to use the default.");
186 .arg(
"port",
"The port to create a stream from or to. Use a dot-separated-path.")
187 .arg(
"policy",
"The connection policy which serves to describe the stream to be created. Use 'ConnPolicy()' to use the default.");
189 this->addOperation(
"connectServices", (
bool(
DeploymentComponent::*)(
const std::string&,
const std::string&))&
DeploymentComponent::connectServices,
this, ClientThread).doc(
"Connect the matching provides/requires services of two Components known to this Component.").arg(
"One",
"The first component.").arg(
"Two",
"The second component.");
190 this->addOperation(
"connectOperations", &
DeploymentComponent::connectOperations,
this, ClientThread).doc(
"Connect the matching provides/requires operations of two Components known to this Component.").arg(
"Requested",
"The requested operation (dot-separated path).").arg(
"Provided",
"The provided operation (dot-separated path).");
193 this->addOperation(
"addPeer", cp,
this, ClientThread).doc(
"Add a peer to a Component.").arg(
"From",
"The first component.").arg(
"To",
"The other component.");
194 this->addOperation(
"aliasPeer", &
DeploymentComponent::aliasPeer,
this, ClientThread).doc(
"Add a peer to a Component with an alternative name.").arg(
"From",
"The component which will see 'To' in its peer list.").arg(
"To",
"The component which will be seen by 'From'.").arg(
"Alias",
"The name under which 'To' is known to 'From'");
196 RPFun rp = &RTT::TaskContext::removePeer;
197 this->addOperation(
"removePeer", rp,
this, ClientThread).doc(
"Remove a peer from this Component.").arg(
"PeerName",
"The name of the peer to remove.");
199 this->addOperation(
"setActivity", &
DeploymentComponent::setActivity,
this, ClientThread).doc(
"Attach an activity to a Component.").arg(
"CompName",
"The name of the Component.").arg(
"Period",
"The period of the activity (set to 0.0 for non periodic).").arg(
"Priority",
"The priority of the activity.").arg(
"SchedType",
"The scheduler type of the activity.");
200 this->addOperation(
"setActivityOnCPU", &
DeploymentComponent::setActivityOnCPU,
this, ClientThread).doc(
"Attach an activity to a Component.").arg(
"CompName",
"The name of the Component.").arg(
"Period",
"The period of the activity (set to 0.0 for non periodic).").arg(
"Priority",
"The priority of the activity.").arg(
"SchedType",
"The scheduler type of the activity.").arg(
"CPU",
"The CPU to run on, starting from zero.");
201 this->addOperation(
"setPeriodicActivity", &
DeploymentComponent::setPeriodicActivity,
this, ClientThread).doc(
"Attach a periodic activity to a Component.").arg(
"CompName",
"The name of the Component.").arg(
"Period",
"The period of the activity.").arg(
"Priority",
"The priority of the activity.").arg(
"SchedType",
"The scheduler type of the activity.");
202 this->addOperation(
"setSequentialActivity", &
DeploymentComponent::setSequentialActivity,
this, ClientThread).doc(
"Attach a 'stand alone' sequential activity to a Component.").arg(
"CompName",
"The name of the Component.");
203 this->addOperation(
"setSlaveActivity", &
DeploymentComponent::setSlaveActivity,
this, ClientThread).doc(
"Attach a 'stand alone' slave activity to a Component.").arg(
"CompName",
"The name of the Component.").arg(
"Period",
"The period of the activity (set to zero for non periodic).");
204 this->addOperation(
"setMasterSlaveActivity", &
DeploymentComponent::setMasterSlaveActivity,
this, ClientThread).doc(
"Attach a slave activity with a master to a Component. The slave becomes a peer of the master as well.").arg(
"Master",
"The name of the Component which is master of the Slave.").arg(
"Slave",
"The name of the Component which gets the SlaveActivity.");
206 .doc(
"Attach a File Descriptor activity to a Component.")
207 .arg(
"CompName",
"The name of the Component.")
208 .arg(
"Timeout",
"The timeout of the activity (set to zero for no timeout).")
209 .arg(
"Priority",
"The priority of the activity.")
210 .arg(
"SchedType",
"The scheduler type of the activity.");
212 this->addOperation(
"setWaitPeriodPolicy", &
DeploymentComponent::setWaitPeriodPolicy,
this, ClientThread).doc(
"Sets the wait period policy of an existing component thread.").arg(
"CompName",
"The name of the Component.").arg(
"Policy",
"The new policy (ORO_WAIT_ABS or ORO_WAIT_REL).");
214 valid_names.insert(
"AutoUnload");
215 valid_names.insert(
"UseNamingService");
216 valid_names.insert(
"Server");
217 valid_names.insert(
"AutoConf");
218 valid_names.insert(
"AutoStart");
219 valid_names.insert(
"AutoConnect");
220 valid_names.insert(
"AutoSave");
221 valid_names.insert(
"PropertyFile");
222 valid_names.insert(
"UpdateProperties");
223 valid_names.insert(
"LoadProperties");
224 valid_names.insert(
"ProgramScript");
225 valid_names.insert(
"StateMachineScript");
226 valid_names.insert(
"Ports");
227 valid_names.insert(
"Peers");
228 valid_names.insert(
"Activity");
229 valid_names.insert(
"Master");
230 valid_names.insert(
"Properties");
231 valid_names.insert(
"Service");
232 valid_names.insert(
"Plugin");
233 valid_names.insert(
"Provides");
234 valid_names.insert(
"RunScript");
237 if (siteFile.empty())
238 siteFile = this->getName() +
"-site.cpf";
239 std::ifstream hassite(siteFile.c_str());
245 log(Info) <<
"No site file was found. Importing 'ocl' by default." <<endlog();
248 }
catch (std::exception& e) {
255 log(Info) <<
"Using site file '" << siteFile <<
"'." << endlog();
262 Logger::In in(
"configure");
263 if (compPath.empty() )
265 compPath = ComponentLoader::Instance()->getComponentPath();
267 log(Info) <<
"RTT_COMPONENT_PATH was set to " << compPath << endlog();
268 log(Info) <<
"Re-scanning for plugins and components..."<<endlog();
269 PluginLoader::Instance()->setPluginPath(compPath);
270 ComponentLoader::Instance()->setComponentPath(compPath);
271 ComponentLoader::Instance()->import(compPath);
283 if ( autoUnload.get() ) {
291 cout <<
"DeploymentComponent: Got interrupt !" <<endl;
297 struct sigaction sa, sold;
298 sa.sa_handler = ctrl_c_catcher;
299 if ( ::sigaction(sig, &sa, &sold) != 0) {
300 cout <<
"DeploymentComponent: Failed to install signal handler for signal " << sig << endl;
303 while (got_signal != sig) {
307 rtos_nanosleep(&ts, 0);
311 if (sold.sa_handler || sold.sa_sigaction)
312 ::sigaction(sig, &sold, NULL);
315 cout <<
"DeploymentComponent: Failed to install signal handler for signal " << sig <<
": Not supported by this Operating System. "<<endl;
322 RTT::Logger::In in(
"connectPeers");
323 RTT::TaskContext* t1 = (((one == this->getName()) || (one ==
"this")) ?
this : this->getPeer(one));
324 RTT::TaskContext* t2 = (((other == this->getName()) || (other ==
"this")) ?
this : this->getPeer(other));
326 log(Error)<<
"No such peer: "<<one<<endlog();
330 log(Error) <<
"No such peer: "<<other<<endlog();
333 return t1->connectPeers(t2);
338 RTT::Logger::In in(
"addPeer");
339 RTT::TaskContext* t1 = (((from == this->getName()) || (from ==
"this")) ?
this : this->getPeer(from));
340 RTT::TaskContext* t2 = (((to == this->getName()) || (to ==
"this")) ?
this : this->getPeer(to));
342 log(Error)<<
"No such peer: "<<from<<endlog();
346 log(Error)<<
"No such peer: "<<to<<endlog();
349 if ( t1->hasPeer(to) ) {
350 log(Info) <<
"addPeer: "<< to <<
" is already a peer of " << from << endlog();
353 return t1->addPeer(t2,to);
358 RTT::Logger::In in(
"addPeer");
359 RTT::TaskContext* t1 = (((from == this->getName()) || (from ==
"this")) ?
this : this->getPeer(from));
360 RTT::TaskContext* t2 = (((to == this->getName()) || (to ==
"this")) ?
this : this->getPeer(to));
362 log(Error)<<
"No such peer known to deployer '"<< this->getName()<<
"': "<<from<<endlog();
366 log(Error)<<
"No such peer known to deployer '"<< this->getName()<<
"': "<<to<<endlog();
369 return t1->addPeer(t2, alias);
373 std::vector<std::string> strs;
374 boost::split(strs, names, boost::is_any_of(
"."));
377 if (strs.empty())
return Service::shared_ptr();
379 string component = strs.front();
380 RTT::TaskContext *tc = (((component == this->getName()) || (component ==
"this")) ?
this : getPeer(component));
382 log(Error) <<
"No such component: '"<< component <<
"'";
383 if ( names.find(
'.') != string::npos )
384 log(Error) <<
" when looking for service '" << names <<
" '";
386 return Service::shared_ptr();
389 Service::shared_ptr ret = tc->provides();
392 strs.erase( strs.begin() );
395 while ( !strs.empty() && ret) {
396 ret = ret->getService( strs.front() );
398 strs.erase( strs.begin() );
401 log(Error) <<
"No such service: '"<< strs.front() <<
"' while looking for service '"<< names<<
"'"<<endlog();
407 std::vector<std::string> strs;
408 boost::split(strs, names, boost::is_any_of(
"."));
410 string component = strs.front();
411 RTT::TaskContext *tc = (((component == this->getName()) || (component ==
"this")) ?
this : getPeer(component));
413 log(Error) <<
"No such component: '"<< component <<
"'" <<endlog();
414 if ( names.find(
'.') != string::npos )
415 log(Error)<<
" when looking for service '" << names <<
"'" <<endlog();
416 return ServiceRequester::shared_ptr();
419 ServiceRequester::shared_ptr ret = tc->requires();
422 strs.erase( strs.begin() );
425 while ( !strs.empty() && ret) {
426 ret = ret->requires( strs.front() );
428 strs.erase( strs.begin() );
431 log(Error) <<
"No such service: '"<< strs.front() <<
"' while looking for service '"<< names<<
"'"<<endlog();
437 std::vector<std::string> strs;
438 boost::split(strs, names, boost::is_any_of(
"."));
441 if (strs.empty())
return 0;
443 string component = strs.front();
444 RTT::TaskContext *tc = (((component == this->getName()) || (component ==
"this")) ?
this : getPeer(component));
446 log(Error) <<
"No such component: '"<< component <<
"'" ;
447 log(Error)<<
" when looking for port '" << names <<
"'" <<endlog();
451 Service::shared_ptr serv = tc->provides();
452 base::PortInterface* ret = 0;
455 strs.erase( strs.begin() );
458 while ( strs.size() != 1 && serv) {
459 serv = serv->getService( strs.front() );
461 strs.erase( strs.begin() );
464 log(Error) <<
"No such service: '"<< strs.front() <<
"' while looking for port '"<< names<<
"'"<<endlog();
467 ret = serv->getPort(strs.front());
469 log(Error) <<
"No such port: '"<< strs.front() <<
"' while looking for port '"<< names<<
"'"<<endlog();
477 RTT::Logger::In in(
"connectPorts");
478 RTT::TaskContext* a, *b;
482 log(Error) << one <<
" could not be found."<< endlog();
486 log(Error) << other <<
" could not be found."<< endlog();
490 return a->connectPorts(b);
494 const std::string& other,
const std::string& other_port)
496 RTT::Logger::In in(
"connectPorts");
497 Service::shared_ptr a,b;
502 base::PortInterface* ap, *bp;
503 ap = a->getPort(one_port);
504 bp = b->getPort(other_port);
506 log(Error) << one <<
" does not have a port "<<one_port<< endlog();
510 log(Error) << other <<
" does not have a port "<<other_port<< endlog();
515 if ( ap->connected() && bp->connected() ) {
516 log(Debug) <<
"Port '"<< ap->getName() <<
"' of Component '"<<a->getName()
517 <<
"' and port '"<< bp->getName() <<
"' of Component '"<<b->getName()
518 <<
"' are already connected but (probably) not to each other. Connecting them anyway."<<endlog();
522 if ( ap->connectTo( bp ) ) {
524 log(Info)<<
"Connected Port " << one +
"." + one_port <<
" to "<< other +
"." + other_port <<
"." << endlog();
527 log(Error)<<
"Failed to connect Port " << one +
"." + one_port <<
" to "<< other +
"." + other_port <<
"." << endlog();
537 PortInterface* porti = serv->getPort(port);
539 log(Error) <<
"Service in component "<<comp<<
" has no port "<< port <<
"."<< endlog();
542 return porti->createStream( policy );
548 RTT::Logger::In in(
"connect");
549 base::PortInterface* ap, *bp;
556 if ( ap->connected() && bp->connected() ) {
557 log(Debug) <<
"Port '"<< ap->getName() <<
"' of '"<< one
558 <<
"' and port '"<< bp->getName() <<
"' of '"<< other
559 <<
"' are already connected but (probably) not to each other. Connecting them anyway."<<endlog();
563 if ( ap->connectTo( bp, cp ) ) {
565 log(Info)<<
"Connected Port " << one <<
" to "<< other <<
"." << endlog();
568 log(Error)<<
"Failed to connect Port " << one <<
" to "<< other <<
"." << endlog();
579 return porti->createStream( policy );
584 RTT::Logger::In in(
"connectServices");
585 RTT::TaskContext* a, *b;
589 log(Error) << one <<
" could not be found."<< endlog();
593 log(Error) << other <<
" could not be found."<< endlog();
597 return a->connectServices(b);
602 RTT::Logger::In in(
"connectOperations");
604 boost::iterator_range<std::string::const_iterator> reqs = boost::algorithm::find_last(required,
".");
605 std::string reqs_name(required.begin(), reqs.begin());
606 std::string rop_name(reqs.begin()+1, required.end());
607 log(Debug) <<
"Looking for required operation " << rop_name <<
" in service " << reqs_name << endlog();
610 boost::iterator_range<std::string::const_iterator> pros = boost::algorithm::find_last(provided,
".");
611 std::string pros_name(provided.begin(), pros.begin());
612 std::string pop_name(pros.begin()+1, provided.end());
613 log(Debug) <<
"Looking for provided operation " << pop_name <<
" in service " << pros_name << endlog();
616 RTT::base::OperationCallerBaseInvoker* rop = r->getOperationCaller(rop_name);
618 log(Error) <<
"No requested operation " << rop_name <<
" found in service " << reqs_name << endlog();
621 if ( rop->ready() ) {
622 log(Error) <<
"Requested operation " << rop_name <<
" already connected to a provided operation!" << endlog();
626 if (! p->hasOperation(pop_name)) {
627 log(Error) <<
"No provided operation " << pop_name <<
" found in service " << pros_name << endlog();
631 rop->setImplementation(p->getLocalOperation( pop_name ), r->getServiceOwner()->engine());
633 log(Debug) <<
"Successfully set up OperationCaller for operation " << rop_name << endlog();
637 int string_to_oro_sched(
const std::string& sched) {
638 if ( sched ==
"ORO_SCHED_OTHER" )
639 return ORO_SCHED_OTHER;
640 if (sched ==
"ORO_SCHED_RT" )
642 log(Error)<<
"Unknown scheduler type: "<< sched <<endlog();
648 const char* tmpfile =
".loadConfigurationString.cpf";
649 std::ofstream file( tmpfile );
650 file << text.c_str();
658 if (file_name.rfind(
".lua") == file_name.length() - 4) {
659 if (!this->provides()->hasService(
"Lua")) {
661 if(!RTT::plugin::PluginLoader::Instance()->loadService(
"Lua",
this)) {
662 RTT::log(RTT::Error) <<
"Could not load lua service." << RTT::endlog();
667 RTT::OperationCaller<bool(std::string)> exec_str =
668 this->provides(
"Lua")->getOperation(
"exec_str");
671 exec_str(
"require(\"rttlib\")");
675 RTT::OperationCaller<bool(std::string)> exec_file =
676 this->provides(
"Lua")->getOperation(
"exec_file");
678 return exec_file( file_name );
681 return this->getProvider<Scripting>(
"scripting")->
runScript( file_name );
691 log(Info) <<
"Successfully loaded, configured and started components from "<< configurationfile <<endlog();
694 log(Error) <<
"Failed to start a component: aborting kick-start."<<endlog();
697 log(Error) <<
"Failed to configure a component: aborting kick-start."<<endlog();
700 log(Error) <<
"Failed to load a component: aborting kick-start."<<endlog();
723 if ( sret && cret && uret) {
724 log(Info) <<
"Kick-out of group " << group <<
" successful."<<endlog();
728 log(Critical) <<
"Kick-out of group " << group <<
" failed: ";
730 log(Critical) <<
" stopComponents() failed.";
732 log(Critical) <<
" cleanupComponents() failed.";
734 log(Critical) <<
" unloadComponents() failed.";
735 log(Critical) << endlog();
754 RTT::Logger::In in(
"loadComponents");
756 RTT::PropertyBag from_file;
757 log(Info) <<
"Loading '" <<configurationfile<<
"' in group " << group <<
"."<< endlog();
759 bool failure =
false;
761 bool valid = validConfig.get();
762 marsh::PropertyDemarshaller demarshaller(configurationfile);
764 if ( demarshaller.deserialize( from_file ) )
767 log(Info)<<
"Validating new configuration..."<<endlog();
768 if ( from_file.empty() ) {
769 log(Error)<<
"Configuration was empty !" <<endlog();
774 for (RTT::PropertyBag::iterator it= from_file.begin(); it!=from_file.end();it++) {
776 if ( (*it)->getName() ==
"Import" ) {
777 RTT::Property<std::string> importp = *it;
778 if ( !importp.ready() ) {
779 log(Error)<<
"Found 'Import' statement, but it is not of type='string'."<<endlog();
783 if ( this->
import( importp.get() ) ==
false )
787 if ( (*it)->getName() ==
"LoadLibrary" ) {
788 RTT::Property<std::string> importp = *it;
789 if ( !importp.ready() ) {
790 log(Error)<<
"Found 'LoadLibrary' statement, but it is not of type='string'."<<endlog();
798 if ( (*it)->getName() ==
"Path" ) {
799 RTT::Property<std::string> pathp = *it;
800 if ( !pathp.ready() ) {
801 log(Error)<<
"Found 'Path' statement, but it is not of type='string'."<<endlog();
805 this->
path( pathp.get() );
808 if ( (*it)->getName() ==
"Include" ) {
809 RTT::Property<std::string> includep = *it;
810 if ( !includep.ready() ) {
811 log(Error)<<
"Found 'Include' statement, but it is not of type='string'."<<endlog();
821 RTT::Property<RTT::PropertyBag> comp = *it;
822 if ( !comp.ready() ) {
823 log(Error)<<
"RTT::Property '"<< *it <<
"' should be a struct, Include, Path or Import statement." << endlog();
830 Property<ConnPolicy> cp_prop((*it)->getName(),
"");
831 assert( cp_prop.ready() );
832 if ( cp_prop.compose( comp ) ) {
834 conmap[cp_prop.getName()].policy = cp_prop.get();
835 log(Debug) <<
"Saw connection policy " << (*it)->getName() << endlog();
840 for (RTT::PropertyBag::const_iterator optit= comp.rvalue().begin(); optit != comp.rvalue().end();optit++) {
841 if ( valid_names.find( (*optit)->getName() ) == valid_names.end() ) {
842 log(Error) <<
"Unknown type syntax: '"<< (*optit)->getName() <<
"' in component struct "<< comp.getName() <<endlog();
846 if ( (*optit)->getName() ==
"AutoConnect" ) {
847 RTT::Property<bool> ps = comp.rvalue().getProperty(
"AutoConnect");
849 log(Error) <<
"AutoConnect must be of type <boolean>" << endlog();
852 compmap[comp.getName()].autoconnect = ps.get();
855 if ( (*optit)->getName() ==
"AutoStart" ) {
856 RTT::Property<bool> ps = comp.rvalue().getProperty(
"AutoStart");
858 log(Error) <<
"AutoStart must be of type <boolean>" << endlog();
861 compmap[comp.getName()].autostart = ps.get();
864 if ( (*optit)->getName() ==
"AutoSave" ) {
865 RTT::Property<bool> ps = comp.rvalue().getProperty(
"AutoSave");
867 log(Error) <<
"AutoSave must be of type <boolean>" << endlog();
870 compmap[comp.getName()].autosave = ps.get();
873 if ( (*optit)->getName() ==
"AutoConf" ) {
874 RTT::Property<bool> ps = comp.rvalue().getProperty(
"AutoConf");
876 log(Error) <<
"AutoConf must be of type <boolean>" << endlog();
879 compmap[comp.getName()].autoconf = ps.get();
882 if ( (*optit)->getName() ==
"Server" ) {
883 RTT::Property<bool> ps = comp.rvalue().getProperty(
"Server");
885 log(Error) <<
"Server must be of type <boolean>" << endlog();
888 compmap[comp.getName()].server = ps.get();
891 if ( (*optit)->getName() ==
"Service" || (*optit)->getName() ==
"Plugin" || (*optit)->getName() ==
"Provides") {
892 RTT::Property<string> ps = *optit;
894 log(Error) << (*optit)->getName() <<
" must be of type <string>" << endlog();
897 compmap[comp.getName()].plugins.push_back(ps.value());
901 if ( (*optit)->getName() ==
"UseNamingService" ) {
902 RTT::Property<bool> ps = comp.rvalue().getProperty(
"UseNamingService");
904 log(Error) <<
"UseNamingService must be of type <boolean>" << endlog();
907 compmap[comp.getName()].use_naming = ps.get();
910 if ( (*optit)->getName() ==
"PropertyFile" ) {
911 RTT::Property<string> ps = comp.rvalue().getProperty(
"PropertyFile");
913 log(Error) <<
"PropertyFile must be of type <string>" << endlog();
916 compmap[comp.getName()].configfile = ps.get();
919 if ( (*optit)->getName() ==
"UpdateProperties" ) {
920 RTT::Property<string> ps = comp.rvalue().getProperty(
"UpdateProperties");
922 log(Error) <<
"UpdateProperties must be of type <string>" << endlog();
925 compmap[comp.getName()].configfile = ps.get();
928 if ( (*optit)->getName() ==
"LoadProperties" ) {
929 RTT::Property<string> ps = comp.rvalue().getProperty(
"LoadProperties");
931 log(Error) <<
"LoadProperties must be of type <string>" << endlog();
934 compmap[comp.getName()].configfile = ps.get();
937 if ( (*optit)->getName() ==
"Properties" ) {
938 base::PropertyBase* ps = comp.rvalue().getProperty(
"Properties");
940 log(Error) <<
"Properties must be a <struct>" << endlog();
945 if ( (*optit)->getName() ==
"RunScript" ) {
946 base::PropertyBase* ps = comp.rvalue().getProperty(
"RunScript");
948 log(Error) <<
"RunScript must be of type <string>" << endlog();
953 if ( (*optit)->getName() ==
"ProgramScript" ) {
954 base::PropertyBase* ps = comp.rvalue().getProperty(
"ProgramScript");
956 log(Error) <<
"ProgramScript must be of type <string>" << endlog();
961 if ( (*optit)->getName() ==
"StateMachineScript" ) {
962 base::PropertyBase* ps = comp.rvalue().getProperty(
"StateMachineScript");
964 log(Error) <<
"StateMachineScript must be of type <string>" << endlog();
972 RTT::TaskContext* c = 0;
973 if ( (*it)->getName() == this->getName() )
976 c = this->getPeer( (*it)->getName() );
979 if (this->
loadComponent( (*it)->getName(), comp.rvalue().getType() ) ==
false) {
980 log(Warning)<<
"Could not configure '"<< (*it)->getName() <<
"': No such peer."<< endlog();
984 c = compmap[(*it)->getName()].instance;
987 compmap[(*it)->getName()].group = group;
988 log(Info) <<
"Component " << (*it)->getName() <<
" added to group " << group <<
"." << endlog();
991 compmap[(*it)->getName()].instance = c;
997 vector<string>& services = compmap[(*it)->getName()].plugins;
998 for (vector<string>::iterator svit = services.begin(); svit != services.end(); ++svit) {
999 if ( c->provides()->hasService( *svit ) ==
false) {
1000 PluginLoader::Instance()->loadService(*svit, c);
1005 if ( comp.value().getProperty(
"PropFile") )
1006 comp.value().getProperty(
"PropFile")->setName(
"PropertyFile");
1009 RTT::Property<RTT::PropertyBag>* ports = comp.value().getPropertyType<PropertyBag>(
"Ports");
1011 for (RTT::PropertyBag::iterator pit = ports->value().begin(); pit != ports->value().end(); pit++) {
1012 Property<string> portcon = *pit;
1013 if ( !portcon.ready() ) {
1014 log(Error)<<
"RTT::Property '"<< (*pit)->getName() <<
"' is not of type 'string'." << endlog();
1018 base::PortInterface* p = c->ports()->getPort( portcon.getName() );
1020 log(Error)<<
"Component '"<< c->getName() <<
"' does not have a Port '"<< portcon.getName()<<
"'." << endlog();
1025 string conn_name = portcon.value();
1029 for(
unsigned int a=0; a < conmap[conn_name].ports.size(); a++)
1031 if( conmap[conn_name].ports.at(a) == p && conmap[conn_name].owners.at(a) == c)
1040 log(Debug)<<
"storing Port: "<<c->getName()<<
"."<< portcon.getName();
1041 log(Debug)<<
" in " << conn_name <<endlog();
1042 conmap[conn_name].ports.push_back( p );
1043 conmap[conn_name].owners.push_back( c );
1051 if ( comp.value().find(
"Peers") != 0) {
1052 RTT::Property<RTT::PropertyBag> nm = comp.value().find(
"Peers");
1053 if ( !nm.ready() ) {
1054 log(Error)<<
"RTT::Property 'Peers' must be a 'struct', was type "<< comp.value().find(
"Peers")->getType() << endlog();
1057 for (RTT::PropertyBag::const_iterator it= nm.rvalue().begin(); it != nm.rvalue().end();it++) {
1058 RTT::Property<std::string> pr = *it;
1059 if ( !pr.ready() ) {
1060 log(Error)<<
"RTT::Property 'Peer' does not have type 'string'."<<endlog();
1069 if ( comp.value().find(
"Activity") != 0) {
1070 RTT::Property<RTT::PropertyBag> nm = comp.value().find(
"Activity");
1071 if ( !nm.ready() ) {
1072 log(Error)<<
"RTT::Property 'Activity' must be a 'struct'."<<endlog();
1075 if ( nm.rvalue().getType() ==
"PeriodicActivity" ) {
1076 RTT::Property<double> per = nm.rvalue().getProperty(
"Period");
1077 if ( !per.ready() ) {
1078 log(Error)<<
"Please specify period <double> of PeriodicActivity."<<endlog();
1081 RTT::Property<int> prio = nm.rvalue().getProperty(
"Priority");
1082 if ( !prio.ready() ) {
1083 log(Error)<<
"Please specify priority <short> of PeriodicActivity."<<endlog();
1087 unsigned cpu_affinity = ~0;
1088 RTT::Property<unsigned> cpu_affinity_prop = nm.rvalue().getProperty(
"CpuAffinity");
1089 if(cpu_affinity_prop.ready()) {
1090 cpu_affinity = cpu_affinity_prop.get();
1094 RTT::Property<string> sched;
1095 if (nm.rvalue().getProperty(
"Scheduler") )
1096 sched = nm.rvalue().getProperty(
"Scheduler");
1097 int scheduler = ORO_SCHED_RT;
1098 if ( sched.ready() ) {
1099 scheduler = string_to_oro_sched( sched.get());
1100 if (scheduler == -1 )
1104 this->
setNamedActivity(comp.getName(), nm.rvalue().getType(), per.get(), prio.get(), scheduler, cpu_affinity );
1107 if ( nm.rvalue().getType() ==
"Activity" || nm.rvalue().getType() ==
"NonPeriodicActivity" ) {
1108 RTT::Property<double> per = nm.rvalue().getProperty(
"Period");
1109 if ( !per.ready() ) {
1110 per = Property<double>(
"p",
"",0.0);
1112 RTT::Property<int> prio = nm.rvalue().getProperty(
"Priority");
1113 if ( !prio.ready() ) {
1114 log(Error)<<
"Please specify priority <short> of Activity."<<endlog();
1118 unsigned int cpu_affinity = ~0;
1119 RTT::Property<unsigned int> cpu_affinity_prop = nm.rvalue().getProperty(
"CpuAffinity");
1120 if(cpu_affinity_prop.ready()) {
1121 cpu_affinity = cpu_affinity_prop.get();
1125 RTT::Property<string> sched = nm.rvalue().getProperty(
"Scheduler");
1126 int scheduler = ORO_SCHED_RT;
1127 if ( sched.ready() ) {
1128 scheduler = string_to_oro_sched( sched.get());
1129 if (scheduler == -1 )
1133 this->
setNamedActivity(comp.getName(), nm.rvalue().getType(), per.get(), prio.get(), scheduler, cpu_affinity );
1136 if ( nm.rvalue().getType() ==
"SlaveActivity" ) {
1137 double period = 0.0;
1139 if ( nm.rvalue().getProperty(
"Master") ) {
1140 master = nm.rvalue().getPropertyType<
string>(
"Master")->
get();
1142 this->
setNamedActivity(comp.getName(), nm.rvalue().getType(), period, 0, 0, master );
1146 if ( nm.rvalue().getProperty(
"Period") )
1147 period = nm.rvalue().getPropertyType<
double>(
"Period")->
get();
1149 this->
setNamedActivity(comp.getName(), nm.rvalue().getType(), period, 0, 0 );
1153 if ( nm.rvalue().getType() ==
"SequentialActivity" ) {
1156 if ( nm.rvalue().getType() ==
"FileDescriptorActivity" ) {
1157 RTT::Property<double> per = nm.rvalue().getProperty(
"Period");
1158 if ( !per.ready() ) {
1159 per = Property<double>(
"p",
"",0.0);
1163 RTT::Property<int> prio = nm.rvalue().getProperty(
"Priority");
1164 if ( !prio.ready() ) {
1165 log(Error)<<
"Please specify priority <short> of FileDescriptorActivity."<<endlog();
1169 unsigned int cpu_affinity = ~0;
1170 RTT::Property<unsigned int> cpu_affinity_prop = nm.rvalue().getProperty(
"CpuAffinity");
1171 if(cpu_affinity_prop.ready()) {
1172 cpu_affinity = cpu_affinity_prop.get();
1176 RTT::Property<string> sched = nm.rvalue().getProperty(
"Scheduler");
1177 int scheduler = ORO_SCHED_RT;
1178 if ( sched.ready() ) {
1179 scheduler = string_to_oro_sched( sched.get());
1180 if (scheduler == -1 )
1184 this->
setNamedActivity(comp.getName(), nm.rvalue().getType(), per.get(), prio.get(), scheduler, cpu_affinity );
1187 log(Error) <<
"Unknown activity type: " << nm.rvalue().getType()<<endlog();
1199 string delimiter(
"@!#?<!");
1200 bool ret = updateProperty(
root, from_file, comp.getName(), delimiter );
1202 log(Error) <<
"Failed to store deployment properties for component " << comp.getName() <<endlog();
1207 deletePropertyBag( from_file );
1211 log(Error)<<
"Some error occured while parsing "<< configurationfile <<endlog();
1216 log(Error)<<
"Uncaught exception in loadcomponents() !"<< endlog();
1219 validConfig.set(valid);
1220 return !failure && valid;
1225 RTT::Logger::In in(
"configureComponents");
1228 for (
int group = 0; group <=
nextGroup; ++group) {
1236 RTT::Logger::In in(
"configureComponents");
1237 if (
root.empty() ) {
1238 RTT::Logger::log() << RTT::Logger::Error
1239 <<
"No components loaded by DeploymentComponent !" <<endlog();
1244 log(Info) <<
"Configuring components in group " << group << endlog();
1247 for (RTT::PropertyBag::iterator it=
root.begin(); it!=
root.end();it++) {
1249 RTT::Property<RTT::PropertyBag> comp = *it;
1252 if (group != compmap[comp.getName()].group) {
1256 RTT::TaskContext* peer = compmap[comp.getName()].instance;
1258 log(Error) <<
"Peer not found: "<< comp.getName() <<endlog();
1263 compmap[comp.getName()].instance = peer;
1267 RTT::Property<RTT::PropertyBag> peers = comp.rvalue().find(
"Peers");
1268 if ( peers.ready() )
1269 for (RTT::PropertyBag::const_iterator it= peers.rvalue().begin(); it != peers.rvalue().end();it++) {
1270 RTT::Property<string> nm = (*it);
1273 if ( this->
addPeer( compmap[comp.getName()].instance->getName(), nm.value() ) ==
false ) {
1274 log(Error) << this->getName() <<
" can't make " << nm.value() <<
" a peer of " <<
1275 compmap[comp.getName()].instance->getName() << endlog();
1278 log(Info) << this->getName() <<
" makes " << nm.value() <<
" a peer of " <<
1279 compmap[comp.getName()].instance->getName() << endlog();
1283 log(Error) <<
"Wrong property type in Peers struct. Expected property of type 'string'," 1284 <<
" got type "<< (*it)->getType() <<endlog();
1291 for(ConMap::iterator it = conmap.begin(); it != conmap.end(); ++it) {
1293 std::string connection_name = it->first;
1295 if ( connection->ports.size() == 1 ){
1296 string owner = connection->owners[0]->getName();
1297 string portname = connection->ports.front()->getName();
1298 string porttype =
dynamic_cast<InputPortInterface*
>(connection->ports.front() ) ?
"InputPort" :
"OutputPort";
1299 if ( connection->ports.front()->createStream( connection->policy ) ==
false) {
1300 log(Warning) <<
"Creating stream with name "<<connection_name<<
" with Port "<<portname<<
" from "<< owner <<
" failed."<< endlog();
1302 log(Info) <<
"Component "<< owner <<
"'s " + porttype<<
" " + portname <<
" will stream to "<< connection->policy.name_id << endlog();
1307 base::PortInterface* writer = 0;
1308 ConnectionData::Ports::iterator p = connection->ports.begin();
1311 vector<OutputPortInterface*> writers;
1312 while (p !=connection->ports.end() ) {
1313 if ( OutputPortInterface* out = dynamic_cast<base::OutputPortInterface*>( *p ) ) {
1315 log(Info) <<
"Forming multi-output connections with additional OutputPort " << (*p)->getName() <<
"."<<endlog();
1318 writers.push_back( out );
1319 std::string owner = it->second.owners[p - it->second.ports.begin()]->getName();
1320 log(Info) <<
"Component "<< owner <<
"'s OutputPort "<< writer->getName()<<
" will write topic "<<it->first<< endlog();
1326 if ( writer == 0 ) {
1327 log(Error) <<
"No OutputPort listed that writes " << it->first << endlog();
1333 p = connection->ports.begin();
1334 vector<OutputPortInterface*>::iterator w = writers.begin();
1336 while (w != writers.end() ) {
1337 while (p != connection->ports.end() ) {
1339 if ( dynamic_cast<base::InputPortInterface*>( *p ) )
1341 string owner = connection->owners[p - connection->ports.begin()]->getName();
1344 if ( (*w)->connectTo( *p, connection->policy ) ==
false) {
1345 log(Error) <<
"Could not subscribe InputPort "<< owner<<
"."<< (*p)->getName() <<
" to topic " << (*w)->getName() <<
'/'<< connection_name <<endlog();
1348 log(Info) <<
"Subscribed InputPort "<< owner<<
"."<< (*p)->getName() <<
" to topic " << (*w)->getName() <<
'/'<< connection_name <<endlog();
1354 p = connection->ports.begin();
1359 for (RTT::PropertyBag::iterator it=
root.begin(); it!=
root.end();it++) {
1360 RTT::Property<RTT::PropertyBag> comp = *it;
1361 if ( !comp.ready() )
1365 if (group != compmap[ comp.getName() ].group) {
1369 RTT::TaskContext* peer = compmap[ comp.getName() ].instance;
1374 if ( compmap[comp.getName()].autoconnect ) {
1376 RTT::TaskContext::PeerList peers = peer->getPeerList();
1377 for(RTT::TaskContext::PeerList::iterator pit = peers.begin(); pit != peers.end(); ++pit) {
1378 if ( compmap.count( *pit ) && compmap[*pit].autoconnect ) {
1379 RTT::TaskContext* other = peer->getPeer( *pit );
1380 valid = RTT::connectPorts( peer, other ) && valid;
1387 for (RTT::PropertyBag::iterator it=
root.begin(); it!=
root.end();it++) {
1389 RTT::Property<RTT::PropertyBag> comp = *it;
1392 if (group != compmap[ comp.getName() ].group) {
1396 RTT::Property<string> dummy;
1397 RTT::TaskContext* peer = compmap[ comp.getName() ].instance;
1400 if ( peer->getTaskState() > Stopped) {
1401 log(Warning) <<
"Component "<< peer->getName()<<
" doesn't need to be configured (already Running)." <<endlog();
1406 for (RTT::PropertyBag::const_iterator pf = comp.rvalue().begin(); pf!= comp.rvalue().end(); ++pf) {
1408 if ( (*pf)->getName() ==
"Properties"){
1409 RTT::Property<RTT::PropertyBag> props = *pf;
1410 bool ret = updateProperties( *peer->properties(), props);
1412 log(Error) <<
"Failed to configure properties from main configuration file for component "<< comp.getName() <<endlog();
1415 log(Info) <<
"Configured Properties of "<< comp.getName() <<
" from main configuration file." <<endlog();
1420 for (RTT::PropertyBag::const_iterator pf = comp.rvalue().begin(); pf!= comp.rvalue().end(); ++pf) {
1422 if ( (*pf)->getName() ==
"PropertyFile" || (*pf)->getName() ==
"UpdateProperties" || (*pf)->getName() ==
"LoadProperties"){
1424 string filename = dummy.get();
1425 marsh::PropertyLoader pl(peer);
1426 bool strict = (*pf)->getName() ==
"PropertyFile" ?
true :
false;
1427 bool load = (*pf)->getName() ==
"LoadProperties" ?
true :
false;
1430 ret = pl.configure( filename, strict );
1432 ret = pl.load(filename);
1434 log(Error) <<
"Failed to configure properties for component "<< comp.getName() <<endlog();
1437 log(Info) <<
"Configured Properties of "<< comp.getName() <<
" from "<<filename<<endlog();
1438 compmap[ comp.getName() ].loadedProperties =
true;
1444 if ( compmap[comp.getName()].act ) {
1445 if ( peer->getActivity() ) {
1446 log(Info) <<
"Re-setting activity of "<< comp.getName() <<endlog();
1448 log(Info) <<
"Setting activity of "<< comp.getName() <<endlog();
1450 if (peer->setActivity( compmap[comp.getName()].act ) ==
false ) {
1452 log(Error) <<
"Failed to set Activity of " << comp.getName() << endlog();
1454 assert( peer->engine()->getActivity() == compmap[comp.getName()].act );
1455 compmap[comp.getName()].act = 0;
1460 for (RTT::PropertyBag::const_iterator ps = comp.rvalue().begin(); ps!= comp.rvalue().end(); ++ps) {
1461 RTT::Property<string> script;
1462 if ( (*ps)->getName() ==
"RunScript" )
1464 if ( script.ready() ) {
1465 valid = valid && peer->getProvider<Scripting>(
"scripting")->
runScript( script.get() );
1468 RTT::Property<string> pscript;
1469 if ( (*ps)->getName() ==
"ProgramScript" )
1471 if ( pscript.ready() ) {
1472 valid = valid && peer->getProvider<Scripting>(
"scripting")->loadPrograms( pscript.get() );
1474 RTT::Property<string> sscript;
1475 if ( (*ps)->getName() ==
"StateMachineScript" )
1477 if ( sscript.ready() ) {
1478 valid = valid && peer->getProvider<Scripting>(
"scripting")->loadStateMachines( sscript.get() );
1483 if (compmap[comp.getName()].autoconf )
1485 if( !peer->isRunning() )
1487 OperationCaller<bool(void)> peerconfigure = peer->getOperation(
"configure");
1488 if ( peerconfigure() ==
false) {
1489 log(Error) <<
"Component " << peer->getName() <<
" returns false in configure()" << endlog();
1494 log(Warning) <<
"Apparently component "<< peer->getName()<<
" don't need to be configured (already Running)." <<endlog();
1501 for ( CompList::iterator cit = comps.begin(); cit != comps.end(); ++cit) {
1503 if ( group == cd->
group && cd->
loaded && cd->autoconf &&
1504 (cd->
instance->getTaskState() != TaskCore::Stopped) &&
1505 (cd->
instance->getTaskState() != TaskCore::Running))
1506 log(Error) <<
"Failed to configure component "<< cd->
instance->getName()
1507 <<
": state is " << cd->
instance->getTaskState() <<endlog();
1510 log(Info) <<
"Configuration successful for group " << group <<
"." <<endlog();
1513 validConfig.set(valid);
1521 for (
int group = 0; group <=
nextGroup; ++group) {
1529 RTT::Logger::In in(
"startComponentsGroup");
1530 if (validConfig.get() ==
false) {
1531 log(Error) <<
"Not starting components with invalid configuration." <<endlog();
1535 for (RTT::PropertyBag::iterator it=
root.begin(); it!=
root.end();it++) {
1538 if (group != compmap[(*it)->getName()].group) {
1542 TaskContext* peer = compmap[(*it)->getName()].instance;
1546 if (peer->isRunning())
1552 OperationCaller<bool(void)> peerstart = peer->getOperation(
"start");
1553 if (compmap[(*it)->getName()].autostart )
1554 if ( !peer || ( !peer->isRunning() && peerstart() ==
false) )
1559 for ( CompList::iterator cit = comps.begin(); cit != comps.end(); ++cit) {
1563 if (group != it->
group) {
1568 log(Error) <<
"Failed to start component "<< *cit <<
": not found." << endlog();
1571 if ( it->autostart && it->
instance->getTaskState() != base::TaskCore::Running )
1572 log(Error) <<
"Failed to start component "<< it->
instance->getName() <<endlog();
1575 log(Info) <<
"Startup of 'AutoStart' components successful for group " << group <<
"." <<endlog();
1584 for (
int group =
nextGroup ; group != -1; --group) {
1592 RTT::Logger::In in(
"stopComponentsGroup");
1593 log(Info) <<
"Stopping group " << group << endlog();
1596 for ( CompList::reverse_iterator cit = comps.rbegin(); cit != comps.rend(); ++cit) {
1599 OperationCaller<bool(void)> instancestop = it->
instance->getOperation(
"stop");
1602 log(Info) <<
"Stopped "<< it->
instance->getName() <<endlog();
1604 log(Error) <<
"Could not stop loaded Component "<< it->
instance->getName() <<endlog();
1616 for (
int group =
nextGroup ; group != -1; --group) {
1624 RTT::Logger::In in(
"cleanupComponentsGroup");
1626 log(Info) <<
"Cleaning up group " << group << endlog();
1628 for ( CompList::reverse_iterator cit = comps.rbegin(); cit != comps.rend(); ++cit) {
1632 if (group != it->
group) {
1637 if ( it->
instance->getTaskState() <= base::TaskCore::Stopped ) {
1638 if ( it->autosave && !it->configfile.empty()) {
1640 string file = it->configfile;
1642 bool ret = pl.save( file,
true );
1644 log(Error) <<
"Failed to save properties for component "<< it->
instance->getName() <<endlog();
1647 log(Info) <<
"Refusing to save property file that was not loaded for "<< it->
instance->getName() <<endlog();
1649 }
else if (it->autosave) {
1650 log(Error) <<
"AutoSave set but no property file specified. Specify one using the UpdateProperties simple element."<<endlog();
1652 }
else if (it->autosave) {
1653 log(Error) <<
"AutoSave set but no property file specified. Specify one using the UpdateProperties simple element."<<endlog();
1655 OperationCaller<bool(void)> instancecleanup = it->
instance->getOperation(
"cleanup");
1657 log(Info) <<
"Cleaned up "<< it->
instance->getName() <<endlog();
1659 log(Error) <<
"Could not cleanup Component "<< it->
instance->getName() <<
" (not Stopped)"<<endlog();
1671 for (
int group =
nextGroup ; group != -1; --group) {
1679 log(Info) <<
"Unloading group " << group << endlog();
1682 CompList::reverse_iterator cit = comps.rbegin();
1683 while ( valid && cit != comps.rend())
1686 if (group == it->
group)
1691 cit = comps.rbegin();
1705 log(Info) <<
"Clearing configuration options."<< endlog();
1707 deletePropertyBag(
root );
1712 RTT::Logger::In in(
"import");
1713 return ComponentLoader::Instance()->import( package,
"" );
1718 RTT::Logger::In in(
"path");
1719 ComponentLoader::Instance()->setComponentPath( ComponentLoader::Instance()->getComponentPath() + path );
1720 PluginLoader::Instance()->setPluginPath( PluginLoader::Instance()->getPluginPath() + path );
1725 RTT::Logger::In in(
"loadLibrary");
1726 return PluginLoader::Instance()->loadLibrary(name) || ComponentLoader::Instance()->loadLibrary(name);
1731 RTT::Logger::In in(
"reloadLibrary");
1732 return ComponentLoader::Instance()->reloadLibrary(name);
1736 TaskContext* peer = 0;
1737 if ((name == getName()) || (name ==
"this"))
1739 else if ( (peer = getPeer(name)) == 0) {
1740 log(Error)<<
"No such peer: "<< name<<
". Can not load service '"<<type<<
"'."<<endlog();
1745 if (peer->provides()->hasService(type))
1747 return PluginLoader::Instance()->loadService(type, peer);
1753 RTT::Logger::In in(
"loadComponent");
1755 if ( type ==
"RTT::PropertyBag" )
1758 if ( this->getPeer(name) || ( compmap.find(name) != compmap.end() && compmap[name].instance != 0) ) {
1759 log(Error) <<
"Failed to load component with name "<<name<<
": already present as peer or loaded."<<endlog();
1763 TaskContext* instance = ComponentLoader::Instance()->loadComponent(name, type);
1770 compmap[name].instance = instance;
1771 comps.push_back(name);
1774 log(Error) <<
"This deployer type refused to connect to "<< instance->getName() <<
": aborting !" << endlog(Error);
1775 compmap[name].instance = 0;
1776 ComponentLoader::Instance()->unloadComponent( instance );
1782 log(Info) <<
"Adding "<< instance->getName() <<
" as new peer: OK."<< endlog(Info);
1784 compmap[name].loaded =
true;
1797 std::string name = cit->first;
1800 if ( !it->
instance->isRunning() ) {
1804 log(Debug) <<
"Disconnecting " <<name <<endlog();
1806 log(Debug) <<
"Terminating " <<name <<endlog();
1808 log(Debug) <<
"Removing proxy for " <<name <<endlog();
1811 for( ConMap::iterator cmit = conmap.begin(); cmit != conmap.end(); ++cmit) {
1813 while ( n != cmit->second.owners.size() ) {
1814 if (cmit->second.owners[n] == it->
instance ) {
1815 cmit->second.owners.erase( cmit->second.owners.begin() + n );
1816 cmit->second.ports.erase( cmit->second.ports.begin() + n );
1823 RTT::Property<RTT::PropertyBag>* pcomp =
root.getPropertyType<PropertyBag>(name);
1825 root.removeProperty(pcomp);
1831 ComponentLoader::Instance()->unloadComponent( it->
instance );
1833 log(Info) <<
"Disconnected and destroyed "<< name <<endlog();
1835 log(Error) <<
"Could not unload Component "<< name <<
": still running." <<endlog();
1843 CompList::iterator it = comps.begin();
1844 while(it != comps.end()) {
1846 it = comps.erase(it);
1856 CompMap::iterator it;
1858 if ( compmap.count( name ) == 0 || compmap[name].loaded == false ) {
1859 log(Error) <<
"Can't unload component '"<<name<<
"': not loaded by "<<this->getName()<<endlog();
1864 it = compmap.find(name);
1869 log(Info) <<
"Successfully unloaded component "<<name<<
"."<<endlog();
1875 FactoryMap::const_iterator it;
1876 cout <<
"I can create the following component types: " <<endl;
1878 cout <<
" " << it->first << endl;
1881 cout <<
" (none)"<<endl;
1886 std::vector<std::string> s;
1887 FactoryMap::const_iterator it;
1889 s.push_back(it->first);
1895 double period,
int priority,
1898 if ( this->
setNamedActivity(comp_name,
"Activity", period, priority, scheduler) ) {
1899 assert( compmap[comp_name].instance );
1900 assert( compmap[comp_name].act );
1901 compmap[comp_name].instance->setActivity( compmap[comp_name].act );
1902 compmap[comp_name].act = 0;
1909 double timeout,
int priority,
1912 if ( this->
setNamedActivity(comp_name,
"FileDescriptorActivity", timeout, priority, scheduler) ) {
1913 assert( compmap[comp_name].instance );
1914 assert( compmap[comp_name].act );
1915 compmap[comp_name].instance->setActivity( compmap[comp_name].act );
1916 compmap[comp_name].act = 0;
1923 double period,
int priority,
1924 int scheduler,
unsigned int cpu_nr)
1926 unsigned int mask = 0x1 << cpu_nr;
1927 if ( this->
setNamedActivity(comp_name,
"Activity", period, priority, scheduler, mask) ) {
1928 assert( compmap[comp_name].instance );
1929 assert( compmap[comp_name].act );
1930 compmap[comp_name].instance->setActivity( compmap[comp_name].act );
1931 compmap[comp_name].act = 0;
1938 double period,
int priority,
1941 if ( this->
setNamedActivity(comp_name,
"PeriodicActivity", period, priority, scheduler) ) {
1942 assert( compmap[comp_name].instance );
1943 assert( compmap[comp_name].act );
1944 compmap[comp_name].instance->setActivity( compmap[comp_name].act );
1945 compmap[comp_name].act = 0;
1954 if ( this->
setNamedActivity(comp_name,
"SlaveActivity", period, 0, ORO_SCHED_OTHER ) ) {
1955 assert( compmap[comp_name].instance );
1956 assert( compmap[comp_name].act );
1957 compmap[comp_name].instance->setActivity( compmap[comp_name].act );
1958 compmap[comp_name].act = 0;
1967 assert( compmap[comp_name].instance );
1968 assert( compmap[comp_name].act );
1969 compmap[comp_name].instance->setActivity( compmap[comp_name].act );
1970 compmap[comp_name].act = 0;
1977 const std::string& slave)
1979 if ( this->
setNamedActivity(slave,
"SlaveActivity", 0, 0, ORO_SCHED_OTHER, master ) ) {
1980 assert( compmap[slave].instance );
1981 assert( compmap[slave].act );
1982 compmap[slave].instance->setActivity( compmap[slave].act );
1983 compmap[slave].act = 0;
1991 const std::string& act_type,
1992 double period,
int priority,
1993 int scheduler,
const std::string& master_name)
2005 const std::string& act_type,
2006 double period,
int priority,
2007 int scheduler,
unsigned cpu_affinity,
2008 const std::string& master_name)
2012 RTT::TaskContext* peer = 0;
2013 base::ActivityInterface* master_act = 0;
2014 if ( comp_name == this->getName() )
2017 if ( compmap.count(comp_name) )
2018 peer = compmap[comp_name].instance;
2020 peer = this->getPeer(comp_name);
2022 log(Error) <<
"Can't create Activity: component "<<comp_name<<
" not found."<<endlog();
2025 if ( !master_name.empty() ) {
2026 if ( master_name == this->getName() )
2027 master_act = this->engine()->getActivity();
2029 if ( compmap.count(master_name) && compmap[master_name].act )
2030 master_act = compmap[master_name].act;
2032 master_act = this->getPeer(master_name) ? getPeer(master_name)->engine()->getActivity() : 0;
2034 if ( !this->getPeer(master_name) ) {
2035 log(Error) <<
"Can't create SlaveActivity: Master component "<<master_name<<
" not known as peer."<<endlog();
2040 log(Error) <<
"Can't create SlaveActivity: Master component "<<master_name<<
" has no activity set."<<endlog();
2045 compmap[comp_name].instance = peer;
2046 if ( peer->isRunning() ) {
2047 log(Error) <<
"Can't change activity of component "<<comp_name<<
" since it is still running."<<endlog();
2051 base::ActivityInterface* newact = 0;
2053 if ( act_type ==
"Activity")
2054 newact =
new RTT::Activity(scheduler, priority, period, cpu_affinity, 0, comp_name);
2057 if ( act_type ==
"PeriodicActivity" && period != 0.0)
2058 newact =
new RTT::extras::PeriodicActivity(scheduler, priority, period, cpu_affinity, 0);
2060 if ( act_type ==
"NonPeriodicActivity" && period == 0.0)
2061 newact =
new RTT::Activity(scheduler, priority, period, cpu_affinity, 0);
2063 if ( act_type ==
"SlaveActivity" ) {
2064 if ( master_act == 0 )
2065 newact =
new extras::SlaveActivity(period);
2067 newact =
new extras::SlaveActivity(master_act);
2068 this->getPeer(master_name)->addPeer( peer );
2072 if (act_type ==
"Activity") {
2073 newact =
new Activity(scheduler, priority, period, cpu_affinity, 0, comp_name);
2076 if (act_type ==
"SequentialActivity") {
2077 newact =
new SequentialActivity();
2079 else if ( act_type ==
"FileDescriptorActivity") {
2080 using namespace RTT::extras;
2081 newact =
new FileDescriptorActivity(scheduler, priority, period, cpu_affinity, 0);
2082 FileDescriptorActivity* fdact =
dynamic_cast< RTT::extras::FileDescriptorActivity*
> (newact);
2083 if (fdact) fdact->setTimeout(period);
2087 log(Error) <<
"Can't create '"<< act_type <<
"' for component "<<comp_name<<
": incorrect arguments."<<endlog();
2092 newact->thread()->setWaitPeriodPolicy(defaultWaitPeriodPolicy);
2095 assert( peer->isRunning() == false );
2096 delete compmap[comp_name].act;
2097 compmap[comp_name].act = newact;
2104 if ( !compmap.count(comp_name) ) {
2105 log(Error) <<
"Can't setWaitPeriodPolicy: component "<<comp_name<<
" not found."<<endlog();
2109 RTT::base::ActivityInterface *activity = compmap[comp_name].instance->getActivity();
2111 log(Error) <<
"Can't setWaitPeriodPolicy: component "<<comp_name<<
" has no activity (yet)."<<endlog();
2115 activity->thread()->setWaitPeriodPolicy(policy);
2126 RTT::Logger::In in(
"DeploymentComponent");
2127 RTT::TaskContext* c;
2128 if ( name == this->getName() )
2131 c = this->getPeer(name);
2133 log(Error)<<
"No such peer to configure: "<<name<<endlog();
2137 marsh::PropertyLoader pl(c);
2138 return pl.configure( filename,
true );
2143 return RTT::ComponentLoader::Instance()->getFactories();
2148 RTT::Logger::In in(
"kickOut");
2149 RTT::PropertyBag from_file;
2150 RTT::Property<std::string> import_file;
2151 std::vector<std::string> deleted_components_type;
2153 marsh::PropertyDemarshaller demarshaller(config_file);
2155 if ( demarshaller.deserialize( from_file ) ){
2156 for (RTT::PropertyBag::iterator it= from_file.begin(); it!=from_file.end();it++) {
2157 if ( (*it)->getName() ==
"Import" )
continue;
2158 if ( (*it)->getName() ==
"Include" )
continue;
2162 deletePropertyBag( from_file );
2165 log(Error)<<
"Some error occured while parsing "<< config_file <<endlog();
2169 log(Error)<<
"Uncaught exception in kickOut() !"<< endlog();
2175 RTT::Logger::In in(
"cleanupComponent");
2179 if ( instance->getTaskState() <= base::TaskCore::Stopped ) {
2180 OperationCaller<bool(void)> instancecleanup = instance->getOperation(
"cleanup");
2182 log(Info) <<
"Cleaned up "<< instance->getName() <<endlog();
2184 log(Error) <<
"Could not cleanup Component "<< instance->getName() <<
" (not Stopped)"<<endlog();
2193 RTT::Logger::In in(
"configureComponent");
2197 OperationCaller<bool(void)> instanceconfigure = instance->getOperation(
"configure");
2198 if(instanceconfigure()) {
2199 log(Info) <<
"Configured " << instance->getName()<<endlog();
2203 log(Error) <<
"Could not configure loaded Component "<< instance->getName() <<endlog();
2211 RTT::Logger::In in(
"startComponent");
2215 OperationCaller<bool(void)> instancestart = instance->getOperation(
"start");
2216 if ( instance->isRunning() ||
2218 log(Info) <<
"Started "<< instance->getName() <<endlog();
2222 log(Error) <<
"Could not start loaded Component "<< instance->getName() <<endlog();
2230 RTT::Logger::In in(
"stopComponent");
2234 OperationCaller<bool(void)> instancestop = instance->getOperation(
"stop");
2235 if ( !instance->isRunning() ||
2237 log(Info) <<
"Stopped "<< instance->getName() <<endlog();
2240 log(Error) <<
"Could not stop loaded Component "<< instance->getName() <<endlog();
2249 RTT::Logger::In in(
"kickOutComponent");
2251 RTT::TaskContext* peer = compmap.count(comp_name) ? compmap[ comp_name ].instance : 0;
2254 log(Error) <<
"Component not loaded by this Deployer: "<< comp_name <<endlog();
2262 root.removeProperty(
root.find( comp_name ) );
2269 static const char* PEER=
"Application";
2270 static const char* NAME=
"shutdownDeployment";
2273 static const char* WAIT_PROP_NAME=
"shutdownWait_ms";
2274 static const char* TOTAL_WAIT_PROP_NAME=
"shutdownTotalWait_ms";
2276 RTT::OperationCaller<void(void)> ds;
2277 bool has_program =
false;
2278 bool has_operation =
false;
2280 RTT::TaskContext* peer = getPeer(PEER);
2282 has_operation = peer->provides()->hasOperation(NAME);
2284 ds = peer->provides()->getOperation(NAME);
2286 log(Info) <<
"Ignoring deployment shutdown function due to missing peer." << endlog();
2291 has_operation =
false;
2292 log(Info) <<
"Ignoring deployment shutdown function, looking for shutdown program script." << endlog();
2293 has_program = peer->getProvider<Scripting>(
"scripting")->hasProgram(NAME);
2296 if (has_operation || has_program)
2298 log(Info) <<
"Shutting down deployment." << endlog();
2299 RTT::SendHandle<void(void)> handle;
2302 if (handle.ready() || peer->getProvider<Scripting>(
"scripting")->startProgram(NAME))
2309 int totalWait = 2000;
2312 RTT::Property<int> wait_prop =
2313 this->properties()->getProperty(WAIT_PROP_NAME);
2314 if (wait_prop.ready())
2316 int w = wait_prop.rvalue();
2320 log(Debug) <<
"Using override value for " << WAIT_PROP_NAME << endlog();
2324 log(Warning) <<
"Ignoring illegal value for " << WAIT_PROP_NAME << endlog();
2329 log(Debug) <<
"Using default value for " << WAIT_PROP_NAME << endlog();
2332 RTT::Property<int> totalWait_prop =
2333 this->properties()->getProperty(TOTAL_WAIT_PROP_NAME);
2334 if (totalWait_prop.ready())
2336 int w = totalWait_prop.rvalue();
2340 log(Debug) <<
"Using override value for " << TOTAL_WAIT_PROP_NAME << endlog();
2344 log(Warning) <<
"Ignoring illegal value for " << TOTAL_WAIT_PROP_NAME << endlog();
2349 log(Debug) <<
"Using default value for " << TOTAL_WAIT_PROP_NAME << endlog();
2353 if (wait > totalWait)
2356 log(Warning) <<
"Setting wait == totalWait" << endlog();
2359 const long int wait_ns = wait * 1000000LL;
2361 ts.tv_sec = wait_ns / 1000000000LL;
2362 ts.tv_nsec = wait_ns % 1000000000LL;
2365 log(Debug) <<
"Waiting for deployment shutdown to complete ..." << endlog();
2367 while ( ( (has_operation && RTT::SendNotReady == handle.collectIfDone() ) ||
2368 (has_program && peer->getProvider<Scripting>(
"scripting")->isProgramRunning(NAME)) )
2369 && (waited < totalWait) )
2371 (void)rtos_nanosleep(&ts, NULL);
2374 if (waited >= totalWait)
2376 log(Error) <<
"Timed out waiting for deployment shutdown to complete." << endlog();
2380 log(Debug) <<
"Deployment shutdown completed." << endlog();
2385 log(Error) <<
"Failed to start operation or scripting program: " << NAME << endlog();
2391 log(Info) <<
"No deployment shutdown function or program available." << endlog();
bool loadComponents(const std::string &config_file)
Load a (partial) application XML configuration from disk.
base::PortInterface * stringToPort(std::string const &names)
Converts a dot-separated path to a service to a Port object.
virtual void componentUnloaded(RTT::TaskContext *c)
Hook function for subclasses.
bool stopComponentsGroup(const int group)
Stop all loaded and running components in group group.
bool configureComponentsGroup(const int group)
Configure the components in group group.
bool kickStart(const std::string &file_name)
This function runs loadComponents, configureComponents and startComponents in a row, given no failures occur along the way.
int group
Group number this component belongs to.
virtual bool componentLoaded(RTT::TaskContext *c)
Hook function for subclasses.
bool configure(const std::string &name)
Configure a component by loading the property file 'name.cpf' for component with name name...
base::ActivityInterface * act
The activity created by DeploymentComponent.
void shutdownDeployment()
Clean up and shutdown the entire deployment If an operation named "shutdownDeployment" is found in a ...
Assembles all ports which share a connection.
bool loadLibrary(const std::string &name)
Use this command to load a plugin or component library into the memory of the current process...
bool cleanupComponents()
Cleanup all loaded and not running components.
void displayComponentTypes() const
This function prints out the component types this DeploymentComponent can create. ...
bool loadConfiguration(const std::string &config_file)
Load a (partial) application XML configuration from disk.
bool setFileDescriptorActivity(const std::string &comp_name, double timeout, int priority, int scheduler)
(Re-)set the activity of a component with a FileDescriptor activity.
bool connect(const std::string &one, const std::string &other, ConnPolicy policy)
Connect two named ports of components.
bool cleanupComponent(RTT::TaskContext *instance)
Cleanup a single loaded and not running component.
~DeploymentComponent()
Cleans up all configuration related information.
bool runScript(const std::string &file_name)
Scripting-alternative to kickStart: runs this script in the Orocos scripting service.
int nextGroup
Next group number.
Service::shared_ptr stringToService(std::string const &names)
Converts a dot-separated path to a service to a Service object.
bool setWaitPeriodPolicy(const std::string &comp_name, int policy)
(Re-)set the wait period policy of a component's thread.
bool stopComponents()
Stop all loaded and running components.
ServiceRequester::shared_ptr stringToServiceRequester(std::string const &names)
Converts a dot-separated path to a service to a ServiceRequester object.
bool loadConfigurationString(const std::string &config_text)
Identical to loadConfiguration, but reads the XML from a string instead of a file.
RTT::TaskContext * instance
The component instance.
bool createStream(const std::string &component, const std::string &port, ConnPolicy policy)
const RTT::FactoryMap & getFactories() const
Returns the factory singleton which creates all types of components for the DeploymentComponent.
bool aliasPeer(const std::string &from, const std::string &target, const std::string &alias)
Make one component a peer of the other, in one direction, with an alternative name, such that one can use the services of the other and knows it under the name of the alias.
bool setNamedActivity(const std::string &comp_name, const std::string &act_type, double period, int priority, int scheduler, const std::string &master_name="")
(Re-)set the activity of a component.
bool waitForInterrupt()
Waits for SIGINT and then returns.
This file contains the macros and definitions to create dynamically loadable components.
bool addPeer(const std::string &from, const std::string &target)
Make one component a peer of the other, in one direction, such that one can use the services of the o...
bool loadComponent(const std::string &name, const std::string &type)
Load a new component in the current process.
bool unloadComponent(const std::string &name)
Unload a loaded component from the current process.
bool configureComponent(RTT::TaskContext *instance)
Configure a single loaded and running component.
bool loadComponentsInGroup(const std::string &config_file, const int group)
Load a (partial) application XML configuration from disk into a specific group.
bool unloadComponentsGroup(const int group)
Unload all loaded and not running components in group group.
DeploymentComponent(std::string name="Deployer", std::string siteFile="")
Constructs and configures this component.
bool cleanupComponentsGroup(const int group)
Cleanup all loaded and not running components.
The Orocos Component Library.
std::vector< std::string > getComponentTypes() const
This function returns the component types this DeploymentComponent can create in a comma separated li...
bool setMasterSlaveActivity(const std::string &comp_name, const std::string &master_name)
(Re-)set the activity of a component with a slave activity with master.
void clearConfiguration()
Clear all loaded configuration options.
bool stream(const std::string &port, ConnPolicy policy)
Creates a stream from a given port of a component.
bool loaded
True if it was loaded and created by DeploymentComponent.
bool loadService(const std::string &component, const std::string &service)
Loads a service in the given component.
bool kickOutAll()
Stop, cleanup and unload all components loaded by the DeploymentComponent.
bool setSequentialActivity(const std::string &comp_name)
(Re-)set the activity of a component with a (threadless, reactive) sequential activity.
bool setActivity(const std::string &comp_name, double period, int priority, int scheduler)
(Re-)set the activity of a component with an activity.
bool setSlaveActivity(const std::string &comp_name, double period)
(Re-)set the activity of a component with a (stand alone) slave activity.
bool configureComponents()
Configure the components with loaded configuration(s).
bool kickOutGroup(const int group)
Stop, cleanup and unload all components in group group.
bool startComponentsGroup(const int group)
Start all components in group group which have AutoStart set to true.
bool kickOutComponent(const std::string &comp_name)
Stop, cleanup and unload a single component which were loaded by this component.
bool connectServices(const std::string &one, const std::string &other)
Connects the required services of one component to the provided services of another and vice versa...
bool configureFromFile(const std::string &name, const std::string &filename)
Configure a component by loading a property file.
A Component for deploying (configuring) other components in an application.
bool setPeriodicActivity(const std::string &comp_name, double period, int priority, int scheduler)
(Re-)set the activity of a component with a periodic activity.
bool loadedProperties
True if successfully loaded a property file, and so will need auto-saving (it autosave is on) ...
Each configured component is stored in a struct like this.
bool connectPeers(const std::string &one, const std::string &other)
Make two components peers in both directions, such that both can use each other's services...
bool connectOperations(const std::string &required, const std::string &provided)
Connects a required operation to a provided operation.
bool reloadLibrary(const std::string &filepath)
Use this command to reload a component library into the memory of the current process.
void path(const std::string &path)
Add an additional path to search for component packages.
bool unloadComponents()
Unload all loaded and not running components.
bool configureHook()
This function imports available plugins from the path formed by the expression.
bool startComponent(RTT::TaskContext *instance)
Stop a single loaded and running component.
RTT::PropertyBag root
This bag stores the current configuration.
bool unloadComponentImpl(CompMap::iterator cit)
This method removes all references to the component hold in cit, on the condition that it is not runn...
bool waitForSignal(int signumber)
Waits for any signal and then returns.
void kickOut(const std::string &config_file)
Identical to kickOutAll, but it reads the name of the Components to kickOut from an XML file...
bool startComponents()
Start all components in the current configuration which have AutoStart set to true.
bool connectPorts(const std::string &one, const std::string &other)
Establish a data flow connection between two tasks.
bool import(const std::string &package)
Import a component package or directory.
bool stopComponent(RTT::TaskContext *instance)
Stop a single loaded and running component.
bool setActivityOnCPU(const std::string &comp_name, double period, int priority, int scheduler, unsigned int cpu_nr)
(Re-)set the activity of a component and run it on a given CPU.