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_MAXSTRING "2147483" // INT_MAX / 1000
46 
47 #ifndef HAVE_SUBSECOND_TIMESTEPS
48 // the step length in s
49 #define DELTA_T 1
50 
51 #define TS (static_cast<SUMOReal>(1.))
52 
53 // x*deltaT
54 #define SPEED2DIST(x) (x)
55 // x/deltaT
56 #define DIST2SPEED(x) (x)
57 // x*deltaT*deltaT
58 #define ACCEL2DIST(x) (x)
59 // x*deltaT
60 #define ACCEL2SPEED(x) (x)
61 // x/deltaT
62 #define SPEED2ACCEL(x) (x)
63 
64 #define STEPS2TIME(x) (static_cast<SUMOReal>(x))
65 #define TIME2STEPS(x) (static_cast<SUMOTime>(x))
66 #define STEPFLOOR(x) (x)
67 
68 #else
69 
70 // the step length in ms
71 extern SUMOTime DELTA_T;
72 
73 // the step length in seconds as SUMOReal
74 #define TS (static_cast<SUMOReal>(DELTA_T/1000.))
75 
76 // x*deltaT
77 #define SPEED2DIST(x) ((x)*TS)
78 // x/deltaT
79 #define DIST2SPEED(x) ((x)/TS)
80 // x*deltaT*deltaT
81 #define ACCEL2DIST(x) ((x)*TS*TS)
82 // x*deltaT
83 #define ACCEL2SPEED(x) ((x)*TS)
84 // x*deltaT
85 #define SPEED2ACCEL(x) ((x)/TS)
86 
87 #define STEPS2TIME(x) (static_cast<SUMOReal>((x)/1000.))
88 #define TIME2STEPS(x) (static_cast<SUMOTime>((x)*1000))
89 #define STEPFLOOR(x) (int(x/DELTA_T)*DELTA_T)
90 
91 #endif
92 
93 
94 // ===========================================================================
95 // method declarations
96 // ===========================================================================
97 SUMOTime string2time(const std::string& r) throw(EmptyData, NumberFormatException, ProcessError);
98 std::string time2string(SUMOTime t) ;
99 
100 
101 #endif
102 
103 /****************************************************************************/
104