SUMO - Simulation of Urban MObility
SUMOTime.h
Go to the documentation of this file.
00001 /****************************************************************************/
00009 // Variables, methods, and tools for internal time representation
00010 /****************************************************************************/
00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00013 /****************************************************************************/
00014 //
00015 //   This file is part of SUMO.
00016 //   SUMO is free software: you can redistribute it and/or modify
00017 //   it under the terms of the GNU General Public License as published by
00018 //   the Free Software Foundation, either version 3 of the License, or
00019 //   (at your option) any later version.
00020 //
00021 /****************************************************************************/
00022 #ifndef SUMOTime_h
00023 #define SUMOTime_h
00024 
00025 
00026 // ===========================================================================
00027 // included modules
00028 // ===========================================================================
00029 #ifdef _MSC_VER
00030 #include <windows_config.h>
00031 #else
00032 #include <config.h>
00033 #endif
00034 
00035 #include <climits>
00036 #include <string>
00037 #include "UtilExceptions.h"
00038 
00039 
00040 // ===========================================================================
00041 // type definitions
00042 // ===========================================================================
00043 typedef int SUMOTime;
00044 #define SUMOTime_MAX INT_MAX
00045 #define SUMOTIME_MAXSTRING "2147483" // INT_MAX / 1000
00046 
00047 #ifndef HAVE_SUBSECOND_TIMESTEPS
00048 // the step length in s
00049 #define DELTA_T 1
00050 
00051 #define TS (static_cast<SUMOReal>(1.))
00052 
00053 // x*deltaT
00054 #define SPEED2DIST(x) (x)
00055 // x/deltaT
00056 #define DIST2SPEED(x) (x)
00057 // x*deltaT*deltaT
00058 #define ACCEL2DIST(x) (x)
00059 // x*deltaT
00060 #define ACCEL2SPEED(x) (x)
00061 // x/deltaT
00062 #define SPEED2ACCEL(x) (x)
00063 
00064 #define STEPS2TIME(x) (static_cast<SUMOReal>(x))
00065 #define TIME2STEPS(x) (static_cast<SUMOTime>(x))
00066 #define STEPFLOOR(x) (x)
00067 
00068 #else
00069 
00070 // the step length in ms
00071 extern SUMOTime DELTA_T;
00072 
00073 // the step length in seconds as SUMOReal
00074 #define TS (static_cast<SUMOReal>(DELTA_T/1000.))
00075 
00076 // x*deltaT
00077 #define SPEED2DIST(x) ((x)*TS)
00078 // x/deltaT
00079 #define DIST2SPEED(x) ((x)/TS)
00080 // x*deltaT*deltaT
00081 #define ACCEL2DIST(x) ((x)*TS*TS)
00082 // x*deltaT
00083 #define ACCEL2SPEED(x) ((x)*TS)
00084 // x*deltaT
00085 #define SPEED2ACCEL(x) ((x)/TS)
00086 
00087 #define STEPS2TIME(x) (static_cast<SUMOReal>((x)/1000.))
00088 #define TIME2STEPS(x) (static_cast<SUMOTime>((x)*1000))
00089 #define STEPFLOOR(x) (int(x/DELTA_T)*DELTA_T)
00090 
00091 #endif
00092 
00093 
00094 // ===========================================================================
00095 // method declarations
00096 // ===========================================================================
00097 SUMOTime string2time(const std::string& r) throw(EmptyData, NumberFormatException, ProcessError);
00098 std::string time2string(SUMOTime t) ;
00099 
00100 
00101 #endif
00102 
00103 /****************************************************************************/
00104 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines