Class to store and manage the central simulation time. More...
#include <systemclock.h>
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 SystemClock & | Instance () |
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! |
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.
Definition at line 67 of file systemclock.h.
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!
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().
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().
SystemClockOffset SystemClock::GetCurrentTime | ( | ) | const [inline] |
Returns the current simulation time.
Definition at line 80 of file systemclock.h.
References currentTime.
Referenced by HWIrqSystem::ClearIrqFlag(), HWWado::CpuCycle(), DumpVCD::cycle(), HWIrqSystem::IrqHandlerFinished(), HWIrqSystem::IrqHandlerStarted(), WarnUnknown::markReadUnknown(), Run(), RunTimeRange(), HWEeprom::SetEecr(), Scope::SetInStateForChannel(), HWIrqSystem::SetIrqFlag(), FlashProgramming::SPM_action(), DumpVCD::stop(), and HWWado::Wdr().
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] |
Returns the central SystemClock instance for the application.
There will be only one instance on a application!
Definition at line 268 of file systemclock.cpp.
Referenced by avr_set_time_tf(), HWIrqSystem::ClearIrqFlag(), HWWado::CpuCycle(), HWEeprom::CpuCycle(), FlashProgramming::CpuCycle(), DumpVCD::cycle(), HWIrqSystem::IrqHandlerFinished(), HWIrqSystem::IrqHandlerStarted(), main(), WarnUnknown::markReadUnknown(), SerialRxBasic::PinStateHasChanged(), Run(), RunTimeRange(), SerialTxBuffered::Send(), HWEeprom::SetEecr(), Scope::SetInStateForChannel(), HWIrqSystem::SetIrqFlag(), FlashProgramming::SPM_action(), AvrDevice::Step(), DumpVCD::stop(), and HWWado::Wdr().
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.
Definition at line 182 of file systemclock.cpp.
References currentTime, MinHeap< Key, Value >::Insert(), and syncMembers.
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().
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().
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().
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().
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().
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().
SystemClockOffset SystemClock::currentTime [protected] |
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().
MinHeap<SystemClockOffset, SimulationMember *> SystemClock::syncMembers [protected] |
earliest first
Definition at line 75 of file systemclock.h.
Referenced by Add(), Rescedule(), ResetClock(), SetTraceModeForAllMembers(), and Step().