29 #ifndef OCL_DEPLOYMENTCOMPONENT_HPP 30 #define OCL_DEPLOYMENTCOMPONENT_HPP 32 #include <rtt/RTT.hpp> 33 #include <rtt/TaskContext.hpp> 34 #include <rtt/extras/Properties.hpp> 35 #include <rtt/Attribute.hpp> 36 #include <rtt/InputPort.hpp> 37 #include <rtt/OutputPort.hpp> 38 #include <ocl/OCL.hpp> 41 #include <rtt/marsh/PropertyDemarshaller.hpp> 87 :
public RTT::TaskContext
96 int defaultWaitPeriodPolicy;
97 RTT::Property<bool> autoUnload;
98 RTT::Attribute<bool> validConfig;
99 RTT::Constant<int> sched_RT;
100 RTT::Constant<int> sched_OTHER;
101 RTT::Constant<int> lowest_Priority;
102 RTT::Constant<int> highest_Priority;
103 RTT::Attribute<std::string> target;
114 : instance(0), act(0), loaded(
false), loadedProperties(
false),
115 autostart(
false), autoconf(
false),
116 autoconnect(
false), autosave(
false),
117 proxy(
false), server(
false),
130 base::ActivityInterface*
act;
142 bool autostart, autoconf, autoconnect, autosave;
143 bool proxy, server, use_naming;
144 std::string configfile;
145 std::vector<std::string> plugins;
154 typedef std::vector<RTT::base::PortInterface*> Ports;
155 typedef std::vector<RTT::TaskContext*> Owners;
158 RTT::ConnPolicy policy;
164 typedef std::map<std::string, ConnectionData>
ConMap;
170 typedef std::map<std::string, ComponentData>
CompMap;
171 typedef std::list<std::string> CompList;
181 bool configureHook();
187 bool unloadComponentImpl( CompMap::iterator cit );
197 virtual bool componentLoaded(RTT::TaskContext* c);
204 virtual void componentUnloaded(RTT::TaskContext* c);
214 Service::shared_ptr stringToService(std::string
const& names);
223 ServiceRequester::shared_ptr stringToServiceRequester(std::string
const& names);
232 base::PortInterface* stringToPort(std::string
const& names);
264 RTT::TaskContext* myGetPeer(std::string name) {
return compmap[ name ].instance; }
276 bool connectPeers(
const std::string& one,
const std::string& other);
278 using TaskContext::connectPorts;
296 bool connectPorts(
const std::string& one,
const std::string& other);
313 bool connectPorts(
const std::string& one,
const std::string& one_port,
314 const std::string& other,
const std::string& other_port);
326 bool connect(
const std::string& one,
const std::string& other, ConnPolicy policy);
335 bool stream(
const std::string& port, ConnPolicy policy);
340 bool createStream(
const std::string& component,
const std::string& port, ConnPolicy policy);
342 using TaskContext::connectServices;
351 bool connectServices(
const std::string& one,
const std::string& other);
359 bool connectOperations(
const std::string& required,
const std::string& provided);
371 bool addPeer(
const std::string& from,
const std::string& target);
384 bool aliasPeer(
const std::string& from,
const std::string& target,
const std::string& alias);
386 using RTT::TaskContext::addPeer;
387 using RTT::TaskContext::connectPeers;
403 bool import(
const std::string& package);
412 void path(
const std::string& path);
423 bool loadLibrary(
const std::string& name);
434 bool reloadLibrary(
const std::string& filepath);
447 bool loadComponent(
const std::string& name,
const std::string& type);
463 bool loadService(
const std::string& component,
const std::string& service);
473 bool unloadComponent(
const std::string& name);
480 void displayComponentTypes()
const;
487 std::vector<std::string> getComponentTypes()
const;
500 bool setPeriodicActivity(
const std::string& comp_name,
501 double period,
int priority,
515 bool setActivity(
const std::string& comp_name,
516 double period,
int priority,
530 bool setFileDescriptorActivity(
const std::string& comp_name,
531 double timeout,
int priority,
546 bool setActivityOnCPU(
const std::string& comp_name,
547 double period,
int priority,
548 int scheduler,
unsigned int cpu_nr);
558 bool setSequentialActivity(
const std::string& comp_name);
569 bool setSlaveActivity(
const std::string& comp_name,
580 bool setMasterSlaveActivity(
const std::string& comp_name,
581 const std::string& master_name);
598 bool setNamedActivity(
const std::string& comp_name,
599 const std::string& act_type,
600 double period,
int priority,
601 int scheduler,
const std::string& master_name =
"");
617 bool setNamedActivity(
const std::string& comp_name,
618 const std::string& act_type,
619 double period,
int priority,
620 int scheduler,
unsigned cpu_affinity,
621 const std::string& master_name =
"");
631 bool setWaitPeriodPolicy(
const std::string& comp_name,
649 bool loadComponents(
const std::string& config_file);
663 bool loadComponentsInGroup(
const std::string& config_file,
692 bool configureComponents();
701 bool configureComponentsGroup(
const int group);
708 bool startComponents();
714 bool startComponentsGroup(
const int group);
720 void clearConfiguration();
725 bool stopComponents();
731 bool stopComponentsGroup(
const int group);
736 bool cleanupComponents();
742 bool cleanupComponentsGroup(
const int group);
747 bool unloadComponents();
753 bool unloadComponentsGroup(
const int group);
759 bool kickStart(
const std::string& file_name);
766 bool kickOutComponent(
const std::string& comp_name);
772 void kickOut(
const std::string& config_file);
784 bool kickOutGroup(
const int group);
790 bool runScript(
const std::string& file_name);
792 using base::TaskCore::configure;
802 bool configure(
const std::string& name);
813 bool configureFromFile(
const std::string& name,
const std::string& filename);
829 bool loadConfiguration(
const std::string& config_file);
837 bool loadConfigurationString(
const std::string& config_text);
843 const RTT::FactoryMap& getFactories()
const;
850 bool configureComponent(RTT::TaskContext *instance);
859 return this->configureComponent( this->getPeer(comp_name) );
867 bool startComponent(RTT::TaskContext *instance);
876 return this->startComponent( this->getPeer(comp_name) );
884 bool stopComponent(RTT::TaskContext *instance);
893 return this->stopComponent( this->getPeer(comp_name) );
901 bool cleanupComponent(RTT::TaskContext *instance);
910 return this->cleanupComponent( this->getPeer(comp_name) );
920 void shutdownDeployment();
928 bool waitForSignals(
int *sigs, std::size_t sig_count);
934 bool waitForSignal(
int signumber);
940 bool waitForInterrupt();
std::map< std::string, ComponentData > CompMap
This list and map hold the dynamically loaded components.
int group
Group number this component belongs to.
base::ActivityInterface * act
The activity created by DeploymentComponent.
Assembles all ports which share a connection.
std::map< std::string, ConnectionData > ConMap
This maps connection names to associated ports.
bool stopComponent(const std::string &comp_name)
Stop a single loaded and running components.
int nextGroup
Next group number.
bool configureComponent(const std::string &comp_name)
Configure a single loaded and running components.
RTT::TaskContext * instance
The component instance.
This file contains the macros and definitions to create dynamically loadable components.
bool cleanupComponent(const std::string &comp_name)
Cleanup a single loaded and not running component.
bool startComponent(const std::string &comp_name)
Stop a single loaded and running components.
The Orocos Component Library.
bool loaded
True if it was loaded and created by DeploymentComponent.
A Component for deploying (configuring) other components in an application.
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.
RTT::PropertyBag root
This bag stores the current configuration.