DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
EmulationUnit.hpp
Go to the documentation of this file.
1/* @file: EmulationUnit.hpp
2 *
3 * Base abstract class for emulation units.
4 *
5 * This is part of the DUNE DAQ Application Framework, copyright 2023.
6 * Licensing/copyright details are in the COPYING file that you should have
7 * received with this code.
8 */
9
10#ifndef TRGTOOLS_EMULATIONUNIT_HPP_
11#define TRGTOOLS_EMULATIONUNIT_HPP_
12
16
17#include <chrono>
18#include <fstream>
19#include <iostream>
20#include <memory>
21#include <vector>
22
23namespace dunedaq {
24namespace trgtools {
25
26template <typename T, typename U, typename V>
28{
29 using input_t = T;
30 using output_t = U;
31 using maker_t = V;
32
33 private:
34 std::unique_ptr<maker_t> m_maker; // TODO: unique may become shared later.
35 std::vector<output_t> m_last_output_buffer;
36 std::string m_timing_file_name;
37
38 public:
39 uint64_t emulate(const input_t& input, std::vector<output_t>& outputs);
40 std::unique_ptr<daqdataformats::Fragment> emulate_vector(const std::vector<input_t>& inputs);
41 std::vector<output_t> get_last_output_buffer();
42 void set_maker(std::unique_ptr<maker_t>& maker) { m_maker = std::move(maker); }
43 void set_timing_file(const std::string& file_name) { m_timing_file_name = file_name; }
44 void write_csv_header(const std::string& header) {
45 std::fstream file_header;
46 file_header.open(m_timing_file_name, std::ios::out | std::ios::app);
47 file_header << header << "\n";
48 file_header.close();
49 }
50};
51
52} // namespace trgtools
53} // namespace dunedaq
54
56
57#endif // TRGTOOLS_EMULATIONUNIT_HPP_
std::unique_ptr< daqdataformats::Fragment > emulate_vector(const std::vector< input_t > &inputs)
std::vector< output_t > get_last_output_buffer()
uint64_t emulate(const input_t &input, std::vector< output_t > &outputs)
std::unique_ptr< maker_t > m_maker
void set_timing_file(const std::string &file_name)
void write_csv_header(const std::string &header)
void set_maker(std::unique_ptr< maker_t > &maker)
std::vector< output_t > m_last_output_buffer
Including Qt Headers.