00001
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #ifndef RTObject_h
00051 #define RTObject_h
00052
00053
00054 #include "rtm/RTC.h"
00055 #include "rtm/Properties.h"
00056 #include "rtm/idl/RTCSkel.h"
00057 #include "rtm/idl/OpenRTMSkel.h"
00058 #include "rtm/PortBase.h"
00059
00060 #include "rtm/PortAdmin.h"
00061 #include <rtm/DataInPort.h>
00062 #include <rtm/DataOutPort.h>
00063 #include <rtm/InPort.h>
00064 #include <rtm/OutPort.h>
00065 #include <rtm/ConfigAdmin.h>
00066
00067
00068 #include <ace/Task.h>
00069
00070
00071 namespace SDOPackage
00072 {
00073 class Configuration_impl;
00074 };
00075
00076 namespace RTC
00077 {
00078 class Manager;
00079
00080 class RTObject_impl
00081 : public virtual POA_RTC::DataFlowComponent,
00082 public virtual PortableServer::RefCountServantBase
00083 {
00084 public:
00085 RTObject_impl(Manager* manager);
00086 RTObject_impl(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa);
00087 virtual ~RTObject_impl();
00088
00089
00090 protected:
00091
00092
00093
00094
00095
00096 virtual ReturnCode_t onInitialize();
00097
00098
00099
00100 virtual ReturnCode_t onFinalize();
00101
00102
00103
00104 virtual ReturnCode_t onStartup(RTC::UniqueId ec_id);
00105
00106
00107
00108 virtual ReturnCode_t onShutdown(RTC::UniqueId ec_id);
00109
00110
00111
00112 virtual ReturnCode_t onActivated(RTC::UniqueId ec_id);
00113
00114
00115
00116 virtual ReturnCode_t onDeactivated(RTC::UniqueId ec_id);
00117
00118
00119
00120 virtual ReturnCode_t onExecute(RTC::UniqueId ec_id);
00121
00122
00123
00124 virtual ReturnCode_t onAborting(RTC::UniqueId ec_id);
00125
00126
00127
00128 virtual ReturnCode_t onError(RTC::UniqueId ec_id);
00129
00130
00131
00132 virtual ReturnCode_t onReset(RTC::UniqueId ec_id);
00133
00134
00135
00136 virtual ReturnCode_t onStateUpdate(RTC::UniqueId ec_id);
00137
00138
00139
00140 virtual ReturnCode_t onRateChanged(RTC::UniqueId ec_id);
00141
00142
00143 public:
00144
00145
00146
00177 virtual ReturnCode_t initialize();
00178
00179
00217 virtual ReturnCode_t finalize();
00218
00219
00255 virtual ReturnCode_t exit();
00256
00277 virtual CORBA::Boolean is_alive();
00278
00279
00287 virtual ExecutionContextList* get_contexts();
00288
00296 virtual ExecutionContext_ptr get_context(const UniqueId ec_id);
00297
00298
00299
00300
00301
00302
00303
00304
00305
00321 virtual ComponentProfile* get_component_profile();
00322
00323
00339 virtual PortList* get_ports();
00340
00341
00359 virtual ExecutionContextServiceList* get_execution_context_services();
00360
00361
00362
00363
00364 UniqueId attach_executioncontext(ExecutionContext_ptr exec_context);
00365 ReturnCode_t detach_executioncontext(UniqueId ec_id);
00366 virtual ReturnCode_t on_initialize();
00367 virtual ReturnCode_t on_finalize();
00368 virtual ReturnCode_t on_startup(UniqueId ec_id);
00369 virtual ReturnCode_t on_shutdown(UniqueId ec_id);
00370 virtual ReturnCode_t on_activated(UniqueId ec_id);
00371 virtual ReturnCode_t on_deactivated(UniqueId ec_id);
00372 virtual ReturnCode_t on_aborting(UniqueId ec_id);
00373 virtual ReturnCode_t on_error(UniqueId ec_id);
00374 virtual ReturnCode_t on_reset(UniqueId ec_id);
00375
00376 virtual ReturnCode_t on_execute(UniqueId ec_id);
00377 virtual ReturnCode_t on_state_update(UniqueId ec_id);
00378 virtual ReturnCode_t on_rate_changed(UniqueId ec_id);
00379
00380
00381
00382
00383
00384
00406 virtual SDOPackage::OrganizationList* get_owned_organizations()
00407 throw (SDOPackage::NotAvailable);
00408
00409
00410
00411
00412
00442 virtual char* get_sdo_id()
00443 throw (SDOPackage::NotAvailable, SDOPackage::InternalError);
00444
00474 virtual char* get_sdo_type()
00475 throw (SDOPackage::NotAvailable, SDOPackage::InternalError);
00476
00507 virtual SDOPackage::DeviceProfile* get_device_profile()
00508 throw (SDOPackage::NotAvailable, SDOPackage::InternalError);
00509
00541 virtual SDOPackage::ServiceProfileList* get_service_profiles()
00542 throw (SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
00543 SDOPackage::InternalError);
00544
00573 virtual SDOPackage::ServiceProfile* get_service_profile(const char* id)
00574 throw (SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
00575 SDOPackage::InternalError);
00576
00604 virtual SDOPackage::SDOService_ptr get_sdo_service(const char* id)
00605 throw (SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
00606 SDOPackage::InternalError);
00607
00647 virtual SDOPackage::Configuration_ptr get_configuration()
00648 throw (SDOPackage::InterfaceNotImplemented, SDOPackage::NotAvailable,
00649 SDOPackage::InternalError);
00650
00689 virtual SDOPackage::Monitoring_ptr get_monitoring()
00690 throw (SDOPackage::InterfaceNotImplemented, SDOPackage::NotAvailable,
00691 SDOPackage::InternalError);
00692
00723 virtual SDOPackage::OrganizationList* get_organizations()
00724 throw (SDOPackage::NotAvailable, SDOPackage::InternalError);
00725
00752 virtual SDOPackage::NVList* get_status_list()
00753 throw (SDOPackage::NotAvailable, SDOPackage::InternalError);
00754
00784 virtual CORBA::Any* get_status(const char* name)
00785 throw (SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
00786 SDOPackage::InternalError);
00787
00788
00789
00790
00791
00792
00793 const char* getInstanceName() {return m_profile.instance_name;}
00794 void setInstanceName(const char* instance_name);
00795 const char* getTypeName() {return m_profile.type_name;}
00796 const char* getDescription() { return m_profile.description;}
00797 const char* getVersion() {return m_profile.version;}
00798 const char* getVendor() {return m_profile.vendor;}
00799 const char* getCategory() {return m_profile.category;}
00800
00801 std::vector<std::string> getNamingNames();
00802
00803 void setObjRef(const RTObject_ptr rtobj);
00804 RTObject_ptr getObjRef() const;
00805
00806
00807
00833 void setProperties(const Properties& prop);
00834
00856 Properties& getProperties();
00857
00858
00859 template <typename VarType>
00860 bool bindParameter(const char* param_name, VarType& var,
00861 const char* def_val,
00862 bool (*trans)(VarType&, const char*) = ::stringTo)
00863 {
00864 m_configsets.bindParameter(param_name, var, def_val, trans);
00865 return true;
00866 }
00867
00868 void updateParameters(const char* config_set);
00869
00901 void registerPort(PortBase& port);
00902
00903 template <class DataType, template <class DataType> class Buffer>
00904 void registerInPort(const char* name,
00905 InPort<DataType, Buffer>& inport)
00906 {
00907 PortBase* port = new DataInPort(name, inport);
00908 registerPort(*port);
00909 }
00910
00911 template <class DataType, template <class DataType> class Buffer>
00912 void registerOutPort(const char* name,
00913 OutPort<DataType, Buffer>& outport)
00914 {
00915 PortBase* port = new DataOutPort(name, outport);
00916 registerPort(*port);
00917 }
00918
00919
00945 void deletePort(PortBase& port);
00946 void deletePortByName(const char* port_name);
00947 void finalizePorts();
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963 protected:
00964 void shutdown();
00965
00966
00967
00968
00969
00970 protected:
00971 Manager* m_pManager;
00972 CORBA::ORB_var m_pORB;
00973 PortableServer::POA_var m_pPOA;
00974
00975
00976
00977
00981 SDOPackage::OrganizationList m_sdoOwnedOrganizations;
00982
00986 SDOPackage::ServiceProfileList m_sdoSvcProfiles;
00987
00991 struct svc_name
00992 {
00993 svc_name (const char* id) : m_id(id) {};
00994 bool operator()(const SDOPackage::ServiceProfile& prof)
00995 {
00996 return m_id == std::string(prof.id);
00997 }
00998 std::string m_id;
00999 };
01000
01004 SDOPackage::Configuration_impl* m_pSdoConfigImpl;
01005 SDOPackage::Configuration_var m_pSdoConfig;
01006
01010 SDOPackage::OrganizationList m_sdoOrganizations;
01011
01015 SDOPackage::NVList m_sdoStatus;
01016
01017
01018
01019
01020
01024 ComponentProfile m_profile;
01025
01026 RTObject_ptr m_objref;
01030 PortAdmin m_portAdmin;
01031
01032 ExecutionContextServiceList m_execContexts;
01033
01034 bool m_created;
01035 bool m_alive;
01036
01040 Properties m_properties;
01041
01042 ConfigAdmin m_configsets;
01043
01044
01045
01046
01047 struct nv_name
01048 {
01049 nv_name(const char* name) : m_name(name) {};
01050 bool operator()(const SDOPackage::NameValue& nv)
01051 {
01052 return m_name == std::string(nv.name);
01053 }
01054 std::string m_name;
01055 };
01056
01057
01058 struct ec_copy
01059 {
01060 ec_copy(ExecutionContextList& eclist)
01061 : m_eclist(eclist)
01062 {
01063 }
01064 void operator()(ExecutionContextService_ptr ecs)
01065 {
01066 CORBA_SeqUtil::push_back(m_eclist, ExecutionContext::_duplicate(ecs));
01067 }
01068 ExecutionContextList& m_eclist;
01069 };
01070
01071
01072 struct deactivate_comps
01073 {
01074 deactivate_comps(LightweightRTObject_ptr comp)
01075 : m_comp(comp)
01076 {
01077 }
01078 void operator()(ExecutionContextService_ptr ec)
01079 {
01080 ec->deactivate_component(RTC::LightweightRTObject::_duplicate(m_comp));
01081 }
01082 LightweightRTObject_var m_comp;
01083 };
01084
01085
01086 };
01087 };
01088 #endif // RTObject