Belle II Software development
ZMQROIConnection.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include <daq/hbasf2/connections/ZMQROIConnection.h>
9#include <arpa/inet.h>
10
11using namespace Belle2;
12
13ZMQDataAndROIOutput::ZMQDataAndROIOutput(const std::string& dataAddress, const std::string& roiAddress,
14 bool addEventSize, const std::shared_ptr<ZMQParent>& parent) :
15 m_dataOutput(dataAddress, addEventSize, parent), m_roiOutput(roiAddress, false, parent) {}
16
17void ZMQDataAndROIOutput::handleEvent(std::unique_ptr<ZMQNoIdMessage> message)
18{
19 if (message->isMessage(EMessageTypes::c_rawDataMessage) or message->isMessage(EMessageTypes::c_eventMessage)) {
20 B2ASSERT("The data message needs to be present!", message->getDataMessage().size() > 0);
21 B2ASSERT("The roi message needs to be present!", message->getAdditionalDataMessage().size() > 0);
22
23 m_dataOutput.handleEvent(std::move(message->getDataMessage()));
24 m_roiOutput.handleEvent(std::move(message->getAdditionalDataMessage()));
25 }
26}
27
29{
32 }
35 }
36}
37
39{
41}
42
43std::vector<zmq::socket_t*> ZMQDataAndROIOutput::getSockets() const
44{
46}
47
49{
51}
52
54{
56}
std::vector< zmq::socket_t * > getSockets() const final
The socket used for polling is just the stored socket.
static bool hasMessage(const ZMQConnection *connection)
Check if the given connection as an incoming message (right now, no waiting).
void handleIncomingData()
Handle both a socket (dis)connect by raw or ROI.
ZMQRawOutput m_dataOutput
The used raw connection.
std::string getROIMonitoringJSON() const
Get the monitoring JSON from the ROI connection.
bool isReady() const final
Ready only when both sockets are ready.
std::string getMonitoringJSON() const final
Get the monitoring JSON from the raw connection.
ZMQRawOutput m_roiOutput
The used ROI connection.
void handleEvent(std::unique_ptr< ZMQNoIdMessage > message)
Send the normal data message to raw and the additional message to ROI.
std::vector< zmq::socket_t * > getSockets() const final
Return both sockets for polling.
ZMQDataAndROIOutput(const std::string &dataAddress, const std::string &roiAddress, bool addEventSize, const std::shared_ptr< ZMQParent > &parent)
Initialize the raw and roi connection.
virtual std::string getMonitoringJSON() const
Convert the stored monitoring values to a JSON string ready for sending out via a message.
Definition: ZMQLogger.cc:15
void handleIncomingData()
Handle incoming data: a socket (dis)connect.
virtual void handleEvent(zmq::message_t message)
Pass on the message - maybe by prefixing it with a htonl-converted data size in bytes.
bool isReady() const final
If no socket is connected, this connection is not ready.
Abstract base class for different kinds of events.