diff options
Diffstat (limited to 'CIAO/examples/BasicSP/EC')
-rw-r--r-- | CIAO/examples/BasicSP/EC/EC.idl | 40 | ||||
-rw-r--r-- | CIAO/examples/BasicSP/EC/EC.mpc | 155 | ||||
-rw-r--r-- | CIAO/examples/BasicSP/EC/EC_exec.cpp | 294 | ||||
-rw-r--r-- | CIAO/examples/BasicSP/EC/EC_exec.h | 166 | ||||
-rw-r--r-- | CIAO/examples/BasicSP/EC/README | 11 | ||||
-rw-r--r-- | CIAO/examples/BasicSP/EC/client.cpp | 60 | ||||
-rw-r--r-- | CIAO/examples/BasicSP/EC/controller.cpp | 124 |
7 files changed, 0 insertions, 850 deletions
diff --git a/CIAO/examples/BasicSP/EC/EC.idl b/CIAO/examples/BasicSP/EC/EC.idl deleted file mode 100644 index 4833e4846e0..00000000000 --- a/CIAO/examples/BasicSP/EC/EC.idl +++ /dev/null @@ -1,40 +0,0 @@ -//============================================================================= -/** - * @file EC.idl - * - * Definition of events, and common interfaces used in the BasicSP module. - * - * @author Balachandran Natarajan <bala@dre.vanderbilt.edu> - */ -//============================================================================= - -#ifndef CIAO_EC_IDL -#define CIAO_EC_IDL - -#include "BasicSP.idl" - -module BasicSP -{ - interface trigger - { - void start (); - void stop (); - }; - - component EC supports trigger - { - publishes TimeOut timeout_value; - - /// The attribute can be configured via the home or the - /// component property file. - attribute long hertz; - }; - - home ECHome manages EC - { - // Explicit operations - factory new_EC (in long hertz); - }; -}; - -#endif /* CIAO_EC_IDL*/ diff --git a/CIAO/examples/BasicSP/EC/EC.mpc b/CIAO/examples/BasicSP/EC/EC.mpc deleted file mode 100644 index 0d5d31c196c..00000000000 --- a/CIAO/examples/BasicSP/EC/EC.mpc +++ /dev/null @@ -1,155 +0,0 @@ -project(EC_idl_gen): componentidldefaults, avoids_ccm_noevent { - custom_only = 1 - idlflags += -I.. \ - -Wb,stub_export_macro=EC_STUB_Export \ - -Wb,stub_export_include=EC_stub_export.h \ - -Wb,skel_export_macro=EC_SVNT_Export \ - -Wb,skel_export_include=EC_svnt_export.h \ - -Wb,exec_export_macro=EC_EXEC_Export \ - -Wb,exec_export_include=EC_exec_export.h - - IDL_Files { - EC.idl - } -} - -project(EC_lem_gen) : ciaoidldefaults , avoids_ccm_noevent{ - after += BasicSP_lem_gen EC_idl_gen - custom_only = 1 - - idlflags += -Wb,export_macro=EC_EXEC_Export \ - -Wb,export_include=EC_exec_export.h \ - -SS \ - -I.. - - IDL_Files { - ECE.idl - } -} - -project(EC_stub): ccm_stub, avoids_ccm_noevent { - after += BasicSP_stub EC_idl_gen - sharedname = EC_stub - includes += .. - libpaths += .. - libout = ../lib - libpaths += ../lib - - libs += BasicSP_stub - - dynamicflags += EC_STUB_BUILD_DLL - - IDL_Files { - } - - Header_Files { - ECC.h - EC_stub_export.h - } - - Source_Files { - ECC.cpp - } - - Inline_Files { - } -} - -project(EC_exec) : ciao_executor, avoids_ccm_noevent { - after += EC_stub EC_lem_gen - sharedname = EC_exec - libs += EC_stub BasicSP_stub - includes += .. - libout = ../lib - libpaths += ../lib - - dynamicflags += EC_EXEC_BUILD_DLL - - IDL_Files { - } - - Header_Files { - EC_exec.h - EC_exec_export.h - ECEC.h - } - - Source_Files { - EC_exec.cpp - ECEC.cpp - } - - Inline_Files { - } -} - -project(EC_svnt) : ciao_servant, avoids_ccm_noevent { - after += BasicSP_svnt EC_exec - includes += .. - - sharedname = EC_svnt - - libs += EC_stub EC_exec - libs += BasicSP_stub BasicSP_svnt - dynamicflags += EC_SVNT_BUILD_DLL - libout = ../lib - libpaths += ../lib - - IDL_Files { - } - - Header_Files { - ECS.h - EC_svnt.h - EC_svnt_export.h - } - - Source_Files { - ECS.cpp - EC_svnt.cpp - } -} - -project (EC_client) : ccm_stub , avoids_ccm_noevent{ - after += EC_stub - exename = client - libs += EC_stub BasicSP_stub - includes += .. - libout = ../lib - libpaths += ../lib - - IDL_Files { - } - - Header_Files { - } - - Source_Files { - client.cpp - } - - Inline_Files { - } -} - -project (EC_controller) : ccm_stub, avoids_ccm_noevent { - after += EC_stub - exename = controller - includes += .. - libs += EC_stub BasicSP_stub - libout = ../lib - libpaths += ../lib - - IDL_Files { - } - - Header_Files { - } - - Source_Files { - controller.cpp - } - - Inline_Files { - } -} diff --git a/CIAO/examples/BasicSP/EC/EC_exec.cpp b/CIAO/examples/BasicSP/EC/EC_exec.cpp deleted file mode 100644 index ebbe5a35700..00000000000 --- a/CIAO/examples/BasicSP/EC/EC_exec.cpp +++ /dev/null @@ -1,294 +0,0 @@ -#include "EC_exec.h" -#include "ace/Timer_Queue.h" -#include "ace/Reactor.h" - -//================================================================= - -MyImpl::timeout_Handler::timeout_Handler (MyImpl::EC_exec_i *cb) - : active_ (0), - done_ (0), - tid_ (0), - pulse_callback_ (cb) -{ - // Nothing - this->reactor (new ACE_Reactor); -} - -MyImpl::timeout_Handler::~timeout_Handler () -{ - delete this->reactor (); - this->reactor (0); -} - -int -MyImpl::timeout_Handler::open_h () -{ - return this->activate (); -} - -int -MyImpl::timeout_Handler::close_h () -{ - this->done_ = 1; - this->reactor ()->notify (); - - ACE_DEBUG ((LM_EMERGENCY, "Waiting\n")); - return this->wait (); -} - -int -MyImpl::timeout_Handler::start (CORBA::Long hertz) -{ - if (hertz == 0 || this->active_ != 0) // Not valid - return -1; - - long usec = 1000000 / hertz; - - this->tid_ = this->reactor ()->schedule_timer (this, - 0, - ACE_Time_Value (0, usec), - ACE_Time_Value (0, usec)); - - this->active_ = 1; - return 0; -} - -int -MyImpl::timeout_Handler::stop (void) -{ - if (this->active_ == 0) // Not valid. - return -1; - - this->reactor ()->cancel_timer (this); - - this->active_ = 0; - return 0; -} - -int -MyImpl::timeout_Handler::active (void) -{ - return this->active_; -} - -int -MyImpl::timeout_Handler::handle_close (ACE_HANDLE handle, - ACE_Reactor_Mask close_mask) -{ - ACE_DEBUG ((LM_EMERGENCY, - ACE_TEXT ("[%x] handle = %d, close_mask = %d\n"), - this, - handle, - close_mask)); - - return 0; -} - -int -MyImpl::timeout_Handler::handle_timeout (const ACE_Time_Value &, - const void *) -{ - this->pulse_callback_->pulse (); - - // ACE_DEBUG ((LM_EMERGENCY, - // ACE_TEXT ("[%x] with count #%05d timed out at %d.%d!\n"), - // this, - // tv.sec (), - // tv.usec ())); - - return 0; -} - -int -MyImpl::timeout_Handler::svc (void) -{ - this->reactor ()->owner (ACE_OS::thr_self ()); - - while (!this->done_) - this->reactor ()->handle_events (); - - return 0; -} - -//================================================================= - -MyImpl::EC_exec_i::EC_exec_i () - : hertz_ (0), - pulser_ (this) -{ - -} - -MyImpl::EC_exec_i::EC_exec_i (CORBA::Long hz) - : hertz_ (hz), - pulser_ (this) -{ -} - -MyImpl::EC_exec_i::~EC_exec_i () -{ -} - -CORBA::Long -MyImpl::EC_exec_i::hertz () -{ - return this->hertz_; -} - -void -MyImpl::EC_exec_i::hertz (CORBA::Long hertz) -{ - this->hertz_ = hertz; -} - -// Operations from supported interface(s) - -void -MyImpl::EC_exec_i::start () -{ - if (this->hertz_ == 0 || this->pulser_.active()) - throw CORBA::BAD_INV_ORDER (); - - // @@ Start the rate generator - this->pulser_.start (this->hertz_); -} - -void -MyImpl::EC_exec_i::stop () -{ - if (! this->pulser_.active ()) - throw CORBA::BAD_INV_ORDER (); - - // @@ stop the rate generator - this->pulser_.stop (); -} - -CORBA::Boolean -MyImpl::EC_exec_i::active () -{ - return this->pulser_.active (); -} - -// Operations from Components::SessionComponent - -void -MyImpl::EC_exec_i::set_session_context (Components::SessionContext_ptr ctx) -{ - ACE_DEBUG ((LM_EMERGENCY, "MyImpl::EC_exec_i::set_session_context\n")); - - this->context_ = - BasicSP::CCM_EC_Context::_narrow (ctx); - - if (CORBA::is_nil (this->context_.in ())) - throw CORBA::INTERNAL (); - // Urm, we actually discard exceptions thown from this operation. - -} - -void -MyImpl::EC_exec_i::configuration_complete () -{ -} - -void -MyImpl::EC_exec_i::ccm_activate () -{ - ACE_DEBUG ((LM_EMERGENCY, "MyImpl::EC_exec_i::ccm_activate\n")); - - this->pulser_.open_h (); -} - -void -MyImpl::EC_exec_i::ccm_passivate () -{ - ACE_DEBUG ((LM_EMERGENCY, "MyImpl::EC_exec_i::ccm_passivate\n")); - this->pulser_.close_h (); -} - -void -MyImpl::EC_exec_i::ccm_remove () -{ - ACE_DEBUG ((LM_EMERGENCY, "MyImpl::EC_exec_i::ccm_remove\n")); -} - -void -MyImpl::EC_exec_i::pulse (void) -{ - try - { - ACE_DEBUG ((LM_EMERGENCY, - ACE_TEXT ("Pushing BasicSP::TimeOut event!\n"))); - - BasicSP::TimeOut_var ev = new OBV_BasicSP::TimeOut (); - - this->context_->push_timeout_value (ev.in ()); - } - catch (const CORBA::Exception& ex) - { - ex._tao_print_exception ("Caught exception while pushing " - "BasicSP::TimeOut event to BMDevice"); - } -} - -extern "C" EC_EXEC_Export ::Components::EnterpriseComponent_ptr -create_BasicSP_EC_Impl (void) -{ - ::Components::EnterpriseComponent_ptr retval = - ::Components::EnterpriseComponent::_nil (); - - ACE_NEW_RETURN (retval, - MyImpl::EC_exec_i, - ::Components::EnterpriseComponent::_nil ()); - - return retval; -} - -MyImpl::ECHome_exec_i::ECHome_exec_i () -{ -} - -MyImpl::ECHome_exec_i::~ECHome_exec_i () -{ -} - -::Components::EnterpriseComponent_ptr -MyImpl::ECHome_exec_i::new_EC (CORBA::Long hertz) -{ - ::Components::EnterpriseComponent_ptr retval = - ::Components::EnterpriseComponent::_nil (); - - ACE_NEW_THROW_EX ( - retval, - MyImpl::EC_exec_i (hertz), - ::CORBA::NO_MEMORY ()); - - return retval; -} - -::Components::EnterpriseComponent_ptr -MyImpl::ECHome_exec_i::create () -{ - ::Components::EnterpriseComponent_ptr retval = - ::Components::EnterpriseComponent::_nil (); - - ACE_NEW_THROW_EX ( - retval, - MyImpl::EC_exec_i, - ::CORBA::NO_MEMORY ()); - - return retval; -} - -extern "C" EC_EXEC_Export ::Components::HomeExecutorBase_ptr -create_BasicSP_ECHome_Impl (void) -{ - ::Components::HomeExecutorBase_ptr retval = - ::Components::HomeExecutorBase::_nil (); - - ACE_NEW_RETURN ( - retval, - MyImpl::ECHome_exec_i, - ::Components::HomeExecutorBase::_nil ()); - - return retval; -} diff --git a/CIAO/examples/BasicSP/EC/EC_exec.h b/CIAO/examples/BasicSP/EC/EC_exec.h deleted file mode 100644 index ab675a14b49..00000000000 --- a/CIAO/examples/BasicSP/EC/EC_exec.h +++ /dev/null @@ -1,166 +0,0 @@ -//============================================================ -/** - * @file EC_exec.h - * - * Header file for the actualy EC and ECHome component - * implementation. - * - * @author Balachandran Natarajan <bala@dre.vanderbilt.edu> - */ -//============================================================ - -#ifndef EC_EXEC_H -#define EC_EXEC_H - -#include "ECEC.h" -#include "tao/LocalObject.h" -#include "ace/Thread_Manager.h" -#include "ace/Task.h" -#include "EC_exec_export.h" - -namespace MyImpl -{ - // Forward decl. - class EC_exec_i; - - /** - * @brief Active pulse generater - */ - class timeout_Handler : public ACE_Task_Base - { - public: - // Default constructor - timeout_Handler (EC_exec_i *cb); - ~timeout_Handler (); - - int open_h (void); - - int close_h (void); - - int start (CORBA::Long hertz); - - int stop (void); - - int active (void); - - // Handle the timeout. - virtual int handle_timeout (const ACE_Time_Value &tv, - const void *arg); - - // Called when <Time_Handler> is removed. - virtual int handle_close (ACE_HANDLE handle, - ACE_Reactor_Mask close_mask); - - virtual int svc (void); - - private: - /// Tracking whether we are actively generating pulse or not. - long active_; - - /// Flag to indicate completion of this active object. - int done_; - - /// The timer id we are waiting. - long tid_; - - EC_exec_i *pulse_callback_; - - ACE_Thread_Manager thr_mgr_; - }; - - extern "C" EC_EXEC_Export ::Components::EnterpriseComponent_ptr - create_BasicSP_EC_Impl (void); - - /** - * @class EC_exec_i - * - * EC executor implementation class. - */ - class EC_EXEC_Export EC_exec_i : - public virtual CIAO_BasicSP_EC_Impl::EC_Exec, - public virtual ::CORBA::LocalObject - { - public: - /// Default constructor. - EC_exec_i (); - - /// Initialize with a default frequency. - EC_exec_i (CORBA::Long hz); - - /// Default destructor. - ~EC_exec_i (); - - // Attribute operations. - - virtual CORBA::Long hertz (); - - virtual void hertz (CORBA::Long hertz); - - // Operations from supported interface(s) - - virtual void start (); - - virtual void stop (); - - virtual CORBA::Boolean active (); - - // Operations from Components::SessionComponent - - virtual void set_session_context (Components::SessionContext_ptr ctx); - - virtual void configuration_complete (); - - virtual void ccm_activate (); - - virtual void ccm_passivate (); - - virtual void ccm_remove (); - - /// Helper function to be called back by timeout_Handler - void pulse (void); - - protected: - /// Frequency - CORBA::Long hertz_; - - /// Copmponent specific context - BasicSP::CCM_EC_Context_var context_; - - /// An active object that actually trigger the generation of - /// periodic events. - timeout_Handler pulser_; - }; - - /** - * @class ECHome_exec_i - * - * EC home executor implementation class. - */ - class EC_EXEC_Export ECHome_exec_i : - public virtual ::CIAO_BasicSP_EC_Impl::ECHome_Exec, - public virtual ::CORBA::LocalObject - { - public: - /// Default ctor. - ECHome_exec_i (); - - /// Default dtor. - ~ECHome_exec_i (); - - // Explicit home operations. - - virtual ::Components::EnterpriseComponent_ptr - new_EC (CORBA::Long hertz); - - // Implicit home operations. - - virtual ::Components::EnterpriseComponent_ptr - create (); - }; - -} - -extern "C" EC_EXEC_Export ::Components::HomeExecutorBase_ptr -createECHome_Impl (void); - -#endif /* CIAO_ECGEN_EXEC_H */ diff --git a/CIAO/examples/BasicSP/EC/README b/CIAO/examples/BasicSP/EC/README deleted file mode 100644 index 0569a1b72da..00000000000 --- a/CIAO/examples/BasicSP/EC/README +++ /dev/null @@ -1,11 +0,0 @@ -/** - - - -@page EC README File - - The EC component. This shouldnt be needed if we had a way to -integrate EC sugly into CIAO. We dont at the time of writing this -example on May 12, 2003. Hence this holy hack! - -*/ diff --git a/CIAO/examples/BasicSP/EC/client.cpp b/CIAO/examples/BasicSP/EC/client.cpp deleted file mode 100644 index 141066cf457..00000000000 --- a/CIAO/examples/BasicSP/EC/client.cpp +++ /dev/null @@ -1,60 +0,0 @@ -//============================================================== -/** - * @file client.cpp - * - * This is a simple client test program that interact with the EC - * component implementation. This test uses the explicit factory - * operation in the home interface to create a EC component - * instance, run it for a while, and destroy the component instance. - */ -//============================================================== - -#include "ECC.h" -#include "ace/streams.h" -#include "ace/OS_NS_unistd.h" - -int -ACE_TMAIN (int argc, ACE_TCHAR *argv[]) -{ - try - { - // Initialize orb - CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); - - // Resolve HomeFinder interface - - CORBA::Object_var obj - = orb->string_to_object ("file://ec.ior"); - - BasicSP::ECHome_var home - = BasicSP::ECHome::_narrow (obj.in ()); - - if (CORBA::is_nil (home.in ())) - ACE_ERROR_RETURN ((LM_ERROR, "Unable to acquire ECHome objref\n"), -1); - - BasicSP::EC_var pulser - = home->create (); - - // Place to plug in the rate - pulser->hertz (5); - - pulser->start (); - - ACE_OS::sleep (45); - - pulser->stop (); - - home->remove_component (pulser.in ()); - - orb->destroy (); - } - catch (const CORBA::Exception& ex) - { - ex._tao_print_exception ("Who is the culprit\n"); - ACE_ERROR_RETURN ((LM_ERROR, - "Uncaught CORBA exception\n"), - 1); - } - - return 0; -} diff --git a/CIAO/examples/BasicSP/EC/controller.cpp b/CIAO/examples/BasicSP/EC/controller.cpp deleted file mode 100644 index 86a0fe2fe6c..00000000000 --- a/CIAO/examples/BasicSP/EC/controller.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/** - * @file controller.cpp - * - * This program interact with a EC component, and set the rate of the - * EC. - */ - -#include "ECC.h" -#include "ace/Get_Opt.h" -#include "ace/streams.h" - -const ACE_TCHAR *rategen_ior_ = ACE_TEXT("file://rategen.ior"); -int rate = 3; -int turn_on = 1; - -int -parse_args (int argc, ACE_TCHAR *argv[]) -{ - ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:r:of")); - int c; - - while ((c = get_opts ()) != -1) - { - switch (c) - { - case 'o': - turn_on = 1; - break; - - case 'f': - turn_on = 0; - break; - - case 'k': - rategen_ior_ = get_opts.opt_arg (); - break; - - case 'r': - rate = ACE_OS::atoi (get_opts.opt_arg ()); - break; - - case '?': // display help for use of the server. - default: - ACE_ERROR_RETURN ((LM_ERROR, - "usage: %s\n" - "-o (Turn on the rate generator)\n" - "-f (Turn off the rate generator)\n" - "-k <EC IOR> (default is file://rategen.ior)\n" - "-r <rate in hertz> (default is 3)\n" - "\n", - argv [0]), - -1); - break; - } - } - - if (rategen_ior_ == 0) - { - rategen_ior_ = ACE_TEXT("file://ec.ior"); - } - - if (rate == 0) - { - rate = 3; - } - - return 0; -} - -int -ACE_TMAIN (int argc, ACE_TCHAR *argv[]) -{ - try - { - // Initialize orb - CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); - - if (parse_args (argc, argv) != 0) - { - return -1; - } - - CORBA::Object_var obj = - orb->string_to_object (rategen_ior_); - - BasicSP::EC_var pulser - = BasicSP::EC::_narrow (obj.in ()); - - if (CORBA::is_nil (pulser.in ())) - { - ACE_ERROR_RETURN ((LM_ERROR, - "Unable to acquire 'EC' objref\n"), - -1); - } - - pulser->hertz (rate); - - if (turn_on) - { - pulser->hertz (rate); - - ACE_DEBUG ((LM_EMERGENCY, "Start up the Event services\n")); - - pulser->start (); - } - else - { - pulser->stop (); - - ACE_DEBUG ((LM_EMERGENCY, "Stop the ES\n")); - } - - orb->destroy (); - } - catch (const CORBA::Exception& ex) - { - ex._tao_print_exception ("Who is the culprit\n"); - ACE_ERROR_RETURN ((LM_ERROR, - "Uncaught CORBA exception\n"), - 1); - } - - return 0; -} |