 |
Belle II Software
release-05-02-19
|
12 #include <framework/pcore/zmq/utils/ZMQParent.h>
13 #include <framework/pcore/zmq/connections/ZMQSimpleConnection.h>
14 #include <daq/rfarm/event/hltsocket/HLTMainLoop.h>
15 #include <framework/pcore/zmq/messages/ZMQMessageFactory.h>
16 #include <framework/logging/Logger.h>
18 #include <boost/program_options.hpp>
21 namespace po = boost::program_options;
47 template<
class AInputConnection,
class AOutputConnection>
48 class ZMQStandardApp {
69 std::unique_ptr<AInputConnection>
m_input;
71 std::unique_ptr<AOutputConnection>
m_output;
73 std::unique_ptr<ZMQSimpleConnection>
m_monitor;
84 virtual void addOptions(po::options_description& desc);
110 std::chrono::system_clock::time_point
m_start;
123 #include <daq/hbasf2/apps/ZMQApp.details.h>
std::chrono::system_clock::time_point m_start
Start time for the timeout.
std::unique_ptr< AOutputConnection > m_output
Pointer to the output connection. Should be set in initialize.
void pollEvent(bool pollOnInput)
Poll until a single event is retreived.
EMessageTypes
Type the messages can have.
bool m_monitorHasPriority
Flag to break out of the polling loop to check for monitoring messages. Except for the finalcollector...
virtual void handleTimeout()
Will get called on a timeout. Can be overridden in a derived class. Empty by default.
bool checkTimer()
Helper function to check, if the timeout should happen.
bool m_terminate
Can be set by functions to terminate the main loop at the next possibility.
void main()
Start the main loop polling on the output and monitoring connections and eventually also on the input...
virtual void handleInput()
Will get called for every message on the input connection. Can be overridden in a derived class....
std::shared_ptr< ZMQParent > m_parent
Pointer to the ZMQParent to be used as base for all connections.
void resetTimer()
Helper function to reset the start time and the remaining time.
virtual void handleExternalSignal(EMessageTypes)
Will get called for every signal message on the monitoring connection. Can be overridden in a derived...
virtual void addOptions(po::options_description &desc)
Override in a derived class to add the command line arguments. Do not forget to call this base functi...
void updateTimer()
Helper function to update the remaining time.
bool terminated() const
Check if the main loop will be exited on next occasion. Can be set via the "m_terminate" flag.
std::unique_ptr< ZMQSimpleConnection > m_monitor
Pointer to the monitoring connection. Should be set in initialize.
Abstract base class for different kinds of events.
int m_remainingTime
Counter for the remaining time until a timeout happens.
HLTMainLoop m_mainLoop
Internal signal handler.
void handleMonitoring()
Handle an incoming message on the monitoring socket by either calling handleExternalSignal() or by pa...
void initFromConsole(const std::string &description, int argc, char *argv[])
Should be called before the main() function to initialize the connections using the paremeters given ...
std::string m_monitoringAddress
Storage for the monitoring address for the cmd arguments.
virtual void handleOutput()
Will get called for every message on the output connection. Can be overridden in a derived class....
virtual void initialize()
Override in a derived class to initialize the connections from the given command line arguments....
unsigned int m_timeout
If set to a value != 0, will call handleTimeout with this frequency (in seconds).
std::unique_ptr< AInputConnection > m_input
Pointer to the input connection. Should be set in initialize.
virtual void fillMonitoringJSON(std::stringstream &buffer) const
Using the connections, fill up a buffer with the content to be monitored.