diff options
author | thrall <thrall@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-08-08 00:25:13 +0000 |
---|---|---|
committer | thrall <thrall@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-08-08 00:25:13 +0000 |
commit | 6cc57489186fddc6da167c1f9ca0763d2b8d0172 (patch) | |
tree | 5b4722dc4298f61d67a7cad0c99d7c8992cb1c1f | |
parent | 989f6e40c672d7ae7ec994b72cf616abbf1924b3 (diff) | |
download | ATCD-6cc57489186fddc6da167c1f9ca0763d2b8d0172.tar.gz |
Implemented abstract syntax parsing, though undebugged. Still need to hook in Kokyu_EC properly and implement ECTestDriver
17 files changed, 1374 insertions, 152 deletions
diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/ConfigurableEC.cpp b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ConfigurableEC.cpp index 59a6f9faf14..07611a250dc 100644 --- a/TAO/orbsvcs/examples/RtEC/ECConfigurator/ConfigurableEC.cpp +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ConfigurableEC.cpp @@ -7,6 +7,7 @@ #include "ACEXML/common/DefaultHandler.h" #include "Configurator_ParseHandler.h" +#include "Configurator_SyntaxHandler.h" struct Arguments { @@ -31,7 +32,24 @@ main (int argc, char *argv[]) { return 1; } - + /* + // ORB initialization boiler plate... + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Object_var object = + orb->resolve_initial_references ("RootPOA" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + PortableServer::POA_var poa = + PortableServer::POA::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + PortableServer::POAManager_var poa_manager = + poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + */ ACEXML_FileCharStream *fcs = new ACEXML_FileCharStream(); if ((retval = fcs->open(args.filename_.c_str())) != 0) { //ACE_DEBUG ((LM_DEBUG, "Could not open file %s\n",args.filename_.c_str())); @@ -58,6 +76,13 @@ main (int argc, char *argv[]) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Finished parsing\n"))); + Configurator_SyntaxHandler cfgtor; + //cfgtor.init(orb,poa); + cfgtor.setRootNode(xmlhandler.getRootNode()); + cfgtor.setNameTable(xmlhandler.getNameTable()); + cfgtor.parse(); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Finished configuring\n"))); } ACEXML_CATCH (ACEXML_SAXException, ex) { diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_ParseHandler.cpp b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_ParseHandler.cpp index e869619e065..623c81b2bca 100644 --- a/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_ParseHandler.cpp +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_ParseHandler.cpp @@ -10,30 +10,32 @@ #include "RtecSchedulerC.h" #include <stdlib.h> //for atol -#include <sstream> //for istringstream +#include <sstream> //for ostringstream Configurator_ParseHandler::Configurator_ParseHandler (const char *filename) : fileName_(filename) , ecconfiguration(0) { + this->nametable.open(); } Configurator_ParseHandler::~Configurator_ParseHandler (void) { + this->nametable.close(); } void Configurator_ParseHandler::characters (const ACEXML_Char * cdata, - int , + int, int ACEXML_ENV_ARG_DECL_NOT_USED) ACE_THROW_SPEC ((ACEXML_SAXException)) { - //ACE_UNUSED_ARG(cdata); + //ACE_DEBUG ((LM_DEBUG,ACE_TEXT("* characters (%s) ***************\n"),cdata)); if (!this->scope_.empty()) { - std::istringstream iss(cdata); + std::string cdatastr(cdata); switch (this->scope_.top()->getSyntaxType()) { @@ -46,18 +48,28 @@ Configurator_ParseHandler::characters (const ACEXML_Char * cdata, case VisitableSyntax::PHASE: case VisitableSyntax::TIME: case VisitableSyntax::VALUE: - intsyn = dynamic_cast<IntegerSyntax*>(this->scope_.top()); - if ((iss >> intsyn->val) == 0) - { - ACEXML_THROW(ACEXML_SAXException(ACE_TEXT ("Invalid number format"))); - } + { + intsyn = dynamic_cast<IntegerSyntax*>(this->scope_.top()); + ACE_ASSERT(intsyn); + std::istringstream iss(cdatastr); + if ((iss >> intsyn->val) == 0) + { + ACEXML_THROW(ACEXML_SAXException(ACE_TEXT ("Invalid number format"))); + } + } break; case VisitableSyntax::EVENTNAME: case VisitableSyntax::SUPPLIERNAME: case VisitableSyntax::TIMEOUTNAME: case VisitableSyntax::IORFILE: strsyn = dynamic_cast<StringSyntax*>(this->scope_.top()); - strsyn->str.set(iss.str().c_str()); + ACE_ASSERT(strsyn); + strsyn->str.set(cdatastr.c_str()); + { + char dbgbuf[MAXTYPESTRINGLEN]; + visitableTypeToString(this->scope_.top()->getSyntaxType(),dbgbuf,MAXTYPESTRINGLEN); + ACE_DEBUG((LM_DEBUG,"Set string of %s to %s: %s\n",dbgbuf,cdatastr.c_str(),strsyn->str.c_str())); + } break; case VisitableSyntax::ECCONFIGURATION: case VisitableSyntax::EVENT: @@ -86,47 +98,15 @@ Configurator_ParseHandler::characters (const ACEXML_Char * cdata, { ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Character data outside of any scope"))); } + + //ACE_DEBUG ((LM_DEBUG,ACE_TEXT("* characters DONE ***************\n"),cdata)); } void Configurator_ParseHandler::endDocument (ACEXML_ENV_SINGLE_ARG_DECL_NOT_USED) ACE_THROW_SPEC ((ACEXML_SAXException)) { - /* - // Print out test_config_t's: - const TestConfig::Test_Config_Set &cfgs = *this->configs_; - char *cfg_format = "{%10d, %10d, %10d, %10d, %10d }"; - - for (size_t i=0; i<cfgs.size(); ++i) { - TestConfig::test_config_t *cfg = cfgs[i]; - - if (i!=0) - { - //finish previous line - ACE_DEBUG ((LM_DEBUG, "\n")); - } - if (cfg->comptype == TestConfig::SOURCE) - { - ACE_DEBUG ((LM_DEBUG, "SOURCE : ")); - } - else if (cfg->comptype == TestConfig::SINK) - { - ACE_DEBUG ((LM_DEBUG, "SINK : ")); - } - else - { - ACE_DEBUG ((LM_DEBUG, "UNKNOWN: ")); - } - ACE_DEBUG ((LM_DEBUG, cfg_format, - cfg->type, - cfg->period, - cfg->criticality, - cfg->importance, - cfg->num_entities)); - } - //finish last line - ACE_DEBUG ((LM_DEBUG, "\n")); - */ + // NO-OP } void @@ -136,17 +116,15 @@ Configurator_ParseHandler::endElement (const ACEXML_Char *namespaceURI, ACEXML_ENV_ARG_DECL_NOT_USED) ACE_THROW_SPEC ((ACEXML_SAXException)) { - /* - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("* Event endElement (%s, %s, %s) ***************\n"), - namespaceURI, localName, qName)); - */ + + //ACE_DEBUG ((LM_DEBUG,ACE_TEXT ("* endElement (%s, %s, %s) ***************\n"),namespaceURI, localName, qName)); + ACE_UNUSED_ARG(namespaceURI); ACE_UNUSED_ARG(localName); ACE_UNUSED_ARG(qName); - if (this->scope_.empty() == 1) + if (this->scope_.empty()) { ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Element end outside of any scope"))); } @@ -213,10 +191,7 @@ Configurator_ParseHandler::startElement (const ACEXML_Char *uri, ACEXML_ENV_ARG_DECL_NOT_USED) ACE_THROW_SPEC ((ACEXML_SAXException)) { - - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("* Event startElement (%s, %s, %s) ***************\n"), - uri, name, qName)); + //ACE_DEBUG ((LM_DEBUG,ACE_TEXT ("* startElement (%s, %s, %s) ***************\n"),uri, name, qName)); /* if (alist != 0) for (size_t i = 0; i < alist->getLength (); ++i) @@ -348,6 +323,8 @@ Configurator_ParseHandler::startElement (const ACEXML_Char *uri, } syn->visit(this,alist); + + //ACE_DEBUG ((LM_DEBUG,ACE_TEXT ("* startElement (%s) DONE ***************\n"),qName)); } void @@ -367,7 +344,6 @@ void Configurator_ParseHandler::error (ACEXML_SAXParseException & ex ACEXML_ENV_ARG_DECL_NOT_USED) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_DEBUG ((LM_DEBUG, "%s:%d:%d ", this->fileName_.c_str(), this->locator_->getLineNumber(), this->locator_->getColumnNumber())); @@ -378,7 +354,6 @@ void Configurator_ParseHandler::fatalError (ACEXML_SAXParseException& ex ACEXML_ENV_ARG_DECL_NOT_USED) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_DEBUG ((LM_DEBUG, "%s:%d:%d ", this->fileName_.c_str(), this->locator_->getLineNumber(), this->locator_->getColumnNumber())); @@ -439,8 +414,17 @@ Configurator_ParseHandler::parseEvent (Event* vs, void* arg) } ECConfiguration *parent = dynamic_cast<ECConfiguration*> (this->scope_.top()); + ACE_ASSERT(parent); parent->events.push_back(vs); + // Insert into name table + if (this->nametable.bind(vs->name,vs)) + { + ACE_CString error("Event has duplicate name: "); + error += vs->name; + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + } + this->scope_.push(vs); return 0; } @@ -449,6 +433,8 @@ int Configurator_ParseHandler::parseCriticality (Criticality* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("ParseHandler visiting Criticality\n"))); + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::EVENT) ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Criticality not child of Event"))); @@ -488,6 +474,7 @@ Configurator_ParseHandler::parseCriticality (Criticality* vs, void* arg) } Event *parent = dynamic_cast<Event*> (this->scope_.top()); + ACE_ASSERT(parent); parent->criticality = vs; this->scope_.push(vs); @@ -498,6 +485,8 @@ int Configurator_ParseHandler::parseImportance (Importance* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("ParseHandler visiting Importance\n"))); + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::EVENT) ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Importance not child of Event"))); @@ -537,6 +526,7 @@ Configurator_ParseHandler::parseImportance (Importance* vs, void* arg) } Event *parent = dynamic_cast<Event*> (this->scope_.top()); + ACE_ASSERT(parent); parent->importance = vs; this->scope_.push(vs); @@ -562,8 +552,17 @@ Configurator_ParseHandler::parseTimeout (Timeout* vs, void* arg) } ECConfiguration *parent = dynamic_cast<ECConfiguration*> (this->scope_.top()); + ACE_ASSERT(parent); parent->timeouts.push_back(vs); + // Insert into name table + if (this->nametable.bind(vs->name,vs)) + { + ACE_CString error("Timeout has duplicate name: "); + error += vs->name; + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + } + this->scope_.push(vs); return 0; } @@ -587,8 +586,17 @@ Configurator_ParseHandler::parseLocalEventChannel (LocalEventChannel* vs, void* } ECConfiguration *parent = dynamic_cast<ECConfiguration*> (this->scope_.top()); + ACE_ASSERT(parent); parent->localECs.push_back(vs); + // Insert into name table + if (this->nametable.bind(vs->name,vs)) + { + ACE_CString error("LocalEventChannel has duplicate name: "); + error += vs->name; + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + } + this->scope_.push(vs); return 0; } @@ -614,8 +622,17 @@ Configurator_ParseHandler::parseRemoteEventChannel (RemoteEventChannel* vs, void } ECConfiguration *parent = dynamic_cast<ECConfiguration*> (this->scope_.top()); + ACE_ASSERT(parent); parent->remoteECs.push_back(vs); + // Insert into name table + if (this->nametable.bind(vs->name,vs)) + { + ACE_CString error("RemoteEventChannel has duplicate name: "); + error += vs->name; + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + } + this->scope_.push(vs); return 0; } @@ -672,6 +689,7 @@ Configurator_ParseHandler::parseSchedulingStrategy (SchedulingStrategy* vs, void } LocalEventChannel *parent = dynamic_cast<LocalEventChannel*> (this->scope_.top()); + ACE_ASSERT(parent); parent->schedulingstrategy = vs; this->scope_.push(vs); @@ -686,7 +704,7 @@ Configurator_ParseHandler::parseConsumer (Consumer* vs, void* arg) ACE_UNUSED_ARG(arg); if (this->scope_.top()->getSyntaxType() != VisitableSyntax::LOCALEVENTCHANNEL - || this->scope_.top()->getSyntaxType() != VisitableSyntax::REMOTEEVENTCHANNEL) + && this->scope_.top()->getSyntaxType() != VisitableSyntax::REMOTEEVENTCHANNEL) ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Consumer not child of LocalEventChannel or RemoteEventChannel"))); ACEXML_Attributes *alist = static_cast<ACEXML_Attributes*>(arg); @@ -700,17 +718,27 @@ Configurator_ParseHandler::parseConsumer (Consumer* vs, void* arg) ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid attributes for Consumer"))); } - if (this->scope_.top()->getSyntaxType() != VisitableSyntax::LOCALEVENTCHANNEL) + if (this->scope_.top()->getSyntaxType() == VisitableSyntax::LOCALEVENTCHANNEL) { LocalEventChannel *parent = dynamic_cast<LocalEventChannel*> (this->scope_.top()); + ACE_ASSERT(parent); parent->consumers.push_back(vs); } else // must be RemoteEventChannel { RemoteEventChannel *parent = dynamic_cast<RemoteEventChannel*> (this->scope_.top()); + ACE_ASSERT(parent); parent->consumers.push_back(vs); } + // Insert into name table + if (this->nametable.bind(vs->name,vs)) + { + ACE_CString error("Consumer has duplicate name: "); + error += vs->name; + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + } + this->scope_.push(vs); return 0; } @@ -725,6 +753,7 @@ Configurator_ParseHandler::parseSubscriptions (Subscriptions* vs, void* arg) ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Subscriptions not child of Consumer"))); Consumer *parent = dynamic_cast<Consumer*> (this->scope_.top()); + ACE_ASSERT(parent); parent->subscriptions = vs; this->scope_.push(vs); @@ -741,6 +770,7 @@ Configurator_ParseHandler::parseDependants (Dependants* vs, void* arg) ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Dependants not child of Consumer"))); Consumer *parent = dynamic_cast<Consumer*> (this->scope_.top()); + ACE_ASSERT(parent); parent->dependants = vs; this->scope_.push(vs); @@ -754,7 +784,7 @@ Configurator_ParseHandler::parseSupplier (Supplier* vs, void* arg) ACE_UNUSED_ARG(arg); if (this->scope_.top()->getSyntaxType() != VisitableSyntax::LOCALEVENTCHANNEL - || this->scope_.top()->getSyntaxType() != VisitableSyntax::REMOTEEVENTCHANNEL) + && this->scope_.top()->getSyntaxType() != VisitableSyntax::REMOTEEVENTCHANNEL) ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Supplier not child of LocalEventChannel"))); ACEXML_Attributes *alist = static_cast<ACEXML_Attributes*>(arg); @@ -768,17 +798,27 @@ Configurator_ParseHandler::parseSupplier (Supplier* vs, void* arg) ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid attributes for Supplier"))); } - if (this->scope_.top()->getSyntaxType() != VisitableSyntax::LOCALEVENTCHANNEL) + if (this->scope_.top()->getSyntaxType() == VisitableSyntax::LOCALEVENTCHANNEL) { LocalEventChannel *parent = dynamic_cast<LocalEventChannel*> (this->scope_.top()); + ACE_ASSERT(parent); parent->suppliers.push_back(vs); } - else // must be RemoteEventChannel + else if (this->scope_.top()->getSyntaxType() == VisitableSyntax::REMOTEEVENTCHANNEL) { RemoteEventChannel *parent = dynamic_cast<RemoteEventChannel*> (this->scope_.top()); + ACE_ASSERT(parent); parent->suppliers.push_back(vs); } + // Insert into name table + if (this->nametable.bind(vs->name,vs)) + { + ACE_CString error("Supplier has duplicate name: "); + error += vs->name; + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + } + this->scope_.push(vs); return 0; } @@ -793,6 +833,7 @@ Configurator_ParseHandler::parsePublications (Publications* vs, void* arg) ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Publications not child of Supplier"))); Supplier *parent = dynamic_cast<Supplier*> (this->scope_.top()); + ACE_ASSERT(parent); parent->publications = vs; this->scope_.push(vs); @@ -809,6 +850,7 @@ Configurator_ParseHandler::parseTriggers (Triggers* vs, void* arg) ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Triggers not child of Supplier"))); Supplier *parent = dynamic_cast<Supplier*> (this->scope_.top()); + ACE_ASSERT(parent); parent->triggers = vs; this->scope_.push(vs); @@ -825,6 +867,7 @@ Configurator_ParseHandler::parseTestDriver (TestDriver* vs, void* arg) ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("TestDriver not child of ECConfiguration"))); ECConfiguration *parent = dynamic_cast<ECConfiguration*> (this->scope_.top()); + ACE_ASSERT(parent); parent->driver = vs; this->scope_.push(vs); @@ -860,23 +903,17 @@ Configurator_ParseHandler::parseStartCondition (StartCondition* vs, void* arg) ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid attributes for StartCondition"))); } val = alist->getValue(ACE_TEXT("master")); - if (val != 0) + if (val != 0 && ACE_OS_String::strcmp(val,ACE_TEXT("yes")) == 0) { - if (ACE_OS_String::strcmp(val,ACE_TEXT("yes")) == 0) - { - vs->master = true; - } - else - { - vs->master = false; - } + vs->master = true; } else { - ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid attributes for StartCondition"))); + vs->master = false; } TestDriver *parent = dynamic_cast<TestDriver*> (this->scope_.top()); + ACE_ASSERT(parent); parent->startcondition = vs; this->scope_.push(vs); @@ -909,6 +946,7 @@ Configurator_ParseHandler::parseStopCondition (StopCondition* vs, void* arg) } TestDriver *parent = dynamic_cast<TestDriver*> (this->scope_.top()); + ACE_ASSERT(parent); parent->stopcondition = vs; this->scope_.push(vs); @@ -922,23 +960,26 @@ Configurator_ParseHandler::parseEventName (EventName* vs, void* arg) ACE_UNUSED_ARG(arg); if (this->scope_.top()->getSyntaxType() != VisitableSyntax::SUBSCRIPTIONS - || this->scope_.top()->getSyntaxType() != VisitableSyntax::PUBLICATIONS - || this->scope_.top()->getSyntaxType() != VisitableSyntax::TRIGGERS) + && this->scope_.top()->getSyntaxType() != VisitableSyntax::PUBLICATIONS + && this->scope_.top()->getSyntaxType() != VisitableSyntax::TRIGGERS) ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("EventName not child of Subscriptions, Publications, or Triggers"))); - if (this->scope_.top()->getSyntaxType() != VisitableSyntax::SUBSCRIPTIONS) + if (this->scope_.top()->getSyntaxType() == VisitableSyntax::SUBSCRIPTIONS) { Subscriptions *parent = dynamic_cast<Subscriptions*> (this->scope_.top()); + ACE_ASSERT(parent); parent->eventnames.push_back(vs); } - else if (this->scope_.top()->getSyntaxType() != VisitableSyntax::PUBLICATIONS) + else if (this->scope_.top()->getSyntaxType() == VisitableSyntax::PUBLICATIONS) { Publications *parent = dynamic_cast<Publications*> (this->scope_.top()); + ACE_ASSERT(parent); parent->eventnames.push_back(vs); } - else if (this->scope_.top()->getSyntaxType() != VisitableSyntax::TRIGGERS) + else if (this->scope_.top()->getSyntaxType() == VisitableSyntax::TRIGGERS) { Triggers *parent = dynamic_cast<Triggers*> (this->scope_.top()); + ACE_ASSERT(parent); parent->eventnames.push_back(vs); } @@ -956,6 +997,7 @@ Configurator_ParseHandler::parseSupplierName (SupplierName* vs, void* arg) ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("SupplierName not child of Dependants"))); Dependants *parent = dynamic_cast<Dependants*> (this->scope_.top()); + ACE_ASSERT(parent); parent->suppliernames.push_back(vs); this->scope_.push(vs); @@ -972,6 +1014,7 @@ Configurator_ParseHandler::parseTimeoutName (TimeoutName* vs, void* arg) ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("TimeoutName not child of Triggers"))); Triggers *parent = dynamic_cast<Triggers*> (this->scope_.top()); + ACE_ASSERT(parent); parent->timeoutnames.push_back(vs); this->scope_.push(vs); @@ -988,6 +1031,7 @@ Configurator_ParseHandler::parseIORFile (IORFile* vs, void* arg) ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("IORFile not child of RemoteEventChannel"))); RemoteEventChannel *parent = dynamic_cast<RemoteEventChannel*> (this->scope_.top()); + ACE_ASSERT(parent); parent->iorfile = vs; this->scope_.push(vs); @@ -1000,10 +1044,13 @@ Configurator_ParseHandler::parseWorstExecution (WorstExecution* vs, void* arg) { ACE_UNUSED_ARG(arg); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("ParseHandler visiting WorstExecution\n"))); + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::EVENT) ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("WorstExecution not child of Event"))); Event *parent = dynamic_cast<Event*> (this->scope_.top()); + ACE_ASSERT(parent); parent->worstexecution = vs; this->scope_.push(vs); @@ -1016,10 +1063,13 @@ Configurator_ParseHandler::parseTypicalExecution (TypicalExecution* vs, void* ar { ACE_UNUSED_ARG(arg); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("ParseHandler visiting TypicalExecution\n"))); + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::EVENT) ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("TypicalExecution not child of Event"))); Event *parent = dynamic_cast<Event*> (this->scope_.top()); + ACE_ASSERT(parent); parent->typicalexecution = vs; this->scope_.push(vs); @@ -1032,18 +1082,22 @@ Configurator_ParseHandler::parsePeriod (Period* vs, void* arg) { ACE_UNUSED_ARG(arg); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("ParseHandler visiting Period\n"))); + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::EVENT - || this->scope_.top()->getSyntaxType() != VisitableSyntax::TIMEOUT) + && this->scope_.top()->getSyntaxType() != VisitableSyntax::TIMEOUT) ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Period not child of Event or Timeout"))); - if (this->scope_.top()->getSyntaxType() != VisitableSyntax::EVENT) + if (this->scope_.top()->getSyntaxType() == VisitableSyntax::EVENT) { Event *parent = dynamic_cast<Event*> (this->scope_.top()); + ACE_ASSERT(parent); parent->period = vs; } - else if (this->scope_.top()->getSyntaxType() != VisitableSyntax::TIMEOUT) + else if (this->scope_.top()->getSyntaxType() == VisitableSyntax::TIMEOUT) { Timeout *parent = dynamic_cast<Timeout*> (this->scope_.top()); + ACE_ASSERT(parent); parent->period = vs; } @@ -1057,18 +1111,22 @@ Configurator_ParseHandler::parsePhase (Phase* vs, void* arg) { ACE_UNUSED_ARG(arg); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("ParseHandler visiting Phase\n"))); + if (this->scope_.top()->getSyntaxType() != VisitableSyntax::EVENT - || this->scope_.top()->getSyntaxType() != VisitableSyntax::TIMEOUT) + && this->scope_.top()->getSyntaxType() != VisitableSyntax::TIMEOUT) ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Phase not child of Event or Timeout"))); - if (this->scope_.top()->getSyntaxType() != VisitableSyntax::EVENT) + if (this->scope_.top()->getSyntaxType() == VisitableSyntax::EVENT) { Event *parent = dynamic_cast<Event*> (this->scope_.top()); + ACE_ASSERT(parent); parent->phase = vs; } - else if (this->scope_.top()->getSyntaxType() != VisitableSyntax::TIMEOUT) + else if (this->scope_.top()->getSyntaxType() == VisitableSyntax::TIMEOUT) { Timeout *parent = dynamic_cast<Timeout*> (this->scope_.top()); + ACE_ASSERT(parent); parent->phase = vs; } @@ -1086,6 +1144,7 @@ Configurator_ParseHandler::parseTime (Time* vs, void* arg) ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Time not child of StartCondition"))); StartCondition *parent = dynamic_cast<StartCondition*> (this->scope_.top()); + ACE_ASSERT(parent); parent->time = vs; this->scope_.push(vs); @@ -1102,6 +1161,7 @@ Configurator_ParseHandler::parseValue (Value* vs, void* arg) ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Value not child of StopCondition"))); StopCondition *parent = dynamic_cast<StopCondition*> (this->scope_.top()); + ACE_ASSERT(parent); parent->value = vs; this->scope_.push(vs); @@ -1113,3 +1173,9 @@ Configurator_ParseHandler::getRootNode (void) { return this->ecconfiguration; } + +NameTable& +Configurator_ParseHandler::getNameTable (void) +{ + return this->nametable; +} diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_ParseHandler.h b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_ParseHandler.h index 842dd8db11c..9b0b9403593 100644 --- a/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_ParseHandler.h +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_ParseHandler.h @@ -23,14 +23,6 @@ #include "SyntaxVisitor.h" #include "SyntaxTree.h" -//TODO: We need a name table. If name order shouldn't matter, we're -//going to need two passes: one to get the names and one to parse the -//rest of the XML. - -//TODO: An element/attribute tag database would be helpful for adding -//new stuff (make this class more generic) and if tag names change. -//We could hardcode it into setup or have it parse the DTD. - /** * @class Configurator_ParseHandler * @@ -230,8 +222,11 @@ public: virtual VisitableSyntax* getRootNode (void); + NameTable& getNameTable (void); + private: + NameTable nametable; ACE_CString fileName_; ACEXML_Locator* locator_; diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_SyntaxHandler.cpp b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_SyntaxHandler.cpp index 5d5967b99a3..27147906a71 100644 --- a/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_SyntaxHandler.cpp +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_SyntaxHandler.cpp @@ -2,10 +2,13 @@ #include "Configurator_SyntaxHandler.h" #include "SyntaxTree.h" +#include "RtSchedEventChannelC.h" +#include "Kokyu_EC.h" #include "ace/ACE.h" #include "ace/Log_Msg.h" #include "ace/OS_String.h" +#include "ace/Hash_Map_Manager.h" #include "RtecSchedulerC.h" @@ -15,10 +18,28 @@ Configurator_SyntaxHandler::Configurator_SyntaxHandler (void) : root(0) { + this->nametable.open(); + this->eventqostable.open(); + this->timeoutqostable.open(); } +/* +int +init (CORBA::ORB_var orb, PortableServer::POA_var poa) +{ + this->orb = orb; + this->poa = poa; + ACE_NEW_RETURN(ginit, + Gateway_Initializer(),-1); + + return 0; +} +*/ Configurator_SyntaxHandler::~Configurator_SyntaxHandler (void) { + this->nametable.close(); + this->eventqostable.close(); + this->timeoutqostable.close(); } // SyntaxVisitor FUNCTIONS // @@ -29,7 +50,7 @@ Configurator_SyntaxHandler::parseVisitableSyntax (VisitableSyntax* vs, void* arg { ACE_UNUSED_ARG(arg); - ACE_CString error("Unknown syntax token: "); + ACE_CString error("Unknown VisitableSyntax: "); char errbuf[MAXTYPESTRINGLEN]; visitableTypeToString(vs->getSyntaxType(),errbuf,MAXTYPESTRINGLEN); error += errbuf; @@ -41,9 +62,55 @@ int Configurator_SyntaxHandler::parseECConfiguration (ECConfiguration* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_UNUSED_ARG(vs); ACE_UNUSED_ARG(arg); + // Visit Children + //events + EventVector::iterator eiter = vs->events.begin(); + for (; eiter != vs->events.end(); eiter++) + { + (*eiter)->visit(this,NULL); + } + + //timeouts + TimeoutVector::iterator titer = vs->timeouts.begin(); + for (; titer != vs->timeouts.end(); titer++) + { + (*titer)->visit(this,NULL); + } + + //driver + // It's important that this happens before the ECs + // since they need stuff like whether or not we're + // the master. + vs->driver->visit(this,NULL); + + //localecs + LocalECVector::iterator leciter = vs->localECs.begin(); + for (; leciter != vs->localECs.end(); leciter++) + { + (*leciter)->visit(this,NULL); + } + + //remoteecs + RemoteECVector::iterator reciter = vs->remoteECs.begin(); + for (; reciter != vs->remoteECs.end(); reciter++) + { + (*reciter)->visit(this,NULL); + } + + // DEBUG -- print name table + NameTable::iterator ntiter = this->nametable.begin(); + for (; ntiter != this->nametable.end(); ntiter++) + { + NameTable::ENTRY entry = *ntiter; + + char typebuf[MAXTYPESTRINGLEN]; + visitableTypeToString(entry.int_id_->getSyntaxType(),typebuf,MAXTYPESTRINGLEN); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("NameTable Entry: %s -> %s\n"),entry.ext_id_.c_str(),typebuf)); + } + // DEBUG END + return 0; } @@ -51,9 +118,37 @@ int Configurator_SyntaxHandler::parseEvent (Event* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_UNUSED_ARG(vs); ACE_UNUSED_ARG(arg); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("SyntaxHandler visiting Event: %s\n"),vs->name.c_str())); + + if (!(vs->period + && vs->phase + && vs->criticality + && vs->importance + && vs->worstexecution + && vs->typicalexecution)) + { + ACE_CString error("Event has missing child: "); + error += vs->name; + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + } + + RtEventChannelAdmin::SchedInfo schedinfo; + + // Visit children + vs->period->visit(this,&schedinfo); + vs->phase->visit(this,&schedinfo); + vs->criticality->visit(this,&schedinfo); + vs->importance->visit(this,&schedinfo); + vs->worstexecution->visit(this,&schedinfo); + vs->typicalexecution->visit(this,&schedinfo); + + // Since nametable was OK, eventqostable should be too + this->eventqostable.bind(vs->name,schedinfo); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("SyntaxHandler DONE visiting Event: %s\n"),vs->name.c_str())); + return 0; } @@ -61,8 +156,12 @@ int Configurator_SyntaxHandler::parseCriticality (Criticality* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_UNUSED_ARG(vs); - ACE_UNUSED_ARG(arg); + RtEventChannelAdmin::SchedInfo *schedinfo = static_cast<RtEventChannelAdmin::SchedInfo*> (arg); + ACE_ASSERT(schedinfo); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("SyntaxHandler visiting Criticality\n"))); + + schedinfo->criticality = vs->value; return 0; } @@ -71,8 +170,12 @@ int Configurator_SyntaxHandler::parseImportance (Importance* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_UNUSED_ARG(vs); - ACE_UNUSED_ARG(arg); + RtEventChannelAdmin::SchedInfo *schedinfo = static_cast<RtEventChannelAdmin::SchedInfo*> (arg); + ACE_ASSERT(schedinfo); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("SyntaxHandler visiting Importance\n"))); + + schedinfo->importance = vs->value; return 0; } @@ -81,9 +184,27 @@ int Configurator_SyntaxHandler::parseTimeout (Timeout* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_UNUSED_ARG(vs); ACE_UNUSED_ARG(arg); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("SyntaxHandler visiting Timeout: %s\n"),vs->name.c_str())); + + if (!(vs->period + && vs->phase)) + { + ACE_CString error("Timeout has missing child: "); + error += vs->name; + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + } + + RtEventChannelAdmin::SchedInfo schedinfo; + + // Visit children + vs->period->visit(this,&schedinfo); + vs->phase->visit(this,&schedinfo); + + // Since nametable was OK, eventqostable should be too + this->timeoutqostable.bind(vs->name,schedinfo); + return 0; } @@ -91,9 +212,72 @@ int Configurator_SyntaxHandler::parseLocalEventChannel (LocalEventChannel* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_UNUSED_ARG(vs); ACE_UNUSED_ARG(arg); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("SyntaxHandler visiting LocalEventChannel: %s\n"),vs->name.c_str())); + + // Get info from SchedulingStrategy + ACE_CString sched_type; + switch (vs->schedulingstrategy->type) { + case SchedulingStrategy::EDF: + sched_type += "edf"; + break; + case SchedulingStrategy::MUF: + sched_type += "muf"; + break; + case SchedulingStrategy::RMS: + sched_type += "rms"; + break; + } + + // TODO: set up local EC + RtEventChannelAdmin::RtSchedEventChannel_var localEC; + /* + Kokyu_EC local_ec; + if (local_ec.init(this->driver->time_master(), + sched_type.c_str(), this->poa.in(), + this->orb->orb_core()->reactor()) == -1) + { + ACE_CString error("Unable to initialize EC: "); + error += vs->name; + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + } + + localEC = local_ec._this(ACE_ENV_SINGLE_ARG_PARAMETER); + + CORBA::String_var ior = orb->object_to_string(local_ec.in() + ACE_ENV_ARG_PARAMETER); + + ACE_CString ior_output_filename; + FILE *ior_output_file = ACE_OS::fopen (ior_output_filename.c_str(), "w"); + if (ior_output_file == 0) + { + ACE_CString error("Unable to open "); + error += vs->name; + error += " for writing."; + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + } + + ACE_OS::fprintf(ior_output_file, ior.in()); + ACE_OS::fclose(ior_output_file); + + this->localECs.push_back(localEC); + */ + // visit localEC children + //consumers + ConsumerVector::iterator citer = vs->consumers.begin(); + for (; citer != vs->consumers.end(); citer++) + { + (*citer)->visit(this,localEC.in()); + } + + //suppliers + SupplierVector::iterator siter = vs->suppliers.begin(); + for (; siter != vs->suppliers.end(); siter++) + { + (*siter)->visit(this,localEC.in()); + } + return 0; } @@ -101,9 +285,42 @@ int Configurator_SyntaxHandler::parseRemoteEventChannel (RemoteEventChannel* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_UNUSED_ARG(vs); ACE_UNUSED_ARG(arg); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("SyntaxHandler visiting RemoteEventChannel: %s\n"),vs->name.c_str())); + + // get IOR filename + ACE_CString iorfilename(vs->iorfile->str); + + // TODO: set up remote EC + RtEventChannelAdmin::RtSchedEventChannel_var remoteEC; + /* + // TODO: for now, just do one gateway init + this->ginitv[0]->init(this->orb,this->poa,localECs[0].in(),ior_output_filename,ior_input_files); + ACE_Time_Value gateway_delay(5,000000); + long timer_id = this->orb->orb_core()->reactor()->schedule_timer(this->ginitv[0],0,gateway_delay); + if (timer_id < 0) + { + ACE_CString error("Could not schedule Gateway_Initializer timer for RemoteEC "); + error += vs->name; + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + } + */ + // visit remoteEC consumers and suppliers + //consumers + ConsumerVector::iterator citer = vs->consumers.begin(); + for (; citer != vs->consumers.end(); citer++) + { + (*citer)->visit(this,remoteEC.in()); + } + + //suppliers + SupplierVector::iterator siter = vs->suppliers.begin(); + for (; siter != vs->suppliers.end(); siter++) + { + (*siter)->visit(this,remoteEC.in()); + } + return 0; } @@ -121,8 +338,28 @@ int Configurator_SyntaxHandler::parseConsumer (Consumer* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_UNUSED_ARG(vs); - ACE_UNUSED_ARG(arg); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("SyntaxHandler visiting Consumer: %s\n"),vs->name.c_str())); + + if (!(vs->subscriptions + && vs->dependants)) + { + ACE_CString error("Consumer has missing child: "); + error += vs->name; + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + } + + // visit Consumer children + QoSVector subs; + vs->subscriptions->visit(this,&subs); + + SupplierVector dependants; //dependants push_back + vs->dependants->visit(this,&dependants); + + // TODO: register Consumer + RtEventChannelAdmin::RtSchedEventChannel *ec = + static_cast<RtEventChannelAdmin::RtSchedEventChannel*> (arg); + + // TODO: map syntax dependants to actual suppliers somehow return 0; } @@ -131,18 +368,48 @@ int Configurator_SyntaxHandler::parseSubscriptions (Subscriptions* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_UNUSED_ARG(vs); - ACE_UNUSED_ARG(arg); + QoSVector *subs = static_cast<QoSVector*> (arg); + ACE_ASSERT(subs); + + // parse Subscriptions + EventNameVector::iterator eniter = vs->eventnames.begin(); + for (; eniter != vs->eventnames.end(); eniter++) + { + QoSVector::value_type subqos; + ACE_DEBUG ((LM_DEBUG,ACE_TEXT("Subscription %s\n"),(*eniter)->str.c_str())); + if (this->eventqostable.find((*eniter)->str,subqos)) + { + ACE_CString error("Unknown subscription event: "); + error += (*eniter)->str; + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + } + subs->push_back(subqos); + } return 0; -} +} //parseSubscriptions() int Configurator_SyntaxHandler::parseDependants (Dependants* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_UNUSED_ARG(vs); - ACE_UNUSED_ARG(arg); + SupplierVector *dependants = static_cast<SupplierVector*> (arg); + ACE_ASSERT(dependants); + + SupplierNameVector::iterator sniter = vs->suppliernames.begin(); + for (; sniter != vs->suppliernames.end(); sniter++) + { + VisitableSyntax *syntax; + if (this->nametable.find((*sniter)->str,syntax)) + { + ACE_CString error("Unknown dependant: "); + error += (*sniter)->str; + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + } + Supplier *supplier = dynamic_cast<Supplier*> (syntax); + ACE_ASSERT(supplier); + dependants->push_back(supplier); + } return 0; } @@ -151,8 +418,26 @@ int Configurator_SyntaxHandler::parseSupplier (Supplier* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_UNUSED_ARG(vs); - ACE_UNUSED_ARG(arg); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("SyntaxHandler visiting Supplier: %s\n"),vs->name.c_str())); + + if (!(vs->publications + && vs->triggers)) + { + ACE_CString error("Supplier has missing child: "); + error += vs->name; + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + } + + // visit Supplier children + QoSVector pubs; + vs->publications->visit(this,&pubs); + + QoSVector trigs; + vs->triggers->visit(this,&trigs); + + // TODO: register Supplier + RtEventChannelAdmin::RtSchedEventChannel *ec = + static_cast<RtEventChannelAdmin::RtSchedEventChannel*> (arg); return 0; } @@ -161,8 +446,23 @@ int Configurator_SyntaxHandler::parsePublications (Publications* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_UNUSED_ARG(vs); - ACE_UNUSED_ARG(arg); + QoSVector *pubs = static_cast<QoSVector*> (arg); + ACE_ASSERT(pubs); + + // parse Publications + EventNameVector::iterator eniter = vs->eventnames.begin(); + for (; eniter != vs->eventnames.end(); eniter++) + { + QoSVector::value_type pubqos; + ACE_DEBUG ((LM_DEBUG,ACE_TEXT("Publication %s\n"),(*eniter)->str.c_str())); + // TODO: fix segfault in this vicinity + if (this->eventqostable.find((*eniter)->str,pubqos)) + { + ACE_CString error("Unknown publication event: "); + error += (*eniter)->str; + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + } + } return 0; } @@ -171,8 +471,36 @@ int Configurator_SyntaxHandler::parseTriggers (Triggers* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_UNUSED_ARG(vs); - ACE_UNUSED_ARG(arg); + QoSVector *trigs = static_cast<QoSVector*> (arg); + ACE_ASSERT(trigs); + + // parse Triggers + EventNameVector::iterator eniter = vs->eventnames.begin(); + for (; eniter != vs->eventnames.end(); eniter++) + { + QoSVector::value_type trigqos; + ACE_DEBUG ((LM_DEBUG,ACE_TEXT("Trigger Event %s\n"),(*eniter)->str.c_str())); + if (this->eventqostable.find((*eniter)->str,trigqos)) + { + ACE_CString error("Unknown trigger event: "); + error += (*eniter)->str; + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + } + trigs->push_back(trigqos); + } + TimeoutNameVector::iterator tniter = vs->timeoutnames.begin(); + for (; tniter != vs->timeoutnames.end(); tniter++) + { + QoSVector::value_type trigqos; + ACE_DEBUG ((LM_DEBUG,ACE_TEXT("Trigger Timeout %s\n"),(*eniter)->str.c_str())); + if (this->timeoutqostable.find((*eniter)->str,trigqos)) + { + ACE_CString error("Unknown trigger timeout: "); + error += (*eniter)->str; + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + } + trigs->push_back(trigqos); + } return 0; } @@ -181,9 +509,26 @@ int Configurator_SyntaxHandler::parseTestDriver (TestDriver* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_UNUSED_ARG(vs); ACE_UNUSED_ARG(arg); + if (!(vs->startcondition + && vs->stopcondition)) + { + ACE_CString error("TestDriver has missing child: "); + error += vs->startcondition ? "StopCondition" : "StartCondition"; + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + } + + // Visit Children + RtEventChannelAdmin::Time starttime; + vs->startcondition->visit(this,&starttime); + + long limit; + vs->stopcondition->visit(this,&limit); + + // TODO: Create TestDriver + this->testdriver = NULL; + return 0; } @@ -191,8 +536,14 @@ int Configurator_SyntaxHandler::parseStartCondition (StartCondition* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_UNUSED_ARG(vs); - ACE_UNUSED_ARG(arg); + if (!vs->time) + { + ACE_CString error("StartCondition has missing child: Time"); + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + } + + // Visit Children + vs->time->visit(this,arg); return 0; } @@ -201,8 +552,14 @@ int Configurator_SyntaxHandler::parseStopCondition (StopCondition* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_UNUSED_ARG(vs); - ACE_UNUSED_ARG(arg); + if (!vs->value) + { + ACE_CString error("StopCondition has missing child: Value"); + ACEXML_THROW (ACEXML_SAXException (error.c_str())); + } + + // Visit Children + vs->value->visit(this,arg); return 0; } @@ -251,8 +608,13 @@ int Configurator_SyntaxHandler::parseWorstExecution (WorstExecution* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_UNUSED_ARG(vs); - ACE_UNUSED_ARG(arg); + RtEventChannelAdmin::SchedInfo *schedinfo = static_cast<RtEventChannelAdmin::SchedInfo*> (arg); + ACE_ASSERT(schedinfo); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("SyntaxHandler visiting WorstExecution\n"))); + + // TODO: convert ms to 100s of ns + schedinfo->wc_time = vs->val; return 0; } @@ -261,8 +623,13 @@ int Configurator_SyntaxHandler::parseTypicalExecution (TypicalExecution* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_UNUSED_ARG(vs); - ACE_UNUSED_ARG(arg); + RtEventChannelAdmin::SchedInfo *schedinfo = static_cast<RtEventChannelAdmin::SchedInfo*> (arg); + ACE_ASSERT(schedinfo); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("SyntaxHandler visiting TypicalExecution\n"))); + + // TODO: convert ms to 100s of ns + schedinfo->typical_time = vs->val; return 0; } @@ -271,8 +638,15 @@ int Configurator_SyntaxHandler::parsePeriod (Period* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_UNUSED_ARG(vs); - ACE_UNUSED_ARG(arg); + RtEventChannelAdmin::SchedInfo *schedinfo = static_cast<RtEventChannelAdmin::SchedInfo*> (arg); + ACE_ASSERT(schedinfo); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("SyntaxHandler visiting Period with arg %@ as SchedInfo %@\n"),arg,schedinfo)); + + // TODO: convert ms to 100s of ns + schedinfo->period = vs->val; + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("SyntaxHandler DONE visiting Period\n"))); return 0; } @@ -281,8 +655,13 @@ int Configurator_SyntaxHandler::parsePhase (Phase* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_UNUSED_ARG(vs); - ACE_UNUSED_ARG(arg); + RtEventChannelAdmin::SchedInfo *schedinfo = static_cast<RtEventChannelAdmin::SchedInfo*> (arg); + ACE_ASSERT(schedinfo); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("SyntaxHandler visiting Phase\n"))); + + // TODO: convert ms to 100s of ns + schedinfo->phase = vs->val; return 0; } @@ -291,8 +670,11 @@ int Configurator_SyntaxHandler::parseTime (Time* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_UNUSED_ARG(vs); - ACE_UNUSED_ARG(arg); + RtEventChannelAdmin::Time *time = static_cast<RtEventChannelAdmin::Time*> (arg); + ACE_ASSERT(time); + + // TODO: convert ms to 100s of ns + *time = vs->val; return 0; } @@ -301,8 +683,10 @@ int Configurator_SyntaxHandler::parseValue (Value* vs, void* arg) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_UNUSED_ARG(vs); - ACE_UNUSED_ARG(arg); + long *value = static_cast<long*> (arg); + ACE_ASSERT(value); + + *value = vs->val; return 0; } @@ -318,3 +702,29 @@ Configurator_SyntaxHandler::setRootNode (VisitableSyntax *vs) { this->root = vs; } + +void +Configurator_SyntaxHandler::parse (void) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + this->root->visit(this,NULL); +} + +ECTestDriver * +Configurator_SyntaxHandler::getTestDriver (void) +{ + return this->testdriver; +} + +void +Configurator_SyntaxHandler::setNameTable(NameTable &nt) +{ + this->nametable.unbind_all(); + + NameTable::ITERATOR ntiter = nt.begin(); + for (; ntiter != nt.end(); ++ntiter) + { + NameTable::ENTRY ntentry = *ntiter; + this->nametable.bind(ntentry.ext_id_,ntentry.int_id_); + } +} diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_SyntaxHandler.h b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_SyntaxHandler.h index 8892d3c40b6..feccadd88fb 100644 --- a/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_SyntaxHandler.h +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Configurator_SyntaxHandler.h @@ -14,10 +14,16 @@ #ifndef CONFIGURATOR_SYNTAXHANDLER_H #define CONFIGURATOR_SYNTAXHANDLER_H -#include "ACEXML/common/SAXExceptions.h" - #include "SyntaxVisitor.h" #include "SyntaxTree.h" +#include "RtSchedEventChannelC.h" + +#include "ACEXML/common/SAXExceptions.h" + +#include <vector> + +// Forward decls +class ECTestDriver; /** * @class Configurator_SyntaxHandler @@ -35,6 +41,8 @@ public: */ Configurator_SyntaxHandler (void); + //int init(CORBA::ORB_var orb, PortableServer::POA_var poa); + /* * Default destructor. */ @@ -103,9 +111,35 @@ public: virtual void setRootNode(VisitableSyntax *vs); + virtual void parse (void) + ACE_THROW_SPEC ((ACEXML_SAXException)); + + ECTestDriver *getTestDriver (void); + + void setNameTable(NameTable &nt); + + typedef ACE_Hash_Map_Manager<ACE_CString,RtEventChannelAdmin::SchedInfo,ACE_Null_Mutex> QoSTable; + typedef std::vector<RtEventChannelAdmin::SchedInfo> QoSVector; + + typedef std::vector<RtEventChannelAdmin::RtSchedEventChannel_var> ECVector; + //typedef std::vector<GatewayInitializer> GatewayInitVector; private: + NameTable nametable; + QoSTable eventqostable; + QoSTable timeoutqostable; + VisitableSyntax *root; + + ECTestDriver *testdriver; + + // ORB stuff + //CORBA::ORB_var orb; + //PortableServer::POA_var poa; + ECVector localECs; + ECVector remoteECs; + //GatewayInitVector ginitv; + }; #endif /* CONFIGURATOR_SYNTAXHANDLER_H */ diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECConsumer.cpp b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECConsumer.cpp new file mode 100644 index 00000000000..3953b47d6e6 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECConsumer.cpp @@ -0,0 +1,166 @@ +// $Id$ + +#include "ECConsumer.h" +#include "ECSupplier.h" +#include "Service_Handler.h" + +#include "ace/Timeprobe.h" +#include "ace/High_Res_Timer.h" +#include "ace/Time_Value.h" +#include "ace/ACE.h" //for is_prime() +#include "orbsvcs/orbsvcs/Time_Utilities.h" //ORBSVCS_Time +#include <ace/Counter.h> +#include <ace/OS_NS_sys_time.h> + +#include <algorithm> + +ACE_RCSID(EC_Examples, ECConsumer, "$Id$") + +ECConsumer::ECConsumer (EventTypeVector &sub_types, + ECSupplier *fwddest, Service_Handler * handler) + : worktime_(0,0) + , fwddest_(fwddest) + , handler_(handler) + , sub_types_(sub_types) +{ +} + +ECConsumer::ECConsumer (EventTypeVector &sub_types, + ACE_Time_Value& worktime, + ECSupplier *fwddest, Service_Handler *handler) + : worktime_(worktime) + , fwddest_(fwddest) + , handler_(handler) + , sub_types_(sub_types) +{ +} + +ECConsumer::~ECConsumer(void) +{ +} + +void +ECConsumer::push (const RtecEventComm::EventSet& events + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (events.length () == 0) + { + ACE_DEBUG ((LM_DEBUG, + "ECConsumer (%P|%t) no events\n")); + return; + } + + ACE_DEBUG ((LM_DEBUG, "ECConsumer (%P|%t) we received event type %d\n", + events[0].header.type)); + + if (this->handler_ != 0) + { + ACE_DEBUG((LM_DEBUG,"ECConsumer (%P|%t) calling handle_service_start()\n")); + this->handler_->handle_service_start(ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_DEBUG((LM_DEBUG,"ECConsumer (%P|%t) handle_service_start() DONE\n")); + } + + if (std::find(this->sub_types_.begin(),this->sub_types_.end(),events[0].header.type) == this->sub_types_.end()) + { + ACE_DEBUG((LM_DEBUG,"ECConsumer (%P|%t) received unknown type %d; ignoring\n",events[0].header.type)); + return; + } + + ACE_High_Res_Timer timer; + ACE_Time_Value elapsed_time; + + static CORBA::ULong prime_number = 9619899; + + ACE_DEBUG((LM_DEBUG,"ECConsumer (%P|%t) worktime is %isec %iusec\n", + this->worktime_.sec(),this->worktime_.usec())); + + ACE_Time_Value start_time(ACE_OS::gettimeofday()); + timer.start(); + int j=0; + while (elapsed_time <= this->worktime_) + { + //ACE_DEBUG((LM_DEBUG,"%isec %iusec elapsed\n",elapsed_time.sec(),elapsed_time.usec())); + + ACE::is_prime (prime_number, + 2, + prime_number / 2); + + ++j; + elapsed_time = ACE_OS::gettimeofday() - start_time; + } + + //ACE_DEBUG((LM_DEBUG,"ECConsumer (%P|%t) elapsed %isec %iusec\n",elapsed_time.sec(),elapsed_time.usec())); + + timer.stop (); + timer.elapsed_time (elapsed_time); //total elapsed time + + ACE_DEBUG ((LM_DEBUG, "ECConsumer (%P|%t) request processing for %d done, " + "elapsed time = %isec %iusec\n", + events[0].header.type,elapsed_time.sec(),elapsed_time.usec())); + ACE_DEBUG((LM_DEBUG,"ECConsumer (%P|%t) processing took %d iterations\n",j)); + ACE_DEBUG((LM_DEBUG,"ECConsumer (%P|%t) event had deadline %i\n", + events[0].header.deadline)); + +// ACE_DEBUG ((LM_DEBUG, +// "Request processing in thread %t done, " +// "prio = %d, load = %d, elapsed time = %umsec\n", +// prio, exec_duration, elapsed_time.msec ())); + + //now, trigger the next subtask if any + if (this->fwddest_ != 0) + { + //trigger next subtask; we assume we are the only ones who set the ECSupplier's mode! + ACE_DEBUG((LM_DEBUG,"ECConsumer (%P|%t) triggering next subtask\n")); + this->fwddest_->timeout_occured(ACE_ENV_SINGLE_ARG_PARAMETER); + } + + if (this->handler_ != 0) + { + ACE_DEBUG((LM_DEBUG,"ECConsumer (%P|%t) calling handle_service_stop()\n")); + this->handler_->handle_service_stop(ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_DEBUG((LM_DEBUG,"ECConsumer (%P|%t) handle_service_stop() DONE\n")); + } +} + +void +ECConsumer::disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +void +ECConsumer::setWorkTime(ACE_Time_Value& worktime) +{ + this->worktime_.set(worktime.sec(),worktime.usec()); +} + +void +ECConsumer::rt_info(InfoHandle consumer_rt_info) +{ + rt_info_ = consumer_rt_info; +} + +ECConsumer::InfoHandle +ECConsumer::rt_info(void) +{ + return rt_info_; +} + +void +ECConsumer::handler(Service_Handler * handler) +{ + this->handler_ = handler; +} + +Service_Handler * +ECConsumer::handler(void) const +{ + return this->handler_; +} + +// **************************************************************** + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +#elif defined(ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECConsumer.h b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECConsumer.h new file mode 100644 index 00000000000..80996cccb88 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECConsumer.h @@ -0,0 +1,95 @@ +/* -*- C++ -*- */ +// $Id$ +// +// ============================================================================ +// +// = LIBRARY +// ORBSVCS Real-time Event Channel examples +// +// = FILENAME +// ECConsumer +// +// = AUTHOR +// Bryan Thrall +// +// ============================================================================ + +#ifndef CONSUMER_H +#define CONSUMER_H + +#include "orbsvcs/RtecEventCommS.h" +#include "orbsvcs/RtecSchedulerC.h" + +#include "ace/Time_Value.h" + +#include "ECSupplier.h" +#include "Service_Handler.h" + +#include <vector> + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +class ECConsumer : public POA_RtecEventComm::PushConsumer +{ + // = TITLE + // Simple consumer object + // + // = DESCRIPTION + // This class is a consumer of events. + // It simply register for two event typesone event type + // The class is just a helper to simplify common tasks in EC + // tests, such as subscribing for a range of events, disconnecting + // from the EC, informing the driver of shutdown messages, etc. + // + // There are several ways to connect and disconnect this class, + // and it is up to the driver program to use the right one. + // +public: + typedef RtecEventComm::EventSourceID SourceID; + typedef RtecEventComm::EventType EventType; + typedef std::vector<EventType> EventTypeVector; + typedef RtecScheduler::handle_t InfoHandle; + + ECConsumer (EventTypeVector &sub_types, + ACE_Time_Value& worktime, + ECSupplier *fwddest = 0, Service_Handler *handler = 0); + // Constructor + + ECConsumer (EventTypeVector &sub_types, + ECSupplier *fwddest = 0, Service_Handler *handler = 0); + // Constructor + + virtual ~ECConsumer(void); + + // = The RtecEventComm::PushConsumer methods + + virtual void push (const RtecEventComm::EventSet& events + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + virtual void disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + // The skeleton methods. + + void setWorkTime(ACE_Time_Value& worktime); + + void rt_info(InfoHandle consumer_rt_info); + InfoHandle rt_info(void); + + void handler(Service_Handler * handler); + + Service_Handler * handler(void) const; + +protected: + ACE_Time_Value worktime_; + + ECSupplier *fwddest_; + InfoHandle rt_info_; + + Service_Handler * handler_; + + EventTypeVector sub_types_; +}; + +#endif /* CONSUMER_H */ diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECSupplier.cpp b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECSupplier.cpp new file mode 100644 index 00000000000..f6fce838bea --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECSupplier.cpp @@ -0,0 +1,143 @@ +// $Id$ + +#include "ECSupplier.h" +#include "ace/Time_Value.h" +#include "ace/Thread.h" //for ACE_Thread::self() +#include "orbsvcs/Event_Service_Constants.h" +#include "orbsvcs/Event/EC_Event_Channel.h" +#include "orbsvcs/RtecEventCommC.h" +#include <ace/Counter.h> +#include <ace/OS_NS_sys_time.h> + +ACE_RCSID(EC_Examples, ECSupplier, "$Id$") + +ECSupplier::ECSupplier (SourceID id, + EventTypeVector &pub_types, + Service_Handler *handler) + : id_ (id) + , pub_types_(pub_types) + , handler_(handler) +{ +} + +ECSupplier::~ECSupplier (void) +{ +} + +void +ECSupplier::set_consumer_proxy(ConsumerProxy proxy) +{ + this->consumer_proxy_ = proxy; +} + +void +ECSupplier::rt_info(InfoHandle supplier_rt_info) +{ + this->rt_info_ = supplier_rt_info; +} + +ECSupplier::InfoHandle +ECSupplier::rt_info(void) +{ + return this->rt_info_; +} + +void +ECSupplier::timeout_occured (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->handler_ != 0) + { + ACE_DEBUG((LM_DEBUG,"ECSupplier (%P|%t) calling handle_service_start()\n")); + this->handler_->handle_service_start(ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_DEBUG((LM_DEBUG,"ECSupplier (%P|%t) handle_service_start() DONE\n")); + } + + RtecEventComm::EventSet event (1); + event.length (1); + event[0].header.source = id_; + event[0].header.ttl = 1; + // TODO: For now, just handle first published type + event[0].header.type = this->pub_types_[0]; + + ACE_DEBUG((LM_DEBUG,"ECSupplier (id %d) in thread %t will push event type %d\n",this->id_,event[0].header.type)); + + this->consumer_proxy_->push (event ACE_ENV_ARG_PARAMETER); + + if (this->handler_ != 0) + { + ACE_DEBUG((LM_DEBUG,"ECSupplier (%P|%t) calling handle_service_stop()\n")); + this->handler_->handle_service_stop(ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_DEBUG((LM_DEBUG,"ECSupplier (%P|%t) handle_service_stop() DONE\n")); + } +} + +void +ECSupplier::disconnect_push_supplier (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +ECSupplier::SourceID +ECSupplier::get_id(void) const +{ + return this->id_; +} + +Service_Handler * +ECSupplier::handler(void) const +{ + return this->handler_; +} + +// **************************************************************** + +ECTimeout_Consumer::ECTimeout_Consumer (ECSupplier* supplier) + :supplier_impl_ (supplier) +{ +} + +void +ECTimeout_Consumer::push (const RtecEventComm::EventSet& events + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (events.length () == 0) + { + ACE_DEBUG ((LM_DEBUG, + "TimeoutConsumer (%t) no events\n")); + return; + } + + ACE_DEBUG ((LM_DEBUG, "(%t) Timeout Event received\n")); + + supplier_impl_->timeout_occured (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +void +ECTimeout_Consumer::disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +// **************************************************************** + +/// Constructor +ECSupplier_Timeout_Handler::ECSupplier_Timeout_Handler (ECSupplier * supplier_impl) + : supplier_impl_(supplier_impl) +{} + +int +ECSupplier_Timeout_Handler::handle_timeout (const ACE_Time_Value &, + const void *) +{ + ACE_DEBUG ((LM_DEBUG, "ECSupplier_Timeout_Handler (%t): timeout received\n")); + supplier_impl_->timeout_occured (ACE_ENV_SINGLE_ARG_PARAMETER); + + return 0; +} //ECSupplier_Timeout_Handler::handle_timeout() + +// **************************************************************** + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +#elif defined(ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECSupplier.h b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECSupplier.h new file mode 100644 index 00000000000..2a75c586fb7 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECSupplier.h @@ -0,0 +1,138 @@ +/* -*- C++ -*- */ +// $Id$ +// +// ============================================================================ +// +// = LIBRARY +// ORBSVCS Real-time Event Channel examples +// +// = FILENAME +// ECSupplier +// +// = AUTHOR +// Carlos O'Ryan (coryan@cs.wustl.edu) +// +// ============================================================================ + +#ifndef SUPPLIER_H +#define SUPPLIER_H + +#include "ace/Event_Handler.h" + +#include "orbsvcs/RtecEventCommS.h" +#include "orbsvcs/RtecEventChannelAdminC.h" +#include "orbsvcs/RtecSchedulerC.h" +#include "orbsvcs/Event/EC_Event_Channel.h" + +#include "Service_Handler.h" + +#include <vector> + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +class ECSupplier : public POA_RtecEventComm::PushSupplier +{ + // = TITLE + // Simple supplier object + // + // = DESCRIPTION + // This class is a supplier of events. + // The class is just a helper to simplify common tasks in EC + // tests, such as subscribing for a range of events, disconnecting + // from the EC, informing the driver of shutdown messages, etc. + // + // There are several ways to connect and disconnect this class, + // and it is up to the driver program to use the right one. + // +public: + typedef RtecEventChannelAdmin::ProxyPushConsumer_var ConsumerProxy; + typedef RtecEventComm::EventSourceID SourceID; + typedef RtecEventComm::EventType EventType; + typedef std::vector<EventType> EventTypeVector; + typedef RtecScheduler::handle_t InfoHandle; + + ECSupplier (SourceID id, EventTypeVector &pub_types, + Service_Handler * handler = 0); + // Constructor + + virtual ~ECSupplier(void); + + // = The RtecEventComm::PushSupplier methods + + virtual void disconnect_push_supplier (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + // The skeleton methods. + + virtual void timeout_occured (ACE_ENV_SINGLE_ARG_DECL); + + void set_consumer_proxy(ConsumerProxy consumer_proxies); + + void rt_info(InfoHandle supplier_rt_info); + InfoHandle rt_info(void); + + SourceID get_id(void) const; + + Service_Handler * handler(void) const; + +protected: + SourceID id_; + EventTypeVector pub_types_; + + ConsumerProxy consumer_proxy_; + + InfoHandle rt_info_; + + Service_Handler *handler_; +}; //class ECSupplier + +class ECTimeout_Consumer : public POA_RtecEventComm::PushConsumer +{ + // = TITLE + // Timer consumer object + // + // = DESCRIPTION + // This class is a consumer of timeout events from EC. + // It registers for timeout event with EC and calls + // the + // +public: + ECTimeout_Consumer (ECSupplier * supplier_impl); + // Constructor + + // = The RtecEventComm::PushConsumer methods + + virtual void push (const RtecEventComm::EventSet& events + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + virtual void disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + // The skeleton methods. + +private: + ECSupplier *supplier_impl_; +}; //class ECTimeout_Consumer + +class ECSupplier_Timeout_Handler : public ACE_Event_Handler +{ + // = TITLE + // Timer consumer object + // + // = DESCRIPTION + // This class is a consumer of timeout events from EC. + // It registers for timeout event with EC and calls + // the + // +public: + ECSupplier_Timeout_Handler (ECSupplier * supplier_impl); + // Constructor + + virtual int handle_timeout (const ACE_Time_Value ¤t_time, + const void *act = 0); + +private: + ECSupplier *supplier_impl_; +}; //class ECSupplier_Timeout_Handler + +#endif /* SUPPLIER_H */ diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/RtSchedEventChannel.idl b/TAO/orbsvcs/examples/RtEC/ECConfigurator/RtSchedEventChannel.idl new file mode 100644 index 00000000000..84720d12920 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/RtSchedEventChannel.idl @@ -0,0 +1,79 @@ +// $Id$ + +#ifndef RTSCHEDEVENTCHANNEL_IDL +#define RTSCHEDEVENTCHANNEL_IDL + +#include "orbsvcs/RtecScheduler.idl" +#include "orbsvcs/RtecEventComm.idl" +#include "orbsvcs/RtecEventChannelAdmin.idl" + +#pragma prefix "" + +module RtEventChannelAdmin +{ + typedef RtecScheduler::handle_t handle_t; + + typedef RtecScheduler::Criticality_t Criticality_t; + typedef RtecScheduler::Time Time; + typedef RtecScheduler::Period_t Period_t; + typedef RtecScheduler::Importance_t Importance_t; + typedef RtecScheduler::Quantum_t Quantum_t; + typedef RtecScheduler::Threads_t Threads_t; + typedef RtecScheduler::Info_Type_t Info_Type_t; + typedef long Phase_t; // 100 of nanoseconds + + struct SchedInfo { + Criticality_t criticality; + Time wc_time; + Time typical_time; + Time cached_time; + Period_t period; + Phase_t phase; + Importance_t importance; + Quantum_t quantum; + Threads_t threads; + Info_Type_t info_type; + }; + + interface RtSchedEventChannel + { + handle_t register_consumer(in string entry_point, + in SchedInfo info, + in RtecEventComm::_EventType type, + in RtecEventComm::PushConsumer consumer, + out RtecEventChannelAdmin::ProxyPushSupplier proxy_supplier) + raises (RtecScheduler::UNKNOWN_TASK, + RtecScheduler::INTERNAL, + RtecScheduler::SYNCHRONIZATION_FAILURE); + + handle_t register_supplier(in string entry_point, + in RtecEventComm::EventSourceID source, + in RtecEventComm::_EventType type, + in RtecEventComm::PushSupplier supplier, + out RtecEventChannelAdmin::ProxyPushConsumer proxy_consumer) + raises (RtecScheduler::UNKNOWN_TASK, + RtecScheduler::INTERNAL, + RtecScheduler::SYNCHRONIZATION_FAILURE); + + void add_dependency(in handle_t handle, + in handle_t dependency, + in long number_of_calls, + in RtecScheduler::Dependency_Type_t dependency_type) + raises (RtecScheduler::SYNCHRONIZATION_FAILURE, + RtecScheduler::UNKNOWN_TASK); + + void start() + raises (RtecScheduler::UNKNOWN_TASK, + RtecScheduler::INTERNAL, + RtecScheduler::SYNCHRONIZATION_FAILURE); + + void notify_gateway_connection(); + + void set_start_time(in Time start_time); + + RtecEventChannelAdmin::EventChannel event_channel(); + RtecScheduler::Scheduler scheduler(); + }; +}; + +#endif diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/Service_Handler.h b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Service_Handler.h new file mode 100644 index 00000000000..9a456ce2578 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/Service_Handler.h @@ -0,0 +1,30 @@ +/* -*- C++ -*- */ +// $Id$ +// +// ============================================================================ +// +// = LIBRARY +// ORBSVCS Real-time Event Channel examples +// +// = FILENAME +// Service_Handler +// +// = AUTHOR +// Bryan Thrall +// +// ============================================================================ + +#ifndef SVC_HANDLER_H +#define SVC_HANDLER_H + +#include "ace/CORBA_macros.h" + +class Service_Handler +{ +public: + virtual void handle_service_start(ACE_ENV_SINGLE_ARG_DECL) = 0; + + virtual void handle_service_stop(ACE_ENV_SINGLE_ARG_DECL) = 0; +}; + +#endif //SVC_HANDLER_H diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxTree.cpp b/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxTree.cpp index 9f776c2fad3..ed691d7b291 100644 --- a/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxTree.cpp +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxTree.cpp @@ -6,7 +6,8 @@ void visitableTypeToString (VisitableSyntax::element type, char *buf, int buflen) { if (buflen <= 0) return; - char* typestr[] = { + static int numtypes = 26; + static char* typestr[] = { "ECCONFIGURATION", "EVENT", "CRITICALITY", @@ -36,8 +37,13 @@ void visitableTypeToString (VisitableSyntax::element type, char *buf, int buflen "VALUE", "UNKNOWN_ELEMENT" }; + //assume type is just index - char *str = typestr[type]; + char *str = NULL; + if (type < numtypes && type >= 0) + str = typestr[type]; + else + str = typestr[numtypes]; //default to UNKNOWN for rest //copy over type string for(int i=0; i<buflen-1; ++i) { diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxTree.h b/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxTree.h index 67a892f1478..619a45562e7 100644 --- a/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxTree.h +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxTree.h @@ -18,6 +18,7 @@ #include "RtecSchedulerC.h" #include "ace/OS_String.h" +#include "ace/Hash_Map_Manager.h" #include <vector> @@ -54,6 +55,20 @@ class Phase; class Time; class Value; +// Typedefs +typedef std::vector<Event*> EventVector; +typedef std::vector<Timeout*> TimeoutVector; +typedef std::vector<LocalEventChannel*> LocalECVector; +typedef std::vector<RemoteEventChannel*> RemoteECVector; +typedef std::vector<Consumer*> ConsumerVector; +typedef std::vector<Supplier*> SupplierVector; +typedef std::vector<EventName*> EventNameVector; +typedef std::vector<SupplierName*> SupplierNameVector; +typedef std::vector<TimeoutName*> TimeoutNameVector; + +typedef ACE_Hash_Map_Manager<ACE_CString,VisitableSyntax*,ACE_Null_Mutex> NameTable; + + // Utility classes class VisitableSyntax @@ -122,7 +137,7 @@ public: {} // Value - int val; + long val; }; class Driver: public VisitableSyntax @@ -154,11 +169,11 @@ public: } // Children - std::vector<Event*> events; - std::vector<Timeout*> timeouts; - std::vector<LocalEventChannel*> localECs; - std::vector<RemoteEventChannel*> remoteECs; - Driver *driver; + EventVector events; + TimeoutVector timeouts; + LocalECVector localECs; + RemoteECVector remoteECs; + Driver *driver; }; class Event : public VisitableSyntax @@ -276,8 +291,8 @@ public: // Children SchedulingStrategy *schedulingstrategy; - std::vector<Consumer*> consumers; - std::vector<Supplier*> suppliers; + ConsumerVector consumers; + SupplierVector suppliers; // Attributes ACE_CString name; @@ -302,8 +317,8 @@ public: // Children IORFile *iorfile; - std::vector<Consumer*> consumers; - std::vector<Supplier*> suppliers; + ConsumerVector consumers; + SupplierVector suppliers; // Attributes ACE_CString name; @@ -376,7 +391,7 @@ public: } // Children - std::vector<EventName*> eventnames; + EventNameVector eventnames; }; class Dependants : public VisitableSyntax @@ -397,7 +412,7 @@ public: } // Children - std::vector<SupplierName*> suppliernames; + SupplierNameVector suppliernames; }; class Supplier : public VisitableSyntax @@ -443,7 +458,7 @@ public: } // Children - std::vector<EventName*> eventnames; + EventNameVector eventnames; }; class Triggers : public VisitableSyntax @@ -464,8 +479,8 @@ public: } // Children - std::vector<EventName*> eventnames; - std::vector<TimeoutName*> timeoutnames; + EventNameVector eventnames; + TimeoutNameVector timeoutnames; }; class TestDriver : public Driver diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxVisitor.h b/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxVisitor.h index a123511ea60..0cf28fca48c 100644 --- a/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxVisitor.h +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/SyntaxVisitor.h @@ -49,7 +49,7 @@ class Value; class SyntaxVisitor { public: - virtual int parseVisitableSyntax (VisitableSyntax vs, void *arg) + virtual int parseVisitableSyntax (VisitableSyntax* vs, void *arg) ACE_THROW_SPEC ((ACEXML_SAXException)) = 0; virtual int parseECConfiguration (ECConfiguration* vs, void *arg) diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/clientconfig.xml b/TAO/orbsvcs/examples/RtEC/ECConfigurator/clientconfig.xml index c170e6b2ee0..bc30cc5222d 100644 --- a/TAO/orbsvcs/examples/RtEC/ECConfigurator/clientconfig.xml +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/clientconfig.xml @@ -11,6 +11,7 @@ <Event name="Subtask1.1 Trigger" > <!-- name must be unique among Events --> <Period>200</Period> <!-- in msec --> + <Phase>0</Phase> <!-- in msec --> <Criticality value="VERY_LOW" /> <Importance value="VERY_LOW" /> <WorstExecution>50</WorstExecution> <!-- in msec --> @@ -19,6 +20,7 @@ <Event name="Subtask1.2 Trigger" > <Period>200</Period> <!-- in msec --> + <Phase>0</Phase> <!-- in msec --> <Criticality value="VERY_LOW" /> <Importance value="VERY_LOW" /> <WorstExecution>50</WorstExecution> <!-- in msec --> diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/ecconfigurator.mpc b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ecconfigurator.mpc index 71deb191b84..3e7b82f9ca3 100644 --- a/TAO/orbsvcs/examples/RtEC/ECConfigurator/ecconfigurator.mpc +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/ecconfigurator.mpc @@ -1,6 +1,7 @@ project(configurable_ec): orbsvcsexe, rtevent, rtsched, rtschedevent, rtkokyuevent, kokyu, acexml { exename = ConfigurableEC libpaths += . + idlflags += -I$(TAO_ROOT) -I$(TAO_ROOT)/orbsvcs -Ge 1 -Wb,pre_include=ace/pre.h -Wb,post_include=ace/post.h includes += $(TAO_ROOT)/orbsvcs $(TAO_ROOT)/orbsvcs/orbsvcs Source_Files { @@ -8,8 +9,23 @@ project(configurable_ec): orbsvcsexe, rtevent, rtsched, rtschedevent, rtkokyueve Configurator_SyntaxHandler.cpp SyntaxTree.cpp ConfigurableEC.cpp + Kokyu_EC.cpp + ECConsumer.cpp + ECSupplier.cpp + } + + Header_Files { + Configurator_ParseHandler.h + Configurator_SyntaxHandler.h + SyntaxTree.h + SyntaxVisitor.h + Kokyu_EC.h + ECConsumer.h + ECSupplier.h + Service_Handler.h } IDL_Files { + RtSchedEventChannel.idl } } diff --git a/TAO/orbsvcs/examples/RtEC/ECConfigurator/serverconfig.xml b/TAO/orbsvcs/examples/RtEC/ECConfigurator/serverconfig.xml index 7dcb310839a..5684bc5e9a8 100644 --- a/TAO/orbsvcs/examples/RtEC/ECConfigurator/serverconfig.xml +++ b/TAO/orbsvcs/examples/RtEC/ECConfigurator/serverconfig.xml @@ -12,6 +12,7 @@ <Event name="Subtask1.1 Trigger" > <!-- name must be unique among Events --> <Period>200</Period> <!-- in msec --> + <Phase>0</Phase> <!-- in msec --> <Criticality value="VERY_LOW" /> <Importance value="VERY_LOW" /> <WorstExecution>50</WorstExecution> <!-- in msec --> @@ -20,6 +21,7 @@ <Event name="Subtask1.2 Trigger" > <Period>200</Period> <!-- in msec --> + <Phase>0</Phase> <!-- in msec --> <Criticality value="VERY_LOW" /> <Importance value="VERY_LOW" /> <WorstExecution>50</WorstExecution> <!-- in msec --> |