From 78bb9e50660f118edbbf5b2050ef2666f4876b01 Mon Sep 17 00:00:00 2001 From: dengg Date: Tue, 10 Oct 2006 21:56:14 +0000 Subject: Checked in my recent changes and bug fixes for the RTEC and their filtering support, CIDL changes, and some IDL enhancements. --- .../CIAO_Events_Base/CIAO_EventServiceBase.h | 12 ++ ciaosvcs/Events/CIAO_Events_Base/CIAO_Events.idl | 7 +- ciaosvcs/Events/CIAO_RTEC/CIAO_RTEvent.cpp | 157 ++++++++++++--------- ciaosvcs/Events/CIAO_RTEC/CIAO_RTEvent.h | 18 ++- ciaosvcs/Events/CIAO_RTEC/CIAO_RTEvent.idl | 13 ++ 5 files changed, 137 insertions(+), 70 deletions(-) diff --git a/ciaosvcs/Events/CIAO_Events_Base/CIAO_EventServiceBase.h b/ciaosvcs/Events/CIAO_Events_Base/CIAO_EventServiceBase.h index 90b9f872ca6..57857bc6d43 100644 --- a/ciaosvcs/Events/CIAO_Events_Base/CIAO_EventServiceBase.h +++ b/ciaosvcs/Events/CIAO_Events_Base/CIAO_EventServiceBase.h @@ -107,6 +107,18 @@ namespace CIAO ACE_ENV_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC (( CORBA::SystemException)) = 0; + + /** + * Pushes event @c ev to all consumers. The source id of the + * supplier is specified through @c source_id. + */ + virtual void ciao_push_event ( + ::Components::EventBase * evt, + const char * source_id + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::BadEventType)) {}; }; class Event_Consumer_Config_Base : diff --git a/ciaosvcs/Events/CIAO_Events_Base/CIAO_Events.idl b/ciaosvcs/Events/CIAO_Events_Base/CIAO_Events.idl index bcfcca9ef93..20f540b69ed 100644 --- a/ciaosvcs/Events/CIAO_Events_Base/CIAO_Events.idl +++ b/ciaosvcs/Events/CIAO_Events_Base/CIAO_Events.idl @@ -34,9 +34,12 @@ module CIAO void destroy (); }; - interface Consumer_Config : Supplier_Config + interface Consumer_Config { attribute CONNECTION_ID consumer_id; + + readonly attribute EventServiceType service_type; + attribute Components::EventConsumerBase consumer; void start_conjunction_group (in long size); @@ -46,6 +49,8 @@ module CIAO void insert_source (in CONNECTION_ID source_id); void insert_type (in long event_type); + + void destroy (); }; interface CIAO_Event_Service : Components::EventConsumerBase diff --git a/ciaosvcs/Events/CIAO_RTEC/CIAO_RTEvent.cpp b/ciaosvcs/Events/CIAO_RTEC/CIAO_RTEvent.cpp index e85c8f0ee4f..e8099d54629 100644 --- a/ciaosvcs/Events/CIAO_RTEC/CIAO_RTEvent.cpp +++ b/ciaosvcs/Events/CIAO_RTEC/CIAO_RTEvent.cpp @@ -14,6 +14,8 @@ #include "CIAO_RTEvent.h" #include "ciao/CIAO_common.h" +#include + namespace CIAO { @@ -63,6 +65,8 @@ namespace CIAO } + // @@TODO: We might want to maintain a map for managing multiple proxy consumers + // to multiple event suppliers. void RTEventService::connect_event_supplier ( Supplier_Config_ptr supplier_config @@ -87,6 +91,7 @@ namespace CIAO ACE_Hash hasher; this->source_id_ = hasher (supplier_config->supplier_id (ACE_ENV_SINGLE_ARG_PARAMETER)); + ACE_CHECK; this->type_id_ = this->source_id_; @@ -168,17 +173,24 @@ namespace CIAO consumer_servant->_this (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; - //@@@ - rt_config->start_disjunction_group (1); - - rt_config->insert_type (ACE_ES_EVENT_ANY); - RtecEventChannelAdmin::ConsumerQOS_var qos = rt_config->rt_event_qos (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; + ACE_DEBUG ((LM_DEBUG, "\n======== ConsumerQoS length is: %d\n\n", + qos->dependencies.length ())); + + if (qos->dependencies.length () == 0) + { + qos->dependencies.length (1); + qos->dependencies[0].event.header.type = ACE_ES_DISJUNCTION_DESIGNATOR; + qos->dependencies[0].event.header.source = ACE_ES_EVENT_SOURCE_ANY; + qos->dependencies[0].rt_info = 0; + } + proxy_supplier->connect_push_consumer (push_consumer.in (), qos.in () + //qos_factory.get_ConsumerQOS () ACE_ENV_ARG_PARAMETER); ACE_CHECK; @@ -199,11 +211,16 @@ namespace CIAO { ACE_UNUSED_ARG (connection_id); - this->proxy_consumer_->disconnect_push_consumer ( - ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK; + /* @todo + if (! CORBA::is_nil (this->proxy_consumer_.in ())) + { + this->proxy_consumer_->disconnect_push_consumer ( + ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } // What to do with the consumers?! + */ } void @@ -245,6 +262,37 @@ namespace CIAO ACE_CHECK; } + void + RTEventService::ciao_push_event ( + Components::EventBase * ev, + const char * source_id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + Components::BadEventType)) + { + if (CIAO::debug_level () > 10) + { + ACE_DEBUG ((LM_DEBUG, "------CIAO::RTEventService::ciao_push_event------\n")); + } + RtecEventComm::EventSet events (1); + events.length (1); + + ACE_Hash hasher; + + events[0].header.source = hasher (source_id); + //events[0].header.source = i++; + + events[0].header.type = ACE_ES_EVENT_ANY; //this->type_id_; + events[0].data.any_value <<= ev; + + ACE_DEBUG ((LM_DEBUG, "******* push event for source string: %s\n", source_id)); + ACE_DEBUG ((LM_DEBUG, "******* push event for source id: %i\n", events[0].header.source)); + + this->proxy_consumer_->push (events ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + void RTEventService::create_rt_event_channel ( ACE_ENV_SINGLE_ARG_DECL) @@ -313,6 +361,13 @@ namespace CIAO for (size_t i = 0; i < events.length (); ++i) { + std::ostringstream out; + out << "Received event," + << " type: " << events[i].header.type + << " source: " << events[i].header.source; + + ACE_OS::printf("%s\n", out.str().c_str()); // printf is synchronized + Components::EventBase * ev = 0; if (events[i].data.any_value >>= ev) { @@ -366,22 +421,31 @@ namespace CIAO ACE_THROW_SPEC (( CORBA::SystemException)) { - if (CIAO::debug_level () > 11) + if (CIAO::debug_level () > 10) { ACE_DEBUG ((LM_DEBUG, "supplier's id: %s\n", supplier_id)); - } this->supplier_id_ = supplier_id; ACE_Hash hasher; + RtecEventComm::EventSourceID source_id = hasher (this->supplier_id_.c_str ()); - +/* this->qos_.insert (source_id, - source_id, + ACE_ES_EVENT_ANY, 0, 1); + +*/ + + this->qos_.insert (ACE_ES_EVENT_SOURCE_ANY, + ACE_ES_EVENT_ANY, + 0, // handle to the rt_info structure + 1); + + ACE_DEBUG ((LM_DEBUG, "supplier's source id is: %d\n", source_id)); } CONNECTION_ID @@ -448,6 +512,9 @@ namespace CIAO ACE_THROW_SPEC (( CORBA::SystemException)) { + ACE_DEBUG + ((LM_DEBUG, "RTEvent_Consumer_Config_impl::start_conjunction_group\n")); + this->qos_.start_conjunction_group (size); } @@ -458,7 +525,11 @@ namespace CIAO ACE_THROW_SPEC (( CORBA::SystemException)) { - this->qos_.start_disjunction_group (size); + // Note, since we only support basic builder here... + if (size == 0L) + this->qos_.start_disjunction_group (); + else + this->qos_.start_disjunction_group (size); } void @@ -468,13 +539,13 @@ namespace CIAO ACE_THROW_SPEC (( CORBA::SystemException)) { - ACE_Hash hasher; - RtecEventComm::EventSourceID int_source_id = - hasher (source_id); + RtecEventComm::EventSourceID int_source_id = hasher (source_id); - this->qos_.insert_source (int_source_id, - 0); + ACE_DEBUG ((LM_DEBUG, "******* the source string is: %s\n", source_id)); + ACE_DEBUG ((LM_DEBUG, "******* the source id is: %i\n", int_source_id)); + + this->qos_.insert_source (int_source_id, 0); } void @@ -483,8 +554,11 @@ namespace CIAO ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((::CORBA::SystemException)) { - this->qos_.insert_type (event_type, - 0); + if (event_type == 0L) + this->qos_.insert_type (ACE_ES_EVENT_ANY, 0); + else + this->qos_.insert_type (event_type, + 0); } void @@ -504,31 +578,6 @@ namespace CIAO this->consumer_id_ = consumer_id; } - void - RTEvent_Consumer_Config_impl::supplier_id ( - const char * supplier_id - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC (( - CORBA::SystemException)) - { - if (CIAO::debug_level () > 10) - { - ACE_DEBUG ((LM_DEBUG, - "RTEvent_Consumer_Config_impl::set_supplier_id:%s\n", - supplier_id)); - } - - this->supplier_id_ = supplier_id; - - ACE_Hash hasher; - RtecEventComm::EventSourceID source_id = - hasher (this->supplier_id_.c_str ()); - - this->qos_.start_disjunction_group (1); - this->qos_.insert (source_id, - source_id, - 0); - } void RTEvent_Consumer_Config_impl::consumer ( @@ -549,19 +598,6 @@ namespace CIAO return CORBA::string_dup (this->consumer_id_.c_str ()); } - CONNECTION_ID - RTEvent_Consumer_Config_impl::supplier_id ( - ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC (( - CORBA::SystemException)) - { - if (CIAO::debug_level () > 10) - { - ACE_DEBUG ((LM_DEBUG, "RTEvent_Consumer_Config_impl::get_supplier_id\n")); - } - - return CORBA::string_dup (this->supplier_id_.c_str ()); - } EventServiceType RTEvent_Consumer_Config_impl::service_type ( @@ -597,11 +633,6 @@ namespace CIAO RtecEventChannelAdmin::ConsumerQOS (this->qos_.get_ConsumerQOS ()), 0); - - // @@@ Hard coded - this->qos_.start_disjunction_group (1); - this->qos_.insert_type (ACE_ES_EVENT_ANY, 0); - return consumer_qos; } diff --git a/ciaosvcs/Events/CIAO_RTEC/CIAO_RTEvent.h b/ciaosvcs/Events/CIAO_RTEC/CIAO_RTEvent.h index 0ba65234b21..3d5ced528ba 100644 --- a/ciaosvcs/Events/CIAO_RTEC/CIAO_RTEvent.h +++ b/ciaosvcs/Events/CIAO_RTEC/CIAO_RTEvent.h @@ -94,6 +94,14 @@ namespace CIAO ACE_THROW_SPEC (( CORBA::SystemException)); + virtual void ciao_push_event ( + Components::EventBase * evt, + const char * source_id + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::BadEventType)); + private: // @@ (GD) This is the place where use could provide a parameter // which specifies the event channel service configuration file. @@ -244,11 +252,11 @@ namespace CIAO virtual CONNECTION_ID consumer_id (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)); - virtual void supplier_id (const char * supplier_id ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)); + //virtual void supplier_id (const char * supplier_id ACE_ENV_ARG_DECL) + // ACE_THROW_SPEC ((CORBA::SystemException)); - virtual CONNECTION_ID supplier_id (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)); + //virtual CONNECTION_ID supplier_id (ACE_ENV_SINGLE_ARG_DECL) + // ACE_THROW_SPEC ((CORBA::SystemException)); virtual void consumer (Components::EventConsumerBase_ptr consumer ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)); @@ -272,8 +280,6 @@ namespace CIAO ACE_CString consumer_id_; - ACE_CString supplier_id_; - Components::EventConsumerBase_var consumer_; EventServiceType service_type_; diff --git a/ciaosvcs/Events/CIAO_RTEC/CIAO_RTEvent.idl b/ciaosvcs/Events/CIAO_RTEC/CIAO_RTEvent.idl index b51d00ec07d..0ec9196006a 100644 --- a/ciaosvcs/Events/CIAO_RTEC/CIAO_RTEvent.idl +++ b/ciaosvcs/Events/CIAO_RTEC/CIAO_RTEvent.idl @@ -35,4 +35,17 @@ module CIAO readonly attribute RtecEventChannelAdmin::SupplierQOS rt_event_qos; }; + interface CIAO_RT_Evnet_Service : + CIAO_Event_Service + { + void create_addr_server (in ); + + void create_sender (); + void create_receiver (); + void create_event_handler (); + + void connect_sender (); + void connect_receiver(); + }; + }; -- cgit v1.2.1