diff options
author | thrall <thrall@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-09-06 22:31:31 +0000 |
---|---|---|
committer | thrall <thrall@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-09-06 22:31:31 +0000 |
commit | 96ee65e6d7b5b918c10fb956797cc1b7941ed867 (patch) | |
tree | 35e8ccbba81fccdbfcf0722a119326449d9fbf33 | |
parent | b8be47ca5b763b3253ca9a0a55b45bc088f17b85 (diff) | |
download | ATCD-96ee65e6d7b5b918c10fb956797cc1b7941ed867.tar.gz |
Implemented ECDriver and ECTestDriver, adding necessary functions
-rw-r--r-- | TAO/orbsvcs/examples/RtEC/ECConfigurator/ECDriver.cpp | 102 | ||||
-rw-r--r-- | TAO/orbsvcs/examples/RtEC/ECConfigurator/ECDriver.h | 44 |
2 files changed, 146 insertions, 0 deletions
diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECDriver.cpp b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECDriver.cpp index d3a60da1b23..668ed0afaca 100644 --- a/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECDriver.cpp +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECDriver.cpp @@ -1,6 +1,10 @@ // $Id$ #include "ECDriver.h" +#include "Kokyu_EC.h" + +#include "ace/Thread.h" +#include "orbsvcs/Time_Utilities.h" ECDriver::ECDriver (void) { @@ -10,6 +14,21 @@ ECDriver::~ECDriver (void) { } +int +ECDriver::init(CORBA::ORB_var orb, PortableServer::POA_var poa) +{ + this->orb = orb; + this->poa = poa; + + return 0; +} + +void +ECDriver::run (int argc, char *argv[]) +{ + this->run_i(argc,argv); +} + ECTestDriver::ECTestDriver (void) { } @@ -29,3 +48,86 @@ ECTestDriver::set_time_master (bool tm) { this->time_master = tm; } + +void +ECTestDriver::set_start_condition(StartCondition::TYPE type, Time time) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + if (type != StartCondition::GLOBALTIME) + { + ACEXML_THROW (ACEXML_SAXException ("ECTestDriver does not support" + " start condition types other than" + "GLOBALTIME")); + } + + this->starttype = type; + this->starttime = time; +} + +void +ECTestDriver::set_stop_condition(StopCondition::TYPE type, long limit) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + if (type == StopCondition::EVENTNUMBER) + { + ACEXML_THROW (ACEXML_SAXException ("ECTestDriver does not support" + " stop condition type EVENTNUMBER")); + } + + this->stoptype = type; + this->stoplimit = limit; +} + +void +ECTestDriver::wait_for_start(Kokyu_EC* ec) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + if (this->time_master) + { + //set start time for all other ECs + RtEventChannelAdmin::Time st; + ACE_Time_Value start_time(30,0); + start_time += ACE_OS::gettimeofday(); //now + 30 sec + ORBSVCS_Time::Time_Value_to_TimeT(st,start_time); + ec->set_start_time(st); //set start time for this EC + Kokyu_EC::ECVector* remote_ecs(ec->remote_ecs()); + for(size_t i=0; i< remote_ecs->size(); ++i) //set start time for remote ECs + { + (*remote_ecs)[i]->set_start_time(st); + ACE_TRY_CHECK; + } + } + + //now wait for start time + ACE_Time_Value sleeptime(0,5); //we'll be within 5usec of start time when we call ec_->start() + ACE_Time_Value now(ACE_OS::gettimeofday()); + ACE_OS::printf("Gateway_Initializer: waiting for start time to be set or to pass; now is %ldsec %ldusec, start time is %ldsec %ldusec\n",now.sec(),now.usec(),ec->start_time().sec(),ec->start_time().usec()); + while (ec->start_time() == ACE_Time_Value::zero + || now < ec->start_time()) + { + //while not time to start + //ACE_DEBUG((LM_DEBUG,"Gateway_Initializer (%P|%t): waiting for start time to be set or to pass; now is %isec %iusec, start time is %isec %iusec\n",now.sec(),now.usec(),ec->start_time().sec(),ec->start_time().usec())); + ACE_OS::sleep(sleeptime); + now = ACE_OS::gettimeofday(); + } +} + +void +ECTestDriver::run_i (int argc, char *argv[]) +{ + //spawn thread to run the reactor event loop + Reactor_Task rt; + rt.initialize(); + + ACE_hthread_t thr_handle; + ACE_Thread::self (thr_handle); + + int prio = ACE_Sched_Params::priority_max (ACE_SCHED_FIFO); + ACE_OS::thr_setprio (thr_handle, prio); + + // for DURATION, limit is in msecs + ACE_Time_Value stop_time(this->stoplimit/1000,this->stoplimit%1000); + + rt.activate(); //need thread creation flags? or priority? + orb->run (stop_time ACE_ENV_ARG_PARAMETER); +} //run_i() diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECDriver.h b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECDriver.h index 18b0cb3818a..8c80f09bf65 100644 --- a/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECDriver.h +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECDriver.h @@ -14,15 +14,44 @@ #ifndef ECDRIVER_H #define ECDRIVER_H +#include "RtSchedEventChannelC.h" +#include "SyntaxTree.h" + +#include "tao/ORB.h" +#include "tao/PortableServer/PortableServer.h" + +class Kokyu_EC; //forward decl + class ECDriver { public: + typedef RtEventChannelAdmin::Time Time; + ECDriver (void); virtual ~ECDriver (void); + virtual int init(CORBA::ORB_var orb, PortableServer::POA_var poa); + + virtual void wait_for_start(Kokyu_EC* ec) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + + void run(int argc = 0, char *argv[] = 0); + virtual bool get_time_master (void) const = 0; virtual void set_time_master (bool tm) = 0; + + virtual void set_start_condition(StartCondition::TYPE type, Time starttime) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + virtual void set_stop_condition(StopCondition::TYPE type, long limit) + ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; + +protected: + virtual void run_i(int argc, char *argv[]) = 0; + + CORBA::ORB_var orb; + PortableServer::POA_var poa; + PortableServer::POAManager_var poa_manager; }; class ECTestDriver : public ECDriver @@ -35,8 +64,23 @@ public: virtual bool get_time_master (void) const; virtual void set_time_master (bool tm); + virtual void set_start_condition(StartCondition::TYPE type, Time time) + ACE_THROW_SPEC ((ACEXML_SAXException)); + virtual void set_stop_condition(StopCondition::TYPE type, long limit) + ACE_THROW_SPEC ((ACEXML_SAXException)); + + virtual void wait_for_start(Kokyu_EC* ec) + ACE_THROW_SPEC ((ACEXML_SAXException)); + protected: + virtual void run_i(int argc, char *argv[]); + bool time_master; + + StartCondition::TYPE starttype; + Time starttime; + StopCondition::TYPE stoptype; + long stoplimit; }; #endif // ECDRIVER_H |