13 std::srand(source_id * 12345);
15 for (
int i = 0; i <
size; i++) {
16 int random_ch = std::rand() % 64;
21template<
class ReadoutType>
34template<
class ReadoutType>
45 std::mt19937 mt(rand());
46 std::uniform_real_distribution<double> dis(0.0, 1.0);
69 for (
size_t i = 0; i <
m_dropouts.size(); ++i) {
82 TLOG() <<
"Generated pattern.";
99template<
class ReadoutType>
112template<
class ReadoutType>
117 std::this_thread::sleep_for(std::chrono::milliseconds(100));
121template<
class ReadoutType>
129 this->
publish(std::move(info));
132template<
class ReadoutType>
146 std::this_thread::sleep_for(std::chrono::milliseconds(100));
150 auto rptr =
reinterpret_cast<ReadoutType*
>(source.data());
153 uint64_t ts_0 = rptr->get_timestamp();
155 auto time_now = std::chrono::system_clock::now().time_since_epoch();
156 uint64_t current_time =
157 std::chrono::duration_cast<std::chrono::microseconds>(time_now).count();
160 ts_0 = 625 * current_time / 10;
163 uint64_t timestamp = ts_0;
164 int dropout_index = 0;
165 uint64_t number_pattern_hits_generated = 0;
167 const uint64_t max_tps_per_frame = 64;
173 if (
offset == num_elem || (
offset + 1) *
sizeof(ReadoutType) > source.size()) {
177 bool create_frame =
m_dropouts[dropout_index];
178 dropout_index = (dropout_index + 1) %
m_dropouts.size();
182 ::memcpy(
static_cast<void*
>(&payload),
183 static_cast<void*
>(source.data() +
offset *
sizeof(ReadoutType)),
184 sizeof(ReadoutType));
193 std::vector<uint16_t> frame_errs;
194 for (
size_t i = 0; i < rptr->get_num_frames(); ++i) {
197 payload.fake_frame_errors(&frame_errs);
200 uint64_t number_pattern_hits_expected = (timestamp - ts_0) /
m_time_to_wait;
203 uint64_t tps_this_frame = 0;
204 if (number_pattern_hits_expected > number_pattern_hits_generated) {
205 tps_this_frame = number_pattern_hits_expected - number_pattern_hits_generated;
208 if (tps_this_frame > max_tps_per_frame) {
209 tps_this_frame = max_tps_per_frame;
213 for (uint64_t tp_idx = 0; tp_idx < tps_this_frame; ++tp_idx) {
218 payload.fake_adc_pattern(channel);
219 }
catch (
const std::out_of_range&) {
226 number_pattern_hits_generated += tps_this_frame;
231 (*m_raw_data_callback)(std::move(payload));
uint32_t get_random_population_size() const
Get "random_population_size" attribute value.
bool get_generate_periodic_adc_pattern() const
Get "generate_periodic_adc_pattern" attribute value.
bool get_set_t0() const
Get "set_t0" attribute value. Set first timestamp to now.
uint32_t get_input_file_size_limit() const
Get "input_file_size_limit" attribute value.
float get_frame_error_rate_hz() const
Get "frame_error_rate_hz" attribute value.
const std::string & get_data_file_name() const
Get "data_file_name" attribute value.
float get_TP_rate_per_channel() const
Get "TP_rate_per_channel" attribute value. TP rate per channel in units of 100 Hz.
const dunedaq::confmodel::GeoId * get_geo_id() const
Get "geo_id" relationship value.
uint32_t get_source_id() const
Get "source_id" attribute value.
uint32_t get_stream_id() const
Get "stream_id" attribute value.
uint32_t get_slot_id() const
Get "slot_id" attribute value.
uint32_t get_crate_id() const
Get "crate_id" attribute value.
static std::shared_ptr< DataMoveCallbackRegistry > get()
ErrorBitGenerator(double rate=0)
const appmodel::DataMoveCallbackConf * m_sink_conf
uint m_frame_errors_length
uint32_t m_this_link_number
virtual void generate_opmon_data() override
utilities::ReusableThread m_producer_thread
std::unique_ptr< RateLimiter > m_rate_limiter
void stop(const appfwk::DAQModule::CommandData_t &)
std::vector< bool > m_dropouts
daqdataformats::SourceID m_sourceid
SourceEmulatorPatternGenerator m_pattern_generator
std::atomic< bool > & m_run_marker
ErrorBitGenerator m_error_bit_generator
void conf(const confmodel::DetectorStream *stream_conf, const appmodel::StreamEmulationParameters *emu_conf)
void start(const appfwk::DAQModule::CommandData_t &)
uint16_t m_frames_per_tick
std::atomic< int > m_packet_count_tot
std::shared_ptr< std::function< void(ReadoutType &&)> > m_raw_data_callback
std::atomic< int > m_packet_count
void acquire_callback() override
uint64_t m_time_tick_diff
bool m_generate_periodic_adc_pattern
double m_frame_error_rate
std::unique_ptr< FileSourceBuffer > m_file_source
std::vector< int > m_channel
void publish(google::protobuf::Message &&, CustomOrigin &&co={}, OpMonLevel l=to_level(EntryOpMonLevel::kDefault)) const noexcept
Base class for any user define issue.
#define TLOG_DEBUG(lvl,...)
FELIX Initialization std::string initerror FELIX queue timed std::string queuename Unexpected chunk size
void warning(const Issue &issue)
void fatal(const Issue &issue)