1 #ifndef artdaq_ots_Generators_UDPReceiver_hh
2 #define artdaq_ots_Generators_UDPReceiver_hh
17 #include "artdaq-core/Data/Fragment.hh"
18 #include "artdaq/Generators/CommandableFragmentGenerator.hh"
19 #include "fhiclcpp/fwd.h"
21 #include <arpa/inet.h>
22 #include <netinet/in.h>
23 #include <sys/socket.h>
24 #include <sys/types.h>
37 enum class CommandType : uint8_t
45 enum class ReturnCode : uint8_t
53 enum class DataType : uint8_t
68 typedef std::string packetBuffer_t;
69 typedef std::list<packetBuffer_t> packetBuffer_list_t;
71 class UDPReceiver :
public artdaq::CommandableFragmentGenerator
74 explicit UDPReceiver(fhicl::ParameterSet
const& ps);
82 bool getNext_(artdaq::FragmentPtrs& output)
override;
83 void start(
void)
override;
84 virtual void start_();
85 virtual void stop(
void)
override;
86 virtual void stopNoMutex(
void)
override;
88 virtual void ProcessData_(artdaq::FragmentPtrs& output,
size_t totalSize);
90 DataType getDataType(uint8_t
byte)
92 return static_cast<DataType
>((
byte & 0xF0) >> 4);
94 ReturnCode getReturnCode(uint8_t
byte) {
return static_cast<ReturnCode
>(
byte & 0xF); }
95 void send(CommandType flag);
97 packetBuffer_list_t packetBuffers_;
100 std::string rawPath_;
119 bool isTimerExpired_();
121 std::unique_ptr<std::thread> receiverThread_;
122 std::mutex receiveBufferLock_;
123 packetBuffer_list_t receiveBuffers_;
128 double fragmentWindow_;
129 std::chrono::high_resolution_clock::time_point lastFrag_;
struct sockaddr_in si_data_
Socket parameters.
bool getNext_(artdaq::FragmentPtrs &output) override
uint8_t expectedPacketNumber_
The packet number of the next packet. Used to discover dropped packets.