DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::hsilibs::HSIEventSender Class Referenceabstract

HSIEventSender provides an interface to process and and send HSIEvents. More...

#include <HSIEventSender.hpp>

Inheritance diagram for dunedaq::hsilibs::HSIEventSender:
[legend]
Collaboration diagram for dunedaq::hsilibs::HSIEventSender:
[legend]

Public Member Functions

 HSIEventSender (const std::string &name)
 HSIEventSender Constructor.
 
 HSIEventSender (const HSIEventSender &)=delete
 HSIEventSender is not copy-constructible.
 
HSIEventSenderoperator= (const HSIEventSender &)=delete
 HSIEventSender is not copy-assignable.
 
 HSIEventSender (HSIEventSender &&)=delete
 HSIEventSender is not move-constructible.
 
HSIEventSenderoperator= (HSIEventSender &&)=delete
 HSIEventSender is not move-assignable.
 
void init (std::shared_ptr< appfwk::ConfigurationManager > mcfg) override
 

Protected Types

using raw_sender_ct = iomanager::SenderConcept<HSI_FRAME_STRUCT>
 
using hsievent_sender_ct = iomanager::SenderConcept<dfmessages::HSIEvent>
 

Protected Member Functions

virtual void do_configure (const nlohmann::json &obj)=0
 
virtual void do_start (const nlohmann::json &obj)=0
 
virtual void do_stop (const nlohmann::json &obj)=0
 
virtual void do_scrap (const nlohmann::json &obj)=0
 
virtual bool ready_to_send (std::chrono::milliseconds timeout)
 
virtual void send_hsi_event (dfmessages::HSIEvent &event)
 
virtual void send_raw_hsi_data (const std::array< uint32_t, 7 > &raw_data, raw_sender_ct *sender)
 

Protected Attributes

std::string m_hsievent_send_connection
 
std::chrono::milliseconds m_queue_timeout
 
std::shared_ptr< hsievent_sender_ctm_hsievent_sender
 
std::atomic< uint64_t > m_sent_counter
 
std::atomic< uint64_t > m_failed_to_send_counter
 
std::atomic< uint64_t > m_last_sent_timestamp
 

Detailed Description

HSIEventSender provides an interface to process and and send HSIEvents.

Definition at line 33 of file HSIEventSender.hpp.

Member Typedef Documentation

◆ hsievent_sender_ct

◆ raw_sender_ct

Constructor & Destructor Documentation

◆ HSIEventSender() [1/3]

dunedaq::hsilibs::HSIEventSender::HSIEventSender ( const std::string & name)
explicit

HSIEventSender Constructor.

Parameters
nameInstance name for this HSIEventSender instance

Definition at line 26 of file HSIEventSender.cpp.

27 : dunedaq::appfwk::DAQModule(name)
30 , m_hsievent_sender(nullptr)
34{
35}
std::atomic< uint64_t > m_last_sent_timestamp
std::atomic< uint64_t > m_failed_to_send_counter
std::atomic< uint64_t > m_sent_counter
std::shared_ptr< hsievent_sender_ct > m_hsievent_sender
std::chrono::milliseconds m_queue_timeout

◆ HSIEventSender() [2/3]

dunedaq::hsilibs::HSIEventSender::HSIEventSender ( const HSIEventSender & )
delete

HSIEventSender is not copy-constructible.

◆ HSIEventSender() [3/3]

dunedaq::hsilibs::HSIEventSender::HSIEventSender ( HSIEventSender && )
delete

HSIEventSender is not move-constructible.

Member Function Documentation

◆ do_configure()

virtual void dunedaq::hsilibs::HSIEventSender::do_configure ( const nlohmann::json & obj)
protectedpure virtual

◆ do_scrap()

virtual void dunedaq::hsilibs::HSIEventSender::do_scrap ( const nlohmann::json & obj)
protectedpure virtual

◆ do_start()

virtual void dunedaq::hsilibs::HSIEventSender::do_start ( const nlohmann::json & obj)
protectedpure virtual

◆ do_stop()

virtual void dunedaq::hsilibs::HSIEventSender::do_stop ( const nlohmann::json & obj)
protectedpure virtual

◆ init()

void dunedaq::hsilibs::HSIEventSender::init ( std::shared_ptr< appfwk::ConfigurationManager > mcfg)
override

Definition at line 38 of file HSIEventSender.cpp.

39{
40 auto mdal = mcfg->get_dal<confmodel::DaqModule>(get_name()); // Only need generic DaqModule for output
41
42 if (!mdal) {
43 throw appfwk::CommandFailed(ERS_HERE, "init", get_name(), "Unable to retrieve configuration object");
44 }
45
46 for (auto con : mdal->get_outputs()) {
47 if (con->get_data_type() == datatype_to_string<dfmessages::HSIEvent>()) {
48 m_hsievent_send_connection = con->UID();
49 }
50 }
51
53}
#define ERS_HERE
static std::shared_ptr< iomanager::SenderConcept< Datatype > > get_iom_sender(iomanager::ConnectionId const &id)
Unknown serialization Cannot deserialize std::string datatype_to_string()

