SUMO - Simulation of Urban MObility
SUMOTime.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // Variables, methods, and tools for internal time representation
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef SUMOTime_h
23 #define SUMOTime_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <limits>
36 #include <string>
37 #include "UtilExceptions.h"
38 
39 
40 // ===========================================================================
41 // type definitions
42 // ===========================================================================
43 typedef long long int SUMOTime;
44 #define SUMOTime_MAX std::numeric_limits<SUMOTime>::max()
45 #define SUMOTime_MIN std::numeric_limits<SUMOTime>::min()
46 #define SUMOTIME_MAXSTRING "9223372036854774" // SUMOTime_MAX / 1000 - 1 (because of rounding errors)
47 
48 #ifndef HAVE_SUBSECOND_TIMESTEPS
49 // the step length in s
50 #define DELTA_T 1
51 
52 #define TS (static_cast<SUMOReal>(1.))
53 
54 // x*deltaT
55 #define SPEED2DIST(x) (x)
56 // x/deltaT
57 #define DIST2SPEED(x) (x)
58 // x*deltaT*deltaT
59 #define ACCEL2DIST(x) (x)
60 // x*deltaT
61 #define ACCEL2SPEED(x) (x)
62 // x/deltaT
63 #define SPEED2ACCEL(x) (x)
64 
65 #define STEPS2TIME(x) (static_cast<SUMOReal>(x))
66 #define TIME2STEPS(x) (static_cast<SUMOTime>(x))
67 #define STEPFLOOR(x) (x)
68 #define STEPS2MS(x) ((x)*1000)
69 
70 #else
71 
72 // the step length in ms
73 extern SUMOTime DELTA_T;
74 
75 // the step length in seconds as SUMOReal
76 #define TS (static_cast<SUMOReal>(DELTA_T/1000.))
77 
78 // x*deltaT
79 #define SPEED2DIST(x) ((x)*TS)
80 // x/deltaT
81 #define DIST2SPEED(x) ((x)/TS)
82 // x*deltaT*deltaT
83 #define ACCEL2DIST(x) ((x)*TS*TS)
84 // x*deltaT
85 #define ACCEL2SPEED(x) ((x)*TS)
86 // x*deltaT
87 #define SPEED2ACCEL(x) ((x)/TS)
88 
89 #define STEPS2TIME(x) (static_cast<SUMOReal>((x)/1000.))
90 #define TIME2STEPS(x) (static_cast<SUMOTime>((x)*1000))
91 #define STEPFLOOR(x) (int(x/DELTA_T)*DELTA_T)
92 #define STEPS2MS(x) (x)
93 
94 #endif
95 
96 #define SIMTIME STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep())
97 
98 // ===========================================================================
99 // method declarations
100 // ===========================================================================
101 SUMOTime string2time(const std::string& r);
102 std::string time2string(SUMOTime t);
103 
104 
105 #endif
106 
107 /****************************************************************************/
108 
long long int SUMOTime
Definition: SUMOTime.h:43
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:61
SUMOTime string2time(const std::string &r)
Definition: SUMOTime.cpp:48
#define DELTA_T
Definition: SUMOTime.h:50