9 #include <yarp/os/BufferedPort.h>
10 #include <yarp/os/Bottle.h>
11 #include <yarp/os/Log.h>
12 #include <yarp/os/LogStream.h>
13 #include <yarp/os/LogComponent.h>
16 YARP_LOG_COMPONENT(RAWVALUESPUBLISHERSERVER,
"iCub.debugLibrary.rawvaluespublisherserver")
19 #undef DEBUG_RAW_VALUES_MACRO
21 using namespace yarp::os;
38 m_threadPeriodInS =
m_period / 1000.0;
40 if(m_threadPeriodInS <= 0)
42 yCError(RAWVALUESPUBLISHERSERVER)
43 <<
"Period parameter is present with value:"
44 << m_threadPeriodInS <<
"but it is not a positive integer. Closing...";
49 m_streamingPortName =
m_name +
"/rawdata:o";
51 if(!m_streamingRawDataPort.open(m_streamingPortName))
53 yCError(RAWVALUESPUBLISHERSERVER)
54 <<
"Error opening streaming raw data port:" << m_streamingPortName;
59 m_rpcPortName =
m_name +
"/rpc:o";
62 if(!this->
yarp().attachAsServer(m_rpcRawDataPort))
64 yCError(RAWVALUESPUBLISHERSERVER)
65 <<
"Failure in attaching RPC port to thrift RPC interface";
70 if(!m_rpcRawDataPort.open(m_rpcPortName))
72 yCError(RAWVALUESPUBLISHERSERVER)
73 <<
"Failure in opening rpc port:" << m_rpcPortName;
78 yCInfo(RAWVALUESPUBLISHERSERVER) <<
"Open ports completes";
96 yCError(RAWVALUESPUBLISHERSERVER)
97 <<
"Trying to expose" <<
p.size() <<
"device(s). Expected only one device to be exposed to YARP ports. Closing...";
102 yarp::dev::PolyDriver* poly =
p[0]->poly;
106 yCError(RAWVALUESPUBLISHERSERVER)
107 <<
"NullPointerException when getting the polyDriver at attachAll.";
113 poly->view(m_iRawValuesPublisher);
116 if(!this->setPeriod(m_threadPeriodInS))
118 yCError(RAWVALUESPUBLISHERSERVER)
119 <<
"Failure in setting periodic thread period";
125 if(!populateMetadata(m_mapOfMetadata))
127 yCError(RAWVALUESPUBLISHERSERVER,
"Failure in getMetadata()");
135 yCError(RAWVALUESPUBLISHERSERVER)
136 <<
"Failure in starting periodic thread";
141 yCInfo(RAWVALUESPUBLISHERSERVER) <<
"Attach completes";
149 if (this->isRunning())
154 m_rpcRawDataPort.close();
155 m_streamingRawDataPort.close();
157 yCInfo(RAWVALUESPUBLISHERSERVER) <<
"Detach complete";
164 return m_mapOfMetadata;
174 m_streamingRawDataPort.unprepare();
179 m_streamingRawDataPort.setEnvelope(m_stamp);
180 m_streamingRawDataPort.write();
191 #ifdef DEBUG_RAW_VALUES_MACRO
194 yCDebug(RAWVALUESPUBLISHERSERVER) <<
"Metadata at key:" << k <<
"with size:" << v.size;
195 for (
size_t i = 0; i < v.size; i++)
197 yCDebug(RAWVALUESPUBLISHERSERVER) <<
"Metadata element:" << v.rawValueNames[i];
bool parseParams(const yarp::os::Searchable &config)
RawValuesPublisherServer()
bool open(yarp::os::Searchable ¶ms) override
rawValuesKeyMetadataMap getMetadata() override
Read the rawvalues metadata necessary to configure the RawValuesPublisherClient device.
~RawValuesPublisherServer()
void threadRelease() override
bool attachAll(const yarp::dev::PolyDriverList &p) override
bool detachAll() override
virtual bool getMetadataMap(rawValuesKeyMetadataMap &metamap)=0
virtual bool getRawDataMap(std::map< std::string, std::vector< std::int32_t >> &map)=0
rawValuesDataVectorsMap IDL struct of a map of vectors to store the raw value data sent by the device
std::map< std::string, std::vector< std::int32_t > > vectorsMap
contain a map of vectors of the raw data as <string, vector> the user wanna send from low to higher l...
Copyright (C) 2008 RobotCub Consortium.