Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* Copyright 2010-2019 LAAS, CNRS
* Thomas Moulard.
*
*/
#define ENABLE_RT_LOG
#include <sstream>
#include <dynamic-graph/entity.h>
#include <dynamic-graph/exception-factory.h>
#include "dynamic-graph/factory.h"
#include "dynamic-graph/pool.h"
#include <dynamic-graph/real-time-logger.h>
#include <dynamic-graph/signal-ptr.h>
#include <dynamic-graph/signal-time-dependent.h>
namespace dynamicgraph
{
class CustomEntity : public Entity
{
public:
dynamicgraph::SignalPtr<double, int> m_sigdSIN;
dynamicgraph::SignalTimeDependent<double, int> m_sigdTimeDepSOUT;
static const std::string CLASS_NAME;
virtual const std::string& getClassName () const
{
return CLASS_NAME;
}
CustomEntity (const std::string n)
: Entity (n)
,m_sigdSIN(NULL,"CustomEntity("+name+")::input(double)::in_double")
,m_sigdTimeDepSOUT(boost::bind(&CustomEntity::update,this,_1,_2),
m_sigdSIN,
"CustomEntity("+name+")::input(double)::out_double")
{

Olivier Stasse
committed
addSignal();
}
void addSignal()
{
signalRegistration(m_sigdSIN << m_sigdTimeDepSOUT);
}
void rmValidSignal()
{
signalDeregistration("in_double");
signalDeregistration("out_double");
}
double & update(double &res, const int &inTime)
{
const double &aDouble = m_sigdSIN(inTime);
res = aDouble;

Olivier Stasse
committed
std::ostringstream oss;
oss << "start update " << res;
sendMsg(oss.str().c_str(),MSG_TYPE_ERROR);
sendMsg("This is a message of level MSG_TYPE_DEBUG",
MSG_TYPE_DEBUG,__FILE__,__LINE__);
sendMsg("This is a message of level MSG_TYPE_INFO",
MSG_TYPE_INFO,__FILE__,__LINE__);
sendMsg("This is a message of level MSG_TYPE_WARNING",
MSG_TYPE_WARNING,__FILE__,__LINE__);
sendMsg("This is a message of level MSG_TYPE_ERROR",
MSG_TYPE_ERROR,__FILE__,__LINE__);
sendMsg("This is a message of level MSG_TYPE_DEBUG_STREAM",
MSG_TYPE_DEBUG_STREAM,__FILE__,__LINE__);
sendMsg("This is a message of level MSG_TYPE_INFO_STREAM",
MSG_TYPE_INFO_STREAM,__FILE__,__LINE__);
sendMsg("This is a message of level MSG_TYPE_WARNING_STREAM",
MSG_TYPE_WARNING_STREAM,__FILE__,__LINE__);
sendMsg("This is a message of level MSG_TYPE_ERROR_STREAM",
MSG_TYPE_ERROR_STREAM,__FILE__,__LINE__);
sendMsg("end update",
MSG_TYPE_ERROR,__FILE__,__LINE__);
return res;
}
};
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN (CustomEntity,"CustomEntity");
}