rename Time::ApproximateTo methods to Time::Get
parent
b4e41a481b
commit
ac043f3e9d
|
@ -17,12 +17,12 @@ MyModel::Start (void)
|
||||||
{
|
{
|
||||||
Simulator::Schedule (Seconds (10.0),
|
Simulator::Schedule (Seconds (10.0),
|
||||||
&MyModel::DealWithEvent,
|
&MyModel::DealWithEvent,
|
||||||
this, Simulator::Now ().ApproximateToSeconds ());
|
this, Simulator::Now ().GetSeconds ());
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
MyModel::DealWithEvent (double value)
|
MyModel::DealWithEvent (double value)
|
||||||
{
|
{
|
||||||
std::cout << "Member method received event at " << Simulator::Now ().ApproximateToSeconds ()
|
std::cout << "Member method received event at " << Simulator::Now ().GetSeconds ()
|
||||||
<< "s started at " << value << "s" << std::endl;
|
<< "s started at " << value << "s" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ static void
|
||||||
random_function (MyModel *model)
|
random_function (MyModel *model)
|
||||||
{
|
{
|
||||||
std::cout << "random function received event at " <<
|
std::cout << "random function received event at " <<
|
||||||
Simulator::Now ().ApproximateToSeconds () << "s" << std::endl;
|
Simulator::Now ().GetSeconds () << "s" << std::endl;
|
||||||
model->Start ();
|
model->Start ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ PcapWriter::WritePacket (Packet const packet)
|
||||||
{
|
{
|
||||||
if (m_writer != 0)
|
if (m_writer != 0)
|
||||||
{
|
{
|
||||||
uint64_t current = Simulator::Now ().ApproximateToMicroSeconds ();
|
uint64_t current = Simulator::Now ().GetMicroSeconds ();
|
||||||
uint64_t s = current / 1000000;
|
uint64_t s = current / 1000000;
|
||||||
uint64_t us = current % 1000000;
|
uint64_t us = current % 1000000;
|
||||||
Write32 (s & 0xffffffff);
|
Write32 (s & 0xffffffff);
|
||||||
|
|
|
@ -307,22 +307,22 @@ public:
|
||||||
* \returns an approximation in seconds of the time stored in this
|
* \returns an approximation in seconds of the time stored in this
|
||||||
* instance.
|
* instance.
|
||||||
*/
|
*/
|
||||||
double ApproximateToSeconds (void) const;
|
double GetSeconds (void) const;
|
||||||
/**
|
/**
|
||||||
* \returns an approximation in milliseconds of the time stored in this
|
* \returns an approximation in milliseconds of the time stored in this
|
||||||
* instance.
|
* instance.
|
||||||
*/
|
*/
|
||||||
int32_t ApproximateToMilliSeconds (void) const;
|
int32_t GetMilliSeconds (void) const;
|
||||||
/**
|
/**
|
||||||
* \returns an approximation in microseconds of the time stored in this
|
* \returns an approximation in microseconds of the time stored in this
|
||||||
* instance.
|
* instance.
|
||||||
*/
|
*/
|
||||||
int64_t ApproximateToMicroSeconds (void) const;
|
int64_t GetMicroSeconds (void) const;
|
||||||
/**
|
/**
|
||||||
* \returns an approximation in nanoseconds of the time stored in this
|
* \returns an approximation in nanoseconds of the time stored in this
|
||||||
* instance.
|
* instance.
|
||||||
*/
|
*/
|
||||||
int64_t ApproximateToNanoSeconds (void) const;
|
int64_t GetNanoSeconds (void) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -177,19 +177,19 @@ void
|
||||||
SimulatorPrivate::StopAt (Time const &at)
|
SimulatorPrivate::StopAt (Time const &at)
|
||||||
{
|
{
|
||||||
assert (at.IsPositive ());
|
assert (at.IsPositive ());
|
||||||
m_stopAt = at.ApproximateToNanoSeconds ();
|
m_stopAt = at.GetNanoSeconds ();
|
||||||
}
|
}
|
||||||
EventId
|
EventId
|
||||||
SimulatorPrivate::Schedule (Time const &time, EventImpl *event)
|
SimulatorPrivate::Schedule (Time const &time, EventImpl *event)
|
||||||
{
|
{
|
||||||
assert (time.IsPositive ());
|
assert (time.IsPositive ());
|
||||||
assert (time >= NanoSeconds (m_currentNs));
|
assert (time >= NanoSeconds (m_currentNs));
|
||||||
uint64_t ns = (uint64_t) time.ApproximateToNanoSeconds ();
|
uint64_t ns = (uint64_t) time.GetNanoSeconds ();
|
||||||
Scheduler::EventKey key = {ns, m_uid};
|
Scheduler::EventKey key = {ns, m_uid};
|
||||||
if (m_logEnable)
|
if (m_logEnable)
|
||||||
{
|
{
|
||||||
m_log << "i "<<m_currentUid<<" "<<m_currentNs<<" "
|
m_log << "i "<<m_currentUid<<" "<<m_currentNs<<" "
|
||||||
<<m_uid<<" "<<time.ApproximateToNanoSeconds () << std::endl;
|
<<m_uid<<" "<<time.GetSeconds () << std::endl;
|
||||||
}
|
}
|
||||||
m_uid++;
|
m_uid++;
|
||||||
return m_events->Insert (event, key);
|
return m_events->Insert (event, key);
|
||||||
|
@ -213,7 +213,7 @@ SimulatorPrivate::ScheduleDestroy (EventImpl *event)
|
||||||
m_destroy.push_back (std::make_pair (event, m_uid));
|
m_destroy.push_back (std::make_pair (event, m_uid));
|
||||||
if (m_logEnable)
|
if (m_logEnable)
|
||||||
{
|
{
|
||||||
m_log << "id " << m_currentUid << " " << Now ().ApproximateToNanoSeconds () << " "
|
m_log << "id " << m_currentUid << " " << Now ().GetNanoSeconds () << " "
|
||||||
<< m_uid << std::endl;
|
<< m_uid << std::endl;
|
||||||
}
|
}
|
||||||
m_uid++;
|
m_uid++;
|
||||||
|
@ -497,7 +497,7 @@ SimulatorTests::~SimulatorTests ()
|
||||||
uint64_t
|
uint64_t
|
||||||
SimulatorTests::NowUs (void)
|
SimulatorTests::NowUs (void)
|
||||||
{
|
{
|
||||||
uint64_t ns = Now ().ApproximateToNanoSeconds ();
|
uint64_t ns = Now ().GetNanoSeconds ();
|
||||||
return ns / 1000;
|
return ns / 1000;
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
|
|
|
@ -31,28 +31,28 @@ Time::Time (TimeUnit<1> time)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
double
|
double
|
||||||
Time::ApproximateToSeconds (void) const
|
Time::GetSeconds (void) const
|
||||||
{
|
{
|
||||||
HighPrecision seconds = GetHighPrecision ();
|
HighPrecision seconds = GetHighPrecision ();
|
||||||
seconds.Div (HighPrecision (1000000000, 0));
|
seconds.Div (HighPrecision (1000000000, 0));
|
||||||
return seconds.GetDouble ();
|
return seconds.GetDouble ();
|
||||||
}
|
}
|
||||||
int32_t
|
int32_t
|
||||||
Time::ApproximateToMilliSeconds (void) const
|
Time::GetMilliSeconds (void) const
|
||||||
{
|
{
|
||||||
HighPrecision ms = GetHighPrecision ();
|
HighPrecision ms = GetHighPrecision ();
|
||||||
ms.Div (HighPrecision (1000000, 0));
|
ms.Div (HighPrecision (1000000, 0));
|
||||||
return (int32_t) ms.GetHigh ();
|
return (int32_t) ms.GetHigh ();
|
||||||
}
|
}
|
||||||
int64_t
|
int64_t
|
||||||
Time::ApproximateToMicroSeconds (void) const
|
Time::GetMicroSeconds (void) const
|
||||||
{
|
{
|
||||||
HighPrecision us = GetHighPrecision ();
|
HighPrecision us = GetHighPrecision ();
|
||||||
us.Div (HighPrecision (1000, 0));
|
us.Div (HighPrecision (1000, 0));
|
||||||
return us.GetHigh ();
|
return us.GetHigh ();
|
||||||
}
|
}
|
||||||
int64_t
|
int64_t
|
||||||
Time::ApproximateToNanoSeconds (void) const
|
Time::GetNanoSeconds (void) const
|
||||||
{
|
{
|
||||||
return GetHighPrecision ().GetHigh ();
|
return GetHighPrecision ().GetHigh ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ Bench::Cb (void)
|
||||||
m_current = m_distribution.begin ();
|
m_current = m_distribution.begin ();
|
||||||
}
|
}
|
||||||
if (gDebug) {
|
if (gDebug) {
|
||||||
std::cerr << "event at " << Simulator::Now ().ApproximateToSeconds () << "s" << std::endl;
|
std::cerr << "event at " << Simulator::Now ().GetSeconds () << "s" << std::endl;
|
||||||
}
|
}
|
||||||
Simulator::Schedule (NanoSeconds (*m_current), &Bench::Cb, this);
|
Simulator::Schedule (NanoSeconds (*m_current), &Bench::Cb, this);
|
||||||
m_current++;
|
m_current++;
|
||||||
|
|
Loading…
Reference in New Issue