Line data Source code
1 : /**
2 : * @file Receiver.hpp Receiver Class implementations
3 : *
4 : * This is part of the DUNE DAQ Application Framework, copyright 2020.
5 : * Licensing/copyright details are in the COPYING file that you should have
6 : * received with this code.
7 : */
8 :
9 : #include "ipm/Receiver.hpp"
10 : #include "ipm/opmon/ipm.pb.h"
11 :
12 : #include <utility>
13 :
14 : dunedaq::ipm::Receiver::Response
15 79472 : dunedaq::ipm::Receiver::receive(const duration_t& timeout, message_size_t bytes, bool no_tmoexcept_mode)
16 : {
17 79472 : if (!can_receive()) {
18 2 : throw KnownStateForbidsReceive(ERS_HERE);
19 : }
20 79470 : auto message = receive_(timeout, no_tmoexcept_mode);
21 :
22 79429 : if (bytes != s_any_size) {
23 4 : auto received_size = static_cast<message_size_t>(message.data.size());
24 4 : if (received_size != bytes) {
25 2 : throw UnexpectedNumberOfBytes(ERS_HERE, received_size, bytes);
26 : }
27 : }
28 :
29 79427 : m_bytes += message.data.size();
30 79427 : ++m_messages;
31 :
32 79427 : return message;
33 2 : }
34 :
35 : void
36 20 : dunedaq::ipm::Receiver::generate_opmon_data()
37 : {
38 :
39 20 : opmon::ReceiverInfo i;
40 :
41 20 : i.set_bytes(m_bytes.exchange(0));
42 20 : i.set_messages(m_messages.exchange(0));
43 :
44 20 : publish(std::move(i));
45 20 : }
|