runMACS
 All Data Structures Files Functions Variables Enumerations Enumerator Macros
GrabberStatsPublisher.cpp
Go to the documentation of this file.
2 #include <stringtricks.h>
3 
5  const std::string & _cameraName) :
6  publishHeader(SSTR("ROCS\x01grabber.", _cameraName)),
7  destinationSocket(_ctx, ZMQ_PUB) {
8  destinationSocket.connect("inproc://log");
9 }
10 
11 void GrabberStatsPublisher::publishJsonValue(Json::Value & _value) {
12  zmq::message_t msgHdr(publishHeader.length());
13  memcpy((char*)msgHdr.data(), publishHeader.c_str(), publishHeader.length());
14  destinationSocket.send(msgHdr, ZMQ_SNDMORE);
15 
16  Json::FastWriter writer;
17  std::string data = writer.write(_value);
18  zmq::message_t msgData(data.length());
19  memcpy((char *)msgData.data(), data.c_str(), data.length());
20  destinationSocket.send(msgData);
21 }
22 
23 void GrabberStatsPublisher::publishBufferLoad(const int usedBuffers, const int totalBuffers) {
24  Json::Value value;
25  value["usedBuffers"] = usedBuffers;
26  value["totalBuffers"] = totalBuffers;
27  publishJsonValue(value);
28 }
void publishBufferLoad(const int usedBuffers, const int totalBuffers)
void publishJsonValue(Json::Value &_value)
std::string SSTR(Args &&...components)
Creates a temporary string stream for string concatenation.
Definition: stringtricks.h:21
GrabberStatsPublisher(zmq::context_t &_ctx, const std::string &_cameraName)