File indexing completed on 2025-01-18 10:17:19
0001
0002
0003
0004
0005 #ifndef JANA2_DETECTORMESSAGE_H
0006 #define JANA2_DETECTORMESSAGE_H
0007
0008 #include <string>
0009 #include <chrono>
0010 #include <JANA/Streaming/JMessage.h>
0011 #include <JANA/JException.h>
0012 #include <cstring>
0013
0014
0015
0016
0017
0018
0019
0020 class ReadoutMessageManual : public JEventMessage {
0021
0022
0023
0024
0025 static const size_t BUFFER_SIZE = 1024;
0026 char m_buffer[BUFFER_SIZE];
0027 size_t m_data_size;
0028
0029 public:
0030
0031
0032 inline char* as_buffer() override { return m_buffer; }
0033 inline size_t get_buffer_size() override { return BUFFER_SIZE; }
0034 inline size_t get_data_size() override { return BUFFER_SIZE; }
0035 inline bool is_end_of_stream() override { return get_source_id() == 0 && get_message_id() == 0 && get_payload_size() == 0; }
0036
0037 ReadoutMessage end_of_stream() override { return {}; }
0038
0039
0040
0041
0042 ReadoutMessage(uint32_t source_id = 0, uint32_t message_id = 0) {
0043 set_source_id(source_id);
0044 set_message_id(message_id);
0045 }
0046
0047 inline friend std::ostream& operator<< (std::ostream& os, const ReadoutMessage& msg) {
0048 std::stringstream ss;
0049 ss << msg.message_id << ": ";
0050 for (int i=0; i<5 && i<N; ++i) {
0051 ss << msg.payload[i] << ", ";
0052 }
0053 ss << "...";
0054 os << ss.str();
0055 return os;
0056 }
0057
0058 inline size_t get_event_number() override {
0059 return 0;
0060 }
0061
0062 inline size_t get_run_number() override {
0063 return 0;
0064 }
0065
0066 };
0067
0068
0069 #endif