SUMO - Simulation of Urban MObility
SUMOTime.cpp
Go to the documentation of this file.
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3
// Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4
/****************************************************************************/
5
//
6
// This program and the accompanying materials
7
// are made available under the terms of the Eclipse Public License v2.0
8
// which accompanies this distribution, and is available at
9
// http://www.eclipse.org/legal/epl-v20.html
10
//
11
/****************************************************************************/
19
// Variables, methods, and tools for internal time representation
20
/****************************************************************************/
21
// ===========================================================================
22
// included modules
23
// ===========================================================================
24
#ifdef _MSC_VER
25
#include <
windows_config.h
>
26
#else
27
#include <
config.h
>
28
#endif
29
30
#include <sstream>
31
#include "
SUMOTime.h
"
32
#include "
TplConvert.h
"
33
#include "
StdDefs.h
"
34
35
36
// ===========================================================================
37
// type definitions
38
// ===========================================================================
39
SUMOTime
DELTA_T
= 1000;
40
41
42
// ===========================================================================
43
// method definitions
44
// ===========================================================================
45
SUMOTime
46
string2time
(
const
std::string& r) {
47
double
time;
48
std::istringstream buf(r);
49
buf >> time;
50
if
(buf.fail() || time >
STEPS2TIME
(
SUMOTime_MAX
)) {
51
throw
ProcessError
(
"Input string '"
+ r +
"' is not a valid number or exceeds the time value range."
);
52
}
else
{
53
return
TIME2STEPS
(time);
54
}
55
}
56
57
58
std::string
59
time2string
(
SUMOTime
t) {
60
// 123456 -> "12.34"
61
std::ostringstream oss;
62
oss.setf(oss.fixed);
63
oss.precision(
gPrecision
);
64
oss <<
STEPS2TIME
(t);
65
return
oss.str();
66
}
67
68
69
/****************************************************************************/
70
windows_config.h
gPrecision
int gPrecision
the precision for floating point outputs
Definition:
StdDefs.cpp:29
time2string
std::string time2string(SUMOTime t)
Definition:
SUMOTime.cpp:59
config.h
DELTA_T
SUMOTime DELTA_T
Definition:
SUMOTime.cpp:39
TIME2STEPS
#define TIME2STEPS(x)
Definition:
SUMOTime.h:66
SUMOTime_MAX
#define SUMOTime_MAX
Definition:
TraCIDefs.h:52
STEPS2TIME
#define STEPS2TIME(x)
Definition:
SUMOTime.h:64
StdDefs.h
string2time
SUMOTime string2time(const std::string &r)
Definition:
SUMOTime.cpp:46
TplConvert.h
SUMOTime
long long int SUMOTime
Definition:
TraCIDefs.h:51
ProcessError
Definition:
UtilExceptions.h:48
SUMOTime.h
src
utils
common
SUMOTime.cpp
Generated on Sun Dec 24 2017 17:07:43 for SUMO - Simulation of Urban MObility by
1.8.13