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
00051
00052
00053 #ifndef RTObject_h
00054 #define RTObject_h
00055
00056
00057 #include "rtm/RTC.h"
00058 #include "rtm/Properties.h"
00059 #include "rtm/idl/RTCSkel.h"
00060 #include "rtm/idl/OpenRTMSkel.h"
00061 #include "rtm/PortBase.h"
00062
00063 #include "rtm/PortAdmin.h"
00064 #include <rtm/DataInPort.h>
00065 #include <rtm/DataOutPort.h>
00066 #include <rtm/InPort.h>
00067 #include <rtm/OutPort.h>
00068 #include <rtm/ConfigAdmin.h>
00069
00070
00071 #include <ace/Task.h>
00072
00073
00074 namespace SDOPackage
00075 {
00076 class Configuration_impl;
00077 };
00078
00079 namespace RTC
00080 {
00081 class Manager;
00082
00083 class RTObject_impl
00084 : public virtual POA_RTC::DataFlowComponent,
00085 public virtual PortableServer::RefCountServantBase
00086 {
00087 public:
00088 RTObject_impl(Manager* manager);
00089 RTObject_impl(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa);
00090 virtual ~RTObject_impl();
00091
00092
00093 protected:
00094
00095
00096
00097
00098
00099 virtual ReturnCode_t onInitialize();
00100
00101
00102
00103 virtual ReturnCode_t onFinalize();
00104
00105
00106
00107 virtual ReturnCode_t onStartup(RTC::UniqueId ec_id);
00108
00109
00110
00111 virtual ReturnCode_t onShutdown(RTC::UniqueId ec_id);
00112
00113
00114
00115 virtual ReturnCode_t onActivated(RTC::UniqueId ec_id);
00116
00117
00118
00119 virtual ReturnCode_t onDeactivated(RTC::UniqueId ec_id);
00120
00121
00122
00123 virtual ReturnCode_t onExecute(RTC::UniqueId ec_id);
00124
00125
00126
00127 virtual ReturnCode_t onAborting(RTC::UniqueId ec_id);
00128
00129
00130
00131 virtual ReturnCode_t onError(RTC::UniqueId ec_id);
00132
00133
00134
00135 virtual ReturnCode_t onReset(RTC::UniqueId ec_id);
00136
00137
00138
00139 virtual ReturnCode_t onStateUpdate(RTC::UniqueId ec_id);
00140
00141
00142
00143 virtual ReturnCode_t onRateChanged(RTC::UniqueId ec_id);
00144
00145
00146 public:
00147
00148
00149
00180 virtual ReturnCode_t initialize();
00181
00182
00220 virtual ReturnCode_t finalize();
00221
00222
00258 virtual ReturnCode_t exit();
00259
00280 virtual CORBA::Boolean is_alive();
00281
00282
00290 virtual ExecutionContextList* get_contexts();
00291
00299 virtual ExecutionContext_ptr get_context(UniqueId ec_id);
00300
00301
00302
00303
00304
00305
00306
00307
00308
00324 virtual ComponentProfile* get_component_profile();
00325
00326
00342 virtual PortList* get_ports();
00343
00344
00362 virtual ExecutionContextServiceList* get_execution_context_services();
00363
00364
00365
00366
00367 UniqueId attach_executioncontext(ExecutionContext_ptr exec_context);
00368 ReturnCode_t detach_executioncontext(UniqueId ec_id);
00369 virtual ReturnCode_t on_initialize();
00370 virtual ReturnCode_t on_finalize();
00371 virtual ReturnCode_t on_startup(UniqueId ec_id);
00372 virtual ReturnCode_t on_shutdown(UniqueId ec_id);
00373 virtual ReturnCode_t on_activated(UniqueId ec_id);
00374 virtual ReturnCode_t on_deactivated(UniqueId ec_id);
00375 virtual ReturnCode_t on_aborting(UniqueId ec_id);
00376 virtual ReturnCode_t on_error(UniqueId ec_id);
00377 virtual ReturnCode_t on_reset(UniqueId ec_id);
00378
00379 virtual ReturnCode_t on_execute(UniqueId ec_id);
00380 virtual ReturnCode_t on_state_update(UniqueId ec_id);
00381 virtual ReturnCode_t on_rate_changed(UniqueId ec_id);
00382
00383
00384
00385
00386
00387
00409 virtual SDOPackage::OrganizationList* get_owned_organizations()
00410 throw (SDOPackage::NotAvailable);
00411
00412
00413
00414
00415
00445 virtual char* get_sdo_id()
00446 throw (SDOPackage::NotAvailable, SDOPackage::InternalError);
00447
00477 virtual char* get_sdo_type()
00478 throw (SDOPackage::NotAvailable, SDOPackage::InternalError);
00479
00510 virtual SDOPackage::DeviceProfile* get_device_profile()
00511 throw (SDOPackage::NotAvailable, SDOPackage::InternalError);
00512
00544 virtual SDOPackage::ServiceProfileList* get_service_profiles()
00545 throw (SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
00546 SDOPackage::InternalError);
00547
00576 virtual SDOPackage::ServiceProfile* get_service_profile(const char* id)
00577 throw (SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
00578 SDOPackage::InternalError);
00579
00607 virtual SDOPackage::SDOService_ptr get_sdo_service(const char* id)
00608 throw (SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
00609 SDOPackage::InternalError);
00610
00650 virtual SDOPackage::Configuration_ptr get_configuration()
00651 throw (SDOPackage::InterfaceNotImplemented, SDOPackage::NotAvailable,
00652 SDOPackage::InternalError);
00653
00692 virtual SDOPackage::Monitoring_ptr get_monitoring()
00693 throw (SDOPackage::InterfaceNotImplemented, SDOPackage::NotAvailable,
00694 SDOPackage::InternalError);
00695
00726 virtual SDOPackage::OrganizationList* get_organizations()
00727 throw (SDOPackage::NotAvailable, SDOPackage::InternalError);
00728
00755 virtual SDOPackage::NVList* get_status_list()
00756 throw (SDOPackage::NotAvailable, SDOPackage::InternalError);
00757
00787 virtual CORBA::Any* get_status(const char* name)
00788 throw (SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
00789 SDOPackage::InternalError);
00790
00791
00792
00793
00794
00795
00796 const char* getInstanceName() {return m_profile.instance_name;}
00797 void setInstanceName(const char* instance_name);
00798 const char* getTypeName() {return m_profile.type_name;}
00799 const char* getDescription() { return m_profile.description;}
00800 const char* getVersion() {return m_profile.version;}
00801 const char* getVendor() {return m_profile.vendor;}
00802 const char* getCategory() {return m_profile.category;}
00803
00804 std::vector<std::string> getNamingNames();
00805
00806 void setObjRef(const RTObject_ptr rtobj);
00807 RTObject_ptr getObjRef() const;
00808
00809
00810
00836 void setProperties(const Properties& prop);
00837
00859 Properties& getProperties();
00860
00861
00862 template <typename VarType>
00863 bool bindParameter(const char* param_name, VarType& var,
00864 const char* def_val,
00865 bool (*trans)(VarType&, const char*) = ::stringTo)
00866 {
00867 m_configsets.bindParameter(param_name, var, def_val, trans);
00868 return true;
00869 }
00870
00871 void updateParameters(const char* config_set);
00872
00904 void registerPort(PortBase& port);
00905
00906 template <class DataType, template <class DataType> class Buffer>
00907 void registerInPort(const char* name,
00908 InPort<DataType, Buffer>& inport)
00909 {
00910 std::string propkey("port.dataport.");
00911 propkey += name;
00912 propkey += ".tcp_any";
00913
00914
00915 m_properties[propkey];
00916 PortBase* port = new DataInPort(name, inport,
00917 *m_properties.getNode(propkey));
00918 registerPort(*port);
00919 }
00920
00921 template <class DataType, template <class DataType> class Buffer>
00922 void registerOutPort(const char* name,
00923 OutPort<DataType, Buffer>& outport)
00924 {
00925 std::string propkey("port.dataport.");
00926 propkey += name;
00927 propkey += ".tcp_any";
00928
00929
00930 m_properties[propkey];
00931 PortBase* port = new DataOutPort(name, outport,
00932 *m_properties.getNode(propkey));
00933 registerPort(*port);
00934 }
00935
00936
00962 void deletePort(PortBase& port);
00963 void deletePortByName(const char* port_name);
00964 void finalizePorts();
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980 protected:
00981 void shutdown();
00982
00983
00984
00985
00986
00987 protected:
00988 Manager* m_pManager;
00989 CORBA::ORB_var m_pORB;
00990 PortableServer::POA_var m_pPOA;
00991
00992
00993
00994
00998 SDOPackage::OrganizationList m_sdoOwnedOrganizations;
00999
01003 SDOPackage::ServiceProfileList m_sdoSvcProfiles;
01004
01008 struct svc_name
01009 {
01010 svc_name (const char* id) : m_id(id) {};
01011 bool operator()(const SDOPackage::ServiceProfile& prof)
01012 {
01013 return m_id == std::string(prof.id);
01014 }
01015 std::string m_id;
01016 };
01017
01021 SDOPackage::Configuration_impl* m_pSdoConfigImpl;
01022 SDOPackage::Configuration_var m_pSdoConfig;
01023
01027 SDOPackage::OrganizationList m_sdoOrganizations;
01028
01032 SDOPackage::NVList m_sdoStatus;
01033
01034
01035
01036
01037
01041 ComponentProfile m_profile;
01042
01043 RTObject_ptr m_objref;
01047 PortAdmin m_portAdmin;
01048
01049 ExecutionContextServiceList m_execContexts;
01050
01051 bool m_created;
01052 bool m_alive;
01053
01057 Properties m_properties;
01058
01059 ConfigAdmin m_configsets;
01060
01061
01062
01063
01064 struct nv_name
01065 {
01066 nv_name(const char* name) : m_name(name) {};
01067 bool operator()(const SDOPackage::NameValue& nv)
01068 {
01069 return m_name == std::string(nv.name);
01070 }
01071 std::string m_name;
01072 };
01073
01074
01075 struct ec_copy
01076 {
01077 ec_copy(ExecutionContextList& eclist)
01078 : m_eclist(eclist)
01079 {
01080 }
01081 void operator()(ExecutionContextService_ptr ecs)
01082 {
01083 CORBA_SeqUtil::push_back(m_eclist, ExecutionContext::_duplicate(ecs));
01084 }
01085 ExecutionContextList& m_eclist;
01086 };
01087
01088
01089 struct deactivate_comps
01090 {
01091 deactivate_comps(LightweightRTObject_ptr comp)
01092 : m_comp(comp)
01093 {
01094 }
01095 void operator()(ExecutionContextService_ptr ec)
01096 {
01097 ec->deactivate_component(RTC::LightweightRTObject::_duplicate(m_comp));
01098 }
01099 LightweightRTObject_var m_comp;
01100 };
01101
01102
01103 };
01104 };
01105 #endif // RTObject