author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Thu, 10 Apr 2008 12:59:31 -0700 | |
changeset 2947 | b0fec3381418 |
parent 2577 | 5b41cb5c3fcf |
child 2953 | db884a56c5c1 |
permissions | -rw-r--r-- |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
144
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
* Copyright (c) 2005,2006 INRIA |
680
0bbe0e4d73c6
add reference to Emmanuelle in Authors/Copyright
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
679
diff
changeset
|
4 |
* Copyright (c) 2007 Emmanuelle Laprise |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* This program is free software; you can redistribute it and/or modify |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
* it under the terms of the GNU General Public License version 2 as |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation; |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* GNU General Public License for more details. |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* along with this program; if not, write to the Free Software |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
* |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
680
0bbe0e4d73c6
add reference to Emmanuelle in Authors/Copyright
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
679
diff
changeset
|
20 |
* TimeStep support by Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca> |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
*/ |
679
0c4773ca0f29
avoid cyclic dependency between Simulator and Time code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
678
diff
changeset
|
22 |
#include "nstime.h" |
372
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
23 |
#include "ns3/fatal-error.h" |
2577
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
24 |
#include "ns3/global-value.h" |
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
25 |
#include "ns3/enum.h" |
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
26 |
#include "ns3/string.h" |
2390
7e6dfae536cd
add Value support to Time
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2170
diff
changeset
|
27 |
#include "ns3/object.h" |
2577
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
28 |
#include "ns3/config.h" |
679
0c4773ca0f29
avoid cyclic dependency between Simulator and Time code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
678
diff
changeset
|
29 |
#include <math.h> |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
30 |
|
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
31 |
namespace ns3 { |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
32 |
|
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
33 |
namespace TimeStepPrecision { |
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
34 |
|
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
35 |
static const uint64_t MS_FACTOR = (uint64_t)pow(10,3); |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
36 |
static const uint64_t US_FACTOR = (uint64_t)pow(10,6); |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
37 |
static const uint64_t NS_FACTOR = (uint64_t)pow(10,9); |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
38 |
static const uint64_t PS_FACTOR = (uint64_t)pow(10,12); |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
39 |
static const uint64_t FS_FACTOR = (uint64_t)pow(10,15); |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
40 |
static uint64_t g_tsPrecFactor = NS_FACTOR; |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
41 |
|
2577
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
42 |
static GlobalValue g_precisionDefaultValue ("TimeStepPrecision", |
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
43 |
"The time unit of the internal 64 bit integer time.", |
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
44 |
Enum (NS), |
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
45 |
MakeEnumChecker (NS, "NS", |
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
46 |
S, "S", |
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
47 |
MS, "MS", |
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
48 |
US, "US", |
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
49 |
PS, "PS", |
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
50 |
FS, "FS") |
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
51 |
); |
684
333ec02c9cc9
add DefaultValue support for TimeStepPrecision
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
680
diff
changeset
|
52 |
|
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
53 |
precision_t |
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
54 |
Get (void) |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
55 |
{ |
2577
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
56 |
Enum v = g_precisionDefaultValue.GetValue (); |
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
57 |
return (precision_t) v.Get (); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
58 |
} |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
59 |
|
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
60 |
void |
684
333ec02c9cc9
add DefaultValue support for TimeStepPrecision
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
680
diff
changeset
|
61 |
Set (precision_t precision) |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
62 |
{ |
2577
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
63 |
g_precisionDefaultValue.SetValue (Enum (precision)); |
684
333ec02c9cc9
add DefaultValue support for TimeStepPrecision
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
680
diff
changeset
|
64 |
g_tsPrecFactor = (uint64_t)pow(10, precision); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
65 |
} |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
66 |
|
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
67 |
} // namespace TimeStepPrecision |
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
68 |
|
372
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
69 |
TimeUnit<1>::TimeUnit(const std::string& s) |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
70 |
{ |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
71 |
std::string::size_type n = s.find_first_not_of("0123456789."); |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
72 |
if (n != std::string::npos) |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
73 |
{ // Found non-numeric |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
74 |
double r = atof(s.substr(0, n).c_str()); |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
75 |
std::string trailer = s.substr(n, std::string::npos); |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
76 |
if (trailer == std::string("s")) |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
77 |
{ |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
78 |
m_data = HighPrecision (r * TimeStepPrecision::g_tsPrecFactor); |
372
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
79 |
return; |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
80 |
} |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
81 |
if (trailer == std::string("ms")) |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
82 |
{ |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
83 |
m_data = HighPrecision ((int64_t)(r * (TimeStepPrecision::g_tsPrecFactor/pow(10,3))), |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
84 |
false); |
372
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
85 |
return; |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
86 |
} |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
87 |
if (trailer == std::string("us")) |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
88 |
{ |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
89 |
m_data = HighPrecision ((int64_t)(r * (TimeStepPrecision::g_tsPrecFactor/pow(10,6))), |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
90 |
false); |
372
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
91 |
return; |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
92 |
} |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
93 |
if (trailer == std::string("ns")) |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
94 |
{ |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
95 |
m_data = HighPrecision ((int64_t)(r * (TimeStepPrecision::g_tsPrecFactor/pow(10,9))), |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
96 |
false); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
97 |
return; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
98 |
} |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
99 |
if (trailer == std::string("ps")) |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
100 |
{ |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
101 |
m_data = HighPrecision ((int64_t)(r * (TimeStepPrecision::g_tsPrecFactor/pow(10,12))), |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
102 |
false); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
103 |
return; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
104 |
} |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
105 |
if (trailer == std::string("fs")) |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
106 |
{ |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
107 |
m_data = HighPrecision ((int64_t)(r * (TimeStepPrecision::g_tsPrecFactor/pow(10,15))), |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
108 |
false); |
372
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
109 |
return; |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
110 |
} |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
111 |
NS_FATAL_ERROR("Can't Parse Time "<<s); |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
112 |
} |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
113 |
//else |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
114 |
//they didn't provide units, assume seconds |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
115 |
m_data = HighPrecision (atof(s.c_str()) * TimeStepPrecision::g_tsPrecFactor); |
372
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
116 |
} |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
117 |
|
143
552ff26b4224
new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
118 |
double |
339
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
119 |
TimeUnit<1>::GetSeconds (void) const |
36
e622fb7a8262
use ns as internal time and export time as ns.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
25
diff
changeset
|
120 |
{ |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
121 |
double timeValue = GetHighPrecision ().GetDouble (); |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
122 |
return timeValue/TimeStepPrecision::g_tsPrecFactor; |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
123 |
} |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
124 |
|
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
125 |
int64_t |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
126 |
TimeUnit<1>::ConvertToUnits (int64_t timeValue, uint64_t unitFactor) const |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
127 |
{ |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
128 |
uint64_t precFactor; |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
129 |
// In order to avoid conversion to double, precFactor can't be less 1 |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
130 |
if (TimeStepPrecision::g_tsPrecFactor < unitFactor) |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
131 |
{ |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
132 |
precFactor = unitFactor / TimeStepPrecision::g_tsPrecFactor; |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
133 |
timeValue = timeValue * precFactor; |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
134 |
} |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
135 |
else |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
136 |
{ |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
137 |
precFactor = TimeStepPrecision::g_tsPrecFactor / unitFactor; |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
138 |
timeValue = timeValue / precFactor; |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
139 |
} |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
140 |
return timeValue; |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
141 |
} |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
142 |
|
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
143 |
|
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
144 |
int64_t |
339
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
145 |
TimeUnit<1>::GetMilliSeconds (void) const |
36
e622fb7a8262
use ns as internal time and export time as ns.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
25
diff
changeset
|
146 |
{ |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
147 |
int64_t ts = GetTimeStep(); |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
148 |
int64_t ms = ConvertToUnits(ts, TimeStepPrecision::MS_FACTOR); |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
149 |
|
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
150 |
return ms; |
143
552ff26b4224
new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
151 |
} |
144
f07f6fb0f660
fix Time::ApproximateTo* return type
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
143
diff
changeset
|
152 |
int64_t |
339
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
153 |
TimeUnit<1>::GetMicroSeconds (void) const |
143
552ff26b4224
new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
154 |
{ |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
155 |
int64_t ts = GetTimeStep(); |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
156 |
int64_t us = ConvertToUnits(ts, TimeStepPrecision::US_FACTOR); |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
157 |
|
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
158 |
return us; |
36
e622fb7a8262
use ns as internal time and export time as ns.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
25
diff
changeset
|
159 |
} |
144
f07f6fb0f660
fix Time::ApproximateTo* return type
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
143
diff
changeset
|
160 |
int64_t |
339
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
161 |
TimeUnit<1>::GetNanoSeconds (void) const |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
162 |
{ |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
163 |
int64_t ts = GetTimeStep(); |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
164 |
int64_t ns = ConvertToUnits(ts, TimeStepPrecision::NS_FACTOR); |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
165 |
|
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
166 |
return ns; |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
167 |
} |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
168 |
int64_t |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
169 |
TimeUnit<1>::GetPicoSeconds (void) const |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
170 |
{ |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
171 |
int64_t ts = GetTimeStep(); |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
172 |
int64_t ps = ConvertToUnits(ts, TimeStepPrecision::PS_FACTOR); |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
173 |
|
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
174 |
return ps; |
36
e622fb7a8262
use ns as internal time and export time as ns.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
25
diff
changeset
|
175 |
} |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
176 |
int64_t |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
177 |
TimeUnit<1>::GetFemtoSeconds (void) const |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
178 |
{ |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
179 |
int64_t ts = GetTimeStep(); |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
180 |
int64_t fs = ConvertToUnits(ts, TimeStepPrecision::FS_FACTOR); |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
181 |
|
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
182 |
return fs; |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
183 |
} |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
184 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
185 |
/** |
684
333ec02c9cc9
add DefaultValue support for TimeStepPrecision
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
680
diff
changeset
|
186 |
* This returns the value with the precision returned by TimeStepPrecision::Get |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
187 |
*/ |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
188 |
int64_t |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
189 |
TimeUnit<1>::GetTimeStep (void) const |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
190 |
{ |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
191 |
int64_t timeValue = GetHighPrecision ().GetInteger (); |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
192 |
return timeValue; |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
193 |
} |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
194 |
|
143
552ff26b4224
new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
195 |
|
209
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
196 |
std::ostream& |
2409
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
197 |
operator<< (std::ostream& os, const Time & time) |
209
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
198 |
{ |
911
de8102a51fbf
append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
684
diff
changeset
|
199 |
std::string unit; |
de8102a51fbf
append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
684
diff
changeset
|
200 |
switch (TimeStepPrecision::Get ()) { |
de8102a51fbf
append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
684
diff
changeset
|
201 |
case TimeStepPrecision::S: |
de8102a51fbf
append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
684
diff
changeset
|
202 |
unit = "s"; |
de8102a51fbf
append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
684
diff
changeset
|
203 |
break; |
de8102a51fbf
append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
684
diff
changeset
|
204 |
case TimeStepPrecision::MS: |
de8102a51fbf
append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
684
diff
changeset
|
205 |
unit = "ms"; |
de8102a51fbf
append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
684
diff
changeset
|
206 |
break; |
de8102a51fbf
append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
684
diff
changeset
|
207 |
case TimeStepPrecision::US: |
de8102a51fbf
append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
684
diff
changeset
|
208 |
unit = "us"; |
de8102a51fbf
append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
684
diff
changeset
|
209 |
break; |
de8102a51fbf
append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
684
diff
changeset
|
210 |
case TimeStepPrecision::NS: |
de8102a51fbf
append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
684
diff
changeset
|
211 |
unit = "ns"; |
de8102a51fbf
append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
684
diff
changeset
|
212 |
break; |
de8102a51fbf
append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
684
diff
changeset
|
213 |
case TimeStepPrecision::PS: |
de8102a51fbf
append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
684
diff
changeset
|
214 |
unit = "ps"; |
de8102a51fbf
append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
684
diff
changeset
|
215 |
break; |
de8102a51fbf
append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
684
diff
changeset
|
216 |
case TimeStepPrecision::FS: |
de8102a51fbf
append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
684
diff
changeset
|
217 |
unit = "fs"; |
de8102a51fbf
append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
684
diff
changeset
|
218 |
break; |
de8102a51fbf
append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
684
diff
changeset
|
219 |
} |
de8102a51fbf
append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
684
diff
changeset
|
220 |
os << time.GetTimeStep () << unit; |
209
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
221 |
return os; |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
222 |
} |
2409
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
223 |
std::istream& operator>> (std::istream& is, Time & time) |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
224 |
{ |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
225 |
std::string value; |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
226 |
is >> value; |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
227 |
std::string::size_type n = value.find_first_not_of("0123456789."); |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
228 |
if (n == std::string::npos) |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
229 |
{ |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
230 |
is.setstate (std::ios_base::failbit); |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
231 |
return is; |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
232 |
} |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
233 |
std::string trailer = value.substr(n, value.size ()-1-n); |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
234 |
std::istringstream iss; |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
235 |
iss.str (value.substr(0, n)); |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
236 |
|
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
237 |
if (trailer == std::string("s")) |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
238 |
{ |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
239 |
double v; |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
240 |
iss >> v; |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
241 |
time = Seconds (v); |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
242 |
return is; |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
243 |
} |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
244 |
uint64_t integer; |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
245 |
iss >> integer; |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
246 |
if (is.bad () || is.fail ()) |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
247 |
{ |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
248 |
is.setstate (std::ios_base::failbit); |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
249 |
} |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
250 |
else if (trailer == std::string("ms")) |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
251 |
{ |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
252 |
time = MilliSeconds (integer); |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
253 |
} |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
254 |
else if (trailer == std::string("us")) |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
255 |
{ |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
256 |
time = MicroSeconds (integer); |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
257 |
} |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
258 |
else if (trailer == std::string("ns")) |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
259 |
{ |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
260 |
time = NanoSeconds (integer); |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
261 |
} |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
262 |
else if (trailer == std::string("ps")) |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
263 |
{ |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
264 |
time = PicoSeconds (integer); |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
265 |
} |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
266 |
else if (trailer == std::string("fs")) |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
267 |
{ |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
268 |
time = FemtoSeconds (integer); |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
269 |
} |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
270 |
else |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
271 |
{ |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
272 |
is.setstate (std::ios_base::failbit); |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
273 |
// XXX: problem ? |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
274 |
} |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
275 |
return is; |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2396
diff
changeset
|
276 |
} |
143
552ff26b4224
new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
277 |
|
209
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
278 |
Time Seconds (double seconds) |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
279 |
{ |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
280 |
double d_sec = seconds * TimeStepPrecision::g_tsPrecFactor; |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
281 |
return Time (HighPrecision (d_sec)); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
282 |
// return Time (HighPrecision ((int64_t)d_sec, false)); |
209
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
283 |
} |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
284 |
|
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
285 |
uint64_t |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
286 |
TimeUnit<1>::UnitsToTimestep (uint64_t unitValue, |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
287 |
uint64_t unitFactor) |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
288 |
{ |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
289 |
uint64_t precFactor; |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
290 |
// In order to avoid conversion to double, precFactor can't be less 1 |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
291 |
if (TimeStepPrecision::g_tsPrecFactor < unitFactor) |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
292 |
{ |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
293 |
precFactor = unitFactor / TimeStepPrecision::g_tsPrecFactor; |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
294 |
unitValue = unitValue / precFactor; |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
295 |
} |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
296 |
else |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
297 |
{ |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
298 |
precFactor = TimeStepPrecision::g_tsPrecFactor / unitFactor; |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
299 |
unitValue = unitValue * precFactor; |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
300 |
} |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
301 |
return unitValue; |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
302 |
} |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
303 |
|
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
304 |
TimeUnit<1>::TimeUnit (Attribute value) |
2390
7e6dfae536cd
add Value support to Time
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2170
diff
changeset
|
305 |
{ |
2447
eee344085a96
convert to new helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
306 |
const TimeValue *v = value.DynCast<const TimeValue *> (); |
eee344085a96
convert to new helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
307 |
if (v == 0) |
eee344085a96
convert to new helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
308 |
{ |
eee344085a96
convert to new helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
309 |
NS_FATAL_ERROR ("Unexpected type of value. Expected \"TimeValue\""); |
eee344085a96
convert to new helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
310 |
} |
eee344085a96
convert to new helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
311 |
*this = v->Get (); |
2390
7e6dfae536cd
add Value support to Time
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2170
diff
changeset
|
312 |
} |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2427
diff
changeset
|
313 |
TimeUnit<1>::operator Attribute () const |
2390
7e6dfae536cd
add Value support to Time
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2170
diff
changeset
|
314 |
{ |
2947
b0fec3381418
get rid of scary implementation details of Attribute.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2577
diff
changeset
|
315 |
return Attribute (ns3::Create<TimeValue> (*this)); |
2390
7e6dfae536cd
add Value support to Time
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2170
diff
changeset
|
316 |
} |
7e6dfae536cd
add Value support to Time
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2170
diff
changeset
|
317 |
|
2447
eee344085a96
convert to new helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
318 |
ATTRIBUTE_VALUE_IMPLEMENT (Time); |
eee344085a96
convert to new helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2436
diff
changeset
|
319 |
ATTRIBUTE_CHECKER_IMPLEMENT (Time); |
2427
9245ec163111
split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2409
diff
changeset
|
320 |
|
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
321 |
Time MilliSeconds (uint64_t ms) |
209
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
322 |
{ |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
323 |
uint64_t ts = TimeUnit<1>::UnitsToTimestep(ms, TimeStepPrecision::MS_FACTOR); |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
324 |
return TimeStep(ts); |
209
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
325 |
} |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
326 |
|
209
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
327 |
Time MicroSeconds (uint64_t us) |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
328 |
{ |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
329 |
uint64_t ts = TimeUnit<1>::UnitsToTimestep(us, TimeStepPrecision::US_FACTOR); |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
330 |
return TimeStep(ts); |
209
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
331 |
} |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
332 |
|
209
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
333 |
Time NanoSeconds (uint64_t ns) |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
334 |
{ |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
335 |
uint64_t ts = TimeUnit<1>::UnitsToTimestep(ns, TimeStepPrecision::NS_FACTOR); |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
336 |
return TimeStep(ts); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
337 |
} |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
338 |
Time PicoSeconds (uint64_t ps) |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
339 |
{ |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
340 |
uint64_t ts = TimeUnit<1>::UnitsToTimestep(ps, TimeStepPrecision::PS_FACTOR); |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
341 |
return TimeStep(ts); |
209
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
342 |
} |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
343 |
Time FemtoSeconds (uint64_t fs) |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
344 |
{ |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
345 |
uint64_t ts = TimeUnit<1>::UnitsToTimestep(fs, TimeStepPrecision::FS_FACTOR); |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
346 |
return TimeStep(ts); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
347 |
} |
2390
7e6dfae536cd
add Value support to Time
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2170
diff
changeset
|
348 |
|
7e6dfae536cd
add Value support to Time
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2170
diff
changeset
|
349 |
|
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
350 |
/* |
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
351 |
* The timestep value passed to this function must be of the precision |
684
333ec02c9cc9
add DefaultValue support for TimeStepPrecision
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
680
diff
changeset
|
352 |
* of TimeStepPrecision::Get |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
353 |
*/ |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
354 |
Time TimeStep (uint64_t ts) |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
355 |
{ |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
356 |
return Time (HighPrecision (ts, false)); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
357 |
} |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
358 |
|
339
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
359 |
TimeUnit<0>::TimeUnit (double scalar) |
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
360 |
: m_data (HighPrecision (scalar)) |
143
552ff26b4224
new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
361 |
{} |
156
3b1563e95ea7
new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
151
diff
changeset
|
362 |
|
158
47af319de4b8
implement Scalar::GetDouble
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
157
diff
changeset
|
363 |
double |
339
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
364 |
TimeUnit<0>::GetDouble (void) const |
158
47af319de4b8
implement Scalar::GetDouble
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
157
diff
changeset
|
365 |
{ |
47af319de4b8
implement Scalar::GetDouble
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
157
diff
changeset
|
366 |
return GetHighPrecision ().GetDouble (); |
47af319de4b8
implement Scalar::GetDouble
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
157
diff
changeset
|
367 |
} |
47af319de4b8
implement Scalar::GetDouble
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
157
diff
changeset
|
368 |
|
2390
7e6dfae536cd
add Value support to Time
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2170
diff
changeset
|
369 |
} // namespace ns3 |
143
552ff26b4224
new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
370 |
|
552ff26b4224
new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
371 |
|
157
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
372 |
#ifdef RUN_SELF_TESTS |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
373 |
|
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
374 |
#include "ns3/test.h" |
211
395e8b0d32a9
add a few more tests for the Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
209
diff
changeset
|
375 |
//#include <iostream> |
157
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
376 |
|
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
377 |
namespace ns3 { |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
378 |
|
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
379 |
class TimeTests : public Test |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
380 |
{ |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
381 |
public: |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
382 |
TimeTests (); |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
383 |
virtual ~TimeTests (); |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
384 |
virtual bool RunTests (void); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
385 |
|
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
386 |
/* |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
387 |
* Verifies that a calculated time value is as expected using |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
388 |
* doubles since GetSeconds() returns a double |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
389 |
*/ |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
390 |
void CheckTimeSec(std::string test_id, double actual, double expected, |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
391 |
bool *flag, double precMultFactor = 1, |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
392 |
bool verbose = false); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
393 |
|
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
394 |
/* |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
395 |
* Verifies that a calculated time value is as expected. |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
396 |
*/ |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
397 |
void CheckTime(std::string test_id, int64_t actual, int64_t expected, |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
398 |
bool *flag, double precMultFactor = 1, |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
399 |
bool verbose = false); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
400 |
|
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
401 |
/* |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
402 |
* Verifies the +, -, * and / operations for the TimeUnit<1> or Time class |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
403 |
*/ |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
404 |
void CheckOperations(Time t0, Time t1, bool *ok, bool verbose = false); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
405 |
|
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
406 |
/* |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
407 |
* Verifies that the TimeUnit class stores values with the precision |
684
333ec02c9cc9
add DefaultValue support for TimeStepPrecision
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
680
diff
changeset
|
408 |
* set in the variable TimeStepPrecision::Get |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
409 |
* Checks that overflow and underflow occur at expected numbers |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
410 |
*/ |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
411 |
void CheckPrecision(TimeStepPrecision::precision_t prec, uint64_t val, bool *ok, |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
412 |
bool verbose = false); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
413 |
|
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
414 |
/* |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
415 |
* Verifies that the conversion between units in the class |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
416 |
* TimeUnit<1> or Time is done correctly. This is verified both when |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
417 |
* setting and retrieving a Time value |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
418 |
*/ |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
419 |
void CheckConversions(uint64_t tval, bool *ok, bool verbose = false); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
420 |
|
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
421 |
/* |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
422 |
* These are the old tests that used to be run |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
423 |
*/ |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
424 |
void CheckOld(bool *ok); |
157
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
425 |
}; |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
426 |
|
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
427 |
TimeTests::TimeTests () |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
428 |
: Test ("Time") |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
429 |
{} |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
430 |
TimeTests::~TimeTests () |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
431 |
{} |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
432 |
|
157
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
433 |
bool TimeTests::RunTests (void) |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
434 |
{ |
1829
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
435 |
bool result = true; |
176
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
436 |
|
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
437 |
Time t0, t1; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
438 |
|
1829
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
439 |
CheckOld(&result); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
440 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
441 |
t0 = MilliSeconds ((uint64_t)10.0); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
442 |
t1 = MilliSeconds ((uint64_t)11.0); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
443 |
|
1829
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
444 |
CheckOperations(t0, t1, &result); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
445 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
446 |
// t0 = Seconds ((uint64_t)10.0); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
447 |
// t1 = Seconds ((uint64_t)11.0); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
448 |
|
1829
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
449 |
// CheckOperations(t0, t1, &result); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
450 |
|
1829
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
451 |
CheckConversions((uint64_t)5, &result); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
452 |
CheckConversions((uint64_t)0, &result); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
453 |
CheckConversions((uint64_t)783, &result); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
454 |
CheckConversions((uint64_t)1132, &result); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
455 |
// CheckConversions((uint64_t)3341039, &result); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
456 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
457 |
// Now vary the precision and check the conversions |
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
458 |
if (TimeStepPrecision::Get () != TimeStepPrecision::NS) { |
1829
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
459 |
result = false; |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
460 |
} |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
461 |
|
1829
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
462 |
CheckPrecision(TimeStepPrecision::US, 7, &result); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
463 |
|
1829
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
464 |
CheckConversions((uint64_t)7, &result); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
465 |
CheckConversions((uint64_t)546, &result); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
466 |
CheckConversions((uint64_t)6231, &result); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
467 |
// CheckConversions((uint64_t)1234639, &result); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
468 |
|
1829
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
469 |
CheckPrecision(TimeStepPrecision::MS, 3, &result); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
470 |
|
1829
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
471 |
CheckConversions((uint64_t)3, &result); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
472 |
CheckConversions((uint64_t)134, &result); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
473 |
CheckConversions((uint64_t)2341, &result); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
474 |
// CheckConversions((uint64_t)8956239, &result); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
475 |
|
1829
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
476 |
CheckPrecision(TimeStepPrecision::PS, 21, &result); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
477 |
|
1829
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
478 |
CheckConversions((uint64_t)4, &result); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
479 |
CheckConversions((uint64_t)342, &result); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
480 |
CheckConversions((uint64_t)1327, &result); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
481 |
// CheckConversions((uint64_t)5439627, &result); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
482 |
|
1829
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
483 |
CheckPrecision(TimeStepPrecision::NS, 12, &result); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
484 |
CheckConversions((uint64_t)12, &result); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
485 |
|
1829
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
486 |
CheckPrecision(TimeStepPrecision::S, 7, &result); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
487 |
CheckConversions((uint64_t)7, &result); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
488 |
|
1829
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
489 |
CheckPrecision(TimeStepPrecision::FS, 5, &result); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
490 |
CheckConversions((uint64_t)5, &result); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
491 |
|
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
492 |
TimeStepPrecision::Set (TimeStepPrecision::NS); |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
493 |
|
2577
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
494 |
Config::SetGlobal ("TimeStepPrecision", String ("S")); |
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
495 |
Config::SetGlobal ("TimeStepPrecision", String ("MS")); |
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
496 |
Config::SetGlobal ("TimeStepPrecision", String ("US")); |
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
497 |
Config::SetGlobal ("TimeStepPrecision", String ("NS")); |
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
498 |
Config::SetGlobal ("TimeStepPrecision", String ("PS")); |
5b41cb5c3fcf
kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2447
diff
changeset
|
499 |
Config::SetGlobal ("TimeStepPrecision", String ("FS")); |
684
333ec02c9cc9
add DefaultValue support for TimeStepPrecision
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
680
diff
changeset
|
500 |
|
1829
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
501 |
|
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
502 |
Time tooBig = TimeStep (0x8000000000000000LL); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
503 |
NS_TEST_ASSERT (tooBig.IsNegative ()); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
504 |
tooBig = TimeStep (0xffffffffffffffffLL); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
505 |
NS_TEST_ASSERT (tooBig.IsNegative ()); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
506 |
tooBig = TimeStep (0x7fffffffffffffffLL); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
507 |
NS_TEST_ASSERT (tooBig.IsPositive ()); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
508 |
tooBig += TimeStep (1); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
509 |
NS_TEST_ASSERT (tooBig.IsNegative ()); |
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
510 |
|
4a4799006fab
check for Time bounds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1696
diff
changeset
|
511 |
return result; |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
512 |
} |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
513 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
514 |
void TimeTests::CheckOld (bool *ok) |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
515 |
{ |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
516 |
double dt0, dt1, dt2; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
517 |
int64_t it0, it1; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
518 |
|
157
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
519 |
Time t0 = Seconds (10.0); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
520 |
CheckTimeSec("old 1", t0.GetSeconds(), 10.0, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
521 |
|
157
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
522 |
Time t1 = Seconds (11.0); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
523 |
CheckTimeSec("old 2", t1.GetSeconds(), 11.0, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
524 |
|
176
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
525 |
t0 = Seconds (1.5); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
526 |
CheckTimeSec("old 3", t0.GetSeconds(), 1.5, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
527 |
|
176
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
528 |
t0 = Seconds (-1.5); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
529 |
CheckTimeSec("old 4", t0.GetSeconds(), -1.5, ok); |
176
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
530 |
|
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
531 |
t0 = MilliSeconds ((uint64_t)10.0); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
532 |
dt0 = t0.GetSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
533 |
CheckTimeSec("old 5", dt0, 0.01, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
534 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
535 |
t1 = MilliSeconds ((uint64_t)11.0); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
536 |
dt1 = t1.GetSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
537 |
CheckTimeSec("old 6", dt1, 0.011, ok); |
176
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
538 |
|
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
539 |
Time t2, t3; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
540 |
|
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
541 |
t2 = t1 - t0; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
542 |
if (!t2.IsStrictlyPositive ()) |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
543 |
{ |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
544 |
ok = false; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
545 |
} |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
546 |
dt2 = t2.GetSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
547 |
CheckTimeSec("old 7", dt2, dt1-dt0, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
548 |
|
176
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
549 |
t2 = t1 - t1; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
550 |
if (!t2.IsZero ()) |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
551 |
{ |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
552 |
ok = false; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
553 |
} |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
554 |
dt2 = t2.GetSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
555 |
CheckTimeSec("old 8", dt2, dt1-dt1, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
556 |
|
157
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
557 |
t2 = t0 - t1; |
176
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
558 |
if (!t2.IsStrictlyNegative ()) |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
559 |
{ |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
560 |
ok = false; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
561 |
} |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
562 |
dt2 = t2.GetSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
563 |
CheckTimeSec("old 9", dt2, dt0-dt1, ok); |
176
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
564 |
|
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
565 |
t1 = NanoSeconds(15); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
566 |
it0 = t0.GetNanoSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
567 |
it1 = t1.GetNanoSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
568 |
TimeUnit<-2> tu4 = t0 / (t1 * t1 * t1); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
569 |
CheckTime("old 10", tu4.GetHighPrecision().GetInteger(), it0 / (it1*it1*it1), |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
570 |
ok, 1e9); |
157
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
571 |
|
211
395e8b0d32a9
add a few more tests for the Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
209
diff
changeset
|
572 |
Time tmp = MilliSeconds (0); |
395e8b0d32a9
add a few more tests for the Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
209
diff
changeset
|
573 |
if ((tmp != NanoSeconds (0)) || |
395e8b0d32a9
add a few more tests for the Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
209
diff
changeset
|
574 |
(tmp > NanoSeconds (0)) || |
395e8b0d32a9
add a few more tests for the Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
209
diff
changeset
|
575 |
(tmp < NanoSeconds (0))) |
395e8b0d32a9
add a few more tests for the Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
209
diff
changeset
|
576 |
{ |
395e8b0d32a9
add a few more tests for the Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
209
diff
changeset
|
577 |
ok = false; |
395e8b0d32a9
add a few more tests for the Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
209
diff
changeset
|
578 |
} |
395e8b0d32a9
add a few more tests for the Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
209
diff
changeset
|
579 |
|
229
37f1ee32c76f
avoid unused variable compiler warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
215
diff
changeset
|
580 |
Time t4; |
37f1ee32c76f
avoid unused variable compiler warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
215
diff
changeset
|
581 |
t4 = Seconds (10.0) * Scalar (1.5); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
582 |
CheckTimeSec("old 11", t4.GetSeconds(), 10, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
583 |
|
229
37f1ee32c76f
avoid unused variable compiler warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
215
diff
changeset
|
584 |
Time t5; |
37f1ee32c76f
avoid unused variable compiler warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
215
diff
changeset
|
585 |
t5 = NanoSeconds (10) * Scalar (1.5); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
586 |
CheckTime("old 12", t5.GetNanoSeconds(), 10, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
587 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
588 |
t4 = Seconds (10.0) * Scalar (15) / Scalar (10); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
589 |
CheckTimeSec("old 13", t4.GetSeconds(), 15, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
590 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
591 |
t5 = NanoSeconds (10) * Scalar (15) / Scalar (10); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
592 |
CheckTime("old 14", t5.GetNanoSeconds(), 15, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
593 |
|
339
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
594 |
|
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
595 |
double foo = (t1 + t2).GetSeconds (); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
596 |
dt1 = t1.GetSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
597 |
dt2 = t2.GetSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
598 |
CheckTimeSec("old 15", foo, dt1+dt2, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
599 |
|
339
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
600 |
foo += (t4 == t5)? 1 : 0; |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
601 |
CheckTimeSec("old 16", foo, dt1+dt2, ok); |
339
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
602 |
|
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
603 |
foo = (t1/t2).GetDouble (); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
604 |
CheckTimeSec("old 17", foo, dt1/dt2, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
605 |
} |
157
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
606 |
|
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
607 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
608 |
void TimeTests::CheckOperations(Time t0, Time t1, bool *ok, bool verbose) |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
609 |
{ |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
610 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
611 |
if (verbose) |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
612 |
std::cout << std::endl << "Check operations: " |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
613 |
<< t0 << " " << t1 << std::endl; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
614 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
615 |
Time t2, t3; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
616 |
double it0, it1, it2, it3, itu2, itu3; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
617 |
int64_t iti0; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
618 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
619 |
it0 = t0.GetSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
620 |
it1 = t1.GetSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
621 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
622 |
t2 = t0 - t1; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
623 |
it2 = t2.GetSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
624 |
CheckTimeSec("ops 1", it2, it0-it1, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
625 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
626 |
t3 = t2 * t0 / t0; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
627 |
it3 = t3.GetSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
628 |
CheckTimeSec("ops 2a", it3, it2*it0/it0, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
629 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
630 |
t3 = t2 * t0 / t1; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
631 |
it3 = t3.GetSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
632 |
CheckTimeSec("ops 2", it3, it2*it0/it1, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
633 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
634 |
t3 = t0 * t2 / t1; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
635 |
it3 = t3.GetSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
636 |
CheckTimeSec("ops 3", it3, it0*it2/it1, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
637 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
638 |
t3 = t0 * t1 / t2; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
639 |
it3 = t3.GetSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
640 |
CheckTimeSec("ops 4", it3, it0*it1/it2, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
641 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
642 |
t3 = t0 * (t1 / t2); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
643 |
it3 = t3.GetSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
644 |
CheckTimeSec("ops 5", it3, it0*(it1/it2), ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
645 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
646 |
t3 = (t0 * t1) / t2; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
647 |
it3 = t3.GetSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
648 |
CheckTimeSec("ops 6", it3, (it0*it1)/it2, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
649 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
650 |
t3 = t0 / t1 * t2; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
651 |
it3 = t3.GetSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
652 |
CheckTimeSec("ops 7", it3, it0/it1*it2, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
653 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
654 |
t3 = (t0 / t1) * t2; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
655 |
it3 = t3.GetSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
656 |
CheckTimeSec("ops 8", it3, (it0/it1)*it2, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
657 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
658 |
t3 = t0 * Scalar (10.0); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
659 |
it3 = t3.GetSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
660 |
CheckTimeSec("ops 9", it3, it0*10, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
661 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
662 |
t3 = Scalar (10.0) * t0; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
663 |
it3 = t3.GetSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
664 |
CheckTimeSec("ops 10", it3, 10 * it0, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
665 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
666 |
t3 = Scalar (10.0) * t0 / t2 * t1; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
667 |
it3 = t3.GetSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
668 |
CheckTimeSec("ops 11", it3, 10 * it0 / it2 * it1, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
669 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
670 |
t3 = (Scalar (10.0) * t0 ) / t2 * t1; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
671 |
it3 = t3.GetSeconds(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
672 |
CheckTimeSec("ops 12", it3, (10 * it0) / it2 * it1, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
673 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
674 |
TimeInvert ti0; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
675 |
ti0 = t0 / (t1 * t2); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
676 |
iti0 = ti0.GetHighPrecision().GetInteger(); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
677 |
// This check is not quite working yet. |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
678 |
// CheckTime("ops 13", iti0, (int64_t)(it0/(it1*it2)), ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
679 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
680 |
Scalar s0 = t0 / t1; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
681 |
CheckTimeSec("ops 14", s0.GetDouble(), it0/it1, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
682 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
683 |
Scalar s1; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
684 |
s1 = t0 * t1 / (t2 * t0); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
685 |
CheckTimeSec("ops 15", s1.GetDouble(), it0*it1/(it2*it0), ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
686 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
687 |
TimeUnit<0> tu0; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
688 |
tu0 = s0; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
689 |
CheckTimeSec("ops 16", tu0.GetDouble(), s0.GetDouble(), ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
690 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
691 |
TimeUnit<1> tu1; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
692 |
tu1 = t0; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
693 |
CheckTimeSec("ops 17", tu1.GetSeconds(), it0, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
694 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
695 |
TimeUnit<2> tu2; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
696 |
tu2 = t0 * t1; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
697 |
CheckTimeSec("ops 18", tu2.GetHighPrecision().GetInteger()/(1e18), |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
698 |
it0 * it1, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
699 |
itu2 = tu2.GetHighPrecision().GetInteger()/(1e18); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
700 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
701 |
TimeUnit<3> tu3; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
702 |
tu3 = t0 / Scalar(10e6) * tu2; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
703 |
CheckTimeSec("ops 19", tu3.GetHighPrecision().GetInteger()/(1e27), |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
704 |
it0 / 1000000 * itu2, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
705 |
itu3 = tu3.GetHighPrecision().GetInteger()/(1e27); |
157
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
706 |
} |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
707 |
|
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
708 |
void TimeTests::CheckConversions(uint64_t tval, bool *ok, bool verbose) { |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
709 |
Time t_sec, t_ms, t_us, t_ns, t_ps, t_fs; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
710 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
711 |
if (verbose) |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
712 |
std::cout << std::endl << "Check conversions: " << tval << std::endl; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
713 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
714 |
// First check the seconds |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
715 |
t_sec = Seconds((double)tval); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
716 |
CheckTimeSec("conv sec sec", t_sec.GetSeconds(), (double)tval, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
717 |
CheckTime("conv sec ms", t_sec.GetMilliSeconds(), (int64_t)(tval*1e3), ok, 1e3); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
718 |
CheckTime("conv sec us", t_sec.GetMicroSeconds(), (int64_t)(tval*1e6), ok, 1e6); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
719 |
CheckTime("conv sec ns", t_sec.GetNanoSeconds(), (int64_t)(tval*1e9), ok, 1e9); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
720 |
CheckTime("conv sec ps", t_sec.GetPicoSeconds(), |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
721 |
(int64_t)(tval*1e12), ok, 1e12); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
722 |
CheckTime("conv sec fs", t_sec.GetFemtoSeconds(), |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
723 |
(int64_t)(tval*1e15), ok, 1e15); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
724 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
725 |
// Then check the milliseconds |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
726 |
t_ms = MilliSeconds(tval); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
727 |
CheckTimeSec("conv ms sec", t_ms.GetSeconds(), (double)tval/1e3, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
728 |
CheckTime("conv ms ms", t_ms.GetMilliSeconds(), (int64_t)(tval), ok, 1e3); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
729 |
CheckTime("conv ms us", t_ms.GetMicroSeconds(), (int64_t)(tval*1e3), ok, 1e6); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
730 |
CheckTime("conv ms ns", t_ms.GetNanoSeconds(), (int64_t)(tval*1e6), ok, 1e9); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
731 |
CheckTime("conv ms ps", t_ms.GetPicoSeconds(), (int64_t)(tval*1e9), ok, 1e12); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
732 |
CheckTime("conv ms fs", t_ms.GetFemtoSeconds(), (int64_t)(tval*1e12), ok, 1e15); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
733 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
734 |
// Then check the microseconds |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
735 |
t_us = MicroSeconds(tval); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
736 |
CheckTimeSec("conv us sec", t_us.GetSeconds(), (double)tval/1e6, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
737 |
CheckTime("conv us ms", t_us.GetMilliSeconds(), (int64_t)(tval/1e3), ok, 1e3); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
738 |
CheckTime("conv us us", t_us.GetMicroSeconds(), (int64_t)(tval), ok, 1e6); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
739 |
CheckTime("conv us ns", t_us.GetNanoSeconds(), (int64_t)(tval*1e3), ok, 1e9); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
740 |
CheckTime("conv us ps", t_us.GetPicoSeconds(), (int64_t)(tval*1e6), ok, 1e12); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
741 |
CheckTime("conv us fs", t_us.GetFemtoSeconds(), (int64_t)(tval*1e9), ok, 1e15); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
742 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
743 |
// Then check the nanoseconds |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
744 |
t_ns = NanoSeconds(tval); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
745 |
CheckTimeSec("conv ns sec", t_ns.GetSeconds(), (double)tval/1e9, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
746 |
CheckTime("conv ns ms", t_ns.GetMilliSeconds(), (int64_t)(tval/1e6), ok, 1e3); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
747 |
CheckTime("conv ns us", t_ns.GetMicroSeconds(), (int64_t)(tval/1e3), ok, 1e6); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
748 |
CheckTime("conv ns ns", t_ns.GetNanoSeconds(), (int64_t)(tval), ok, 1e9); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
749 |
CheckTime("conv ns ps", t_ns.GetPicoSeconds(), (int64_t)(tval*1e3), ok, 1e12); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
750 |
CheckTime("conv ns fs", t_ns.GetFemtoSeconds(), (int64_t)(tval*1e6), ok, 1e15); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
751 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
752 |
// Then check the picoseconds |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
753 |
t_ps = PicoSeconds(tval); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
754 |
CheckTimeSec("conv ps sec", t_ps.GetSeconds(), (double)tval/1e12, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
755 |
CheckTime("conv ps ms", t_ps.GetMilliSeconds(), (int64_t)(tval/1e9), ok, 1e3); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
756 |
CheckTime("conv ps us", t_ps.GetMicroSeconds(), (int64_t)(tval/1e6), ok, 1e6); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
757 |
CheckTime("conv ps ns", t_ps.GetNanoSeconds(), (int64_t)(tval/1e3), ok, 1e9); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
758 |
CheckTime("conv ps ps", t_ps.GetPicoSeconds(), (int64_t)(tval), ok, 1e12); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
759 |
CheckTime("conv ps fs", t_ps.GetFemtoSeconds(), (int64_t)(tval*1e3), ok, 1e15); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
760 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
761 |
// Then check the femtoseconds |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
762 |
t_fs = FemtoSeconds(tval); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
763 |
CheckTimeSec("conv fs sec", t_fs.GetSeconds(), (double)tval/1e15, ok); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
764 |
CheckTime("conv fs ms", t_fs.GetMilliSeconds(), (int64_t)(tval/1e12), ok, 1e3); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
765 |
CheckTime("conv fs us", t_fs.GetMicroSeconds(), (int64_t)(tval/1e9), ok, 1e6); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
766 |
CheckTime("conv fs ns", t_fs.GetNanoSeconds(), (int64_t)(tval/1e6), ok, 1e9); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
767 |
CheckTime("conv fs ps", t_fs.GetPicoSeconds(), (int64_t)(tval/1e3), ok, 1e12); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
768 |
CheckTime("conv fs fs", t_fs.GetFemtoSeconds(), (int64_t)(tval), ok, 1e15); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
769 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
770 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
771 |
} |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
772 |
|
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
773 |
void TimeTests::CheckPrecision(TimeStepPrecision::precision_t prec, uint64_t val, bool *ok, |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
774 |
bool verbose) { |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
775 |
if (verbose) { |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
776 |
std::cout << "check precision 10^-" << prec << std::endl; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
777 |
} |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
778 |
|
677
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
779 |
TimeStepPrecision::Set (prec); |
de21f6a2435e
namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
676
diff
changeset
|
780 |
if (TimeStepPrecision::Get () != prec) { |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
781 |
ok = false; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
782 |
} |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
783 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
784 |
/* These still need to be fixed. |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
785 |
// The smallest value that can be stored is 1x10^(-prec) |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
786 |
Time smallest = Seconds(pow(10,-prec)); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
787 |
CheckTimeSec("Prec small: ", smallest.GetSeconds(), pow(10,-prec), ok, 0.1, |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
788 |
true); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
789 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
790 |
double d_ts = pow(10,-prec) - pow(10, -(prec+3)); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
791 |
Time too_small = Seconds(d_ts); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
792 |
CheckTimeSec("Prec too small: ", too_small.GetSeconds(), 0, ok, 0.1, true); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
793 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
794 |
double d_la = 0xFFFFFFFF*pow(10,-prec); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
795 |
Time largest = Seconds(d_la); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
796 |
CheckTimeSec("Prec large: ", largest.GetSeconds(), d_la, ok, 0.1, true); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
797 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
798 |
double d_tl = (0xFFFFFFFF*pow(10,-prec)) + 1; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
799 |
Time too_large = Seconds(d_tl); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
800 |
if ((largest.GetSeconds() + 1) == too_large.GetSeconds()) |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
801 |
std::cout << "Overflow did not occur." << std::endl; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
802 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
803 |
NS_ASSERT(d_la+1 == d_tl); |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
804 |
*/ |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
805 |
} |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
806 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
807 |
void TimeTests::CheckTimeSec (std::string test_id, double actual, |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
808 |
double expected, bool *flag, double precMultFactor, |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
809 |
bool verbose) |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
810 |
{ |
684
333ec02c9cc9
add DefaultValue support for TimeStepPrecision
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
680
diff
changeset
|
811 |
double prec = pow(10,-((double)(ns3::TimeStepPrecision::Get ()))) * precMultFactor; |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
812 |
if ((actual < (expected-prec)) || (actual > (expected+prec))) { |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
813 |
std::cout << "FAIL " << test_id |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
814 |
<< " Expected:" << expected |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
815 |
<< " Actual: " << actual |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
816 |
<< " Precision: " << prec << std::endl; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
817 |
*flag = false; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
818 |
} else { |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
819 |
if (verbose) { |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
820 |
std::cout << "PASS " << test_id |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
821 |
<< " Expected:" << expected |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
822 |
<< " Actual: " << actual |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
823 |
<< " Precision: " << prec << std::endl; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
824 |
} |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
825 |
} |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
826 |
} |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
827 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
828 |
void TimeTests::CheckTime (std::string test_id, int64_t actual, |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
829 |
int64_t expected, bool *flag, double precMultFactor, |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
830 |
bool verbose) |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
831 |
{ |
684
333ec02c9cc9
add DefaultValue support for TimeStepPrecision
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
680
diff
changeset
|
832 |
double prec = pow(10,-((double)(ns3::TimeStepPrecision::Get ()))) * precMultFactor; |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
833 |
if ((actual < (expected-prec)) || (actual > (expected+prec))) { |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
834 |
std::cout << "FAIL " << test_id |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
835 |
<< " Expected:" << expected |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
836 |
<< " Actual: " << actual |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
837 |
<< " Precision: " << prec << std::endl; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
838 |
*flag = false; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
839 |
} else { |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
840 |
if (verbose) { |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
841 |
std::cout << "PASS " << test_id |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
842 |
<< " Expected:" << expected |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
843 |
<< " Actual: " << actual |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
844 |
<< " Precision: " << prec << std::endl; |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
845 |
} |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
846 |
} |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
847 |
} |
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
848 |
|
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
372
diff
changeset
|
849 |
|
157
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
850 |
static TimeTests g_time_tests; |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
851 |
|
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
852 |
}; |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
853 |
|
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
854 |
#endif /* RUN_SELF_TESTS */ |