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() ) {
289 int sigs[] = { SIGINT, SIGTERM, SIGHUP };
292 cout <<
"DeploymentComponent: Got interrupt !" <<endl;
302 struct sigaction sa, sold[sig_count];
303 std::size_t index = 0;
304 sa.sa_handler = ctrl_c_catcher;
305 for( ; index < sig_count; ++index) {
306 if ( ::sigaction(sigs[index], &sa, &sold[index]) != 0) {
307 cout <<
"DeploymentComponent: Failed to install signal handler for signal " << sigs[index] << endl;
312 if (index == sig_count) {
313 bool break_loop =
false;
315 for(std::size_t check = 0; check < sig_count; ++check) {
316 if (got_signal == sigs[check]) break_loop =
true;
321 rtos_nanosleep(&ts, 0);
329 if (sold[index].sa_handler || sold[index].sa_sigaction) {
330 ::sigaction(sigs[index], &sold[index], NULL);
335 cout <<
"DeploymentComponent: Failed to install signal handler for signal " << sig <<
": Not supported by this Operating System. "<<endl;
342 RTT::Logger::In in(
"connectPeers");
343 RTT::TaskContext* t1 = (((one == this->getName()) || (one ==
"this")) ?
this : this->getPeer(one));
344 RTT::TaskContext* t2 = (((other == this->getName()) || (other ==
"this")) ?
this : this->getPeer(other));
346 log(Error)<<
"No such peer: "<<one<<endlog();
350 log(Error) <<
"No such peer: "<<other<<endlog();
353 return t1->connectPeers(t2);
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: "<<from<<endlog();
366 log(Error)<<
"No such peer: "<<to<<endlog();
369 if ( t1->hasPeer(to) ) {
370 log(Info) <<
"addPeer: "<< to <<
" is already a peer of " << from << endlog();
373 return t1->addPeer(t2,to);
378 RTT::Logger::In in(
"addPeer");
379 RTT::TaskContext* t1 = (((from == this->getName()) || (from ==
"this")) ?
this : this->getPeer(from));
380 RTT::TaskContext* t2 = (((to == this->getName()) || (to ==
"this")) ?
this : this->getPeer(to));
382 log(Error)<<
"No such peer known to deployer '"<< this->getName()<<
"': "<<from<<endlog();
386 log(Error)<<
"No such peer known to deployer '"<< this->getName()<<
"': "<<to<<endlog();
389 return t1->addPeer(t2, alias);
393 std::vector<std::string> strs;
394 boost::split(strs, names, boost::is_any_of(
"."));
397 if (strs.empty())
return Service::shared_ptr();
399 string component = strs.front();
400 RTT::TaskContext *tc = (((component == this->getName()) || (component ==
"this")) ?
this : getPeer(component));
402 log(Error) <<
"No such component: '"<< component <<
"'";
403 if ( names.find(
'.') != string::npos )
404 log(Error) <<
" when looking for service '" << names <<
" '";
406 return Service::shared_ptr();
409 Service::shared_ptr ret = tc->provides();
412 strs.erase( strs.begin() );
415 while ( !strs.empty() && ret) {
416 ret = ret->getService( strs.front() );
418 strs.erase( strs.begin() );
421 log(Error) <<
"No such service: '"<< strs.front() <<
"' while looking for service '"<< names<<
"'"<<endlog();
427 std::vector<std::string> strs;
428 boost::split(strs, names, boost::is_any_of(
"."));
430 string component = strs.front();
431 RTT::TaskContext *tc = (((component == this->getName()) || (component ==
"this")) ?
this : getPeer(component));
433 log(Error) <<
"No such component: '"<< component <<
"'" <<endlog();
434 if ( names.find(
'.') != string::npos )
435 log(Error)<<
" when looking for service '" << names <<
"'" <<endlog();
436 return ServiceRequester::shared_ptr();
439 ServiceRequester::shared_ptr ret = tc->requires();
442 strs.erase( strs.begin() );
445 while ( !strs.empty() && ret) {
446 ret = ret->requires( strs.front() );
448 strs.erase( strs.begin() );
451 log(Error) <<
"No such service: '"<< strs.front() <<
"' while looking for service '"<< names<<
"'"<<endlog();
457 std::vector<std::string> strs;
458 boost::split(strs, names, boost::is_any_of(
"."));
461 if (strs.empty())
return 0;
463 string component = strs.front();
464 RTT::TaskContext *tc = (((component == this->getName()) || (component ==
"this")) ?
this : getPeer(component));
466 log(Error) <<
"No such component: '"<< component <<
"'" ;
467 log(Error)<<
" when looking for port '" << names <<
"'" <<endlog();
471 Service::shared_ptr serv = tc->provides();
472 base::PortInterface* ret = 0;
475 strs.erase( strs.begin() );
478 while ( strs.size() != 1 && serv) {
479 serv = serv->getService( strs.front() );
481 strs.erase( strs.begin() );
484 log(Error) <<
"No such service: '"<< strs.front() <<
"' while looking for port '"<< names<<
"'"<<endlog();
487 ret = serv->getPort(strs.front());
489 log(Error) <<
"No such port: '"<< strs.front() <<
"' while looking for port '"<< names<<
"'"<<endlog();
497 RTT::Logger::In in(
"connectPorts");
498 RTT::TaskContext* a, *b;
502 log(Error) << one <<
" could not be found."<< endlog();
506 log(Error) << other <<
" could not be found."<< endlog();
510 return a->connectPorts(b);
514 const std::string& other,
const std::string& other_port)
516 RTT::Logger::In in(
"connectPorts");
517 Service::shared_ptr a,b;
522 base::PortInterface* ap, *bp;
523 ap = a->getPort(one_port);
524 bp = b->getPort(other_port);
526 log(Error) << one <<
" does not have a port "<<one_port<< endlog();
530 log(Error) << other <<
" does not have a port "<<other_port<< endlog();
535 if ( ap->connected() && bp->connected() ) {
536 log(Debug) <<
"Port '"<< ap->getName() <<
"' of Component '"<<a->getName()
537 <<
"' and port '"<< bp->getName() <<
"' of Component '"<<b->getName()
538 <<
"' are already connected but (probably) not to each other. Connecting them anyway."<<endlog();
542 if ( ap->connectTo( bp ) ) {
544 log(Info)<<
"Connected Port " << one +
"." + one_port <<
" to "<< other +
"." + other_port <<
"." << endlog();
547 log(Error)<<
"Failed to connect Port " << one +
"." + one_port <<
" to "<< other +
"." + other_port <<
"." << endlog();
557 PortInterface* porti = serv->getPort(port);
559 log(Error) <<
"Service in component "<<comp<<
" has no port "<< port <<
"."<< endlog();
562 return porti->createStream( policy );
568 RTT::Logger::In in(
"connect");
569 base::PortInterface* ap, *bp;
576 if ( ap->connected() && bp->connected() ) {
577 log(Debug) <<
"Port '"<< ap->getName() <<
"' of '"<< one
578 <<
"' and port '"<< bp->getName() <<
"' of '"<< other
579 <<
"' are already connected but (probably) not to each other. Connecting them anyway."<<endlog();
583 if ( ap->connectTo( bp, cp ) ) {
585 log(Info)<<
"Connected Port " << one <<
" to "<< other <<
"." << endlog();
588 log(Error)<<
"Failed to connect Port " << one <<
" to "<< other <<
"." << endlog();
599 return porti->createStream( policy );
604 RTT::Logger::In in(
"connectServices");
605 RTT::TaskContext* a, *b;
609 log(Error) << one <<
" could not be found."<< endlog();
613 log(Error) << other <<
" could not be found."<< endlog();
617 return a->connectServices(b);
622 RTT::Logger::In in(
"connectOperations");
624 boost::iterator_range<std::string::const_iterator> reqs = boost::algorithm::find_last(required,
".");
625 std::string reqs_name(required.begin(), reqs.begin());
626 std::string rop_name(reqs.begin()+1, required.end());
627 log(Debug) <<
"Looking for required operation " << rop_name <<
" in service " << reqs_name << endlog();
630 boost::iterator_range<std::string::const_iterator> pros = boost::algorithm::find_last(provided,
".");
631 std::string pros_name(provided.begin(), pros.begin());
632 std::string pop_name(pros.begin()+1, provided.end());
633 log(Debug) <<
"Looking for provided operation " << pop_name <<
" in service " << pros_name << endlog();
636 RTT::base::OperationCallerBaseInvoker* rop = r->getOperationCaller(rop_name);
638 log(Error) <<
"No requested operation " << rop_name <<
" found in service " << reqs_name << endlog();
641 if ( rop->ready() ) {
642 log(Error) <<
"Requested operation " << rop_name <<
" already connected to a provided operation!" << endlog();
646 if (! p->hasOperation(pop_name)) {
647 log(Error) <<
"No provided operation " << pop_name <<
" found in service " << pros_name << endlog();
651 rop->setImplementation(p->getLocalOperation( pop_name ), r->getServiceOwner()->engine());
653 log(Debug) <<
"Successfully set up OperationCaller for operation " << rop_name << endlog();
657 int string_to_oro_sched(
const std::string& sched) {
658 if ( sched ==
"ORO_SCHED_OTHER" )
659 return ORO_SCHED_OTHER;
660 if (sched ==
"ORO_SCHED_RT" )
662 log(Error)<<
"Unknown scheduler type: "<< sched <<endlog();
668 const char* tmpfile =
".loadConfigurationString.cpf";
669 std::ofstream file( tmpfile );
670 file << text.c_str();
678 if (file_name.rfind(
".lua") == file_name.length() - 4) {
679 if (!this->provides()->hasService(
"Lua")) {
681 if(!RTT::plugin::PluginLoader::Instance()->loadService(
"Lua",
this)) {
682 RTT::log(RTT::Error) <<
"Could not load lua service." << RTT::endlog();
687 RTT::OperationCaller<bool(std::string)> exec_str =
688 this->provides(
"Lua")->getOperation(
"exec_str");
691 exec_str(
"require(\"rttlib\")");
695 RTT::OperationCaller<bool(std::string)> exec_file =
696 this->provides(
"Lua")->getOperation(
"exec_file");
698 return exec_file( file_name );
701 return this->getProvider<Scripting>(
"scripting")->
runScript( file_name );
711 log(Info) <<
"Successfully loaded, configured and started components from "<< configurationfile <<endlog();
714 log(Error) <<
"Failed to start a component: aborting kick-start."<<endlog();
717 log(Error) <<
"Failed to configure a component: aborting kick-start."<<endlog();
720 log(Error) <<
"Failed to load a component: aborting kick-start."<<endlog();
743 if ( sret && cret && uret) {
744 log(Info) <<
"Kick-out of group " << group <<
" successful."<<endlog();
748 log(Critical) <<
"Kick-out of group " << group <<
" failed: ";
750 log(Critical) <<
" stopComponents() failed.";
752 log(Critical) <<
" cleanupComponents() failed.";
754 log(Critical) <<
" unloadComponents() failed.";
755 log(Critical) << endlog();
774 RTT::Logger::In in(
"loadComponents");
776 RTT::PropertyBag from_file;
777 log(Info) <<
"Loading '" <<configurationfile<<
"' in group " << group <<
"."<< endlog();
779 bool failure =
false;
781 bool valid = validConfig.get();
782 marsh::PropertyDemarshaller demarshaller(configurationfile);
784 if ( demarshaller.deserialize( from_file ) )
787 log(Info)<<
"Validating new configuration..."<<endlog();
788 if ( from_file.empty() ) {
789 log(Error)<<
"Configuration was empty !" <<endlog();
794 for (RTT::PropertyBag::iterator it= from_file.begin(); it!=from_file.end();it++) {
796 if ( (*it)->getName() ==
"Import" ) {
797 RTT::Property<std::string> importp = *it;
798 if ( !importp.ready() ) {
799 log(Error)<<
"Found 'Import' statement, but it is not of type='string'."<<endlog();
803 if ( this->
import( importp.get() ) ==
false )
807 if ( (*it)->getName() ==
"LoadLibrary" ) {
808 RTT::Property<std::string> importp = *it;
809 if ( !importp.ready() ) {
810 log(Error)<<
"Found 'LoadLibrary' statement, but it is not of type='string'."<<endlog();
818 if ( (*it)->getName() ==
"Path" ) {
819 RTT::Property<std::string> pathp = *it;
820 if ( !pathp.ready() ) {
821 log(Error)<<
"Found 'Path' statement, but it is not of type='string'."<<endlog();
825 this->
path( pathp.get() );
828 if ( (*it)->getName() ==
"Include" ) {
829 RTT::Property<std::string> includep = *it;
830 if ( !includep.ready() ) {
831 log(Error)<<
"Found 'Include' statement, but it is not of type='string'."<<endlog();
841 RTT::Property<RTT::PropertyBag> comp = *it;
842 if ( !comp.ready() ) {
843 log(Error)<<
"RTT::Property '"<< *it <<
"' should be a struct, Include, Path or Import statement." << endlog();
850 Property<ConnPolicy> cp_prop((*it)->getName(),
"");
851 assert( cp_prop.ready() );
852 if ( cp_prop.compose( comp ) ) {
854 #if defined(RTT_VERSION_GTE) 855 #if RTT_VERSION_GTE(2,8,99) 857 if (cp_prop.getName() ==
"Default") {
858 RTT::ConnPolicy::Default() = cp_prop.get();
862 conmap[cp_prop.getName()].policy = cp_prop.get();
863 #if defined(RTT_VERSION_GTE) 864 #if RTT_VERSION_GTE(2,8,99) 868 log(Debug) <<
"Saw connection policy " << (*it)->getName() << endlog();
873 for (RTT::PropertyBag::const_iterator optit= comp.rvalue().begin(); optit != comp.rvalue().end();optit++) {
874 if ( valid_names.find( (*optit)->getName() ) == valid_names.end() ) {
875 log(Error) <<
"Unknown type syntax: '"<< (*optit)->getName() <<
"' in component struct "<< comp.getName() <<endlog();
879 if ( (*optit)->getName() ==
"AutoConnect" ) {
880 RTT::Property<bool> ps = comp.rvalue().getProperty(
"AutoConnect");
882 log(Error) <<
"AutoConnect must be of type <boolean>" << endlog();
885 compmap[comp.getName()].autoconnect = ps.get();
888 if ( (*optit)->getName() ==
"AutoStart" ) {
889 RTT::Property<bool> ps = comp.rvalue().getProperty(
"AutoStart");
891 log(Error) <<
"AutoStart must be of type <boolean>" << endlog();
894 compmap[comp.getName()].autostart = ps.get();
897 if ( (*optit)->getName() ==
"AutoSave" ) {
898 RTT::Property<bool> ps = comp.rvalue().getProperty(
"AutoSave");
900 log(Error) <<
"AutoSave must be of type <boolean>" << endlog();
903 compmap[comp.getName()].autosave = ps.get();
906 if ( (*optit)->getName() ==
"AutoConf" ) {
907 RTT::Property<bool> ps = comp.rvalue().getProperty(
"AutoConf");
909 log(Error) <<
"AutoConf must be of type <boolean>" << endlog();
912 compmap[comp.getName()].autoconf = ps.get();
915 if ( (*optit)->getName() ==
"Server" ) {
916 RTT::Property<bool> ps = comp.rvalue().getProperty(
"Server");
918 log(Error) <<
"Server must be of type <boolean>" << endlog();
921 compmap[comp.getName()].server = ps.get();
924 if ( (*optit)->getName() ==
"Service" || (*optit)->getName() ==
"Plugin" || (*optit)->getName() ==
"Provides") {
925 RTT::Property<string> ps = *optit;
927 log(Error) << (*optit)->getName() <<
" must be of type <string>" << endlog();
930 compmap[comp.getName()].plugins.push_back(ps.value());
934 if ( (*optit)->getName() ==
"UseNamingService" ) {
935 RTT::Property<bool> ps = comp.rvalue().getProperty(
"UseNamingService");
937 log(Error) <<
"UseNamingService must be of type <boolean>" << endlog();
940 compmap[comp.getName()].use_naming = ps.get();
943 if ( (*optit)->getName() ==
"PropertyFile" ) {
944 RTT::Property<string> ps = comp.rvalue().getProperty(
"PropertyFile");
946 log(Error) <<
"PropertyFile must be of type <string>" << endlog();
949 compmap[comp.getName()].configfile = ps.get();
952 if ( (*optit)->getName() ==
"UpdateProperties" ) {
953 RTT::Property<string> ps = comp.rvalue().getProperty(
"UpdateProperties");
955 log(Error) <<
"UpdateProperties must be of type <string>" << endlog();
958 compmap[comp.getName()].configfile = ps.get();
961 if ( (*optit)->getName() ==
"LoadProperties" ) {
962 RTT::Property<string> ps = comp.rvalue().getProperty(
"LoadProperties");
964 log(Error) <<
"LoadProperties must be of type <string>" << endlog();
967 compmap[comp.getName()].configfile = ps.get();
970 if ( (*optit)->getName() ==
"Properties" ) {
971 base::PropertyBase* ps = comp.rvalue().getProperty(
"Properties");
973 log(Error) <<
"Properties must be a <struct>" << endlog();
978 if ( (*optit)->getName() ==
"RunScript" ) {
979 base::PropertyBase* ps = comp.rvalue().getProperty(
"RunScript");
981 log(Error) <<
"RunScript must be of type <string>" << endlog();
986 if ( (*optit)->getName() ==
"ProgramScript" ) {
987 base::PropertyBase* ps = comp.rvalue().getProperty(
"ProgramScript");
989 log(Error) <<
"ProgramScript must be of type <string>" << endlog();
994 if ( (*optit)->getName() ==
"StateMachineScript" ) {
995 base::PropertyBase* ps = comp.rvalue().getProperty(
"StateMachineScript");
997 log(Error) <<
"StateMachineScript must be of type <string>" << endlog();
1005 RTT::TaskContext* c = 0;
1006 if ( (*it)->getName() == this->getName() )
1009 c = this->getPeer( (*it)->getName() );
1012 if (this->
loadComponent( (*it)->getName(), comp.rvalue().getType() ) ==
false) {
1013 log(Warning)<<
"Could not configure '"<< (*it)->getName() <<
"': No such peer."<< endlog();
1017 c = compmap[(*it)->getName()].instance;
1020 compmap[(*it)->getName()].group = group;
1021 log(Info) <<
"Component " << (*it)->getName() <<
" added to group " << group <<
"." << endlog();
1024 compmap[(*it)->getName()].instance = c;
1030 vector<string>& services = compmap[(*it)->getName()].plugins;
1031 for (vector<string>::iterator svit = services.begin(); svit != services.end(); ++svit) {
1032 if ( c->provides()->hasService( *svit ) ==
false) {
1033 PluginLoader::Instance()->loadService(*svit, c);
1038 if ( comp.value().getProperty(
"PropFile") )
1039 comp.value().getProperty(
"PropFile")->setName(
"PropertyFile");
1042 RTT::Property<RTT::PropertyBag>* ports = comp.value().getPropertyType<PropertyBag>(
"Ports");
1044 for (RTT::PropertyBag::iterator pit = ports->value().begin(); pit != ports->value().end(); pit++) {
1045 Property<string> portcon = *pit;
1046 if ( !portcon.ready() ) {
1047 log(Error)<<
"RTT::Property '"<< (*pit)->getName() <<
"' is not of type 'string'." << endlog();
1051 base::PortInterface* p = c->ports()->getPort( portcon.getName() );
1053 log(Error)<<
"Component '"<< c->getName() <<
"' does not have a Port '"<< portcon.getName()<<
"'." << endlog();
1058 string conn_name = portcon.value();
1062 for(
unsigned int a=0; a < conmap[conn_name].ports.size(); a++)
1064 if( conmap[conn_name].ports.at(a) == p && conmap[conn_name].owners.at(a) == c)
1073 log(Debug)<<
"storing Port: "<<c->getName()<<
"."<< portcon.getName();
1074 log(Debug)<<
" in " << conn_name <<endlog();
1075 conmap[conn_name].ports.push_back( p );
1076 conmap[conn_name].owners.push_back( c );
1084 if ( comp.value().find(
"Peers") != 0) {
1085 RTT::Property<RTT::PropertyBag> nm = comp.value().find(
"Peers");
1086 if ( !nm.ready() ) {
1087 log(Error)<<
"RTT::Property 'Peers' must be a 'struct', was type "<< comp.value().find(
"Peers")->getType() << endlog();
1090 for (RTT::PropertyBag::const_iterator it= nm.rvalue().begin(); it != nm.rvalue().end();it++) {
1091 RTT::Property<std::string> pr = *it;
1092 if ( !pr.ready() ) {
1093 log(Error)<<
"RTT::Property 'Peer' does not have type 'string'."<<endlog();
1102 if ( comp.value().find(
"Activity") != 0) {
1103 RTT::Property<RTT::PropertyBag> nm = comp.value().find(
"Activity");
1104 if ( !nm.ready() ) {
1105 log(Error)<<
"RTT::Property 'Activity' must be a 'struct'."<<endlog();
1108 if ( nm.rvalue().getType() ==
"PeriodicActivity" ) {
1109 RTT::Property<double> per = nm.rvalue().getProperty(
"Period");
1110 if ( !per.ready() ) {
1111 log(Error)<<
"Please specify period <double> of PeriodicActivity."<<endlog();
1114 RTT::Property<int> prio = nm.rvalue().getProperty(
"Priority");
1115 if ( !prio.ready() ) {
1116 log(Error)<<
"Please specify priority <short> of PeriodicActivity."<<endlog();
1120 unsigned cpu_affinity = ~0;
1121 RTT::Property<unsigned> cpu_affinity_prop = nm.rvalue().getProperty(
"CpuAffinity");
1122 if(cpu_affinity_prop.ready()) {
1123 cpu_affinity = cpu_affinity_prop.get();
1127 RTT::Property<string> sched;
1128 if (nm.rvalue().getProperty(
"Scheduler") )
1129 sched = nm.rvalue().getProperty(
"Scheduler");
1130 int scheduler = ORO_SCHED_RT;
1131 if ( sched.ready() ) {
1132 scheduler = string_to_oro_sched( sched.get());
1133 if (scheduler == -1 )
1137 this->
setNamedActivity(comp.getName(), nm.rvalue().getType(), per.get(), prio.get(), scheduler, cpu_affinity );
1140 if ( nm.rvalue().getType() ==
"Activity" || nm.rvalue().getType() ==
"NonPeriodicActivity" ) {
1141 RTT::Property<double> per = nm.rvalue().getProperty(
"Period");
1142 if ( !per.ready() ) {
1143 per = Property<double>(
"p",
"",0.0);
1145 RTT::Property<int> prio = nm.rvalue().getProperty(
"Priority");
1146 if ( !prio.ready() ) {
1147 log(Error)<<
"Please specify priority <short> of Activity."<<endlog();
1151 unsigned int cpu_affinity = ~0;
1152 RTT::Property<unsigned int> cpu_affinity_prop = nm.rvalue().getProperty(
"CpuAffinity");
1153 if(cpu_affinity_prop.ready()) {
1154 cpu_affinity = cpu_affinity_prop.get();
1158 RTT::Property<string> sched = nm.rvalue().getProperty(
"Scheduler");
1159 int scheduler = ORO_SCHED_RT;
1160 if ( sched.ready() ) {
1161 scheduler = string_to_oro_sched( sched.get());
1162 if (scheduler == -1 )
1166 this->
setNamedActivity(comp.getName(), nm.rvalue().getType(), per.get(), prio.get(), scheduler, cpu_affinity );
1169 if ( nm.rvalue().getType() ==
"SlaveActivity" ) {
1170 double period = 0.0;
1172 if ( nm.rvalue().getProperty(
"Master") ) {
1173 master = nm.rvalue().getPropertyType<
string>(
"Master")->
get();
1175 this->
setNamedActivity(comp.getName(), nm.rvalue().getType(), period, 0, 0, master );
1179 if ( nm.rvalue().getProperty(
"Period") )
1180 period = nm.rvalue().getPropertyType<
double>(
"Period")->
get();
1182 this->
setNamedActivity(comp.getName(), nm.rvalue().getType(), period, 0, 0 );
1186 if ( nm.rvalue().getType() ==
"SequentialActivity" ) {
1189 if ( nm.rvalue().getType() ==
"FileDescriptorActivity" ) {
1190 RTT::Property<double> per = nm.rvalue().getProperty(
"Period");
1191 if ( !per.ready() ) {
1192 per = Property<double>(
"p",
"",0.0);
1196 RTT::Property<int> prio = nm.rvalue().getProperty(
"Priority");
1197 if ( !prio.ready() ) {
1198 log(Error)<<
"Please specify priority <short> of FileDescriptorActivity."<<endlog();
1202 unsigned int cpu_affinity = ~0;
1203 RTT::Property<unsigned int> cpu_affinity_prop = nm.rvalue().getProperty(
"CpuAffinity");
1204 if(cpu_affinity_prop.ready()) {
1205 cpu_affinity = cpu_affinity_prop.get();
1209 RTT::Property<string> sched = nm.rvalue().getProperty(
"Scheduler");
1210 int scheduler = ORO_SCHED_RT;
1211 if ( sched.ready() ) {
1212 scheduler = string_to_oro_sched( sched.get());
1213 if (scheduler == -1 )
1217 this->
setNamedActivity(comp.getName(), nm.rvalue().getType(), per.get(), prio.get(), scheduler, cpu_affinity );
1220 log(Error) <<
"Unknown activity type: " << nm.rvalue().getType()<<endlog();
1232 string delimiter(
"@!#?<!");
1233 bool ret = updateProperty(
root, from_file, comp.getName(), delimiter );
1235 log(Error) <<
"Failed to store deployment properties for component " << comp.getName() <<endlog();
1240 deletePropertyBag( from_file );
1244 log(Error)<<
"Some error occured while parsing "<< configurationfile <<endlog();
1249 log(Error)<<
"Uncaught exception in loadcomponents() !"<< endlog();
1252 validConfig.set(valid);
1253 return !failure && valid;
1258 RTT::Logger::In in(
"configureComponents");
1261 for (
int group = 0; group <=
nextGroup; ++group) {
1269 RTT::Logger::In in(
"configureComponents");
1270 if (
root.empty() ) {
1271 RTT::Logger::log() << RTT::Logger::Error
1272 <<
"No components loaded by DeploymentComponent !" <<endlog();
1277 log(Info) <<
"Configuring components in group " << group << endlog();
1280 for (RTT::PropertyBag::iterator it=
root.begin(); it!=
root.end();it++) {
1282 RTT::Property<RTT::PropertyBag> comp = *it;
1285 if (group != compmap[comp.getName()].group) {
1289 RTT::TaskContext* peer = compmap[comp.getName()].instance;
1291 log(Error) <<
"Peer not found: "<< comp.getName() <<endlog();
1296 compmap[comp.getName()].instance = peer;
1300 RTT::Property<RTT::PropertyBag> peers = comp.rvalue().find(
"Peers");
1301 if ( peers.ready() )
1302 for (RTT::PropertyBag::const_iterator it= peers.rvalue().begin(); it != peers.rvalue().end();it++) {
1303 RTT::Property<string> nm = (*it);
1306 if ( this->
addPeer( compmap[comp.getName()].instance->getName(), nm.value() ) ==
false ) {
1307 log(Error) << this->getName() <<
" can't make " << nm.value() <<
" a peer of " <<
1308 compmap[comp.getName()].instance->getName() << endlog();
1311 log(Info) << this->getName() <<
" makes " << nm.value() <<
" a peer of " <<
1312 compmap[comp.getName()].instance->getName() << endlog();
1316 log(Error) <<
"Wrong property type in Peers struct. Expected property of type 'string'," 1317 <<
" got type "<< (*it)->getType() <<endlog();
1324 for(ConMap::iterator it = conmap.begin(); it != conmap.end(); ++it) {
1326 std::string connection_name = it->first;
1329 if (connection->policy.name_id.empty()) {
1330 connection->policy.name_id = connection_name;
1333 if ( connection->ports.size() == 1 ){
1334 string owner = connection->owners[0]->getName();
1335 string portname = connection->ports.front()->getName();
1336 string porttype =
dynamic_cast<InputPortInterface*
>(connection->ports.front() ) ?
"InputPort" :
"OutputPort";
1337 if ( connection->ports.front()->createStream( connection->policy ) ==
false) {
1338 log(Warning) <<
"Creating stream with name "<<connection_name<<
" with Port "<<portname<<
" from "<< owner <<
" failed."<< endlog();
1340 log(Info) <<
"Component "<< owner <<
"'s " + porttype<<
" " + portname <<
" will stream to "<< connection->policy.name_id << endlog();
1345 base::PortInterface* writer = 0;
1346 ConnectionData::Ports::iterator p = connection->ports.begin();
1349 vector<OutputPortInterface*> writers;
1350 while (p !=connection->ports.end() ) {
1351 if ( OutputPortInterface* out = dynamic_cast<base::OutputPortInterface*>( *p ) ) {
1353 log(Info) <<
"Forming multi-output connections with additional OutputPort " << (*p)->getName() <<
"."<<endlog();
1356 writers.push_back( out );
1357 std::string owner = it->second.owners[p - it->second.ports.begin()]->getName();
1358 log(Info) <<
"Component "<< owner <<
"'s OutputPort "<< writer->getName()<<
" will write topic "<<it->first<< endlog();
1364 if ( writer == 0 ) {
1365 log(Error) <<
"No OutputPort listed that writes " << it->first << endlog();
1371 p = connection->ports.begin();
1372 vector<OutputPortInterface*>::iterator w = writers.begin();
1374 while (w != writers.end() ) {
1375 while (p != connection->ports.end() ) {
1377 if ( dynamic_cast<base::InputPortInterface*>( *p ) )
1379 string owner = connection->owners[p - connection->ports.begin()]->getName();
1382 if ( (*w)->connectTo( *p, connection->policy ) ==
false) {
1383 log(Error) <<
"Could not subscribe InputPort "<< owner<<
"."<< (*p)->getName() <<
" to topic " << (*w)->getName() <<
'/'<< connection_name <<endlog();
1386 log(Info) <<
"Subscribed InputPort "<< owner<<
"."<< (*p)->getName() <<
" to topic " << (*w)->getName() <<
'/'<< connection_name <<endlog();
1392 p = connection->ports.begin();
1397 for (RTT::PropertyBag::iterator it=
root.begin(); it!=
root.end();it++) {
1398 RTT::Property<RTT::PropertyBag> comp = *it;
1399 if ( !comp.ready() )
1403 if (group != compmap[ comp.getName() ].group) {
1407 RTT::TaskContext* peer = compmap[ comp.getName() ].instance;
1412 if ( compmap[comp.getName()].autoconnect ) {
1414 RTT::TaskContext::PeerList peers = peer->getPeerList();
1415 for(RTT::TaskContext::PeerList::iterator pit = peers.begin(); pit != peers.end(); ++pit) {
1416 if ( compmap.count( *pit ) && compmap[*pit].autoconnect ) {
1417 RTT::TaskContext* other = peer->getPeer( *pit );
1418 valid = RTT::connectPorts( peer, other ) && valid;
1425 for (RTT::PropertyBag::iterator it=
root.begin(); it!=
root.end();it++) {
1427 RTT::Property<RTT::PropertyBag> comp = *it;
1430 if (group != compmap[ comp.getName() ].group) {
1434 RTT::Property<string> dummy;
1435 RTT::TaskContext* peer = compmap[ comp.getName() ].instance;
1438 if ( peer->getTaskState() > Stopped) {
1439 log(Warning) <<
"Component "<< peer->getName()<<
" doesn't need to be configured (already Running)." <<endlog();
1444 for (RTT::PropertyBag::const_iterator pf = comp.rvalue().begin(); pf!= comp.rvalue().end(); ++pf) {
1446 if ( (*pf)->getName() ==
"Properties"){
1447 RTT::Property<RTT::PropertyBag> props = *pf;
1448 bool ret = updateProperties( *peer->properties(), props);
1450 log(Error) <<
"Failed to configure properties from main configuration file for component "<< comp.getName() <<endlog();
1453 log(Info) <<
"Configured Properties of "<< comp.getName() <<
" from main configuration file." <<endlog();
1458 for (RTT::PropertyBag::const_iterator pf = comp.rvalue().begin(); pf!= comp.rvalue().end(); ++pf) {
1460 if ( (*pf)->getName() ==
"PropertyFile" || (*pf)->getName() ==
"UpdateProperties" || (*pf)->getName() ==
"LoadProperties"){
1462 string filename = dummy.get();
1463 marsh::PropertyLoader pl(peer);
1464 bool strict = (*pf)->getName() ==
"PropertyFile" ?
true :
false;
1465 bool load = (*pf)->getName() ==
"LoadProperties" ?
true :
false;
1468 ret = pl.configure( filename, strict );
1470 ret = pl.load(filename);
1472 log(Error) <<
"Failed to configure properties for component "<< comp.getName() <<endlog();
1475 log(Info) <<
"Configured Properties of "<< comp.getName() <<
" from "<<filename<<endlog();
1476 compmap[ comp.getName() ].loadedProperties =
true;
1482 if ( compmap[comp.getName()].act ) {
1483 if ( peer->getActivity() ) {
1484 log(Info) <<
"Re-setting activity of "<< comp.getName() <<endlog();
1486 log(Info) <<
"Setting activity of "<< comp.getName() <<endlog();
1488 if (peer->setActivity( compmap[comp.getName()].act ) ==
false ) {
1490 log(Error) <<
"Failed to set Activity of " << comp.getName() << endlog();
1492 assert( peer->engine()->getActivity() == compmap[comp.getName()].act );
1493 compmap[comp.getName()].act = 0;
1498 for (RTT::PropertyBag::const_iterator ps = comp.rvalue().begin(); ps!= comp.rvalue().end(); ++ps) {
1499 RTT::Property<string> script;
1500 if ( (*ps)->getName() ==
"RunScript" )
1502 if ( script.ready() ) {
1503 valid = valid && peer->getProvider<Scripting>(
"scripting")->
runScript( script.get() );
1506 RTT::Property<string> pscript;
1507 if ( (*ps)->getName() ==
"ProgramScript" )
1509 if ( pscript.ready() ) {
1510 valid = valid && peer->getProvider<Scripting>(
"scripting")->loadPrograms( pscript.get() );
1512 RTT::Property<string> sscript;
1513 if ( (*ps)->getName() ==
"StateMachineScript" )
1515 if ( sscript.ready() ) {
1516 valid = valid && peer->getProvider<Scripting>(
"scripting")->loadStateMachines( sscript.get() );
1521 if (compmap[comp.getName()].autoconf )
1523 if( !peer->isRunning() )
1525 OperationCaller<bool(void)> peerconfigure = peer->getOperation(
"configure");
1526 if ( peerconfigure() ==
false) {
1527 log(Error) <<
"Component " << peer->getName() <<
" returns false in configure()" << endlog();
1532 log(Warning) <<
"Apparently component "<< peer->getName()<<
" don't need to be configured (already Running)." <<endlog();
1539 for ( CompList::iterator cit = comps.begin(); cit != comps.end(); ++cit) {
1541 if ( group == cd->
group && cd->
loaded && cd->autoconf &&
1542 (cd->
instance->getTaskState() != TaskCore::Stopped) &&
1543 (cd->
instance->getTaskState() != TaskCore::Running))
1544 log(Error) <<
"Failed to configure component "<< cd->
instance->getName()
1545 <<
": state is " << cd->
instance->getTaskState() <<endlog();
1548 log(Info) <<
"Configuration successful for group " << group <<
"." <<endlog();
1551 validConfig.set(valid);
1559 for (
int group = 0; group <=
nextGroup; ++group) {
1567 RTT::Logger::In in(
"startComponentsGroup");
1568 if (validConfig.get() ==
false) {
1569 log(Error) <<
"Not starting components with invalid configuration." <<endlog();
1573 for (RTT::PropertyBag::iterator it=
root.begin(); it!=
root.end();it++) {
1576 if (group != compmap[(*it)->getName()].group) {
1580 TaskContext* peer = compmap[(*it)->getName()].instance;
1584 if (peer->isRunning())
1590 OperationCaller<bool(void)> peerstart = peer->getOperation(
"start");
1591 if (compmap[(*it)->getName()].autostart )
1592 if ( !peer || ( !peer->isRunning() && peerstart() ==
false) )
1597 for ( CompList::iterator cit = comps.begin(); cit != comps.end(); ++cit) {
1601 if (group != it->
group) {
1606 log(Error) <<
"Failed to start component "<< *cit <<
": not found." << endlog();
1609 if ( it->autostart && it->
instance->getTaskState() != base::TaskCore::Running )
1610 log(Error) <<
"Failed to start component "<< it->
instance->getName() <<endlog();
1613 log(Info) <<
"Startup of 'AutoStart' components successful for group " << group <<
"." <<endlog();
1622 for (
int group =
nextGroup ; group != -1; --group) {
1630 RTT::Logger::In in(
"stopComponentsGroup");
1631 log(Info) <<
"Stopping group " << group << endlog();
1634 for ( CompList::reverse_iterator cit = comps.rbegin(); cit != comps.rend(); ++cit) {
1637 OperationCaller<bool(void)> instancestop = it->
instance->getOperation(
"stop");
1640 log(Info) <<
"Stopped "<< it->
instance->getName() <<endlog();
1642 log(Error) <<
"Could not stop loaded Component "<< it->
instance->getName() <<endlog();
1654 for (
int group =
nextGroup ; group != -1; --group) {
1662 RTT::Logger::In in(
"cleanupComponentsGroup");
1664 log(Info) <<
"Cleaning up group " << group << endlog();
1666 for ( CompList::reverse_iterator cit = comps.rbegin(); cit != comps.rend(); ++cit) {
1670 if (group != it->
group) {
1675 if ( it->
instance->getTaskState() <= base::TaskCore::Stopped ) {
1676 if ( it->autosave && !it->configfile.empty()) {
1678 string file = it->configfile;
1680 bool ret = pl.save( file,
true );
1682 log(Error) <<
"Failed to save properties for component "<< it->
instance->getName() <<endlog();
1685 log(Info) <<
"Refusing to save property file that was not loaded for "<< it->
instance->getName() <<endlog();
1687 }
else if (it->autosave) {
1688 log(Error) <<
"AutoSave set but no property file specified. Specify one using the UpdateProperties simple element."<<endlog();
1690 }
else if (it->autosave) {
1691 log(Error) <<
"AutoSave set but no property file specified. Specify one using the UpdateProperties simple element."<<endlog();
1693 OperationCaller<bool(void)> instancecleanup = it->
instance->getOperation(
"cleanup");
1695 log(Info) <<
"Cleaned up "<< it->
instance->getName() <<endlog();
1697 log(Error) <<
"Could not cleanup Component "<< it->
instance->getName() <<
" (not Stopped)"<<endlog();
1709 for (
int group =
nextGroup ; group != -1; --group) {
1717 log(Info) <<
"Unloading group " << group << endlog();
1720 CompList::reverse_iterator cit = comps.rbegin();
1721 while ( valid && cit != comps.rend())
1724 if (group == it->
group)
1729 cit = comps.rbegin();
1743 log(Info) <<
"Clearing configuration options."<< endlog();
1745 deletePropertyBag(
root );
1750 RTT::Logger::In in(
"import");
1751 return ComponentLoader::Instance()->import( package,
"" );
1756 RTT::Logger::In in(
"path");
1757 ComponentLoader::Instance()->setComponentPath( ComponentLoader::Instance()->getComponentPath() + path );
1758 PluginLoader::Instance()->setPluginPath( PluginLoader::Instance()->getPluginPath() + path );
1763 RTT::Logger::In in(
"loadLibrary");
1764 return PluginLoader::Instance()->loadLibrary(name) || ComponentLoader::Instance()->loadLibrary(name);
1769 RTT::Logger::In in(
"reloadLibrary");
1770 return ComponentLoader::Instance()->reloadLibrary(name);
1774 TaskContext* peer = 0;
1775 if ((name == getName()) || (name ==
"this"))
1777 else if ( (peer = getPeer(name)) == 0) {
1778 log(Error)<<
"No such peer: "<< name<<
". Can not load service '"<<type<<
"'."<<endlog();
1783 if (peer->provides()->hasService(type))
1785 return PluginLoader::Instance()->loadService(type, peer);
1791 RTT::Logger::In in(
"loadComponent");
1793 if ( type ==
"RTT::PropertyBag" )
1796 if ( this->getPeer(name) || ( compmap.find(name) != compmap.end() && compmap[name].instance != 0) ) {
1797 log(Error) <<
"Failed to load component with name "<<name<<
": already present as peer or loaded."<<endlog();
1801 TaskContext* instance = ComponentLoader::Instance()->loadComponent(name, type);
1808 compmap[name].instance = instance;
1809 comps.push_back(name);
1812 log(Error) <<
"This deployer type refused to connect to "<< instance->getName() <<
": aborting !" << endlog(Error);
1813 compmap[name].instance = 0;
1814 ComponentLoader::Instance()->unloadComponent( instance );
1819 this->
addPeer( instance, name );
1820 log(Info) <<
"Adding "<< name <<
" as new peer: OK."<< endlog(Info);
1822 compmap[name].loaded =
true;
1835 std::string name = cit->first;
1838 if ( !it->
instance->isRunning() ) {
1842 log(Debug) <<
"Disconnecting " <<name <<endlog();
1844 log(Debug) <<
"Terminating " <<name <<endlog();
1846 log(Debug) <<
"Removing proxy for " <<name <<endlog();
1849 for( ConMap::iterator cmit = conmap.begin(); cmit != conmap.end(); ++cmit) {
1851 while ( n != cmit->second.owners.size() ) {
1852 if (cmit->second.owners[n] == it->
instance ) {
1853 cmit->second.owners.erase( cmit->second.owners.begin() + n );
1854 cmit->second.ports.erase( cmit->second.ports.begin() + n );
1861 RTT::Property<RTT::PropertyBag>* pcomp =
root.getPropertyType<PropertyBag>(name);
1863 root.removeProperty(pcomp);
1869 ComponentLoader::Instance()->unloadComponent( it->
instance, name );
1871 log(Info) <<
"Disconnected and destroyed "<< name <<endlog();
1873 log(Error) <<
"Could not unload Component "<< name <<
": still running." <<endlog();
1881 CompList::iterator it = comps.begin();
1882 while(it != comps.end()) {
1884 it = comps.erase(it);
1894 CompMap::iterator it;
1896 if ( compmap.count( name ) == 0 || compmap[name].loaded == false ) {
1897 log(Error) <<
"Can't unload component '"<<name<<
"': not loaded by "<<this->getName()<<endlog();
1902 it = compmap.find(name);
1907 log(Info) <<
"Successfully unloaded component "<<name<<
"."<<endlog();
1913 FactoryMap::const_iterator it;
1914 cout <<
"I can create the following component types: " <<endl;
1916 cout <<
" " << it->first << endl;
1919 cout <<
" (none)"<<endl;
1924 std::vector<std::string> s;
1925 FactoryMap::const_iterator it;
1927 s.push_back(it->first);
1933 double period,
int priority,
1936 if ( this->
setNamedActivity(comp_name,
"Activity", period, priority, scheduler) ) {
1937 assert( compmap[comp_name].instance );
1938 assert( compmap[comp_name].act );
1939 compmap[comp_name].instance->setActivity( compmap[comp_name].act );
1940 compmap[comp_name].act = 0;
1947 double timeout,
int priority,
1950 if ( this->
setNamedActivity(comp_name,
"FileDescriptorActivity", timeout, priority, scheduler) ) {
1951 assert( compmap[comp_name].instance );
1952 assert( compmap[comp_name].act );
1953 compmap[comp_name].instance->setActivity( compmap[comp_name].act );
1954 compmap[comp_name].act = 0;
1961 double period,
int priority,
1962 int scheduler,
unsigned int cpu_nr)
1964 unsigned int mask = 0x1 << cpu_nr;
1965 if ( this->
setNamedActivity(comp_name,
"Activity", period, priority, scheduler, mask) ) {
1966 assert( compmap[comp_name].instance );
1967 assert( compmap[comp_name].act );
1968 compmap[comp_name].instance->setActivity( compmap[comp_name].act );
1969 compmap[comp_name].act = 0;
1976 double period,
int priority,
1979 if ( this->
setNamedActivity(comp_name,
"PeriodicActivity", period, priority, scheduler) ) {
1980 assert( compmap[comp_name].instance );
1981 assert( compmap[comp_name].act );
1982 compmap[comp_name].instance->setActivity( compmap[comp_name].act );
1983 compmap[comp_name].act = 0;
1992 if ( this->
setNamedActivity(comp_name,
"SlaveActivity", period, 0, ORO_SCHED_OTHER ) ) {
1993 assert( compmap[comp_name].instance );
1994 assert( compmap[comp_name].act );
1995 compmap[comp_name].instance->setActivity( compmap[comp_name].act );
1996 compmap[comp_name].act = 0;
2005 assert( compmap[comp_name].instance );
2006 assert( compmap[comp_name].act );
2007 compmap[comp_name].instance->setActivity( compmap[comp_name].act );
2008 compmap[comp_name].act = 0;
2015 const std::string& slave)
2017 if ( this->
setNamedActivity(slave,
"SlaveActivity", 0, 0, ORO_SCHED_OTHER, master ) ) {
2018 assert( compmap[slave].instance );
2019 assert( compmap[slave].act );
2020 compmap[slave].instance->setActivity( compmap[slave].act );
2021 compmap[slave].act = 0;
2029 const std::string& act_type,
2030 double period,
int priority,
2031 int scheduler,
const std::string& master_name)
2043 const std::string& act_type,
2044 double period,
int priority,
2045 int scheduler,
unsigned cpu_affinity,
2046 const std::string& master_name)
2050 RTT::TaskContext* peer = 0;
2051 base::ActivityInterface* master_act = 0;
2052 if ( comp_name == this->getName() )
2055 if ( compmap.count(comp_name) )
2056 peer = compmap[comp_name].instance;
2058 peer = this->getPeer(comp_name);
2060 log(Error) <<
"Can't create Activity: component "<<comp_name<<
" not found."<<endlog();
2063 if ( !master_name.empty() ) {
2064 if ( master_name == this->getName() )
2065 master_act = this->engine()->getActivity();
2067 if ( compmap.count(master_name) && compmap[master_name].act )
2068 master_act = compmap[master_name].act;
2070 master_act = this->getPeer(master_name) ? getPeer(master_name)->engine()->getActivity() : 0;
2072 if ( !this->getPeer(master_name) ) {
2073 log(Error) <<
"Can't create SlaveActivity: Master component "<<master_name<<
" not known as peer."<<endlog();
2078 log(Error) <<
"Can't create SlaveActivity: Master component "<<master_name<<
" has no activity set."<<endlog();
2083 compmap[comp_name].instance = peer;
2084 if ( peer->isRunning() ) {
2085 log(Error) <<
"Can't change activity of component "<<comp_name<<
" since it is still running."<<endlog();
2089 base::ActivityInterface* newact = 0;
2091 if ( act_type ==
"Activity")
2092 newact =
new RTT::Activity(scheduler, priority, period, cpu_affinity, 0, comp_name);
2095 if ( act_type ==
"PeriodicActivity" && period != 0.0)
2096 newact =
new RTT::extras::PeriodicActivity(scheduler, priority, period, cpu_affinity, 0);
2098 if ( act_type ==
"NonPeriodicActivity" && period == 0.0)
2099 newact =
new RTT::Activity(scheduler, priority, period, cpu_affinity, 0);
2101 if ( act_type ==
"SlaveActivity" ) {
2102 if ( master_act == 0 )
2103 newact =
new extras::SlaveActivity(period);
2105 newact =
new extras::SlaveActivity(master_act);
2106 this->getPeer(master_name)->addPeer( peer );
2110 if (act_type ==
"Activity") {
2111 newact =
new Activity(scheduler, priority, period, cpu_affinity, 0, comp_name);
2114 if (act_type ==
"SequentialActivity") {
2115 newact =
new SequentialActivity();
2117 else if ( act_type ==
"FileDescriptorActivity") {
2118 using namespace RTT::extras;
2119 newact =
new FileDescriptorActivity(scheduler, priority, period, cpu_affinity, 0);
2120 FileDescriptorActivity* fdact =
dynamic_cast< RTT::extras::FileDescriptorActivity*
> (newact);
2121 if (fdact) fdact->setTimeout(period);
2125 log(Error) <<
"Can't create '"<< act_type <<
"' for component "<<comp_name<<
": incorrect arguments."<<endlog();
2130 newact->thread()->setWaitPeriodPolicy(defaultWaitPeriodPolicy);
2133 assert( peer->isRunning() == false );
2134 delete compmap[comp_name].act;
2135 compmap[comp_name].act = newact;
2142 if ( !compmap.count(comp_name) ) {
2143 log(Error) <<
"Can't setWaitPeriodPolicy: component "<<comp_name<<
" not found."<<endlog();
2147 RTT::base::ActivityInterface *activity = compmap[comp_name].instance->getActivity();
2149 log(Error) <<
"Can't setWaitPeriodPolicy: component "<<comp_name<<
" has no activity (yet)."<<endlog();
2153 activity->thread()->setWaitPeriodPolicy(policy);
2164 RTT::Logger::In in(
"DeploymentComponent");
2165 RTT::TaskContext* c;
2166 if ( name == this->getName() )
2169 c = this->getPeer(name);
2171 log(Error)<<
"No such peer to configure: "<<name<<endlog();
2175 marsh::PropertyLoader pl(c);
2176 return pl.configure( filename,
true );
2181 return RTT::ComponentLoader::Instance()->getFactories();
2186 RTT::Logger::In in(
"kickOut");
2187 RTT::PropertyBag from_file;
2188 RTT::Property<std::string> import_file;
2189 std::vector<std::string> deleted_components_type;
2191 marsh::PropertyDemarshaller demarshaller(config_file);
2193 if ( demarshaller.deserialize( from_file ) ){
2194 for (RTT::PropertyBag::iterator it= from_file.begin(); it!=from_file.end();it++) {
2195 if ( (*it)->getName() ==
"Import" )
continue;
2196 if ( (*it)->getName() ==
"Include" )
continue;
2200 deletePropertyBag( from_file );
2203 log(Error)<<
"Some error occured while parsing "<< config_file <<endlog();
2207 log(Error)<<
"Uncaught exception in kickOut() !"<< endlog();
2213 RTT::Logger::In in(
"cleanupComponent");
2217 if ( instance->getTaskState() <= base::TaskCore::Stopped ) {
2218 OperationCaller<bool(void)> instancecleanup = instance->getOperation(
"cleanup");
2220 log(Info) <<
"Cleaned up "<< instance->getName() <<endlog();
2222 log(Error) <<
"Could not cleanup Component "<< instance->getName() <<
" (not Stopped)"<<endlog();
2231 RTT::Logger::In in(
"configureComponent");
2235 OperationCaller<bool(void)> instanceconfigure = instance->getOperation(
"configure");
2236 if(instanceconfigure()) {
2237 log(Info) <<
"Configured " << instance->getName()<<endlog();
2241 log(Error) <<
"Could not configure loaded Component "<< instance->getName() <<endlog();
2249 RTT::Logger::In in(
"startComponent");
2253 OperationCaller<bool(void)> instancestart = instance->getOperation(
"start");
2254 if ( instance->isRunning() ||
2256 log(Info) <<
"Started "<< instance->getName() <<endlog();
2260 log(Error) <<
"Could not start loaded Component "<< instance->getName() <<endlog();
2268 RTT::Logger::In in(
"stopComponent");
2272 OperationCaller<bool(void)> instancestop = instance->getOperation(
"stop");
2273 if ( !instance->isRunning() ||
2275 log(Info) <<
"Stopped "<< instance->getName() <<endlog();
2278 log(Error) <<
"Could not stop loaded Component "<< instance->getName() <<endlog();
2287 RTT::Logger::In in(
"kickOutComponent");
2289 RTT::TaskContext* peer = compmap.count(comp_name) ? compmap[ comp_name ].instance : 0;
2292 log(Error) <<
"Component not loaded by this Deployer: "<< comp_name <<endlog();
2300 root.removeProperty(
root.find( comp_name ) );
2307 static const char* PEER=
"Application";
2308 static const char* NAME=
"shutdownDeployment";
2311 static const char* WAIT_PROP_NAME=
"shutdownWait_ms";
2312 static const char* TOTAL_WAIT_PROP_NAME=
"shutdownTotalWait_ms";
2314 RTT::OperationCaller<void(void)> ds;
2315 bool has_program =
false;
2316 bool has_operation =
false;
2318 RTT::TaskContext* peer = getPeer(PEER);
2320 has_operation = peer->provides()->hasOperation(NAME);
2322 ds = peer->provides()->getOperation(NAME);
2324 log(Info) <<
"Ignoring deployment shutdown function due to missing peer." << endlog();
2329 has_operation =
false;
2330 log(Info) <<
"Ignoring deployment shutdown function, looking for shutdown program script." << endlog();
2331 has_program = peer->getProvider<Scripting>(
"scripting")->hasProgram(NAME);
2334 if (has_operation || has_program)
2336 log(Info) <<
"Shutting down deployment." << endlog();
2337 RTT::SendHandle<void(void)> handle;
2340 if (handle.ready() || peer->getProvider<Scripting>(
"scripting")->startProgram(NAME))
2347 int totalWait = 2000;
2350 RTT::Property<int> wait_prop =
2351 this->properties()->getProperty(WAIT_PROP_NAME);
2352 if (wait_prop.ready())
2354 int w = wait_prop.rvalue();
2358 log(Debug) <<
"Using override value for " << WAIT_PROP_NAME << endlog();
2362 log(Warning) <<
"Ignoring illegal value for " << WAIT_PROP_NAME << endlog();
2367 log(Debug) <<
"Using default value for " << WAIT_PROP_NAME << endlog();
2370 RTT::Property<int> totalWait_prop =
2371 this->properties()->getProperty(TOTAL_WAIT_PROP_NAME);
2372 if (totalWait_prop.ready())
2374 int w = totalWait_prop.rvalue();
2378 log(Debug) <<
"Using override value for " << TOTAL_WAIT_PROP_NAME << endlog();
2382 log(Warning) <<
"Ignoring illegal value for " << TOTAL_WAIT_PROP_NAME << endlog();
2387 log(Debug) <<
"Using default value for " << TOTAL_WAIT_PROP_NAME << endlog();
2391 if (wait > totalWait)
2394 log(Warning) <<
"Setting wait == totalWait" << endlog();
2397 const long int wait_ns = wait * 1000000LL;
2399 ts.tv_sec = wait_ns / 1000000000LL;
2400 ts.tv_nsec = wait_ns % 1000000000LL;
2403 log(Debug) <<
"Waiting for deployment shutdown to complete ..." << endlog();
2405 while ( ( (has_operation && RTT::SendNotReady == handle.collectIfDone() ) ||
2406 (has_program && peer->getProvider<Scripting>(
"scripting")->isProgramRunning(NAME)) )
2407 && (waited < totalWait) )
2409 (void)rtos_nanosleep(&ts, NULL);
2412 if (waited >= totalWait)
2414 log(Error) <<
"Timed out waiting for deployment shutdown to complete." << endlog();
2418 log(Debug) <<
"Deployment shutdown completed." << endlog();
2423 log(Error) <<
"Failed to start operation or scripting program: " << NAME << endlog();
2429 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, SIGTERM or SIGHUP 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 waitForSignals(int *sigs, std::size_t sig_count)
Waits for any signal in the list and then returns.
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.