◆ operator=() [1/2]

HSIEventSender & dunedaq::hsilibs::HSIEventSender::operator= ( const HSIEventSender & )
delete

HSIEventSender is not copy-assignable.

◆ operator=() [2/2]

HSIEventSender & dunedaq::hsilibs::HSIEventSender::operator= ( HSIEventSender && )
delete

HSIEventSender is not move-assignable.

◆ ready_to_send()

bool dunedaq::hsilibs::HSIEventSender::ready_to_send ( std::chrono::milliseconds timeout)
protectedvirtual

Definition at line 56 of file HSIEventSender.cpp.

57{
58 if (m_hsievent_sender == nullptr) {
59 return false;
60 }
61 return m_hsievent_sender->is_ready_for_sending(timeout);
62}

◆ send_hsi_event()

void dunedaq::hsilibs::HSIEventSender::send_hsi_event ( dfmessages::HSIEvent & event)
protectedvirtual

Definition at line 65 of file HSIEventSender.cpp.

66{
67 TLOG_DEBUG(3) << get_name() << ": Sending HSIEvent to " << m_hsievent_send_connection << ". \n"
68 << event.header << ", " << std::bitset<32>(event.signal_map) << ", " << event.timestamp << ", "
69 << event.sequence_counter << "\n";
70
71 bool was_successfully_sent = false;
72 while (!was_successfully_sent) {
73 try {
74 dfmessages::HSIEvent event_copy(event);
75 m_hsievent_sender->send(std::move(event_copy), m_queue_timeout);
77 m_last_sent_timestamp.store(event.timestamp);
78 was_successfully_sent = true;
79 } catch (const dunedaq::iomanager::TimeoutExpired& excpt) {
80 std::ostringstream oss_warn;
81 oss_warn << "push to output connection \"" << m_hsievent_send_connection << "\"";
82 ers::error(dunedaq::iomanager::TimeoutExpired(ERS_HERE, get_name(), oss_warn.str(), m_queue_timeout.count()));
84 }
85 }
86 if (m_sent_counter > 0 && m_sent_counter % 200000 == 0)
87 TLOG_DEBUG(3) << "Have sent out " << m_sent_counter << " HSI events";
88}
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
void error(const Issue &issue)
Definition ers.hpp:81

◆ send_raw_hsi_data()

void dunedaq::hsilibs::HSIEventSender::send_raw_hsi_data ( const std::array< uint32_t, 7 > & raw_data,
raw_sender_ct * sender )
protectedvirtual

Definition at line 91 of file HSIEventSender.cpp.

92{
93 HSI_FRAME_STRUCT payload;
94 ::memcpy(&payload, &raw_data[0], sizeof(HSI_FRAME_STRUCT));
95
96 TLOG_DEBUG(3) << get_name() << ": Sending HSI_FRAME_STRUCT " << std::hex << "0x" << payload.frame.version << ", 0x"
97 << payload.frame.detector_id
98
99 << "; 0x" << payload.frame.timestamp_low << "; 0x" << payload.frame.timestamp_high << "; 0x"
100 << payload.frame.input_low << "; 0x" << payload.frame.input_high << "; 0x" << payload.frame.trigger
101 << "; 0x" << payload.frame.sequence << std::endl;
102
103 try {
104 // TODO deal with this
105 if (!sender) {
106 throw(QueueIsNullFatalError(ERS_HERE, get_name(), "HSIEventSender output"));
107 }
108 sender->send(std::move(payload), m_queue_timeout);
109 } catch (const dunedaq::iomanager::TimeoutExpired& excpt) {
110 std::ostringstream oss_warn;
111 oss_warn << "push to output raw hsi data queue failed";
112 ers::error(dunedaq::iomanager::TimeoutExpired(ERS_HERE, get_name(), oss_warn.str(), m_queue_timeout.count()));
114 }
115}

Member Data Documentation

◆ m_failed_to_send_counter

std::atomic<uint64_t> dunedaq::hsilibs::HSIEventSender::m_failed_to_send_counter
protected

Definition at line 71 of file HSIEventSender.hpp.

◆ m_hsievent_send_connection

std::string dunedaq::hsilibs::HSIEventSender::m_hsievent_send_connection
protected

Definition at line 57 of file HSIEventSender.hpp.

◆ m_hsievent_sender

std::shared_ptr<hsievent_sender_ct> dunedaq::hsilibs::HSIEventSender::m_hsievent_sender
protected

Definition at line 63 of file HSIEventSender.hpp.

◆ m_last_sent_timestamp

std::atomic<uint64_t> dunedaq::hsilibs::HSIEventSender::m_last_sent_timestamp
protected

Definition at line 72 of file HSIEventSender.hpp.

◆ m_queue_timeout

std::chrono::milliseconds dunedaq::hsilibs::HSIEventSender::m_queue_timeout
protected

Definition at line 58 of file HSIEventSender.hpp.

◆ m_sent_counter

std::atomic<uint64_t> dunedaq::hsilibs::HSIEventSender::m_sent_counter
protected

Definition at line 70 of file HSIEventSender.hpp.


The documentation for this class was generated from the following files: