void MSTriggeredXMLReader::myInit() { try { myParser = XMLSubSys::getSAXReader(*this); if (!myParser->parseFirst(getFileName().c_str(), myToken)) { throw ProcessError("Can not read XML-file '" + getFileName() + "'."); } } catch (SAXException& e) { throw ProcessError(TplConvert<XMLCh>::_2str(e.getMessage())); } catch (XMLException& e) { throw ProcessError(TplConvert<XMLCh>::_2str(e.getMessage())); } if (readNextTriggered()) { if (myOffset < MSNet::getInstance()->getCurrentTimeStep()) { myOffset = MSNet::getInstance()->getCurrentTimeStep() + 1; // !!! Warning? } } else { myHaveMore = false; } }
SUMOTime MSTriggeredReader::wrappedExecute(SUMOTime current) { if (!isInitialised()) { init(); } SUMOTime next = current; // loop until the next action lies in the future while (current == next) { // run the next action // if it could be accomplished... if (processNextEntryReaderTriggered()) { // read the next one if (readNextTriggered()) { // set the time for comparison if a next one exists next = myOffset; } else { // leave if no further exists return 0; } } else { // action could not be accomplished; try next time step return DELTA_T; } } // come back if the next action shall be executed if (myOffset - current <= 0) { // current is delayed; return DELTA_T; } return myOffset - current; }