SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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.sourceforge.net/
12 // Copyright (C) 2001-2012 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 <climits>
36 #include <string>
37 #include "UtilExceptions.h"
38 
39 
40 // ===========================================================================
41 // type definitions
42 // ===========================================================================
43 typedef int SUMOTime;
44 #define SUMOTime_MAX INT_MAX
45 #define SUMOTime_MIN INT_MIN
46 #define SUMOTIME_MAXSTRING "2147483" // INT_MAX / 1000
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 
69 #else
70 
71 // the step length in ms
72 extern SUMOTime DELTA_T;
73 
74 // the step length in seconds as SUMOReal
75 #define TS (static_cast<SUMOReal>(DELTA_T/1000.))
76 
77 // x*deltaT
78 #define SPEED2DIST(x) ((x)*TS)
79 // x/deltaT
80 #define DIST2SPEED(x) ((x)/TS)
81 // x*deltaT*deltaT
82 #define ACCEL2DIST(x) ((x)*TS*TS)
83 // x*deltaT
84 #define ACCEL2SPEED(x) ((x)*TS)
85 // x*deltaT
86 #define SPEED2ACCEL(x) ((x)/TS)
87 
88 #define STEPS2TIME(x) (static_cast<SUMOReal>((x)/1000.))
89 #define TIME2STEPS(x) (static_cast<SUMOTime>((x)*1000))
90 #define STEPFLOOR(x) (int(x/DELTA_T)*DELTA_T)
91 
92 #endif
93 
94 
95 // ===========================================================================
96 // method declarations
97 // ===========================================================================
98 SUMOTime string2time(const std::string& r) throw(EmptyData, NumberFormatException, ProcessError);
99 std::string time2string(SUMOTime t);
100 
101 
102 #endif
103 
104 /****************************************************************************/
105