24 #ifndef SKA_CHEETAH_EXPORTERS_SPCCLSPEADREADER_H 25 #define SKA_CHEETAH_EXPORTERS_SPCCLSPEADREADER_H 29 #include "detail/SpCclSpeadStreamTraits.h" 30 #include "SpCclSpeadReaderConfig.h" 31 #include "cheetah/data/SpCandidateData.h" 32 #include "pss/astrotypes/utils/TypeTraits.h" 33 #include <spead2/common_defines.h> 34 #include <spead2/recv_heap.h> 35 #include <spead2/recv_udp.h> 53 template<
typename TimeFrequencyT,
typename Callback=std::function<
void(std::shared_ptr<data::SpCand
idateData<TimeFrequencyT>>)>
54 ,
typename DataFactory=std::function<data::SpCand
idateData<TimeFrequencyT>*()>>
55 class SpCclSpeadReader :
public SpCclSpeadStreamTraits
58 typedef TimeFrequencyT TimeFrequencyType;
59 typedef data::SpCandidateData<TimeFrequencyType> SpCclType;
60 typedef typename TimeFrequencyType::FrequencyType FrequencyType;
61 typedef typename TimeFrequencyType::TimeType TimeType;
62 typedef typename TimeFrequencyType::DataType NumericalRep;
64 class Stream :
public spead2::recv::stream
66 typedef spead2::recv::stream BaseT;
69 Stream(SpCclSpeadReader& reader, boost::asio::io_service& engine, DataFactory
const& factory, Callback callback);
70 Stream(Stream
const&) =
delete;
73 void heap_ready(spead2::recv::live_heap &&)
override;
74 void stop_received()
override;
79 boost::asio::io_service& _engine;
80 SpCclSpeadReader& _reader;
81 DataFactory _data_factory;
86 SpCclSpeadReader(SpCclSpeadReaderConfig
const&, Callback callback, DataFactory
const& factory=[]() {
return new SpCclType(); });
88 SpCclSpeadReader(SpCclSpeadReader
const&) =
delete;
103 static void fill(SpCclType& data, spead2::recv::heap
const&);
114 void add_stop_callback(std::function<
void()>
const& fn);
119 void add_start_callback(std::function<
void()>
const& fn);
124 void visit_stop_listeners();
125 void visit_start_listeners();
128 std::mutex _stop_mutex;
130 std::size_t _max_heaps;
131 std::unique_ptr<Stream> _spead_stream;
132 boost::asio::ip::udp::endpoint _spead_stream_endpoint;
133 std::vector<std::function<void()>> _stop_listeners;
134 std::vector<std::function<void()>> _start_listeners;
141 #include "detail/SpCclSpeadReader.cpp" 142 #endif // ENABLE_SPEAD 144 #endif // SKA_CHEETAH_EXPORTERS_SPCCLSPEADREADER_H Some limits and constants for FLDO.