Line data Source code
1 : #ifndef artdaq_Application_MPI2_BoardReaderApp_hh
2 : #define artdaq_Application_MPI2_BoardReaderApp_hh
3 :
4 : #include "artdaq/Application/BoardReaderCore.hh"
5 : #include "artdaq/Application/Commandable.hh"
6 :
7 : namespace artdaq {
8 : class BoardReaderApp;
9 : }
10 :
11 : /**
12 : * \brief BoardReaderApp is an artdaq::Commandable derived class which controls the BoardReaderCore state machine
13 : */
14 : class artdaq::BoardReaderApp : public artdaq::Commandable
15 : {
16 : public:
17 : /**
18 : * \brief BoardReaderApp Constructor
19 : */
20 : BoardReaderApp();
21 :
22 : /**
23 : * \brief Copy Constructor is deleted
24 : */
25 : BoardReaderApp(BoardReaderApp const&) = delete;
26 :
27 : /**
28 : * \brief Default Destructor
29 : */
30 0 : virtual ~BoardReaderApp() = default;
31 :
32 : /**
33 : * \brief Copy Assignment Operator is deleted
34 : * \return BoardReaderApp copy
35 : */
36 : BoardReaderApp& operator=(BoardReaderApp const&) = delete;
37 :
38 : BoardReaderApp(BoardReaderApp&&) = delete; ///< Move Constructor is deleted
39 : BoardReaderApp& operator=(BoardReaderApp&&) = delete; ///< Move Assignment Operator is deleted
40 :
41 : // these methods provide the operations that are used by the state machine
42 : /**
43 : * \brief Initialize the BoardReaderCore
44 : * \param pset ParameterSet used to configure the BoardReaderCore
45 : * \param timeout Timeout for transition
46 : * \param timestamp Timestamp of transition
47 : * \return Whether the transition succeeded
48 : */
49 : bool do_initialize(fhicl::ParameterSet const& pset, uint64_t timeout, uint64_t timestamp) override;
50 :
51 : /**
52 : * \brief Start the BoardReaderCore
53 : * \param id Run ID of new run
54 : * \param timeout Timeout for transition
55 : * \param timestamp Timestamp of transition
56 : * \return Whether the transition succeeded
57 : */
58 : bool do_start(art::RunID id, uint64_t timeout, uint64_t timestamp) override;
59 :
60 : /**
61 : * \brief Stop the BoardReaderCore
62 : * \param timeout Timeout for transition
63 : * \param timestamp Timestamp of transition
64 : * \return Whether the transition succeeded
65 : */
66 : bool do_stop(uint64_t timeout, uint64_t timestamp) override;
67 :
68 : /**
69 : * \brief Pause the BoardReaderCore
70 : * \param timeout Timeout for transition
71 : * \param timestamp Timestamp of transition
72 : * \return Whether the transition succeeded
73 : */
74 : bool do_pause(uint64_t timeout, uint64_t timestamp) override;
75 :
76 : /**
77 : * \brief Resume the BoardReaderCore
78 : * \param timeout Timeout for transition
79 : * \param timestamp Timestamp of transition
80 : * \return Whether the transition succeeded
81 : */
82 : bool do_resume(uint64_t timeout, uint64_t timestamp) override;
83 :
84 : /**
85 : * \brief Shutdown the BoardReaderCore
86 : * \param timeout Timeout for transition
87 : * \return Whether the transition succeeded
88 : */
89 : bool do_shutdown(uint64_t timeout) override;
90 :
91 : /**
92 : * \brief Soft-Initialize the BoardReaderCore
93 : * \param pset ParameterSet used to configure the BoardReaderCore
94 : * \param timeout Timeout for transition
95 : * \param timestamp Timestamp of transition
96 : * \return Whether the transition succeeded
97 : */
98 : bool do_soft_initialize(fhicl::ParameterSet const& pset, uint64_t timeout, uint64_t timestamp) override;
99 :
100 : /**
101 : * \brief Reinitialize the BoardReaderCore
102 : * \param pset ParameterSet used to configure the BoardReaderCore
103 : * \param timeout Timeout for transition
104 : * \param timestamp Timestamp of transition
105 : * \return Whether the transition succeeded
106 : */
107 : bool do_reinitialize(fhicl::ParameterSet const& pset, uint64_t timeout, uint64_t timestamp) override;
108 :
109 : /**
110 : * \brief Action taken upon entering the "Booted" state
111 : *
112 : * This resets the BoardReaderCore pointer
113 : */
114 : void BootedEnter() override;
115 :
116 : /**
117 : * \brief Perform a user-defined command (passed to CommandableFragmentGenerator)
118 : * \param command Name of the command
119 : * \param arg Argument for the command
120 : * \return Whether the command succeeded
121 : */
122 : bool do_meta_command(std::string const& command, std::string const& arg) override;
123 :
124 : /* Report_ptr */
125 : /**
126 : * \brief If which is "transition_status", report the status of the last transition. Otherwise pass through to BoardReaderCore
127 : * \param which What to report on
128 : * \return Report string. Empty for unknown "which" parameter
129 : */
130 : std::string report(std::string const& which) const override;
131 :
132 : CommandableFragmentGenerator const* GetGeneratorPointer()
133 : {
134 : if (fragment_receiver_ptr_)
135 : return fragment_receiver_ptr_->GetGeneratorPointer();
136 : else
137 : return nullptr;
138 : }
139 :
140 : private:
141 : std::unique_ptr<artdaq::BoardReaderCore> fragment_receiver_ptr_;
142 : boost::thread fragment_input_thread_;
143 : boost::thread fragment_output_thread_;
144 : };
145 :
146 : #endif /* artdaq_Application_MPI2_BoardReaderApp_hh */
|