Skip to content

Commit e832cff

Browse files
committed
Add signal to Switch entity
1 parent 45d91b8 commit e832cff

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

include/sot/core/switch.hh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,32 @@ namespace dynamicgraph {
4545

4646
public: /* --- SIGNAL --- */
4747
DYNAMIC_GRAPH_ENTITY_DECL();
48-
dynamicgraph::Signal<bool,int> outSOUT;
48+
Signal<bool,int> outSOUT;
49+
Signal<bool,int> turnOnSOUT;
50+
Signal<bool,int> turnOffSOUT;
4951

5052
protected:
5153
bool signalOutput;
5254
void turnOn(){ signalOutput = true; }
55+
bool& turnOnSwitch(bool& res, int){ res = signalOutput = true; return res; }
5356

5457
void turnOff(){ signalOutput = false; }
58+
bool& turnOffSwitch(bool& res, int){ res = signalOutput = false; return res; }
5559

5660
bool& switchOutput(bool& res, int){ res = signalOutput; return res; }
5761

5862
public:
5963
Switch( const std::string& name )
6064
: Entity(name)
6165
,outSOUT("Switch("+name+")::output(bool)::out")
66+
,turnOnSOUT ("Switch("+name+")::output(bool)::turnOnSout")
67+
,turnOffSOUT("Switch("+name+")::output(bool)::turnOffSout")
6268
{
6369
outSOUT.setFunction(boost::bind(&Switch::switchOutput,this,_1,_2));
70+
turnOnSOUT .setFunction(boost::bind(&Switch::turnOnSwitch ,this,_1,_2));
71+
turnOffSOUT.setFunction(boost::bind(&Switch::turnOffSwitch,this,_1,_2));
6472
signalOutput = false;
65-
signalRegistration (outSOUT );
73+
signalRegistration (outSOUT << turnOnSOUT << turnOffSOUT);
6674
addCommand ("turnOn",
6775
makeCommandVoid0 (*this, &Switch::turnOn,
6876
docCommandVoid0 ("Turn on the switch")));

0 commit comments

Comments
 (0)