SIMLIB/C++  3.07
Public Member Functions | Protected Member Functions | Protected Attributes | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
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:
Inheritance graph
[legend]
Collaboration diagram for simlib3::Sampler:
Collaboration graph
[legend]

Public Member Functions

 Sampler (void(*pf)(), double dt=0.0)
 
virtual ~Sampler ()
 
virtual void Output () const override
 print object to default output More...
 
void Start ()
 start + sample More...
 
void Stop ()
 sample + stop More...
 
void Sample ()
 performs sample (function call) More...
 
double SetStep (double dt=0.0)
 change step More...
 
double GetStep () const
 get current step More...
 
- Public Member Functions inherited from simlib3::Event
 Event (Priority_t p=DEFAULT_PRIORITY)
 constructor, default priority if not specified More...
 
virtual ~Event ()
 destructor More...
 
virtual std::string Name () const override
 name of object More...
 
virtual void Activate (double t) override
 activate at time t (schedule) More...
 
- Public Member Functions inherited from simlib3::Entity
unsigned long id () const
 
 Entity (Priority_t p=DEFAULT_PRIORITY)
 constructor More...
 
virtual ~Entity ()
 destructor More...
 
 operator Entity * ()
 
double ActivationTime ()
 get activation time of entity - iff scheduled
it is here, because Entity has no knowledge of calendar activation record structure More...
 
void Activate ()
 activate now More...
 
virtual void Passivate ()
 deactivation More...
 
bool Idle ()
 entity activation is not scheduled in calendar More...
 
void Cancel ()
 end Behavior() and remove entity More...
 
virtual void Out () override
 remove entity from queue More...
 
EventNoticeGetEventNotice ()
 
- 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 More...
 
 SimObject ()
 constructor More...
 
virtual ~SimObject ()
 virtual destructor More...
 
void * operator new (size_t size)
 allocate object, set _flags More...
 
void operator delete (void *ptr)
 deallocate object More...
 
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 More...
 

Protected Member Functions

virtual void Behavior () override
 behavior description More...
 

Protected Attributes

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

Static Private Member Functions

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

Private Attributes

SamplerNext
 

Static Private Attributes

static SamplerFirst = 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) More...
 
- Static Protected Attributes inherited from simlib3::Entity
static unsigned long _Number = 0L
 current number of entities More...
 

Detailed Description

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

Definition at line 506 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, InitAll(), INSTALL_HOOK, and Next.

◆ ~Sampler()

simlib3::Sampler::~Sampler ( )
virtual

Definition at line 59 of file sampler.cc.

References Dprintf, First, INSTALL_HOOK, and Next.

Member Function Documentation

◆ ActivateAll()

void simlib3::Sampler::ActivateAll ( )
staticprivate

start all samplers (Run)

Definition at line 113 of file sampler.cc.

References First, and Next.

Referenced by Sampler().

◆ Behavior()

void simlib3::Sampler::Behavior ( )
overrideprotectedvirtual

behavior description

Implements simlib3::Event.

Definition at line 90 of file sampler.cc.

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

◆ GetStep()

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

◆ InitAll()

void simlib3::Sampler::InitAll ( )
staticprivate

initialize all samplers (Init)

Definition at line 103 of file sampler.cc.

References First, and Next.

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 last, on, and simlib3::Print().

◆ Sample()

void simlib3::Sampler::Sample ( )

performs sample (function call)

Definition at line 147 of file sampler.cc.

References 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::Entity::Activate(), and on.

◆ Stop()

void simlib3::Sampler::Stop ( )

sample + stop

Definition at line 135 of file sampler.cc.

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

Member Data Documentation

◆ First

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

Definition at line 507 of file simlib.h.

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

◆ function

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

function to call periodically

Definition at line 510 of file simlib.h.

◆ last

double simlib3::Sampler::last
protected

last sample time – prevents sample duplication

Definition at line 511 of file simlib.h.

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

◆ Next

Sampler* simlib3::Sampler::Next
private

Definition at line 508 of file simlib.h.

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

◆ on

bool simlib3::Sampler::on
protected

switch on/off

Definition at line 513 of file simlib.h.

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

◆ step

double simlib3::Sampler::step
protected

step of sampling

Definition at line 512 of file simlib.h.

Referenced by Behavior(), and SetStep().


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