DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::asiolibs::SourceModel< TargetPayloadType > Class Template Reference

#include <SourceModel.hpp>

Inheritance diagram for dunedaq::asiolibs::SourceModel< TargetPayloadType >:
[legend]
Collaboration diagram for dunedaq::asiolibs::SourceModel< TargetPayloadType >:
[legend]

Public Types

using sink_t = iomanager::SenderConcept<TargetPayloadType>
 
using inherited = SourceConcept
 
using data_t = nlohmann::json
 
- Public Types inherited from dunedaq::opmonlib::MonitorableObject
using NodePtr = std::weak_ptr<MonitorableObject>
 
using NewNodePtr = std::shared_ptr<MonitorableObject>
 
using ElementId = std::string
 

Public Member Functions

 SourceModel ()
 SourceModel Constructor.
 
 ~SourceModel ()
 
void set_sink (const std::string &sink_name, bool callback_mode) override
 
void acquire_callback () override
 
std::shared_ptr< sink_t > & get_sink ()
 
bool handle_payload (char *message, std::size_t size)
 
std::size_t get_target_payload_size () const override
 
void generate_opmon_data () override
 
- Public Member Functions inherited from dunedaq::asiolibs::SourceConcept
 SourceConcept ()
 
virtual ~SourceConcept ()
 
 SourceConcept (const SourceConcept &)=delete
 SourceConcept is not copy-constructible.
 
SourceConceptoperator= (const SourceConcept &)=delete
 SourceConcept is not copy-assginable.
 
 SourceConcept (SourceConcept &&)=delete
 SourceConcept is not move-constructible.
 
SourceConceptoperator= (SourceConcept &&)=delete
 SourceConcept is not move-assignable.
 
void set_sink_name (const std::string &sink_name)
 
- Public Member Functions inherited from dunedaq::opmonlib::MonitorableObject
 MonitorableObject (const MonitorableObject &)=delete
 
MonitorableObjectoperator= (const MonitorableObject &)=delete
 
 MonitorableObject (MonitorableObject &&)=delete
 
MonitorableObjectoperator= (MonitorableObject &&)=delete
 
virtual ~MonitorableObject ()=default
 
auto get_opmon_id () const noexcept
 
auto get_opmon_level () const noexcept
 

Private Types

using sink_cb_t = std::shared_ptr<std::function<void(TargetPayloadType&&)>>
 

Private Attributes

std::string m_sink_id
 
bool m_sink_is_set { false }
 
std::shared_ptr< sink_tm_sink_queue
 
bool m_callback_mode
 
bool m_callback_is_acquired { false }
 
sink_cb_t m_sink_callback
 
std::atomic< uint64_t > m_dropped_packets {0}
 

Additional Inherited Members

- Static Public Member Functions inherited from dunedaq::opmonlib::MonitorableObject
static bool publishable_metric (OpMonLevel entry, OpMonLevel system) noexcept
 
- Public Attributes inherited from dunedaq::asiolibs::SourceConcept
std::string m_sink_name
 
- Protected Member Functions inherited from dunedaq::opmonlib::MonitorableObject
 MonitorableObject ()=default
 
void register_node (ElementId name, NewNodePtr)
 
void publish (google::protobuf::Message &&, CustomOrigin &&co={}, OpMonLevel l=to_level(EntryOpMonLevel::kDefault)) const noexcept
 

Detailed Description

template<class TargetPayloadType>
class dunedaq::asiolibs::SourceModel< TargetPayloadType >

Definition at line 36 of file SourceModel.hpp.

Member Typedef Documentation

◆ data_t

template<class TargetPayloadType >
using dunedaq::asiolibs::SourceModel< TargetPayloadType >::data_t = nlohmann::json

Definition at line 41 of file SourceModel.hpp.

◆ inherited

template<class TargetPayloadType >
using dunedaq::asiolibs::SourceModel< TargetPayloadType >::inherited = SourceConcept

Definition at line 40 of file SourceModel.hpp.

◆ sink_cb_t

template<class TargetPayloadType >
using dunedaq::asiolibs::SourceModel< TargetPayloadType >::sink_cb_t = std::shared_ptr<std::function<void(TargetPayloadType&&)>>
private

Definition at line 134 of file SourceModel.hpp.

◆ sink_t

template<class TargetPayloadType >
using dunedaq::asiolibs::SourceModel< TargetPayloadType >::sink_t = iomanager::SenderConcept<TargetPayloadType>

Definition at line 39 of file SourceModel.hpp.

Constructor & Destructor Documentation

◆ SourceModel()

template<class TargetPayloadType >
dunedaq::asiolibs::SourceModel< TargetPayloadType >::SourceModel ( )
inline

SourceModel Constructor.

Parameters
nameInstance name for this SourceModel instance

Definition at line 47 of file SourceModel.hpp.

◆ ~SourceModel()

template<class TargetPayloadType >
dunedaq::asiolibs::SourceModel< TargetPayloadType >::~SourceModel ( )
inline

Definition at line 50 of file SourceModel.hpp.

50{}

Member Function Documentation

◆ acquire_callback()

template<class TargetPayloadType >
void dunedaq::asiolibs::SourceModel< TargetPayloadType >::acquire_callback ( )
inlineoverridevirtual

Implements dunedaq::asiolibs::SourceConcept.

Definition at line 67 of file SourceModel.hpp.

68 {
69 if (m_callback_mode) {
71 TLOG_DEBUG(5) << "SourceModel callback is already acquired!";
72 } else {
73 // Getting DataMoveCBRegistry
75 m_sink_callback = dmcbr->get_callback<TargetPayloadType>(inherited::m_sink_name);
77 }
78 } else {
79 TLOG_DEBUG(5) << "Won't acquire callback, as IOM sink is set!";
80 }
81 }
static std::shared_ptr< DataMoveCallbackRegistry > get()
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112

◆ generate_opmon_data()

template<class TargetPayloadType >
void dunedaq::asiolibs::SourceModel< TargetPayloadType >::generate_opmon_data ( )
inlineoverridevirtual

Hook for customisable pubblication. The function can throw, exception will be caught by the monitoring thread

Reimplemented from dunedaq::opmonlib::MonitorableObject.

Definition at line 117 of file SourceModel.hpp.

117 {
118
119 opmon::SourceInfo info;
120 info.set_dropped_frames( m_dropped_packets.load() );
121
122 publish( std::move(info) );
123 }
std::atomic< uint64_t > m_dropped_packets
void publish(google::protobuf::Message &&, CustomOrigin &&co={}, OpMonLevel l=to_level(EntryOpMonLevel::kDefault)) const noexcept

◆ get_sink()

template<class TargetPayloadType >
std::shared_ptr< sink_t > & dunedaq::asiolibs::SourceModel< TargetPayloadType >::get_sink ( )
inline

Definition at line 83 of file SourceModel.hpp.

83{ return m_sink_queue; }
std::shared_ptr< sink_t > m_sink_queue

◆ get_target_payload_size()

template<class TargetPayloadType >
std::size_t dunedaq::asiolibs::SourceModel< TargetPayloadType >::get_target_payload_size ( ) const
inlineoverridevirtual

Implements dunedaq::asiolibs::SourceConcept.

Definition at line 112 of file SourceModel.hpp.

112 {
113 TargetPayloadType target_payload;
114 return target_payload.get_frame_size(); // TODO (DTE): Could be a static function?
115 }

◆ handle_payload()

template<class TargetPayloadType >
bool dunedaq::asiolibs::SourceModel< TargetPayloadType >::handle_payload ( char * message,
std::size_t size )
inlinevirtual

Implements dunedaq::asiolibs::SourceConcept.

Definition at line 85 of file SourceModel.hpp.

86 {
87 bool push_out = true;
88 if (push_out) {
89
90 TargetPayloadType& target_payload = *reinterpret_cast<TargetPayloadType*>(message);
91
92 if (m_callback_mode) {
93 (*m_sink_callback)(std::move(target_payload));
94 } else {
95 if (!m_sink_queue->try_send(std::move(target_payload), iomanager::Sender::s_no_block)) {
96 //if(m_dropped_packets == 0 || m_dropped_packets%10000) {
97 // TLOG() << "Dropped data " << m_dropped_packets;
98 //}
100 }
101 }
102
103 } else {
104 TargetPayloadType target_payload;
105 uint32_t bytes_copied = 0;
106 datahandlinglibs::buffer_copy(message, size, static_cast<void*>(&target_payload), bytes_copied, sizeof(target_payload));
107 }
108
109 return true;
110 }
static constexpr timeout_t s_no_block
Definition Sender.hpp:26
void buffer_copy(const char *data, std::size_t size, void *buffer, std::uint32_t buffer_pos, const std::size_t &buffer_size)
Unknown serialization Cannot deserialize message
FELIX Initialization std::string initerror FELIX queue timed std::string queuename Unexpected chunk size

◆ set_sink()

template<class TargetPayloadType >
void dunedaq::asiolibs::SourceModel< TargetPayloadType >::set_sink ( const std::string & sink_name,
bool callback_mode )
inlineoverridevirtual

Implements dunedaq::asiolibs::SourceConcept.

Definition at line 52 of file SourceModel.hpp.

53 {
54 m_callback_mode = callback_mode;
55 if (callback_mode) {
56 TLOG_DEBUG(5) << "Callback mode requested. Won't acquire iom sender!";
57 } else {
58 if (m_sink_is_set) {
59 TLOG_DEBUG(5) << "SourceModel sink is already set in initialized!";
60 } else {
62 m_sink_is_set = true;
63 }
64 }
65 }
static std::shared_ptr< iomanager::SenderConcept< Datatype > > get_iom_sender(iomanager::ConnectionId const &id)

Member Data Documentation

◆ m_callback_is_acquired

template<class TargetPayloadType >
bool dunedaq::asiolibs::SourceModel< TargetPayloadType >::m_callback_is_acquired { false }
private

Definition at line 133 of file SourceModel.hpp.

133{ false };

◆ m_callback_mode

template<class TargetPayloadType >
bool dunedaq::asiolibs::SourceModel< TargetPayloadType >::m_callback_mode
private

Definition at line 132 of file SourceModel.hpp.

◆ m_dropped_packets

template<class TargetPayloadType >
std::atomic<uint64_t> dunedaq::asiolibs::SourceModel< TargetPayloadType >::m_dropped_packets {0}
private

Definition at line 137 of file SourceModel.hpp.

137{0};

◆ m_sink_callback

template<class TargetPayloadType >
sink_cb_t dunedaq::asiolibs::SourceModel< TargetPayloadType >::m_sink_callback
private

Definition at line 135 of file SourceModel.hpp.

◆ m_sink_id

template<class TargetPayloadType >
std::string dunedaq::asiolibs::SourceModel< TargetPayloadType >::m_sink_id
private

Definition at line 127 of file SourceModel.hpp.

◆ m_sink_is_set

template<class TargetPayloadType >
bool dunedaq::asiolibs::SourceModel< TargetPayloadType >::m_sink_is_set { false }
private

Definition at line 128 of file SourceModel.hpp.

128{ false };

◆ m_sink_queue

template<class TargetPayloadType >
std::shared_ptr<sink_t> dunedaq::asiolibs::SourceModel< TargetPayloadType >::m_sink_queue
private

Definition at line 129 of file SourceModel.hpp.


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