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-2017 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 // the step length in ms
49 extern SUMOTime DELTA_T;
50 
51 // the step length in seconds as double
52 #define TS (static_cast<double>(DELTA_T/1000.))
53 
54 // x*deltaT
55 #define SPEED2DIST(x) ((x)*TS)
56 // x/deltaT
57 #define DIST2SPEED(x) ((x)/TS)
58 // x*deltaT*deltaT
59 #define ACCEL2DIST(x) ((x)*TS*TS)
60 // x*deltaT
61 #define ACCEL2SPEED(x) ((x)*TS)
62 // x*deltaT
63 #define SPEED2ACCEL(x) ((x)/TS)
64 
65 #define STEPS2TIME(x) (static_cast<double>((x)/1000.))
66 #define TIME2STEPS(x) (static_cast<SUMOTime>((x)*1000))
67 #define STEPFLOOR(x) (int(x/DELTA_T)*DELTA_T)
68 #define STEPS2MS(x) (x)
69 
70 #define SIMTIME STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep())
71 
72 // ===========================================================================
73 // method declarations
74 // ===========================================================================
75 SUMOTime string2time(const std::string& r);
76 std::string time2string(SUMOTime t);
77 
78 
79 #endif
80 
81 /****************************************************************************/
82 
long long int SUMOTime
Definition: SUMOTime.h:43
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:60
SUMOTime string2time(const std::string &r)
Definition: SUMOTime.cpp:47
SUMOTime DELTA_T
Definition: SUMOTime.cpp:40
long long int SUMOTime
Definition: TraCIDefs.h:52