77 lines
1.8 KiB
C++
77 lines
1.8 KiB
C++
/*
|
||
* StatusTrigger.hpp
|
||
*
|
||
* Created on: 29 сент. 2019 г.
|
||
* Author: user
|
||
*/
|
||
|
||
#ifndef SOURCE_SCHEMATIC_STATUSTRIGGER_HPP_
|
||
#define SOURCE_SCHEMATIC_STATUSTRIGGER_HPP_
|
||
|
||
#include "../systemic/IStatus.hh"
|
||
#include "../systemic/Timer.hh"
|
||
|
||
#include "StatusConst.hpp"
|
||
#include "StatusFilter.hh"
|
||
|
||
namespace systemic { namespace detail {
|
||
|
||
class TriggeredTrue : public IStatus {
|
||
private:
|
||
IStatus & value;
|
||
mutable bool trigger;
|
||
|
||
public:
|
||
TriggeredTrue( IStatus & value ) : value(value), trigger(false) {}
|
||
|
||
operator bool() const { return trigger ? true : trigger = value; }
|
||
|
||
};
|
||
|
||
/*
|
||
* Табл. истинности для TriggeredTrueReset
|
||
* value | reset | out - 1 | out
|
||
* ---------+-----------+-----------+-----
|
||
* 0 | 0 | 0 | 0
|
||
* 1 | 0 | x | 1
|
||
* val | 1 | x | val
|
||
* x | 0 | 1 | 1
|
||
*/
|
||
|
||
//out = value при reset = 1
|
||
//выход устанавливается в 0 по заднему фронту reset
|
||
|
||
class TriggeredTrueReset : public IStatus {
|
||
IStatus & value;
|
||
IStatus & reset;
|
||
|
||
mutable bool trigger;
|
||
|
||
public:
|
||
TriggeredTrueReset( IStatus & value, IStatus & reset ) :
|
||
value(value), reset(reset), trigger(false) {}
|
||
|
||
operator bool() const { return trigger ?
|
||
( reset ? trigger = value : true )
|
||
: trigger = value; }
|
||
|
||
};
|
||
|
||
class StatusDelay : public StatusFilter {
|
||
private:
|
||
class Status : public IStatus {
|
||
const bool b;
|
||
public:
|
||
operator bool() const { return b; }
|
||
Status(bool b) : b(b) {}
|
||
} status;
|
||
public:
|
||
StatusDelay( bool init_state ) : status(not init_state), StatusFilter(status, init_state) {}
|
||
|
||
virtual ~StatusDelay() = default;
|
||
};
|
||
|
||
}}
|
||
|
||
#endif /* SOURCE_SCHEMATIC_STATUSTRIGGER_HPP_ */
|