diff options
author | edwardgt <edwardgt@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-05-07 00:00:11 +0000 |
---|---|---|
committer | edwardgt <edwardgt@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-05-07 00:00:11 +0000 |
commit | b60cb1c43b574b1b40884bccd61d643795c7deef (patch) | |
tree | 6cec9eff16798b078f6e1c1f06204b3a00e653e2 | |
parent | 575c43bfb9221138eabdfe1b4ada2d07700c20f4 (diff) | |
download | ATCD-b60cb1c43b574b1b40884bccd61d643795c7deef.tar.gz |
*** empty log message ***
24 files changed, 1191 insertions, 29 deletions
diff --git a/TAO/CIAO/examples/UAV/BBN_UAV.idl b/TAO/CIAO/examples/UAV/BBN_UAV.idl index 7b1b1928ae6..89f68216d81 100644 --- a/TAO/CIAO/examples/UAV/BBN_UAV.idl +++ b/TAO/CIAO/examples/UAV/BBN_UAV.idl @@ -56,6 +56,21 @@ module BBN_UAV */ eventtype StartMove {}; + /** + * @eventtype: published by UAV, and consumed by Satellite. + */ + eventtype UAVReady {}; + + /** + * @eventtype: published by UCAV, and consumed by Satellite. + */ + eventtype UCAVReady {}; + + /** + * @eventtype: published by Battle, and consumed by Satellite. + */ + eventtype BattleReady {}; + }; #endif /*CIAO_BBN_UAV_IDL*/ diff --git a/TAO/CIAO/examples/UAV/Battle/Battle.idl b/TAO/CIAO/examples/UAV/Battle/Battle.idl index 0d80ee27e08..960ddee40db 100644 --- a/TAO/CIAO/examples/UAV/Battle/Battle.idl +++ b/TAO/CIAO/examples/UAV/Battle/Battle.idl @@ -18,6 +18,7 @@ module BBN_UAV { component Battle { + publishes BattleReady battle_ready; consumes StartEngage start_engage; }; diff --git a/TAO/CIAO/examples/UAV/Battle/Battle_exec.cpp b/TAO/CIAO/examples/UAV/Battle/Battle_exec.cpp index ef851715530..382ba3c9cf3 100644 --- a/TAO/CIAO/examples/UAV/Battle/Battle_exec.cpp +++ b/TAO/CIAO/examples/UAV/Battle/Battle_exec.cpp @@ -22,8 +22,14 @@ MyImpl::Battle_exec_i::push_start_engage (BBN_UAV::StartEngage *ev ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { - ACE_DEBUG ((LM_DEBUG, - "Battle, received a StartEngage from Engagement \n")); + // Notify others + BBN_UAV::BattleReady_var event = new OBV_BBN_UAV::BattleReady; + + //ACE_DEBUG ((LM_DEBUG, + // "Battle, received a StartEngage from Engagement \n")); + + this->context_->push_battle_ready (event + ACE_ENV_ARG_PARAMETER); } // Operations from Components::SessionComponent diff --git a/TAO/CIAO/examples/UAV/Battle/Battle_svnt.cpp b/TAO/CIAO/examples/UAV/Battle/Battle_svnt.cpp index 4fae9c65473..9e8a3fb6524 100644 --- a/TAO/CIAO/examples/UAV/Battle/Battle_svnt.cpp +++ b/TAO/CIAO/examples/UAV/Battle/Battle_svnt.cpp @@ -138,6 +138,104 @@ namespace Battle_Impl // Operations for Battle receptacles and event sources, // defined in ::BBN_UAV::CCM_Battle_Context. + void + Battle_Context::push_battle_ready ( + ::BBN_UAV::BattleReady *ev + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + + ACE_CString my_uuid = this->servant_->component_UUID (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + my_uuid += "_battle_ready_publisher"; + + this->container_->push_event (ev, + my_uuid.c_str () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + /* + ACE_Active_Map_Manager< + ::BBN_UAV::TargetLocatedConsumer_var>::iterator end = + this->ciao_publishes_target_located_map_.end (); + + for (ACE_Active_Map_Manager< + ::BBN_UAV::TargetLocatedConsumer_var>::iterator iter = + this->ciao_publishes_target_located_map_.begin (); + iter != end; + ++iter) + { + ACE_Active_Map_Manager< + ::BBN_UAV::TargetLocatedConsumer_var>::ENTRY &entry = *iter; + + ::BBN_UAV::TargetLocatedConsumer_var c = + ::BBN_UAV::TargetLocatedConsumer::_narrow ( + entry.int_id_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + entry.int_id_->push_TargetLocated ( + ev + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + */ + + } + + ::Components::Cookie * + Battle_Context::subscribe_battle_ready ( + ::BBN_UAV::BattleReadyConsumer_ptr c + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::ExceededConnectionLimit)) + { + if (CORBA::is_nil (c)) + { + ACE_THROW_RETURN (CORBA::BAD_PARAM (), 0); + } + + ::BBN_UAV::BattleReadyConsumer_var sub = + ::BBN_UAV::BattleReadyConsumer::_duplicate (c); + + ACE_Active_Map_Manager_Key key; + this->ciao_publishes_battle_ready_map_.bind (sub.in (), key); + sub._retn (); + + ::Components::Cookie_var retv = new ::CIAO::Map_Key_Cookie (key); + return retv._retn (); + } + + ::BBN_UAV::BattleReadyConsumer_ptr + Battle_Context::unsubscribe_battle_ready ( + ::Components::Cookie *ck + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::InvalidConnection)) + { + ::BBN_UAV::BattleReadyConsumer_var retv; + ACE_Active_Map_Manager_Key key; + + if (ck == 0 || ::CIAO::Map_Key_Cookie::extract (ck, key) == -1) + { + ACE_THROW_RETURN ( + ::Components::InvalidConnection (), + ::BBN_UAV::BattleReadyConsumer::_nil ()); + } + + + if (this->ciao_publishes_battle_ready_map_.unbind (key, retv) != 0) + { + ACE_THROW_RETURN ( + ::Components::InvalidConnection (), + ::BBN_UAV::BattleReadyConsumer::_nil ()); + } + + return retv._retn (); + } + // CIAO-specific. ::CIAO::Session_Container * @@ -294,6 +392,32 @@ namespace Battle_Impl ACE_THROW_RETURN (::CORBA::NO_IMPLEMENT (), 0); } + ::Components::Cookie * + Battle_Servant::subscribe_battle_ready ( + ::BBN_UAV::BattleReadyConsumer_ptr c + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::ExceededConnectionLimit)) + { + return this->context_->subscribe_battle_ready ( + c + ACE_ENV_ARG_PARAMETER); + } + + ::BBN_UAV::BattleReadyConsumer_ptr + Battle_Servant::unsubscribe_battle_ready ( + ::Components::Cookie *ck + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::InvalidConnection)) + { + return this->context_->unsubscribe_battle_ready ( + ck + ACE_ENV_ARG_PARAMETER); + } + Battle_Servant::StartEngageConsumer_start_engage_Servant::StartEngageConsumer_start_engage_Servant ( ::BBN_UAV::CCM_Battle_ptr executor, ::BBN_UAV::CCM_Battle_Context_ptr c) @@ -546,6 +670,24 @@ namespace Battle_Impl ACE_THROW_RETURN (::Components::InvalidName (), 0); } + if (ACE_OS::strcmp (publisher_name, "battle_ready") == 0) + { + ::BBN_UAV::BattleReadyConsumer_var _ciao_consumer = + ::BBN_UAV::BattleReadyConsumer::_narrow ( + subscribe + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (::CORBA::is_nil (_ciao_consumer.in ())) + { + ACE_THROW_RETURN (::Components::InvalidConnection (), 0); + } + + return this->subscribe_battle_ready ( + _ciao_consumer.in () + ACE_ENV_ARG_PARAMETER); + } + ACE_THROW_RETURN (::Components::InvalidName (), 0); } @@ -569,6 +711,13 @@ namespace Battle_Impl ::Components::EventConsumerBase::_nil ()); } + if (ACE_OS::strcmp (publisher_name, "battle_ready") == 0) + { + return this->unsubscribe_battle_ready ( + ck + ACE_ENV_ARG_PARAMETER); + } + ACE_THROW_RETURN ( ::Components::InvalidName (), ::Components::EventConsumerBase::_nil ()); diff --git a/TAO/CIAO/examples/UAV/Battle/Battle_svnt.h b/TAO/CIAO/examples/UAV/Battle/Battle_svnt.h index 62b728fe9ed..cd118101434 100644 --- a/TAO/CIAO/examples/UAV/Battle/Battle_svnt.h +++ b/TAO/CIAO/examples/UAV/Battle/Battle_svnt.h @@ -106,6 +106,12 @@ namespace Battle_Impl // Operations for Battle receptacles and event sources, // defined in ::BBN_UAV::CCM_Battle_Context. + virtual void + push_battle_ready ( + ::BBN_UAV::BattleReady *ev + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + // CIAO-specific. ::CIAO::Session_Container * @@ -119,7 +125,27 @@ namespace Battle_Impl protected: // Methods that manage this component's connections and consumers. + virtual ::Components::Cookie * + subscribe_battle_ready ( + ::BBN_UAV::BattleReadyConsumer_ptr c + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::ExceededConnectionLimit)); + + virtual ::BBN_UAV::BattleReadyConsumer_ptr + unsubscribe_battle_ready ( + ::Components::Cookie *ck + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::InvalidConnection)); + protected: + ACE_Active_Map_Manager< + ::BBN_UAV::BattleReadyConsumer_var> + ciao_publishes_battle_ready_map_; + ::Components::CCMHome_var home_; ::CIAO::Session_Container *container_; @@ -148,6 +174,22 @@ namespace Battle_Impl // Public port operations. + virtual ::Components::Cookie * + subscribe_battle_ready ( + ::BBN_UAV::BattleReadyConsumer_ptr c + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::ExceededConnectionLimit)); + + virtual ::BBN_UAV::BattleReadyConsumer_ptr + unsubscribe_battle_ready ( + ::Components::Cookie *ck + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::InvalidConnection)); + // Servant class for the start_engage consumer. class BATTLE_SVNT_Export StartEngageConsumer_start_engage_Servant : public virtual POA_BBN_UAV::StartEngageConsumer, diff --git a/TAO/CIAO/examples/UAV/CAOC/CAOC_exec.cpp b/TAO/CIAO/examples/UAV/CAOC/CAOC_exec.cpp index 4978eba4c02..7420d429a1d 100644 --- a/TAO/CIAO/examples/UAV/CAOC/CAOC_exec.cpp +++ b/TAO/CIAO/examples/UAV/CAOC/CAOC_exec.cpp @@ -26,8 +26,8 @@ MyImpl::CAOC_exec_i::push_target_located (BBN_UAV::TargetLocated *ev BBN_UAV::PrepareCapture_var event1 = new OBV_BBN_UAV::PrepareCapture; BBN_UAV::PrepareEngage_var event2 = new OBV_BBN_UAV::PrepareEngage; - ACE_DEBUG ((LM_DEBUG, - "CAOC, received a TargetLocated from Satellite \n")); + //ACE_DEBUG ((LM_DEBUG, + // "CAOC, received a TargetLocated from Satellite \n")); this->context_->push_prepare_capture (event1 ACE_ENV_ARG_PARAMETER); diff --git a/TAO/CIAO/examples/UAV/Engagement/Engagement_exec.cpp b/TAO/CIAO/examples/UAV/Engagement/Engagement_exec.cpp index a991ba93c29..ef33f73b093 100644 --- a/TAO/CIAO/examples/UAV/Engagement/Engagement_exec.cpp +++ b/TAO/CIAO/examples/UAV/Engagement/Engagement_exec.cpp @@ -26,8 +26,8 @@ MyImpl::Engagement_exec_i::push_prepare_engage (BBN_UAV::PrepareEngage *ev BBN_UAV::StartEngage_var event1 = new OBV_BBN_UAV::StartEngage; BBN_UAV::PrepareMove_var event2 = new OBV_BBN_UAV::PrepareMove; - ACE_DEBUG ((LM_DEBUG, - "Engagement, received a PrepareEngage from CAOC \n")); + //ACE_DEBUG ((LM_DEBUG, + // "Engagement, received a PrepareEngage from CAOC \n")); this->context_->push_start_engage (event1 ACE_ENV_ARG_PARAMETER); diff --git a/TAO/CIAO/examples/UAV/Ground/UAV_GS_exec.cpp b/TAO/CIAO/examples/UAV/Ground/UAV_GS_exec.cpp index bc17412763c..f000f70eb37 100644 --- a/TAO/CIAO/examples/UAV/Ground/UAV_GS_exec.cpp +++ b/TAO/CIAO/examples/UAV/Ground/UAV_GS_exec.cpp @@ -25,8 +25,8 @@ MyImpl::UAV_GS_exec_i::push_prepare_capture (BBN_UAV::PrepareCapture *ev // Notify others BBN_UAV::StartCapture_var event = new OBV_BBN_UAV::StartCapture; - ACE_DEBUG ((LM_DEBUG, - "UAV_GS, received a PrepareCapture from CAOC \n")); + //ACE_DEBUG ((LM_DEBUG, + // "UAV_GS, received a PrepareCapture from CAOC \n")); this->context_->push_start_capture (event ACE_ENV_ARG_PARAMETER); diff --git a/TAO/CIAO/examples/UAV/Satellite/Satellite.idl b/TAO/CIAO/examples/UAV/Satellite/Satellite.idl index 0a5fd98f53e..482145b66c7 100644 --- a/TAO/CIAO/examples/UAV/Satellite/Satellite.idl +++ b/TAO/CIAO/examples/UAV/Satellite/Satellite.idl @@ -23,6 +23,9 @@ module BBN_UAV component Satellite supports trigger { publishes TargetLocated target_located; + consumes UAVReady uav_ready; + consumes UCAVReady ucav_ready; + consumes BattleReady battle_ready; }; home SatelliteHome manages Satellite diff --git a/TAO/CIAO/examples/UAV/Satellite/Satellite_exec.cpp b/TAO/CIAO/examples/UAV/Satellite/Satellite_exec.cpp index b35d7fb596c..18a2d45b304 100644 --- a/TAO/CIAO/examples/UAV/Satellite/Satellite_exec.cpp +++ b/TAO/CIAO/examples/UAV/Satellite/Satellite_exec.cpp @@ -1,14 +1,15 @@ // $Id$ +#include <fstream> +#include <iostream> #include "CIAO_common.h" #include "Satellite_exec.h" -#include "ace/High_Res_Timer.h" #define DISPLACEMENT 256 /// Default constructor. MyImpl::Satellite_exec_i::Satellite_exec_i (void) - : str_ ("BM DEVICE DATA") + : str_ ("BM DEVICE DATA"), counter_ (-1) { } @@ -18,6 +19,48 @@ MyImpl::Satellite_exec_i::~Satellite_exec_i () { } +// Operations from event sink(s) + +void +MyImpl::Satellite_exec_i::push_uav_ready (BBN_UAV::UAVReady *ev + ACE_ENV_ARG_DECL) +ACE_THROW_SPEC ((CORBA::SystemException)) +{ + static int count = 0; + + ACE_hrtime_t end = ACE_OS::gethrtime (); + //ACE_DEBUG ((LM_DEBUG, "UAV RTT = %i\n", end - start_)); + this->UAV_times_[count++] = end - this->start_; + + +} + +void +MyImpl::Satellite_exec_i::push_ucav_ready (BBN_UAV::UCAVReady *ev + ACE_ENV_ARG_DECL) +ACE_THROW_SPEC ((CORBA::SystemException)) +{ + static int count = 0; + + ACE_hrtime_t end = ACE_OS::gethrtime (); + //ACE_DEBUG ((LM_DEBUG, "UCAV RTT = %i\n", end - start_)); + this->UCAV_times_[count++] = end - this->start_; + +} + +void +MyImpl::Satellite_exec_i::push_battle_ready (BBN_UAV::BattleReady *ev + ACE_ENV_ARG_DECL) +ACE_THROW_SPEC ((CORBA::SystemException)) +{ + + ACE_hrtime_t end = ACE_OS::gethrtime (); + //ACE_DEBUG ((LM_DEBUG, "Battle RTT = %i\n", end - start_)); + + this->Battle_times_[this->counter_] = end - this->start_; + +} + // Operations from supported interface(s) void @@ -29,13 +72,40 @@ MyImpl::Satellite_exec_i::alert (ACE_ENV_SINGLE_ARG_DECL) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Satellite, pushing TargetLocated!\n"))); - - ACE_hrtime_t start = ACE_OS::gethrtime (); - this->context_->push_target_located (ev.in () - ACE_ENV_ARG_PARAMETER); - ACE_hrtime_t end = ACE_OS::gethrtime (); - - ACE_DEBUG ((LM_DEBUG, "RTT = %i\n", end - start)); + this->counter_++; + if (this->counter_ == 1000) + { + + std::ofstream UAV_out; + std::ofstream UCAV_out; + std::ofstream battle_out; + + UAV_out.open ("UAV_stats.dat"); + UCAV_out.open ("UCAV_out.dat"); + battle_out.open ("Battle_stats.dat"); + + for (int i = 0; i < 3000; ++i) + { + UAV_out << (long)this->UAV_times_[i] << "\t"; + } + + for (int j = 0; j < 3000; ++j) + { + UCAV_out << (long)this->UCAV_times_[j] << "\t"; + } + + for (int k = 0; k < 1000; ++k) + { + battle_out << (long)this->Battle_times_[k] << "\t"; + } + + } + else + { + this->start_ = ACE_OS::gethrtime (); + this->context_->push_target_located (ev.in () + ACE_ENV_ARG_PARAMETER); + } } // Operations from Components::SessionComponent @@ -68,6 +138,15 @@ MyImpl::Satellite_exec_i::ccm_activate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) int argc = sizeof(argv)/sizeof(argv[0]); CORBA::ORB_var orb = CORBA::ORB_init(argc, argv ACE_ENV_ARG_PARAMETER); + CIAO_REGISTER_VALUE_FACTORY (orb.in(), BBN_UAV::UAVReady_init, + BBN_UAV::UAVReady); + + CIAO_REGISTER_VALUE_FACTORY (orb.in(), BBN_UAV::UCAVReady_init, + BBN_UAV::UCAVReady); + + + CIAO_REGISTER_VALUE_FACTORY (orb.in(), BBN_UAV::BattleReady_init, + BBN_UAV::BattleReady); } void diff --git a/TAO/CIAO/examples/UAV/Satellite/Satellite_exec.h b/TAO/CIAO/examples/UAV/Satellite/Satellite_exec.h index 8908f4b705b..841441ef665 100644 --- a/TAO/CIAO/examples/UAV/Satellite/Satellite_exec.h +++ b/TAO/CIAO/examples/UAV/Satellite/Satellite_exec.h @@ -13,6 +13,7 @@ #include "SatelliteEIC.h" #include "tao/LocalObject.h" +#include "ace/High_Res_Timer.h" // The namespace name for the actual implementation classes doesn't // really matter. Since there may be several different @@ -38,6 +39,23 @@ namespace MyImpl /// Default destructor. ~Satellite_exec_i (void); + // Operations from event sink(s) + + virtual void + push_uav_ready (BBN_UAV::UAVReady *ev + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void + push_ucav_ready (BBN_UAV::UCAVReady *ev + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void + push_battle_ready (BBN_UAV::BattleReady *ev + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + // Operations from supported interface(s) virtual void alert (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) @@ -70,6 +88,16 @@ namespace MyImpl /// Copmponent specific context BBN_UAV::CCM_Satellite_Context_var context_; + + ACE_hrtime_t start_; + + ACE_hrtime_t UAV_times_[3000]; + + ACE_hrtime_t UCAV_times_[3000]; + + ACE_hrtime_t Battle_times_[1000]; + + int counter_; }; /** diff --git a/TAO/CIAO/examples/UAV/Satellite/Satellite_svnt.cpp b/TAO/CIAO/examples/UAV/Satellite/Satellite_svnt.cpp index 0c71dcea062..c95fe4ffa2f 100644 --- a/TAO/CIAO/examples/UAV/Satellite/Satellite_svnt.cpp +++ b/TAO/CIAO/examples/UAV/Satellite/Satellite_svnt.cpp @@ -144,8 +144,6 @@ namespace Satellite_Impl ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { - - ACE_CString my_uuid = this->servant_->component_UUID (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; my_uuid += "_target_located_publisher"; @@ -418,6 +416,264 @@ namespace Satellite_Impl ACE_ENV_ARG_PARAMETER); } + Satellite_Servant::UAVReadyConsumer_uav_ready_Servant::UAVReadyConsumer_uav_ready_Servant ( + ::BBN_UAV::CCM_Satellite_ptr executor, + ::BBN_UAV::CCM_Satellite_Context_ptr c) + : executor_ (::BBN_UAV::CCM_Satellite::_duplicate (executor)), + ctx_ (::BBN_UAV::CCM_Satellite_Context::_duplicate (c)) + { + } + + Satellite_Servant::UAVReadyConsumer_uav_ready_Servant::~UAVReadyConsumer_uav_ready_Servant (void) + { + } + + CORBA::Object_ptr + Satellite_Servant::UAVReadyConsumer_uav_ready_Servant::_get_component ( + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + return this->ctx_->get_CCM_object (ACE_ENV_SINGLE_ARG_PARAMETER); + } + + void + Satellite_Servant::UAVReadyConsumer_uav_ready_Servant::push_UAVReady ( + ::BBN_UAV::UAVReady *evt + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + this->executor_->push_uav_ready ( + evt + ACE_ENV_ARG_PARAMETER); + } + + // Inherited from ::Components::EventConsumerBase. + void + Satellite_Servant::UAVReadyConsumer_uav_ready_Servant::push_event ( + ::Components::EventBase *ev + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::BadEventType)) + { + ::BBN_UAV::UAVReady_var ev_type = + ::BBN_UAV::UAVReady::_downcast (ev); + + if (ev_type != 0) + { + this->push_UAVReady ( + ev_type.in () + ACE_ENV_ARG_PARAMETER); + + return; + } + + ACE_THROW (::Components::BadEventType ()); + } + + ::BBN_UAV::UAVReadyConsumer_ptr + Satellite_Servant::get_consumer_uav_ready ( + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + if (CORBA::is_nil (this->consumes_uav_ready_.in ())) + { + Satellite_Servant::UAVReadyConsumer_uav_ready_Servant *svt = + new Satellite_Servant::UAVReadyConsumer_uav_ready_Servant ( + this->executor_.in (), + this->context_); + PortableServer::ServantBase_var safe_servant (svt); + + CORBA::Object_var obj = + this->container_->install_servant ( + svt + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (::BBN_UAV::UAVReadyConsumer::_nil ()); + + ::BBN_UAV::UAVReadyConsumer_var eco = + ::BBN_UAV::UAVReadyConsumer::_narrow ( + obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (::BBN_UAV::UAVReadyConsumer::_nil ()); + + this->consumes_uav_ready_ = eco; + } + + return ::BBN_UAV::UAVReadyConsumer::_duplicate (this->consumes_uav_ready_.in ()); + } + + Satellite_Servant::UCAVReadyConsumer_ucav_ready_Servant::UCAVReadyConsumer_ucav_ready_Servant ( + ::BBN_UAV::CCM_Satellite_ptr executor, + ::BBN_UAV::CCM_Satellite_Context_ptr c) + : executor_ (::BBN_UAV::CCM_Satellite::_duplicate (executor)), + ctx_ (::BBN_UAV::CCM_Satellite_Context::_duplicate (c)) + { + } + + Satellite_Servant::UCAVReadyConsumer_ucav_ready_Servant::~UCAVReadyConsumer_ucav_ready_Servant (void) + { + } + + CORBA::Object_ptr + Satellite_Servant::UCAVReadyConsumer_ucav_ready_Servant::_get_component ( + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + return this->ctx_->get_CCM_object (ACE_ENV_SINGLE_ARG_PARAMETER); + } + + void + Satellite_Servant::UCAVReadyConsumer_ucav_ready_Servant::push_UCAVReady ( + ::BBN_UAV::UCAVReady *evt + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + this->executor_->push_ucav_ready ( + evt + ACE_ENV_ARG_PARAMETER); + } + + // Inherited from ::Components::EventConsumerBase. + void + Satellite_Servant::UCAVReadyConsumer_ucav_ready_Servant::push_event ( + ::Components::EventBase *ev + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::BadEventType)) + { + ::BBN_UAV::UCAVReady_var ev_type = + ::BBN_UAV::UCAVReady::_downcast (ev); + + if (ev_type != 0) + { + this->push_UCAVReady ( + ev_type.in () + ACE_ENV_ARG_PARAMETER); + + return; + } + + ACE_THROW (::Components::BadEventType ()); + } + + ::BBN_UAV::UCAVReadyConsumer_ptr + Satellite_Servant::get_consumer_ucav_ready ( + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + if (CORBA::is_nil (this->consumes_ucav_ready_.in ())) + { + Satellite_Servant::UCAVReadyConsumer_ucav_ready_Servant *svt = + new Satellite_Servant::UCAVReadyConsumer_ucav_ready_Servant ( + this->executor_.in (), + this->context_); + PortableServer::ServantBase_var safe_servant (svt); + + CORBA::Object_var obj = + this->container_->install_servant ( + svt + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (::BBN_UAV::UCAVReadyConsumer::_nil ()); + + ::BBN_UAV::UCAVReadyConsumer_var eco = + ::BBN_UAV::UCAVReadyConsumer::_narrow ( + obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (::BBN_UAV::UCAVReadyConsumer::_nil ()); + + this->consumes_ucav_ready_ = eco; + } + + return ::BBN_UAV::UCAVReadyConsumer::_duplicate (this->consumes_ucav_ready_.in ()); + } + + Satellite_Servant::BattleReadyConsumer_battle_ready_Servant::BattleReadyConsumer_battle_ready_Servant ( + ::BBN_UAV::CCM_Satellite_ptr executor, + ::BBN_UAV::CCM_Satellite_Context_ptr c) + : executor_ (::BBN_UAV::CCM_Satellite::_duplicate (executor)), + ctx_ (::BBN_UAV::CCM_Satellite_Context::_duplicate (c)) + { + } + + Satellite_Servant::BattleReadyConsumer_battle_ready_Servant::~BattleReadyConsumer_battle_ready_Servant (void) + { + } + + CORBA::Object_ptr + Satellite_Servant::BattleReadyConsumer_battle_ready_Servant::_get_component ( + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + return this->ctx_->get_CCM_object (ACE_ENV_SINGLE_ARG_PARAMETER); + } + + void + Satellite_Servant::BattleReadyConsumer_battle_ready_Servant::push_BattleReady ( + ::BBN_UAV::BattleReady *evt + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + this->executor_->push_battle_ready ( + evt + ACE_ENV_ARG_PARAMETER); + } + + // Inherited from ::Components::EventConsumerBase. + void + Satellite_Servant::BattleReadyConsumer_battle_ready_Servant::push_event ( + ::Components::EventBase *ev + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::BadEventType)) + { + ::BBN_UAV::BattleReady_var ev_type = + ::BBN_UAV::BattleReady::_downcast (ev); + + if (ev_type != 0) + { + this->push_BattleReady ( + ev_type.in () + ACE_ENV_ARG_PARAMETER); + + return; + } + + ACE_THROW (::Components::BadEventType ()); + } + + ::BBN_UAV::BattleReadyConsumer_ptr + Satellite_Servant::get_consumer_battle_ready ( + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + if (CORBA::is_nil (this->consumes_battle_ready_.in ())) + { + Satellite_Servant::BattleReadyConsumer_battle_ready_Servant *svt = + new Satellite_Servant::BattleReadyConsumer_battle_ready_Servant ( + this->executor_.in (), + this->context_); + PortableServer::ServantBase_var safe_servant (svt); + + CORBA::Object_var obj = + this->container_->install_servant ( + svt + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (::BBN_UAV::BattleReadyConsumer::_nil ()); + + ::BBN_UAV::BattleReadyConsumer_var eco = + ::BBN_UAV::BattleReadyConsumer::_narrow ( + obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (::BBN_UAV::BattleReadyConsumer::_nil ()); + + this->consumes_battle_ready_ = eco; + } + + return ::BBN_UAV::BattleReadyConsumer::_duplicate (this->consumes_battle_ready_.in ()); + } + ::Components::Cookie * Satellite_Servant::connect ( const char *name, @@ -510,6 +766,21 @@ namespace Satellite_Impl ::Components::EventConsumerBase::_nil ()); } + if (ACE_OS::strcmp (sink_name, "uav_ready") == 0) + { + return this->get_consumer_uav_ready (ACE_ENV_SINGLE_ARG_PARAMETER); + } + + if (ACE_OS::strcmp (sink_name, "ucav_ready") == 0) + { + return this->get_consumer_ucav_ready (ACE_ENV_SINGLE_ARG_PARAMETER); + } + + if (ACE_OS::strcmp (sink_name, "battle_ready") == 0) + { + return this->get_consumer_battle_ready (ACE_ENV_SINGLE_ARG_PARAMETER); + } + ACE_THROW_RETURN ( ::Components::InvalidName (), ::Components::EventConsumerBase::_nil ()); diff --git a/TAO/CIAO/examples/UAV/Satellite/Satellite_svnt.h b/TAO/CIAO/examples/UAV/Satellite/Satellite_svnt.h index ef1857ebeb2..681b18fde78 100644 --- a/TAO/CIAO/examples/UAV/Satellite/Satellite_svnt.h +++ b/TAO/CIAO/examples/UAV/Satellite/Satellite_svnt.h @@ -195,6 +195,141 @@ namespace Satellite_Impl ::CORBA::SystemException, ::Components::InvalidConnection)); + // Servant class for the uav_ready consumer. + class SATELLITE_SVNT_Export UAVReadyConsumer_uav_ready_Servant + : public virtual POA_BBN_UAV::UAVReadyConsumer, + public virtual PortableServer::RefCountServantBase + { + public: + UAVReadyConsumer_uav_ready_Servant ( + ::BBN_UAV::CCM_Satellite_ptr executor, + ::BBN_UAV::CCM_Satellite_Context_ptr c); + + virtual ~UAVReadyConsumer_uav_ready_Servant (void); + + virtual void + push_UAVReady ( + ::BBN_UAV::UAVReady *evt + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Inherited from ::Components::EventConsumerBase. + virtual void + push_event (::Components::EventBase *ev + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::BadEventType)); + + // Get component implementation. + virtual CORBA::Object_ptr + _get_component ( + ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + protected: + ::BBN_UAV::CCM_Satellite_var + executor_; + + ::BBN_UAV::CCM_Satellite_Context_var + ctx_; + }; + + virtual ::BBN_UAV::UAVReadyConsumer_ptr + get_consumer_uav_ready ( + ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Servant class for the ucav_ready consumer. + class SATELLITE_SVNT_Export UCAVReadyConsumer_ucav_ready_Servant + : public virtual POA_BBN_UAV::UCAVReadyConsumer, + public virtual PortableServer::RefCountServantBase + { + public: + UCAVReadyConsumer_ucav_ready_Servant ( + ::BBN_UAV::CCM_Satellite_ptr executor, + ::BBN_UAV::CCM_Satellite_Context_ptr c); + + virtual ~UCAVReadyConsumer_ucav_ready_Servant (void); + + virtual void + push_UCAVReady ( + ::BBN_UAV::UCAVReady *evt + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Inherited from ::Components::EventConsumerBase. + virtual void + push_event (::Components::EventBase *ev + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::BadEventType)); + + // Get component implementation. + virtual CORBA::Object_ptr + _get_component ( + ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + protected: + ::BBN_UAV::CCM_Satellite_var + executor_; + + ::BBN_UAV::CCM_Satellite_Context_var + ctx_; + }; + + virtual ::BBN_UAV::UCAVReadyConsumer_ptr + get_consumer_ucav_ready ( + ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Servant class for the battle_ready consumer. + class SATELLITE_SVNT_Export BattleReadyConsumer_battle_ready_Servant + : public virtual POA_BBN_UAV::BattleReadyConsumer, + public virtual PortableServer::RefCountServantBase + { + public: + BattleReadyConsumer_battle_ready_Servant ( + ::BBN_UAV::CCM_Satellite_ptr executor, + ::BBN_UAV::CCM_Satellite_Context_ptr c); + + virtual ~BattleReadyConsumer_battle_ready_Servant (void); + + virtual void + push_BattleReady ( + ::BBN_UAV::BattleReady *evt + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Inherited from ::Components::EventConsumerBase. + virtual void + push_event (::Components::EventBase *ev + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::BadEventType)); + + // Get component implementation. + virtual CORBA::Object_ptr + _get_component ( + ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + protected: + ::BBN_UAV::CCM_Satellite_var + executor_; + + ::BBN_UAV::CCM_Satellite_Context_var + ctx_; + }; + + virtual ::BBN_UAV::BattleReadyConsumer_ptr + get_consumer_battle_ready ( + ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + // Component attribute operations. // Operations for Navigation interface. @@ -439,6 +574,12 @@ namespace Satellite_Impl ::CIAO::Session_Container * container_; + ::BBN_UAV::UAVReadyConsumer_var + consumes_uav_ready_; + ::BBN_UAV::UCAVReadyConsumer_var + consumes_ucav_ready_; + ::BBN_UAV::BattleReadyConsumer_var + consumes_battle_ready_; ACE_CString component_UUID_; }; diff --git a/TAO/CIAO/examples/UAV/Satellite/controller.cpp b/TAO/CIAO/examples/UAV/Satellite/controller.cpp index 87a18d940a4..e6ba5c27f82 100644 --- a/TAO/CIAO/examples/UAV/Satellite/controller.cpp +++ b/TAO/CIAO/examples/UAV/Satellite/controller.cpp @@ -70,8 +70,11 @@ main (int argc, char *argv[]) ACE_DEBUG ((LM_DEBUG, "Send a satellite alert\n")); - sat->alert (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + for (int i = 0; i < 1001; ++i) + { + sat->alert (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; diff --git a/TAO/CIAO/examples/UAV/UAV/UAV.idl b/TAO/CIAO/examples/UAV/UAV/UAV.idl index 7abcefa9468..48406f51fe2 100644 --- a/TAO/CIAO/examples/UAV/UAV/UAV.idl +++ b/TAO/CIAO/examples/UAV/UAV/UAV.idl @@ -18,6 +18,7 @@ module BBN_UAV { component UAV { + publishes UAVReady uav_ready; consumes StartCapture start_capture; }; diff --git a/TAO/CIAO/examples/UAV/UAV/UAV_exec.cpp b/TAO/CIAO/examples/UAV/UAV/UAV_exec.cpp index 0445ee9f073..0eb2703a5fb 100644 --- a/TAO/CIAO/examples/UAV/UAV/UAV_exec.cpp +++ b/TAO/CIAO/examples/UAV/UAV/UAV_exec.cpp @@ -22,9 +22,14 @@ MyImpl::UAV_exec_i::push_start_capture (BBN_UAV::StartCapture *ev ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { + // Notify others + BBN_UAV::UAVReady_var event = new OBV_BBN_UAV::UAVReady; - ACE_DEBUG ((LM_DEBUG, - "UAV, received a StartCapture from UAV_GS \n")); + //ACE_DEBUG ((LM_DEBUG, + // "UAV, received a StartCapture from UAV_GS \n")); + + this->context_->push_uav_ready (event + ACE_ENV_ARG_PARAMETER); } // Operations from Components::SessionComponent diff --git a/TAO/CIAO/examples/UAV/UAV/UAV_svnt.cpp b/TAO/CIAO/examples/UAV/UAV/UAV_svnt.cpp index 50c8ae261c0..ac04263ff1e 100644 --- a/TAO/CIAO/examples/UAV/UAV/UAV_svnt.cpp +++ b/TAO/CIAO/examples/UAV/UAV/UAV_svnt.cpp @@ -138,6 +138,103 @@ namespace UAV_Impl // Operations for UAV receptacles and event sources, // defined in ::BBN_UAV::CCM_UAV_Context. + void + UAV_Context::push_uav_ready ( + ::BBN_UAV::UAVReady *ev + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + + ACE_CString my_uuid = this->servant_->component_UUID (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + my_uuid += "_uav_ready_publisher"; + + this->container_->push_event (ev, + my_uuid.c_str () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + /* + ACE_Active_Map_Manager< + ::BBN_UAV::TargetLocatedConsumer_var>::iterator end = + this->ciao_publishes_target_located_map_.end (); + + for (ACE_Active_Map_Manager< + ::BBN_UAV::TargetLocatedConsumer_var>::iterator iter = + this->ciao_publishes_target_located_map_.begin (); + iter != end; + ++iter) + { + ACE_Active_Map_Manager< + ::BBN_UAV::TargetLocatedConsumer_var>::ENTRY &entry = *iter; + + ::BBN_UAV::TargetLocatedConsumer_var c = + ::BBN_UAV::TargetLocatedConsumer::_narrow ( + entry.int_id_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + entry.int_id_->push_TargetLocated ( + ev + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + */ + } + + ::Components::Cookie * + UAV_Context::subscribe_uav_ready ( + ::BBN_UAV::UAVReadyConsumer_ptr c + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::ExceededConnectionLimit)) + { + if (CORBA::is_nil (c)) + { + ACE_THROW_RETURN (CORBA::BAD_PARAM (), 0); + } + + ::BBN_UAV::UAVReadyConsumer_var sub = + ::BBN_UAV::UAVReadyConsumer::_duplicate (c); + + ACE_Active_Map_Manager_Key key; + this->ciao_publishes_uav_ready_map_.bind (sub.in (), key); + sub._retn (); + + ::Components::Cookie_var retv = new ::CIAO::Map_Key_Cookie (key); + return retv._retn (); + } + + ::BBN_UAV::UAVReadyConsumer_ptr + UAV_Context::unsubscribe_uav_ready ( + ::Components::Cookie *ck + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::InvalidConnection)) + { + ::BBN_UAV::UAVReadyConsumer_var retv; + ACE_Active_Map_Manager_Key key; + + if (ck == 0 || ::CIAO::Map_Key_Cookie::extract (ck, key) == -1) + { + ACE_THROW_RETURN ( + ::Components::InvalidConnection (), + ::BBN_UAV::UAVReadyConsumer::_nil ()); + } + + + if (this->ciao_publishes_uav_ready_map_.unbind (key, retv) != 0) + { + ACE_THROW_RETURN ( + ::Components::InvalidConnection (), + ::BBN_UAV::UAVReadyConsumer::_nil ()); + } + + return retv._retn (); + } + // CIAO-specific. ::CIAO::Session_Container * @@ -294,6 +391,32 @@ namespace UAV_Impl ACE_THROW_RETURN (::CORBA::NO_IMPLEMENT (), 0); } + ::Components::Cookie * + UAV_Servant::subscribe_uav_ready ( + ::BBN_UAV::UAVReadyConsumer_ptr c + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::ExceededConnectionLimit)) + { + return this->context_->subscribe_uav_ready ( + c + ACE_ENV_ARG_PARAMETER); + } + + ::BBN_UAV::UAVReadyConsumer_ptr + UAV_Servant::unsubscribe_uav_ready ( + ::Components::Cookie *ck + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::InvalidConnection)) + { + return this->context_->unsubscribe_uav_ready ( + ck + ACE_ENV_ARG_PARAMETER); + } + UAV_Servant::StartCaptureConsumer_start_capture_Servant::StartCaptureConsumer_start_capture_Servant ( ::BBN_UAV::CCM_UAV_ptr executor, ::BBN_UAV::CCM_UAV_Context_ptr c) @@ -546,6 +669,24 @@ namespace UAV_Impl ACE_THROW_RETURN (::Components::InvalidName (), 0); } + if (ACE_OS::strcmp (publisher_name, "uav_ready") == 0) + { + ::BBN_UAV::UAVReadyConsumer_var _ciao_consumer = + ::BBN_UAV::UAVReadyConsumer::_narrow ( + subscribe + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (::CORBA::is_nil (_ciao_consumer.in ())) + { + ACE_THROW_RETURN (::Components::InvalidConnection (), 0); + } + + return this->subscribe_uav_ready ( + _ciao_consumer.in () + ACE_ENV_ARG_PARAMETER); + } + ACE_THROW_RETURN (::Components::InvalidName (), 0); } @@ -569,6 +710,13 @@ namespace UAV_Impl ::Components::EventConsumerBase::_nil ()); } + if (ACE_OS::strcmp (publisher_name, "uav_ready") == 0) + { + return this->unsubscribe_uav_ready ( + ck + ACE_ENV_ARG_PARAMETER); + } + ACE_THROW_RETURN ( ::Components::InvalidName (), ::Components::EventConsumerBase::_nil ()); diff --git a/TAO/CIAO/examples/UAV/UAV/UAV_svnt.h b/TAO/CIAO/examples/UAV/UAV/UAV_svnt.h index 3b08eb345b4..ff49c077dc8 100644 --- a/TAO/CIAO/examples/UAV/UAV/UAV_svnt.h +++ b/TAO/CIAO/examples/UAV/UAV/UAV_svnt.h @@ -106,6 +106,12 @@ namespace UAV_Impl // Operations for UAV receptacles and event sources, // defined in ::BBN_UAV::CCM_UAV_Context. + virtual void + push_uav_ready ( + ::BBN_UAV::UAVReady *ev + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + // CIAO-specific. ::CIAO::Session_Container * @@ -119,7 +125,27 @@ namespace UAV_Impl protected: // Methods that manage this component's connections and consumers. + virtual ::Components::Cookie * + subscribe_uav_ready ( + ::BBN_UAV::UAVReadyConsumer_ptr c + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::ExceededConnectionLimit)); + + virtual ::BBN_UAV::UAVReadyConsumer_ptr + unsubscribe_uav_ready ( + ::Components::Cookie *ck + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::InvalidConnection)); + protected: + ACE_Active_Map_Manager< + ::BBN_UAV::UAVReadyConsumer_var> + ciao_publishes_uav_ready_map_; + ::Components::CCMHome_var home_; ::CIAO::Session_Container *container_; @@ -148,6 +174,22 @@ namespace UAV_Impl // Public port operations. + virtual ::Components::Cookie * + subscribe_uav_ready ( + ::BBN_UAV::UAVReadyConsumer_ptr c + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::ExceededConnectionLimit)); + + virtual ::BBN_UAV::UAVReadyConsumer_ptr + unsubscribe_uav_ready ( + ::Components::Cookie *ck + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::InvalidConnection)); + // Servant class for the start_capture consumer. class UAV_SVNT_Export StartCaptureConsumer_start_capture_Servant : public virtual POA_BBN_UAV::StartCaptureConsumer, diff --git a/TAO/CIAO/examples/UAV/UCAV/UCAV.idl b/TAO/CIAO/examples/UAV/UCAV/UCAV.idl index fb04763402f..d036d896457 100644 --- a/TAO/CIAO/examples/UAV/UCAV/UCAV.idl +++ b/TAO/CIAO/examples/UAV/UCAV/UCAV.idl @@ -18,6 +18,7 @@ module BBN_UAV { component UCAV { + publishes UCAVReady ucav_ready; consumes StartMove start_move; }; diff --git a/TAO/CIAO/examples/UAV/UCAV/UCAV_exec.cpp b/TAO/CIAO/examples/UAV/UCAV/UCAV_exec.cpp index 19abdb3416c..6a1c28c76af 100644 --- a/TAO/CIAO/examples/UAV/UCAV/UCAV_exec.cpp +++ b/TAO/CIAO/examples/UAV/UCAV/UCAV_exec.cpp @@ -22,8 +22,14 @@ MyImpl::UCAV_exec_i::push_start_move (BBN_UAV::StartMove *ev ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { - ACE_DEBUG ((LM_DEBUG, - "UCAV, received a StartMove from UCAV_GS \n")); + // Notify others + BBN_UAV::UCAVReady_var event = new OBV_BBN_UAV::UCAVReady; + + //ACE_DEBUG ((LM_DEBUG, + // "UCAV, received a StartMove from UCAV_GS \n")); + + this->context_->push_ucav_ready (event + ACE_ENV_ARG_PARAMETER); } // Operations from Components::SessionComponent diff --git a/TAO/CIAO/examples/UAV/UCAV/UCAV_svnt.cpp b/TAO/CIAO/examples/UAV/UCAV/UCAV_svnt.cpp index c4cd9c79a76..c99cefa790f 100644 --- a/TAO/CIAO/examples/UAV/UCAV/UCAV_svnt.cpp +++ b/TAO/CIAO/examples/UAV/UCAV/UCAV_svnt.cpp @@ -138,6 +138,102 @@ namespace UCAV_Impl // Operations for UCAV receptacles and event sources, // defined in ::BBN_UAV::CCM_UCAV_Context. + void + UCAV_Context::push_ucav_ready ( + ::BBN_UAV::UCAVReady *ev + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + ACE_CString my_uuid = this->servant_->component_UUID (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + my_uuid += "_ucav_ready_publisher"; + + this->container_->push_event (ev, + my_uuid.c_str () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + /* + ACE_Active_Map_Manager< + ::BBN_UAV::TargetLocatedConsumer_var>::iterator end = + this->ciao_publishes_target_located_map_.end (); + + for (ACE_Active_Map_Manager< + ::BBN_UAV::TargetLocatedConsumer_var>::iterator iter = + this->ciao_publishes_target_located_map_.begin (); + iter != end; + ++iter) + { + ACE_Active_Map_Manager< + ::BBN_UAV::TargetLocatedConsumer_var>::ENTRY &entry = *iter; + + ::BBN_UAV::TargetLocatedConsumer_var c = + ::BBN_UAV::TargetLocatedConsumer::_narrow ( + entry.int_id_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + entry.int_id_->push_TargetLocated ( + ev + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + */ + } + + ::Components::Cookie * + UCAV_Context::subscribe_ucav_ready ( + ::BBN_UAV::UCAVReadyConsumer_ptr c + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::ExceededConnectionLimit)) + { + if (CORBA::is_nil (c)) + { + ACE_THROW_RETURN (CORBA::BAD_PARAM (), 0); + } + + ::BBN_UAV::UCAVReadyConsumer_var sub = + ::BBN_UAV::UCAVReadyConsumer::_duplicate (c); + + ACE_Active_Map_Manager_Key key; + this->ciao_publishes_ucav_ready_map_.bind (sub.in (), key); + sub._retn (); + + ::Components::Cookie_var retv = new ::CIAO::Map_Key_Cookie (key); + return retv._retn (); + } + + ::BBN_UAV::UCAVReadyConsumer_ptr + UCAV_Context::unsubscribe_ucav_ready ( + ::Components::Cookie *ck + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::InvalidConnection)) + { + ::BBN_UAV::UCAVReadyConsumer_var retv; + ACE_Active_Map_Manager_Key key; + + if (ck == 0 || ::CIAO::Map_Key_Cookie::extract (ck, key) == -1) + { + ACE_THROW_RETURN ( + ::Components::InvalidConnection (), + ::BBN_UAV::UCAVReadyConsumer::_nil ()); + } + + + if (this->ciao_publishes_ucav_ready_map_.unbind (key, retv) != 0) + { + ACE_THROW_RETURN ( + ::Components::InvalidConnection (), + ::BBN_UAV::UCAVReadyConsumer::_nil ()); + } + + return retv._retn (); + } + // CIAO-specific. ::CIAO::Session_Container * @@ -294,6 +390,32 @@ namespace UCAV_Impl ACE_THROW_RETURN (::CORBA::NO_IMPLEMENT (), 0); } + ::Components::Cookie * + UCAV_Servant::subscribe_ucav_ready ( + ::BBN_UAV::UCAVReadyConsumer_ptr c + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::ExceededConnectionLimit)) + { + return this->context_->subscribe_ucav_ready ( + c + ACE_ENV_ARG_PARAMETER); + } + + ::BBN_UAV::UCAVReadyConsumer_ptr + UCAV_Servant::unsubscribe_ucav_ready ( + ::Components::Cookie *ck + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::InvalidConnection)) + { + return this->context_->unsubscribe_ucav_ready ( + ck + ACE_ENV_ARG_PARAMETER); + } + UCAV_Servant::StartMoveConsumer_start_move_Servant::StartMoveConsumer_start_move_Servant ( ::BBN_UAV::CCM_UCAV_ptr executor, ::BBN_UAV::CCM_UCAV_Context_ptr c) @@ -546,6 +668,24 @@ namespace UCAV_Impl ACE_THROW_RETURN (::Components::InvalidName (), 0); } + if (ACE_OS::strcmp (publisher_name, "ucav_ready") == 0) + { + ::BBN_UAV::UCAVReadyConsumer_var _ciao_consumer = + ::BBN_UAV::UCAVReadyConsumer::_narrow ( + subscribe + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (::CORBA::is_nil (_ciao_consumer.in ())) + { + ACE_THROW_RETURN (::Components::InvalidConnection (), 0); + } + + return this->subscribe_ucav_ready ( + _ciao_consumer.in () + ACE_ENV_ARG_PARAMETER); + } + ACE_THROW_RETURN (::Components::InvalidName (), 0); } @@ -569,6 +709,13 @@ namespace UCAV_Impl ::Components::EventConsumerBase::_nil ()); } + if (ACE_OS::strcmp (publisher_name, "ucav_ready") == 0) + { + return this->unsubscribe_ucav_ready ( + ck + ACE_ENV_ARG_PARAMETER); + } + ACE_THROW_RETURN ( ::Components::InvalidName (), ::Components::EventConsumerBase::_nil ()); @@ -595,7 +742,6 @@ namespace UCAV_Impl // Operations for CCMObject interface. - void UCAV_Servant::component_UUID ( const char * new_component_UUID diff --git a/TAO/CIAO/examples/UAV/UCAV/UCAV_svnt.h b/TAO/CIAO/examples/UAV/UCAV/UCAV_svnt.h index de88f0cc4bd..f0f4215ea29 100644 --- a/TAO/CIAO/examples/UAV/UCAV/UCAV_svnt.h +++ b/TAO/CIAO/examples/UAV/UCAV/UCAV_svnt.h @@ -106,6 +106,12 @@ namespace UCAV_Impl // Operations for UCAV receptacles and event sources, // defined in ::BBN_UAV::CCM_UCAV_Context. + virtual void + push_ucav_ready ( + ::BBN_UAV::UCAVReady *ev + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + // CIAO-specific. ::CIAO::Session_Container * @@ -119,7 +125,27 @@ namespace UCAV_Impl protected: // Methods that manage this component's connections and consumers. + virtual ::Components::Cookie * + subscribe_ucav_ready ( + ::BBN_UAV::UCAVReadyConsumer_ptr c + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::ExceededConnectionLimit)); + + virtual ::BBN_UAV::UCAVReadyConsumer_ptr + unsubscribe_ucav_ready ( + ::Components::Cookie *ck + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::InvalidConnection)); + protected: + ACE_Active_Map_Manager< + ::BBN_UAV::UCAVReadyConsumer_var> + ciao_publishes_ucav_ready_map_; + ::Components::CCMHome_var home_; ::CIAO::Session_Container *container_; @@ -148,6 +174,22 @@ namespace UCAV_Impl // Public port operations. + virtual ::Components::Cookie * + subscribe_ucav_ready ( + ::BBN_UAV::UCAVReadyConsumer_ptr c + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::ExceededConnectionLimit)); + + virtual ::BBN_UAV::UCAVReadyConsumer_ptr + unsubscribe_ucav_ready ( + ::Components::Cookie *ck + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::InvalidConnection)); + // Servant class for the start_move consumer. class UCAV_SVNT_Export StartMoveConsumer_start_move_Servant : public virtual POA_BBN_UAV::StartMoveConsumer, diff --git a/TAO/CIAO/examples/UAV/UCAV_GS/UCAV_GS_exec.cpp b/TAO/CIAO/examples/UAV/UCAV_GS/UCAV_GS_exec.cpp index 62b58c42411..7edb1d8340f 100644 --- a/TAO/CIAO/examples/UAV/UCAV_GS/UCAV_GS_exec.cpp +++ b/TAO/CIAO/examples/UAV/UCAV_GS/UCAV_GS_exec.cpp @@ -25,8 +25,8 @@ MyImpl::UCAV_GS_exec_i::push_prepare_move (BBN_UAV::PrepareMove *ev // Notify others BBN_UAV::StartMove_var event = new OBV_BBN_UAV::StartMove; - ACE_DEBUG ((LM_DEBUG, - "UCAV_GS, received a PrepareMove from Engagement \n")); + //ACE_DEBUG ((LM_DEBUG, + // "UCAV_GS, received a PrepareMove from Engagement \n")); this->context_->push_start_move (event ACE_ENV_ARG_PARAMETER); diff --git a/TAO/CIAO/examples/UAV/descriptors/BBN_UAV.cad b/TAO/CIAO/examples/UAV/descriptors/BBN_UAV.cad index bcecdf98390..a1f87fedf00 100644 --- a/TAO/CIAO/examples/UAV/descriptors/BBN_UAV.cad +++ b/TAO/CIAO/examples/UAV/descriptors/BBN_UAV.cad @@ -234,7 +234,40 @@ <publishesidentifier>start_move</publishesidentifier> <componentinstantiationref idref="a_UCAV_GS"/> </publishesport> - </connectevent> + </connectevent> + + <connectevent> + <consumesport> + <consumesidentifier>uav_ready</consumesidentifier> + <componentinstantiationref idref="a_Satellite"/> + </consumesport> + <publishesport> + <publishesidentifier>uav_ready</publishesidentifier> + <componentinstantiationref idref="a_UAV"/> + </publishesport> + </connectevent> + + <connectevent> + <consumesport> + <consumesidentifier>ucav_ready</consumesidentifier> + <componentinstantiationref idref="a_Satellite"/> + </consumesport> + <publishesport> + <publishesidentifier>ucav_ready</publishesidentifier> + <componentinstantiationref idref="a_UCAV"/> + </publishesport> + </connectevent> + + <connectevent> + <consumesport> + <consumesidentifier>battle_ready</consumesidentifier> + <componentinstantiationref idref="a_Satellite"/> + </consumesport> + <publishesport> + <publishesidentifier>battle_ready</publishesidentifier> + <componentinstantiationref idref="a_Battle"/> + </publishesport> + </connectevent> </connections> |