UniSet  2.6.0
TDelay.h
1 /*
2  * Copyright (c) 2015 Pavel Vainerman.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as
6  * published by the Free Software Foundation, version 2.1.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Lesser Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 //--------------------------------------------------------------------------
17 #ifndef TDelay_H_
18 #define TDelay_H_
19 // --------------------------------------------------------------------------
20 #include "PassiveTimer.h"
21 #include "Element.h"
22 // --------------------------------------------------------------------------
23 namespace uniset
24 {
25  // ---------------------------------------------------------------------------
26  // "ON" delay element
27  // Сбрасывается без задержки.. а срабатывает с задержкой.
28  class TDelay:
29  public Element
30  {
31 
32  public:
33  TDelay( Element::ElementID id, timeout_t delayMS = 0, size_t inCount = 0 );
34  virtual ~TDelay();
35 
36  virtual void tick() override;
37  virtual void setIn( size_t num, bool state ) override;
38  virtual bool getOut() const override;
39  virtual std::string getType() const override
40  {
41  return "Delay";
42  }
43 
44  void setDelay( timeout_t timeMS );
45  inline timeout_t getDelay() const
46  {
47  return delay;
48  }
49 
50  protected:
51  TDelay(): myout(false), delay(0) {};
52 
53  bool myout;
54  PassiveTimer pt;
55  timeout_t delay;
56 
57  private:
58  };
59  // --------------------------------------------------------------------------
60 } // end of namespace uniset
61 // ---------------------------------------------------------------------------
62 #endif
63 // ---------------------------------------------------------------------------
64