SUMOTime.cpp File Reference

#include <config.h>
#include <sstream>
#include "SUMOTime.h"
#include "TplConvert.h"

Go to the source code of this file.

Functions

SUMOTime string2time (const std::string &r) throw (EmptyData, NumberFormatException)
std::string time2string (SUMOTime t) throw ()


Function Documentation

SUMOTime string2time ( const std::string &  r  )  throw (EmptyData, NumberFormatException)

Definition at line 45 of file SUMOTime.cpp.

References TplConvert< E >::_2int().

Referenced by MSDetectorControl::addDetectorAndInterval(), NLHandler::addEdgeLaneMeanData(), ROLoader::buildNamedHandler(), NLTriggerBuilder::buildVaporizer(), MSDevice_Routing::buildVehicleDevices(), MSRouteHandler::closeFlow(), MSRouteHandler::closeVehicle(), traci::TraCIServer::commandChangeRoute(), computeRoutes(), FXIMPLEMENT(), main(), MSNet::MSNet(), MSPhaseDefinition::MSPhaseDefinition(), ROLoader::openRoutes(), traci::TraCIHandler::openVehicleTag(), SUMOVehicleParserHelper::parseFlowAttributes(), readDetectorFlows(), testclient::TraCITestClient::run(), GUILoadThread::run(), MSFrame::setMSGlobals(), NLHandler::setOffset(), and startComputation().

00045                                                                         {
00046     size_t idx = r.find('.');
00047     if (idx==std::string::npos) {
00048         // no sub-seconds
00049         return TplConvert<char>::_2int(r.c_str())*1000;
00050     }
00051     int secs = idx>0 ? TplConvert<char>::_2int(r.substr(0, idx).c_str()) : 0;
00052     int subsecs = TplConvert<char>::_2int((r.substr(idx+1)+"0000").substr(0,3).c_str()) * 10;
00053     do {
00054         subsecs = subsecs / 10;
00055     } while (idx<r.length()&&r[idx]=='0');
00056     return secs*1000 + subsecs;
00057 }

std::string time2string ( SUMOTime  t  )  throw ()

Definition at line 61 of file SUMOTime.cpp.

References SUMOReal.

Referenced by testclient::TraCITestClient::commandChangeLane(), testclient::TraCITestClient::commandGetTLStatus(), testclient::TraCITestClient::commandSimulationStep(), testclient::TraCITestClient::commandSlowDown(), testclient::TraCITestClient::commandStopNode(), MSPersonControl::erase(), MSVTypeProbe::execute(), Command_SaveTLSSwitchStates::execute(), Command_SaveTLSSwitches::execute(), Command_SaveTLSState::execute(), GUIVehicle::getParameterWindow(), GUIApplicationWindow::handleEvent_SimulationLoaded(), GUIApplicationWindow::handleEvent_SimulationStep(), main(), MSEmitter::MSEmitter_FileTriggeredChild::myStartElement(), ROLoader::openRoutes(), MSNet::postSimStepOutput(), MSNet::preSimStepOutput(), ROLoader::processRoutesStepWise(), MSVehicleControl::scheduleVehicleRemoval(), MSPerson::MSPersonStage_Waiting::tripInfoOutput(), MSPerson::MSPersonStage_Driving::tripInfoOutput(), MSPerson::MSPersonStage_Walking::tripInfoOutput(), testclient::TraCITestClient::validateGetTLStatus(), testclient::TraCITestClient::validateSimulationStep(), testclient::TraCITestClient::validateStopNode(), MSXMLRawOut::write(), SUMOVehicleParameter::writeAs(), MSNet::writeOutput(), ROLoader::writeStats(), MSRouteProbe::writeXMLOutput(), MSMeanData::writeXMLOutput(), MSInductLoop::writeXMLOutput(), MSE3Collector::writeXMLOutput(), MSE2Collector::writeXMLOutput(), and MSVehicle::writeXMLRoute().

00061                                 {
00062     std::ostringstream oss;
00063     oss << ((SUMOReal) t / 1000.);
00064     std::string ret = oss.str();
00065     size_t idx = ret.find('.');
00066     if (idx==std::string::npos) {
00067         return ret + ".00";
00068     }
00069     return (ret+"00").substr(0, idx+3);
00070 }


Generated on Wed May 5 00:06:39 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6