SIMLIB/C++  3.07
zdelay.h
Go to the documentation of this file.
1 /////////////////////////////////////////////////////////////////////////////
2 //! \file zdelay.h unit delay block interface
3 //
4 // Copyright (c) 1997-2004 Petr Peringer
5 //
6 // This library is licensed under GNU Library GPL. See the file COPYING.
7 //
8 
9 //
10 // This is the interface for ZDelay blocks
11 //
12 // WARNING: needs some testing --- this is the prototype
13 //
14 
15 #ifndef __SIMLIB__
16 # error "zdelay.h: 16: you must include simlib.h first"
17 #endif
18 #if (__SIMLIB__ < 0x0214)
19 # error "zdelay.h: 19: requires SIMLIB version 2.14 and higher"
20 #endif
21 
22 namespace simlib3 {
23 
24 class ZDelay;
25 class ZDelayTimer;
26 
27 ////////////////////////////////////////////////////////////////////////////
28 // class ZDelayTimer --- clock for ZDelay blocks
29 //
30 class ZDelayTimer : public Event {
31  ZDelayTimer(const ZDelayTimer&); // ##
32  ZDelayTimer&operator=(const ZDelayTimer&); // ##
33  double dt; // clock period
34  class ZDelayContainer; // implementation-defined container
36  void Register(ZDelay*); // insert into container
37  void UnRegister(ZDelay*); // remove from container
38  friend class ZDelay; // no one else can register
39  public:
40  static const bool Default = true;
41  ZDelayTimer(double dt, bool is_default = false);
42  //ZDelayTimer(ZDelayTimer *p, unsigned long divide_by);
43  operator ZDelayTimer * () { return this; }
44  void Behavior() override;
45  void Init(); // called each Run()
46  void Start(); // clock activation
47  void Stop(); // stop clock
48  void Set(double new_dt) { dt = new_dt; }
49  ~ZDelayTimer();
50 };
51 
52 ////////////////////////////////////////////////////////////////////////////
53 // class ZDelay --- continuous signal / discrete time delay blocks
54 //
55 class ZDelay : public aContiBlock1 {
56  ZDelay(const ZDelay&); // disable copy ctor
57  void operator= (const ZDelay&); // disable assignment
58  double input_value; // temporary
59  ZDelayTimer *clock; // timer-event for this block
60  friend class ZDelayTimer;
61  protected:
62  virtual void SampleIn(); // sample input (called automatically by ZDelayTimer)
63  virtual void SampleOut(); // sample output (called automatically)
64  protected: // status
65  double new_value; // stored input value
66  double old_value; // output value (delayed signal)
67  protected: // parameters
68  double initval; // initial output value
70  public: // interface
71  explicit ZDelay( Input i, ZDelayTimer * clock = default_clock, double initvalue = 0 );
72  ZDelay( Input i, double initvalue );
73  ~ZDelay();
74  void Init(double iv); // set initial value of ZDelay block
75  virtual void Init(); // initialize ZDelay block
76  virtual double Value() override; // output of ZDelay block
77 }; // class ZDelay
78 
79 }
80 
81 // end
82 
static ZDelayTimer * default_clock
Definition: zdelay.h:69
ZDelayTimer & operator=(const ZDelayTimer &)
friend class ZDelay
Definition: zdelay.h:38
continuous block connection (transparent reference) wrapper for pointer to objects of aContiBlock der...
Definition: simlib.h:895
static const bool Default
Definition: zdelay.h:40
void Set(double new_dt)
Definition: zdelay.h:48
double initval
Definition: zdelay.h:68
Implementation of class CalendarList interface is static - using global functions in SQS namespace...
Definition: algloop.cc:32
void UnRegister(ZDelay *)
Definition: zdelay.cc:181
double new_value
Definition: zdelay.h:65
double old_value
Definition: zdelay.h:66
ZDelayTimer * clock
Definition: zdelay.h:59
abstract base class for events Event behavior is simple function (can not be interrupted) ...
Definition: simlib.h:488
ZDelayTimer(const ZDelayTimer &)
ZDelayContainer * c
Definition: zdelay.h:34
void Behavior() override
behavior description
Definition: zdelay.cc:159
base for continuous blocks with single input and algebraic loop check
Definition: simlib.h:940
void Register(ZDelay *)
Definition: zdelay.cc:172
double input_value
Definition: zdelay.h:58