27 #ifndef __sot_talos_balance_delay_H__
28 #define __sot_talos_balance_delay_H__
30 #include <dynamic-graph/command-bind.h>
31 #include <dynamic-graph/entity.h>
32 #include <dynamic-graph/factory.h>
33 #include <dynamic-graph/signal-ptr.h>
34 #include <dynamic-graph/signal.h>
37 #if defined(delay_EXPORTS)
38 #define DELAY_EXPORT __declspec(dllexport)
40 #define DELAY_EXPORT __declspec(dllimport)
48 namespace talos_balance {
50 template <
typename Value,
typename Time =
int>
52 DYNAMIC_GRAPH_ENTITY_DECL();
56 sin(NULL,
"Delay(" +
name +
")::input(unspecified)::sin"),
57 currentOUT(
"Delay(" +
name +
")::output(unspecified)::current"),
58 previousOUT(
"Delay(" +
name +
")::output(unspecified)::previous") {
59 currentOUT.setFunction(boost::bind(&Delay::current,
this, _1, _2));
60 previousOUT.setFunction(boost::bind(&Delay::previous,
this, _1, _2));
61 signalRegistration(sin << currentOUT << previousOUT);
63 using command::makeCommandVoid1;
64 std::string docstring =
66 " Set current value in memory\n";
67 addCommand(
"setMemory",
68 makeCommandVoid1(*
this, &Delay::setMemory, docstring));
74 virtual std::string getDocString()
const {
75 return "Enable delayed signal in SoT.\n"
76 "Signal previous at time t+1 will return the value of signal "
78 " at time <= t (the last time signal current was called).";
81 void setMemory(
const Value& val) { mem = val; }
84 Value& current(Value& res,
const Time& time) {
85 previousOUT.access(time);
86 res = sin.access(time);
91 Value& previous(Value& res,
const Time&) {
97 SignalPtr<Value, Time> sin;
98 Signal<Value, Time> currentOUT, previousOUT;
106 #endif // #ifndef __sot_talos_balance_simple_pid_H__