SUMO - Simulation of Urban MObility

SUMOTime.h

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