latch.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2017-, Rohan Budhiraja, Joseph Mirabel, CNRS
3  *
4  */
5 
6 #ifndef __SOT_LATCH_H__
7 #define __SOT_LATCH_H__
8 
9 /* --------------------------------------------------------------------- */
10 /* --- INCLUDE --------------------------------------------------------- */
11 /* --------------------------------------------------------------------- */
12 
13 /* SOT */
16 #include <dynamic-graph/entity.h>
17 
18 #include <sot/core/pool.hh>
19 
20 /* STD */
21 #include <string>
22 
23 namespace dynamicgraph {
24 namespace sot {
25 
26 /* --------------------------------------------------------------------- */
27 /* --- CLASS ----------------------------------------------------------- */
28 /* --------------------------------------------------------------------- */
32 
33 class Latch : public Entity {
34  public: /* --- SIGNAL --- */
39 
40  protected:
42  void turnOn() { signalOutput = true; }
43  bool &turnOnLatch(bool &res, sigtime_t) {
44  res = signalOutput = true;
45  return res;
46  }
47 
48  void turnOff() { signalOutput = false; }
49  bool &turnOffLatch(bool &res, sigtime_t) {
50  res = signalOutput = false;
51  return res;
52  }
53 
54  bool &latchOutput(bool &res, sigtime_t) {
55  res = signalOutput;
56  return res;
57  }
58 
59  public:
60  Latch(const std::string &name)
61  : Entity(name),
62  outSOUT("Latch(" + name + ")::output(bool)::out"),
63  turnOnSOUT("Latch(" + name + ")::output(bool)::turnOnSout"),
64  turnOffSOUT("Latch(" + name + ")::output(bool)::turnOffSout") {
65  outSOUT.setFunction(boost::bind(&Latch::latchOutput, this, _1, _2));
66  turnOnSOUT.setFunction(boost::bind(&Latch::turnOnLatch, this, _1, _2));
67  turnOffSOUT.setFunction(boost::bind(&Latch::turnOffLatch, this, _1, _2));
68  signalOutput = false;
70  addCommand("turnOn",
72  docCommandVoid0("Turn on the latch")));
73  addCommand("turnOff",
75  docCommandVoid0("Turn off the latch")));
76  }
77 
78  virtual ~Latch(void){};
79 };
80 } /* namespace sot */
81 } /* namespace dynamicgraph */
82 
83 #endif // #ifndef __SOT_LATCH_H__
dynamicgraph::Signal< bool, sigtime_t >
dynamicgraph::sot::Latch::turnOnSOUT
Signal< bool, sigtime_t > turnOnSOUT
Definition: latch.hh:37
dynamicgraph
dynamicgraph::sot::Latch::turnOffLatch
bool & turnOffLatch(bool &res, sigtime_t)
Definition: latch.hh:49
dynamicgraph::sot::Latch::turnOn
void turnOn()
Definition: latch.hh:42
dynamicgraph::sot::Latch::turnOff
void turnOff()
Definition: latch.hh:48
dynamicgraph::Entity
dynamicgraph::sot::Latch::outSOUT
Signal< bool, sigtime_t > outSOUT
Definition: latch.hh:36
dynamicgraph::sot::Latch::Latch
Latch(const std::string &name)
Definition: latch.hh:60
dynamicgraph::command::docCommandVoid0
std::string docCommandVoid0(const std::string &doc)
dynamicgraph::Entity::name
std::string name
dynamicgraph::Signal::setFunction
virtual void setFunction(boost::function2< T &, T &, Time > t, Mutex *mutexref=NULL)
dynamicgraph::command::makeCommandVoid0
CommandVoid0< E > * makeCommandVoid0(E &entity, boost::function< void(E *)> function, const std::string &docString)
command-bind.h
res
res
dynamicgraph::sigtime_t
int64_t sigtime_t
dynamicgraph::sot::Latch::DYNAMIC_GRAPH_ENTITY_DECL
DYNAMIC_GRAPH_ENTITY_DECL()
all-signals.h
dynamicgraph::sot::Latch::latchOutput
bool & latchOutput(bool &res, sigtime_t)
Definition: latch.hh:54
dynamicgraph::sot::Latch::turnOffSOUT
Signal< bool, sigtime_t > turnOffSOUT
Definition: latch.hh:38
pool.hh
dynamicgraph::sot::Latch::signalOutput
bool signalOutput
Definition: latch.hh:41
dynamicgraph::Entity::addCommand
void addCommand(const std::string &name, command::Command *command)
dynamicgraph::Entity::signalRegistration
void signalRegistration(const SignalArray< sigtime_t > &signals)
dynamicgraph::sot::Latch::turnOnLatch
bool & turnOnLatch(bool &res, sigtime_t)
Definition: latch.hh:43
dynamicgraph::sot::Latch::~Latch
virtual ~Latch(void)
Definition: latch.hh:78
dynamicgraph::sot::Latch
Definition: latch.hh:33


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Tue Oct 24 2023 02:26:31