SystemClock Class Reference

Class to store and manage the central simulation time. More...

#include <systemclock.h>

Collaboration diagram for SystemClock:
Collaboration graph
[legend]

List of all members.

Public Member Functions

SystemClockOffset GetCurrentTime () const
 Returns the current simulation time.
void SetCurrentTime (SystemClockOffset of)
 Set the simulation time to a dedicated value.
void IncrTime (SystemClockOffset of)
 Increments the current simulation time with a offset.
void Add (SimulationMember *dev)
 Add a simulation member (normally a device).
void AddAsyncMember (SimulationMember *dev)
 Add a async simulation member, this will be called every simulation step.
int Step (bool &untilCoreStepFinished)
 Process one simulation step.
void Endless ()
 Run simulation endless till SIGINT or SIGTERM signal.
void Run (SystemClockOffset maxRunTime)
 Run simulation till given time is arrived or signal is cached.
int RunTimeRange (SystemClockOffset timeRange)
 Like Run method, but stops on breakpoint or after given time offset.
void Rescedule (SimulationMember *sm, SystemClockOffset newTime)
 Moves the given simulation member to a new place in time table.
void SetTraceModeForAllMembers (int trace_on)
 Switches trace mode for all current found simulation members.
void stop ()
 Gives the possibillity to stop Run od Endless method by programm.
void ResetClock (void)
 Resets the simulation time and clears table for simulation members and async simulation members.

Static Public Member Functions

static SystemClockInstance ()
 Returns the central SystemClock instance for the application.

Protected Attributes

SystemClockOffset currentTime
 time in [ns] since start of simulation
MinHeap< SystemClockOffset,
SimulationMember * > 
syncMembers
 earliest first
std::vector< SimulationMember * > asyncMembers
 List of asynchron working simulation members, will be called every step!

Private Member Functions

 SystemClock ()
 Do not this constructor from application code!
 SystemClock (const SystemClock &)
 Do not this constructor from application code!

Detailed Description

Class to store and manage the central simulation time.

This acts as a time table, a simulation member gets a place on this ordered table, where it should be called next time, the placement depends on the results of Step method call Step on this simulation member.

Todo:
In multiple core simulations which uses also gdb with single stepping we need a other solution to fit the time accurate behaviour. Currently on a single step from gdb the simulation runs until the command is completly executed which is NOT correct. Some commands need up to 4 cycles and the actual implementation do up to 4 steps for one step so the other cores run slower then in normal operation. This is not a problem today because we are not able to run multiple cores with gdb but this will be implementated later. So this version is only made for running the regression tests and stepping in gdb. Normal operation/simulation is not affected. (taken over from systemclock.cpp, but to check!)

Definition at line 67 of file systemclock.h.


Constructor & Destructor Documentation

SystemClock::SystemClock (  )  [private]

Do not this constructor from application code!

Definition at line 115 of file systemclock.cpp.

References avr_error, and currentTime.

SystemClock::SystemClock ( const SystemClock  )  [private]

Do not this constructor from application code!


Member Function Documentation

void SystemClock::Add ( SimulationMember dev  ) 

Add a simulation member (normally a device).

Definition at line 134 of file systemclock.cpp.

References currentTime, MinHeap< Key, Value >::Insert(), and syncMembers.

Referenced by main(), SerialRxBasic::PinStateHasChanged(), and SerialTxBuffered::Send().

Here is the call graph for this function:

Here is the caller graph for this function:

void SystemClock::AddAsyncMember ( SimulationMember dev  ) 

Add a async simulation member, this will be called every simulation step.

Definition at line 138 of file systemclock.cpp.

References asyncMembers.

void SystemClock::Endless (  ) 

Run simulation endless till SIGINT or SIGTERM signal.

Definition at line 213 of file systemclock.cpp.

References breakMessage, Application::GetInstance(), OnBreak(), Application::PrintResults(), and Step().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

SystemClockOffset SystemClock::GetCurrentTime (  )  const [inline]
void SystemClock::IncrTime ( SystemClockOffset  of  )  [inline]

Increments the current simulation time with a offset.

Attention! Use this method with care, if you don't want crazy results

Definition at line 86 of file systemclock.h.

References currentTime.

SystemClock & SystemClock::Instance (  )  [static]
void SystemClock::Rescedule ( SimulationMember sm,
SystemClockOffset  newTime 
)

Moves the given simulation member to a new place in time table.

The next time, simulation member will be called, is calculated as a given offset to current simulation time + 1.

Todo:
This method is possibly obsolete!

Definition at line 182 of file systemclock.cpp.

References currentTime, MinHeap< Key, Value >::Insert(), and syncMembers.

Here is the call graph for this function:

void SystemClock::ResetClock ( void   ) 

Resets the simulation time and clears table for simulation members and async simulation members.

Definition at line 207 of file systemclock.cpp.

References asyncMembers, currentTime, and syncMembers.

void SystemClock::Run ( SystemClockOffset  maxRunTime  ) 

Run simulation till given time is arrived or signal is cached.

Definition at line 231 of file systemclock.cpp.

References breakMessage, GetCurrentTime(), Application::GetInstance(), Instance(), OnBreak(), Application::PrintResults(), and Step().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

int SystemClock::RunTimeRange ( SystemClockOffset  timeRange  ) 

Like Run method, but stops on breakpoint or after given time offset.

Definition at line 250 of file systemclock.cpp.

References breakMessage, GetCurrentTime(), Instance(), OnBreak(), and Step().

Here is the call graph for this function:

void SystemClock::SetCurrentTime ( SystemClockOffset  of  )  [inline]

Set the simulation time to a dedicated value.

Attention! Use this method with care, if you don't want crazy results

Definition at line 83 of file systemclock.h.

References currentTime.

Referenced by avr_set_time_tf().

Here is the caller graph for this function:

void SystemClock::SetTraceModeForAllMembers ( int  trace_on  ) 

Switches trace mode for all current found simulation members.

Definition at line 123 of file systemclock.cpp.

References syncMembers, and AvrDevice::trace_on.

int SystemClock::Step ( bool &  untilCoreStepFinished  ) 

Process one simulation step.

Definition at line 142 of file systemclock.cpp.

References asyncMembers, currentTime, MinHeap< Key, Value >::IsEmpty(), MinHeap< Key, Value >::RemoveMinimum(), MinHeap< Key, Value >::RemoveMinimumAndInsert(), SimulationMember::Step(), and syncMembers.

Referenced by Endless(), Run(), and RunTimeRange().

Here is the call graph for this function:

Here is the caller graph for this function:

void SystemClock::stop (  ) 

Gives the possibillity to stop Run od Endless method by programm.

Definition at line 203 of file systemclock.cpp.

References breakMessage.

Referenced by AvrDevice::Step().

Here is the caller graph for this function:


Member Data Documentation

std::vector<SimulationMember*> SystemClock::asyncMembers [protected]

List of asynchron working simulation members, will be called every step!

Definition at line 76 of file systemclock.h.

Referenced by AddAsyncMember(), ResetClock(), and Step().

time in [ns] since start of simulation

Definition at line 74 of file systemclock.h.

Referenced by Add(), GetCurrentTime(), IncrTime(), Rescedule(), ResetClock(), SetCurrentTime(), Step(), and SystemClock().

earliest first

Definition at line 75 of file systemclock.h.

Referenced by Add(), Rescedule(), ResetClock(), SetTraceModeForAllMembers(), and Step().


The documentation for this class was generated from the following files:
Generated on Sun Feb 12 16:53:10 2012 for Simulavr by  doxygen 1.6.3