SIMLIB/C++ 3.09
Loading...
Searching...
No Matches
simlib3::Sampler Class Reference

objects of this class call global function periodically (typicaly used for output of continuous model) More...

#include <simlib.h>

Inheritance diagram for simlib3::Sampler:
Collaboration diagram for simlib3::Sampler:

Public Member Functions

 Sampler (void(*pf)(), double dt=0.0)
virtual ~Sampler ()
virtual void Output () const override
 print object to default output
void Start ()
 start + sample
void Stop ()
 sample + stop
void Sample ()
 performs sample (function call)
double SetStep (double dt=0.0)
 change step
double GetStep () const
 get current step
Public Member Functions inherited from simlib3::Event
 Event (Priority_t p=DEFAULT_PRIORITY)
 constructor, default priority if not specified
virtual ~Event ()
 destructor
virtual std::string Name () const override
 name of object
virtual void Activate (double t) override
 activate at time t (schedule)
void Activate ()
 activate now
Public Member Functions inherited from simlib3::Entity
unsigned long id () const
 Entity (Priority_t p=DEFAULT_PRIORITY)
 constructor
virtual ~Entity ()
 destructor
 operator Entity * ()
double ActivationTime ()
 get activation time of entity - iff scheduled
it is here, because Entity has no knowledge of calendar activation record structure
void Activate ()
 activate now
virtual void Passivate ()
 deactivation
bool Idle ()
 entity activation is not scheduled in calendar
void Cancel ()
 end Behavior() and remove entity
virtual void Out () override
 remove entity from queue
EventNotice * GetEventNotice ()
Public Member Functions inherited from simlib3::SimObject
bool TestAndSetFlag (bool new_value, unsigned n)
 internal method for flag manipulation is used for algebraic loop checking in continuous blocks
 SimObject ()
 constructor
virtual ~SimObject ()
 virtual destructor
void * operator new (size_t size)
 allocate object, set _flags
void operator delete (void *ptr)
 deallocate object
void * operator new[] (size_t size)=delete
void operator delete[] (void *ptr)=delete
bool isAllocated () const
bool HasName () const
void SetName (const std::string &name)
 assign the name

Protected Member Functions

virtual void Behavior () override
 behavior description

Protected Attributes

void(*) function ()
 function to call periodically
double last
 last sample time – prevents sample duplication
double step
 step of sampling
bool on
 switch on/off
Protected Attributes inherited from simlib3::Entity
unsigned long _Ident
 unique identification number of entity
double _MarkTime
union simlib3::Entity:: { ... }  
ServicePriority_t _SPrio
 priority of service in Facility
Protected Attributes inherited from simlib3::SimObject
unsigned _flags
 bool flags for internal use (TODO bitfield?)

Static Private Member Functions

static void InitAll ()
 initialize all samplers (Init)
static void ActivateAll ()
 start all samplers (Run)

Private Attributes

Sampler * Next

Static Private Attributes

static Sampler * First = 0

Additional Inherited Members

Public Types inherited from simlib3::Entity
typedef EntityPriority_t Priority_t
Public Types inherited from simlib3::SimObject
enum  _Flags { _CLEAR_ALL_FLAGS = 0 , _ALLOCATED_FLAG = 1<<0 , _EVAL_FLAG = 1<<1 , _HAS_NAME_FLAG = 1<<2 }
Public Attributes inherited from simlib3::Entity
Priority_t Priority
 priority of the entity (scheduling,queues)
Static Protected Attributes inherited from simlib3::Entity
static unsigned long _Number = 0L
 current number of entities

Detailed Description

objects of this class call global function periodically (typicaly used for output of continuous model)

Definition at line 511 of file simlib.h.

Constructor & Destructor Documentation

◆ Sampler()

simlib3::Sampler::Sampler ( void(* pf )(),
double dt = 0.0 )

Definition at line 39 of file sampler.cc.

References ActivateAll(), Dprintf, First, function, InitAll(), INSTALL_HOOK, last, Next, on, and step.

Referenced by ActivateAll(), InitAll(), and ~Sampler().

◆ ~Sampler()

simlib3::Sampler::~Sampler ( )
virtual

Definition at line 59 of file sampler.cc.

References Dprintf, First, function, INSTALL_HOOK, Next, and Sampler().

Member Function Documentation

◆ ActivateAll()

void simlib3::Sampler::ActivateAll ( )
staticprivate

start all samplers (Run)

Definition at line 113 of file sampler.cc.

References First, Next, and Sampler().

Referenced by Sampler().

◆ Behavior()

void simlib3::Sampler::Behavior ( )
overrideprotectedvirtual

behavior description

Implements simlib3::Event.

Definition at line 90 of file sampler.cc.

References simlib3::Event::Activate(), Dprintf, on, simlib3::Entity::Passivate(), Sample(), step, and simlib3::Time.

◆ GetStep()

double simlib3::Sampler::GetStep ( ) const
inline

get current step

Definition at line 528 of file simlib.h.

References step.

◆ InitAll()

void simlib3::Sampler::InitAll ( )
staticprivate

initialize all samplers (Init)

Definition at line 103 of file sampler.cc.

References First, Next, and Sampler().

Referenced by Sampler().

◆ Output()

void simlib3::Sampler::Output ( ) const
overridevirtual

print object to default output

Reimplemented from simlib3::Event.

Definition at line 80 of file sampler.cc.

References function, last, on, and simlib3::Print().

◆ Sample()

void simlib3::Sampler::Sample ( )

performs sample (function call)

Definition at line 147 of file sampler.cc.

References function, last, and simlib3::Time.

Referenced by Behavior().

◆ SetStep()

double simlib3::Sampler::SetStep ( double dt = 0.0)

change step

Definition at line 157 of file sampler.cc.

References step.

◆ Start()

void simlib3::Sampler::Start ( )

start + sample

Definition at line 126 of file sampler.cc.

References simlib3::Event::Activate(), and on.

◆ Stop()

void simlib3::Sampler::Stop ( )

sample + stop

Definition at line 135 of file sampler.cc.

References simlib3::Event::Activate(), last, on, simlib3::Entity::Passivate(), and simlib3::Time.

Member Data Documentation

◆ First

Sampler * simlib3::Sampler::First = 0
staticprivate

Definition at line 512 of file simlib.h.

Referenced by ActivateAll(), InitAll(), Sampler(), and ~Sampler().

◆ function

void(*) simlib3::Sampler::function()
protected

function to call periodically

Definition at line 515 of file simlib.h.

Referenced by Output(), Sample(), Sampler(), and ~Sampler().

◆ last

double simlib3::Sampler::last
protected

last sample time – prevents sample duplication

Definition at line 516 of file simlib.h.

Referenced by Output(), Sample(), Sampler(), and Stop().

◆ Next

Sampler* simlib3::Sampler::Next
private

Definition at line 513 of file simlib.h.

Referenced by ActivateAll(), InitAll(), Sampler(), and ~Sampler().

◆ on

bool simlib3::Sampler::on
protected

switch on/off

Definition at line 518 of file simlib.h.

Referenced by Behavior(), Output(), Sampler(), Start(), and Stop().

◆ step

double simlib3::Sampler::step
protected

step of sampling

Definition at line 517 of file simlib.h.

Referenced by Behavior(), GetStep(), Sampler(), and SetStep().


The documentation for this class was generated from the following files: