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

#include <SourceModel.hpp>

Inheritance diagram for dunedaq::crtmodules::SourceModel< TargetPayloadType >:
[legend]
Collaboration diagram for dunedaq::crtmodules::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_frame_size () const override
 
void generate_opmon_data () override
 
- Public Member Functions inherited from dunedaq::crtmodules::SourceConcept
 SourceConcept ()
 
virtual ~SourceConcept ()
 
 SourceConcept (const SourceConcept &)=delete
 SourceConcept is not copy-constructible.
 
SourceConceptoperator= (const SourceConcept &)=delete
 SourceConcept is not copy-assignable.
 
 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
 

Static Public Attributes

static constexpr auto buffer_size = sizeof(TargetPayloadType)
 Buffer size based on TargetPayloadType.
 

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::crtmodules::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::crtmodules::SourceModel< TargetPayloadType >

Definition at line 36 of file SourceModel.hpp.

Member Typedef Documentation

◆ data_t

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

Definition at line 41 of file SourceModel.hpp.

◆ inherited

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

Definition at line 40 of file SourceModel.hpp.

◆ sink_cb_t

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

Definition at line 139 of file SourceModel.hpp.

◆ sink_t

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

Definition at line 39 of file SourceModel.hpp.

Constructor & Destructor Documentation

◆ SourceModel()

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

SourceModel Constructor.

Parameters
nameInstance name for this SourceModel instance

Definition at line 52 of file SourceModel.hpp.

◆ ~SourceModel()

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

Definition at line 55 of file SourceModel.hpp.

55{}

Member Function Documentation

◆ acquire_callback()

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

Implements dunedaq::crtmodules::SourceConcept.

Definition at line 72 of file SourceModel.hpp.

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

◆ generate_opmon_data()

template<class TargetPayloadType >
void dunedaq::crtmodules::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 122 of file SourceModel.hpp.

122 {
123
124 opmon::SourceInfo info;
125 info.set_dropped_frames( m_dropped_packets.load() );
126
127 publish( std::move(info) );
128 }
std::atomic< uint64_t > m_dropped_packets
void publish(google::protobuf::Message &&, CustomOrigin &&co={}, OpMonLevel l=to_level(EntryOpMonLevel::kDefault)) const noexcept

◆ get_frame_size()

template<class TargetPayloadType >
std::size_t dunedaq::crtmodules::SourceModel< TargetPayloadType >::get_frame_size ( ) const
inlineoverridevirtual

Implements dunedaq::crtmodules::SourceConcept.

Definition at line 117 of file SourceModel.hpp.

117 {
118 TargetPayloadType target_payload;
119 return target_payload.get_frame_size(); // TODO (DTE): Could be a static function?
120 }

◆ get_sink()

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

Definition at line 88 of file SourceModel.hpp.

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

◆ handle_payload()

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

Implements dunedaq::crtmodules::SourceConcept.

Definition at line 90 of file SourceModel.hpp.

91 {
92 bool push_out = true;
93 if (push_out) {
94
95 TargetPayloadType& target_payload = *reinterpret_cast<TargetPayloadType*>(message);
96
97 if (m_callback_mode) {
98 (*m_sink_callback)(std::move(target_payload));
99 } else {
100 if (!m_sink_queue->try_send(std::move(target_payload), iomanager::Sender::s_no_block)) {
101 //if(m_dropped_packets == 0 || m_dropped_packets%10000) {
102 // TLOG() << "Dropped data " << m_dropped_packets;
103 //}
105 }
106 }
107
108 } else {
109 TargetPayloadType target_payload;
110 uint32_t bytes_copied = 0;
111 datahandlinglibs::buffer_copy(message, size, static_cast<void*>(&target_payload), bytes_copied, sizeof(target_payload));
112 }
113
114 return true;
115 }
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::crtmodules::SourceModel< TargetPayloadType >::set_sink ( const std::string & sink_name,
bool callback_mode )
inlineoverridevirtual

Implements dunedaq::crtmodules::SourceConcept.

Definition at line 57 of file SourceModel.hpp.

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

Member Data Documentation

◆ buffer_size

template<class TargetPayloadType >
auto dunedaq::crtmodules::SourceModel< TargetPayloadType >::buffer_size = sizeof(TargetPayloadType)
staticconstexpr

Buffer size based on TargetPayloadType.

Definition at line 46 of file SourceModel.hpp.

◆ m_callback_is_acquired

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

Definition at line 138 of file SourceModel.hpp.

138{ false };

◆ m_callback_mode

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

Definition at line 137 of file SourceModel.hpp.

◆ m_dropped_packets

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

Definition at line 142 of file SourceModel.hpp.

142{0};

◆ m_sink_callback

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

Definition at line 140 of file SourceModel.hpp.

◆ m_sink_id

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

Definition at line 132 of file SourceModel.hpp.

◆ m_sink_is_set

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

Definition at line 133 of file SourceModel.hpp.

133{ false };

◆ m_sink_queue

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

Definition at line 134 of file SourceModel.hpp.


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