diff options
author | thrall <thrall@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-12-06 19:27:45 +0000 |
---|---|---|
committer | thrall <thrall@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-12-06 19:27:45 +0000 |
commit | e414168da2d2b4d186f8731882543c7c206e1212 (patch) | |
tree | 70b6d31643066c4c046c7c6e236ce10f6bf704b5 | |
parent | d862015f23c3f1e081bbda8bfc64689d11918e07 (diff) | |
download | ATCD-e414168da2d2b4d186f8731882543c7c206e1212.tar.gz |
Generic commit
9 files changed, 119 insertions, 24 deletions
diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_ParseHandler.cpp b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_ParseHandler.cpp index d4042f1232e..03bad2155e6 100644 --- a/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_ParseHandler.cpp +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_ParseHandler.cpp @@ -641,7 +641,31 @@ Configurator_ParseHandler::parseRemoteEventChannel (RemoteEventChannel* vs, void } else { - ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid attributes for LocalEventChannel"))); + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid name attribute for LocalEventChannel"))); + } + val = alist->getValue(ACE_TEXT("connection")); + if (val != 0) + { + if (ACE_OS_String::strcmp(val,ACE_TEXT("Input")) == 0) + { + vs->conn = RemoteEventChannel::INPUT; + } + else if (ACE_OS_String::strcmp(val,ACE_TEXT("Output")) == 0) + { + vs->conn = RemoteEventChannel::OUTPUT; + } + else if (ACE_OS_String::strcmp(val,ACE_TEXT("TwoWay")) == 0) + { + vs->conn = RemoteEventChannel::TWOWAY; + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid connection attribute value for RemoteEventChannel"))); + } + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid connection attribute for RemoteEventChannel"))); } ECConfiguration *parent = dynamic_cast<ECConfiguration*> (this->scope_.top()); diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_SyntaxHandler.cpp b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_SyntaxHandler.cpp index beec9850e67..c4ee713cbb8 100644 --- a/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_SyntaxHandler.cpp +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_SyntaxHandler.cpp @@ -18,6 +18,37 @@ #include <stdlib.h> //for atol #include <sstream> //for istringstream +#include <pair.h> +#include <algorithm> //for_each, count_if + +struct OutputInserter +{ + typedef Gateway_Initializer::FileNameVector FileNameVector; + typedef Configurator_SyntaxHandler::ConnectionVector::value_type ECConnection; + typedef RemoteEventChannel::CONNECTION ConnType; + + OutputInserter(FileNameVector& fnv) : fnvec(fnv) {} + + void operator() (ECConnection& conn) + { + ConnType t = conn.first; + if (t == RemoteEventChannel::OUTPUT + || t == RemoteEventChannel::TWOWAY) + { + fnvec.push_back(strdup(conn.second)); + } + } + +private: + FileNameVector& fnvec; +}; + +struct InputCounter +{ + typedef Configurator_SyntaxHandler::ConnectionVector::value_type Value; + bool operator() (Value& v) { return v.first == RemoteEventChannel::INPUT + || v.first == RemoteEventChannel::TWOWAY; } +}; Configurator_SyntaxHandler::Configurator_SyntaxHandler (void) : root(0) @@ -100,11 +131,11 @@ Configurator_SyntaxHandler::parseECConfiguration (ECConfiguration* vs, void* arg } //remoteecs - Gateway_Initializer::FileNameVector remote_ior_files; + ConnectionVector connections; RemoteECVector::iterator reciter = vs->remoteECs.begin(); for (; reciter != vs->remoteECs.end(); reciter++) { - (*reciter)->visit(this,&remote_ior_files); + (*reciter)->visit(this,&connections); } // Initialize gateways from local ECs to remote ECs @@ -114,11 +145,25 @@ Configurator_SyntaxHandler::parseECConfiguration (ECConfiguration* vs, void* arg KokyuECVector::value_type kokyuEC = *keciter; kokyuEC->setEventTypes(ev); //now it owns ev + // only want Gateway for Output and TwoWay remote ECs, but want + // to wait for Input and TwoWay ECs to connect + + Gateway_Initializer::FileNameVector output_ior_files; + // insert all Output and TwoWay EC IOR filenames into output_ior_files + std::for_each(connections.begin(),connections.end(), + OutputInserter(output_ior_files)); + // count the number of Input and TwoWay ECs + int numInputs = std::count_if(connections.begin(),connections.end(), + InputCounter()); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("num Output connections: %d, num Input connections: %d\n"),output_ior_files.size(),numInputs)); + Gateway_Initializer *ginit; ACE_NEW_RETURN(ginit, Gateway_Initializer(),-1); + // ginit takes ownership of strings copied by OutputInserter ginit->init(this->orb,this->poa,kokyuEC,this->driver, - kokyuEC->get_name(),remote_ior_files); + kokyuEC->get_name(),output_ior_files,numInputs); ACE_Time_Value gateway_delay(5,000000); long timer_id = this->driver->reactor()->schedule_timer(ginit,0,gateway_delay); if (timer_id < 0) @@ -130,6 +175,11 @@ Configurator_SyntaxHandler::parseECConfiguration (ECConfiguration* vs, void* arg this->ginitv.push_back(ginit); } + // delete name strings in connections + ConnectionVector::iterator citer = connections.begin(); + for (; citer != connections.end(); ++citer) + delete (*citer).second; + // DEBUG -- print name table NameTable::iterator ntiter = this->nametable.begin(); for (; ntiter != this->nametable.end(); ntiter++) @@ -272,6 +322,7 @@ Configurator_SyntaxHandler::parseLocalEventChannel (LocalEventChannel* vs, void* Kokyu_EC *local_ec; ACE_NEW_RETURN(local_ec, Kokyu_EC(),-1); + local_ec->set_name(vs->name.c_str()); //copied by local_ec if (local_ec->init(this->driver->get_time_master(), sched_type.c_str(), this->poa.in(), @@ -293,7 +344,7 @@ Configurator_SyntaxHandler::parseLocalEventChannel (LocalEventChannel* vs, void* if (ior_output_file == 0) { ACE_CString error("Unable to open "); - error += vs->name; + error += ior_output_filename; error += " for writing."; ACEXML_THROW (ACEXML_SAXException (error.c_str())); } @@ -302,7 +353,6 @@ Configurator_SyntaxHandler::parseLocalEventChannel (LocalEventChannel* vs, void* ACE_OS::fclose(ior_output_file); this->kokyuECs.push_back(local_ec); - this->localECs.push_back(localEC); // visit localEC children // suppliers go first because consumers might need them as dependants @@ -310,7 +360,6 @@ Configurator_SyntaxHandler::parseLocalEventChannel (LocalEventChannel* vs, void* SupplierVector::iterator siter = vs->suppliers.begin(); for (; siter != vs->suppliers.end(); siter++) { - //(*siter)->visit(this,localEC.in()); (*siter)->visit(this,local_ec); } @@ -318,7 +367,6 @@ Configurator_SyntaxHandler::parseLocalEventChannel (LocalEventChannel* vs, void* ConsumerVector::iterator citer = vs->consumers.begin(); for (; citer != vs->consumers.end(); citer++) { - //(*citer)->visit(this,localEC.in()); (*citer)->visit(this,local_ec); } @@ -335,10 +383,10 @@ Configurator_SyntaxHandler::parseRemoteEventChannel (RemoteEventChannel* vs, voi // get IOR filename ACE_CString iorfilename(vs->iorfile->str); - Gateway_Initializer::FileNameVector *remote_ior_filenames = - static_cast<Gateway_Initializer::FileNameVector*> (arg); - ACE_ASSERT(remote_ior_filenames); - remote_ior_filenames->push_back(iorfilename.rep()); //copies string + ConnectionVector *connections = + static_cast<ConnectionVector*> (arg); + ACE_ASSERT(connections); + connections->push_back(make_pair(vs->conn,iorfilename.rep())); //copies string /* TODO: for now, don't allow consumers and suppliers on remote EC // Set up remote EC RtEventChannelAdmin::RtSchedEventChannel_var remoteEC; @@ -502,9 +550,7 @@ Configurator_SyntaxHandler::parseSupplier (Supplier* vs, void* arg) if (!vs->publications) { - ACE_CString error("Supplier has missing child: "); - error += vs->publications ? "Triggers" : "Publications"; - ACEXML_THROW (ACEXML_SAXException (error.c_str())); + ACEXML_THROW (ACEXML_SAXException ("Supplier has missing Publications child")); } // visit Supplier children diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_SyntaxHandler.h b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_SyntaxHandler.h index 16ebe0652f6..530b1e6de43 100644 --- a/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_SyntaxHandler.h +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_SyntaxHandler.h @@ -24,6 +24,7 @@ #include "tao/PortableServer/PortableServer.h" #include <vector> +#include <pair.h> // Forward decls class ECDriver; @@ -128,9 +129,10 @@ public: typedef ACE_Hash_Map_Manager<ACE_CString,RtEventChannelAdmin::SchedInfo,ACE_Null_Mutex> QoSTable; - typedef std::vector<RtEventChannelAdmin::RtSchedEventChannel_var> ECVector; typedef std::vector<Kokyu_EC*> KokyuECVector; typedef std::vector<Gateway_Initializer*> GatewayInitVector; + typedef RemoteEventChannel::CONNECTION ConnectionType; + typedef std::vector<pair<ConnectionType,const char*> > ConnectionVector; typedef ACE_Hash_Map_Manager<ACE_CString,ECSupplier*,ACE_Null_Mutex> SupplierMap; typedef ACE_Hash_Map_Manager<ACE_CString,ECConsumer*,ACE_Null_Mutex> ConsumerMap; @@ -150,8 +152,6 @@ private: // EC stuff KokyuECVector kokyuECs; // for convenience - ECVector localECs; - ECVector remoteECs; GatewayInitVector ginitv; // Consumer/Supplier stuff diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECDriver.cpp b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECDriver.cpp index bbede997c69..98dc5c36d16 100644 --- a/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECDriver.cpp +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECDriver.cpp @@ -30,6 +30,7 @@ ECDriver::run (int argc, char *argv[]) } ECTestDriver::ECTestDriver (void) + : time_master(false) { } @@ -95,8 +96,10 @@ ECTestDriver::wait_for_start(Kokyu_EC* ec) if (this->time_master) { //set start time for all other ECs + // only support DELAYAFTERCONNECT, so no need to check type RtEventChannelAdmin::Time st; - ACE_Time_Value start_time(30,0); + ACE_Time_Value start_time; + ORBSVCS_Time::TimeT_to_Time_Value(start_time,this->starttime); 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 diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxTree.h b/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxTree.h index f1ac83ecf87..7f461b7e6be 100644 --- a/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxTree.h +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxTree.h @@ -349,6 +349,10 @@ public: SupplierVector suppliers; // Attributes + typedef enum { INPUT, + OUTPUT, + TWOWAY } CONNECTION; + CONNECTION conn; ACE_CString name; }; diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/chain_test/conssuppec.xml b/TAO/orbsvcs/examples/RtEC/ECConfigurator/chain_test/conssuppec.xml index de3aa68e807..f632234ddb3 100644 --- a/TAO/orbsvcs/examples/RtEC/ECConfigurator/chain_test/conssuppec.xml +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/chain_test/conssuppec.xml @@ -23,9 +23,12 @@ </Event> <!-- Configure the ECs --> -<RemoteEventChannel name="Client" > +<RemoteEventChannel name="Client" connection="Output"> <IORFile>Client.ior</IORFile> </RemoteEventChannel> +<RemoteEventChannel name="Server" connection="Input"> + <IORFile>Server.ior</IORFile> +</RemoteEventChannel> <LocalEventChannel name="Middle" > <SchedulingStrategy type="EDF" enableRG="true" /> @@ -47,7 +50,7 @@ <!-- Configure the driver --> <TestDriver> <StartCondition type="DelayAfterConnect" > - <Time>30000</Time> <!-- in msecs --> + <Time>10000</Time> <!-- in msecs --> </StartCondition> <StopCondition type="Duration" > <Value>340000</Value> <!-- duration in msecs --> diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/chain_test/consumerec.xml b/TAO/orbsvcs/examples/RtEC/ECConfigurator/chain_test/consumerec.xml index fae6c9161e5..26cff342ec4 100644 --- a/TAO/orbsvcs/examples/RtEC/ECConfigurator/chain_test/consumerec.xml +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/chain_test/consumerec.xml @@ -13,6 +13,15 @@ </Event> <!-- Configure the ECs --> +<RemoteEventChannel name="Middle" connection="Input"> + <IORFile>Middle.ior</IORFile> +</RemoteEventChannel> +<RemoteEventChannel name="Server" connection="Input"> +<!-- we don't actually receive from this EC, but it needs to be --> +<!-- connected so it can set our start time --> + <IORFile>Server.ior</IORFile> +</RemoteEventChannel> + <LocalEventChannel name="Client" > <SchedulingStrategy type="EDF" enableRG="true" /> <Consumer name="Subtask3 Executor" > @@ -26,7 +35,7 @@ <!-- there should only be one Driver --> <TestDriver> <StartCondition type="DelayAfterConnect"> - <Time>30000</Time> <!-- in msecs --> + <Time>10000</Time> <!-- in msecs --> </StartCondition> <StopCondition type="Duration" > <Value>340000</Value> <!-- duration in msecs --> diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/chain_test/supplierec.xml b/TAO/orbsvcs/examples/RtEC/ECConfigurator/chain_test/supplierec.xml index 98178c26d68..3dd48824442 100644 --- a/TAO/orbsvcs/examples/RtEC/ECConfigurator/chain_test/supplierec.xml +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/chain_test/supplierec.xml @@ -29,9 +29,14 @@ </Event> <!-- Configure the ECs --> -<RemoteEventChannel name="Middle" > +<RemoteEventChannel name="Middle" connection="Output"> <IORFile>Middle.ior</IORFile> </RemoteEventChannel> +<RemoteEventChannel name="Client" connection="Output"> +<!-- we don't actually push to this EC, but we need to be connected so --> +<!-- we can set its start time --> + <IORFile>Client.ior</IORFile> +</RemoteEventChannel> <LocalEventChannel name="Server" > <SchedulingStrategy type="EDF" enableRG="true" /> @@ -61,7 +66,7 @@ <!-- Configure the driver --> <TestDriver> <StartCondition type="DelayAfterConnect" master="yes" > - <Time>30000</Time> <!-- in msecs --> + <Time>10000</Time> <!-- in msecs --> </StartCondition> <StopCondition type="Duration" > <Value>340000</Value> <!-- duration in msecs --> diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/ecconfig.dtd b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ecconfig.dtd index 172b9187419..ee973cd6221 100644 --- a/TAO/orbsvcs/examples/RtEC/ECConfigurator/ecconfig.dtd +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ecconfig.dtd @@ -60,6 +60,7 @@ <!-- Consumer/Supplier on remote are local but subscribe/publish remotely --> <!ELEMENT RemoteEventChannel (IORFile, (Consumer,Supplier)*) > <!ATTLIST RemoteEventChannel name CDATA #REQUIRED > + <!ATTLIST RemoteEventChannel connection (Input|Output|TwoWay|StartTime) #REQUIRED > <!ELEMENT IORFile (#PCDATA) > |