Belle II Software development

Modules

 daq data objects
 
 daq modules
 

Classes

class  EvtSocketSend
 
class  EvtSocketRecv
 
class  EvtSocketManager
 
class  REvtSocketRecv
 
class  REvtSocketSend
 
class  RSocketSend
 
class  RSocketRecv
 
class  SocketIO
 
class  SocketRecv
 
class  SocketSend
 
class  SocketManager
 
class  DqmMasterCallback
 
class  DqmMemFile
 
class  DqmSharedMem
 
class  HistoManager
 
class  HistoManager2
 
class  HistoRelay
 
class  HistoServer
 
class  HistoServer2
 
class  ERecoDistributor
 
class  ERecoEventProcessor
 
class  ERecoEventSampler
 
class  ERecoMaster
 
class  ERecoMasterCallback
 
class  ERecoRunControlCallback
 
class  EventSampler
 
class  EventServer
 
class  EventServerCallback
 
class  ZMQStandardApp< AInputConnection, AOutputConnection >
 Generic base class for all standalone ZMQ applications. More...
 
class  ZMQReadySender
 App to only send a ready on every incoming message - behaves the same as the input of a worker (but without an output). More...
 
class  ZMQAcceptor
 App to only send a confirmation on every incoming message - behaves the same as the input of a (final)collector (but without an output). More...
 
class  ZMQWorker
 App to mimick a basf2-worker by accepting an incoming message with a ready message and sending it out via the output - requiring a confirmation message from the next step. More...
 
class  ZMQCollector
 Normal collector app: receive messages on the input reacting with a confirmation message and sends them out via a load-balanced connection to ready workers. More...
 
class  ZMQOutputAdapter
 Special collector app for translating between ZMQ and raw connections: send ready messages (like a typical worker) on the input and send all received events to the raw connection at output. More...
 
class  ZMQProxyCollector
 Special collector app: receive messages on the input reacting with a confirmation message and sends them out via a confirmed connection to ready workers. More...
 
class  ZMQFinalCollector
 Final collector app: receive messages on the input reacting with a confirmation message and sends them out via a raw connection (e.g. More...
 
class  ZMQFinalCollectorWithROI
 Special form of the ZMQFinalCollector for sending out the additional data message to a ROI receiver. More...
 
class  ZMQDistributor
 Standard distributor app: receive data via a raw connection (e.g. More...
 
class  ZMQInputAdapter
 
class  ZMQHistogramToFileServer
 Final histogram app: receive histogram messages from all clients and react with a confirmation message. More...
 
class  ZMQHistogramToZMQServer
 Non-Final histogram app: receive histogram messages from all clients and react with a confirmation message. More...
 
class  ZMQHistogramToRawServer
 Non-Final histogram app: receive histogram messages from all clients and react with a confirmation message. More...
 
class  ZMQHistoServerToFileOutput
 Output histograms into a ROOT file and shared memory after merging. More...
 
class  ZMQHistoServerToZMQOutput
 Send the histograms as compressed byte stream via a ZMQConfirmedOutput connection after merging with all the properties of a normal confirmed output. More...
 
class  ZMQHistoServerToRawOutput
 Same as ZMQHistoServerToZMQOutput just send uncompressed to a raw output. More...
 
class  ZMQHistogramOutput< AConnectionClass >
 Add the common functionality to the histogram output classes. More...
 
class  ZMQROIOutput
 Dedicated output to send ROI messages to the PXD ONSEN system. More...
 
class  ZMQDataAndROIOutput
 Helper connection hosting both a normal raw and a ROI output and sending to both at the same time. More...
 
class  HistogramMapping
 Utility to store received histograms (hierarchical tree structures) from clients (as an event message), with a function to add multiple histogram trees together. More...
 
class  HLTEventProcessor
 EventProcessor to be used on the HLT with all specialities of the HLT processing: More...
 
class  HLTStreamHelper
 Helper class for data store serialization. More...
 
class  StorageStreamHelper
 Helper class for data store serialization. More...
 
class  CprErrorMessage
 
class  DesSer
 A class definition of an input module for Sequential ROOT I/O. More...
 
class  DesSerCOPPER
 A class definition of an input module for Sequential ROOT I/O. More...
 
class  DesSerPrePC
 A class definition of an input module for Sequential ROOT I/O. More...
 
class  HLTFile
 
class  HLTMainLoop
 
class  HLTSocket
 
class  RawRevRb2Sock
 
class  Rb2Sock
 
class  RevRb2Sock
 
class  RevSock2Rb
 
class  Sock2Rb
 
class  RFCommand
 
struct  RFConf_t
 
class  RFConf
 
class  RFDqmServer
 
class  RFEventProcessor
 
class  RFEventServer
 
class  RFFlowStat
 
class  RFLogManager
 
class  RFMaster
 
class  RFMasterCallback
 
struct  RfNodeInfo
 
class  RFNodeManager
 
class  RFNSM_Status
 
class  RFNSM
 
class  RFOutputServer
 
class  RFProcessManager
 
class  RFRoiSender
 
class  RFRunControlCallback
 
class  RFServerBase
 
struct  RfShm_Cell
 
struct  RfShm_Data
 
class  RFSharedMem
 
struct  RfUnitInfo
 
class  SharedMem
 
class  RoiSenderCallback
 
class  AbstractDBObject
 
class  ConfigFile
 
class  Connection
 
class  Date
 
class  Enum
 
class  ERRORNo
 
class  Exception
 
class  IOException
 
class  Reader
 
class  Serializable
 
struct  StringUtil
 
class  TimeoutException
 
class  Writer
 
class  DAQLogDB
 
class  DAQLogMessage
 
class  DBHandlerException
 
class  DBInterface
 
class  DBObject
 
class  DBObjectLoader
 
class  DBRecord
 
class  MonitorDB
 
class  RunNumber
 
class  RunNumberTable
 
class  AbstractNSMCallback
 
class  Callback
 
class  NSMCallback
 
class  NSMCommand
 
class  NSMCommunicator
 
class  NSMData
 
struct  NSMDataPaket
 
class  NSMDataStore
 
class  NSMHandlerException
 
class  NSMMessage
 
class  NSMNode
 
class  NSMNodeDaemon
 
class  NSMNotConnectedException
 
class  NSMState
 
class  NSMVar
 
class  NSMVHandler
 
class  NSMVHandlerInt
 
class  NSMVHandlerFloat
 
class  NSMVHandlerText
 
class  NSMVHandlerIntArray
 
class  NSMVHandlerFloatArray
 
class  NSMVHandlerRef
 
class  PostgreSQLInterface
 
class  FlowMonitor
 
class  IOInfo
 
class  LogListener
 
class  ProcessController
 
class  ProcessSubmitter
 
class  ProcessListener
 
struct  ro_summary
 
struct  event_header
 
struct  ronode_info
 
struct  ronode_status
 
class  RunInfoBuffer
 
class  RCCallback
 
class  RCCommand
 
class  RCConfig
 
class  RCHandlerException
 
class  RCHandlerFatalException
 
class  RCNode
 
class  RCNodeDaemon
 
class  RCState
 
class  RCConfigHandler
 
class  Buffer
 
class  BufferedReader
 
class  BufferedWriter
 
class  CommandLine
 
class  Cond
 
class  Daemon
 
class  DynamicLoader
 
class  DynamicLoadException
 
class  Executor
 
class  Fifo
 
class  File
 
class  FileDescriptor
 
class  FileReader< FD >
 
class  FileWriter< FD >
 
class  Fork
 
class  InotifyEvent
 
class  Inotify
 
class  GenericLockGuard< AMutex >
 Lock Guard for a Mutex instance. More...
 
struct  LogFile
 
class  MCond
 
class  MMutex
 
class  Mutex
 
class  Process
 
class  PThread
 
class  RWLock
 
class  SharedMemory
 
class  StreamSizeCounter
 
class  TCPServerSocket
 
class  TCPSocket
 
class  Time
 
class  UDPSocket
 
struct  BinTrailer
 
struct  BinHeader
 
class  BinData
 
class  EventBuffer
 
class  ONSENBinData
 
class  SharedEventBuffer
 
class  EvtBuffer
 
class  Sender
 

Typedefs

typedef unsigned short u_short
 
using ZMQHistoServerToFile = ZMQHistogramOutput< ZMQHistoServerToFileOutput >
 
using ZMQHistoServerToZMQ = ZMQHistogramOutput< ZMQHistoServerToZMQOutput >
 
using ZMQHistoServerToRaw = ZMQHistogramOutput< ZMQHistoServerToRawOutput >
 
typedef std::vector< std::string > StringList
 
typedef std::vector< DAQLogMessageDAQLogMessageList
 
typedef std::vector< DBRecordDBRecordList
 
typedef std::map< std::string, std::string > DBFieldTypeList
 
typedef std::vector< DBObjectDBObjectList
 
typedef std::map< std::string, std::string > DBFieldList
 
typedef std::vector< RunNumberRunNumberList
 
typedef std::map< std::string, NSMNodeNSMNodeMap
 
typedef std::map< std::string, NSMNodeMap > NSMNodeMapMap
 
typedef std::map< std::string, NSMDataNSMDataMap
 
typedef std::vector< NSMCommunicator * > NSMCommunicatorList
 
typedef std::vector< NSMDataNSMDataList
 
typedef std::map< std::string, NSMDataList > NSMDataListMap
 
typedef std::vector< NSMVarNSMVarList
 
typedef std::map< std::string, NSMVHandler * > NSMVHandlerList
 
typedef FileReader< FilePipeReader
 
typedef FileReader< FifoFifoReader
 
typedef FileWriter< FifoFifoWriter
 
typedef std::vector< InotifyEventInotifyEventList
 
typedef GenericLockGuard< MutexLockGuard
 
typedef GenericLockGuard< MMutexMLockGuard
 
typedef FileReader< TCPSocketTCPSocketReader
 
typedef FileWriter< TCPSocketTCPSocketWriter
 

Functions

int nsm_read_argv (int argc, const char **argv, int(*help)(const char **argv), char **argv_in, ConfigFile &config, std::string &name, std::string &username, int nargv)
 
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 on command line.
 
void main ()
 Start the main loop polling on the output and monitoring connections and eventually also on the input if the output is ready.
 
void pollEvent (bool pollOnInput)
 Poll until a single event is retreived.
 
virtual void initialize ()
 Override in a derived class to initialize the connections from the given command line arguments. Do not forget to call this base function also.
 
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 function also.
 
virtual void handleExternalSignal (EMessageTypes)
 Will get called for every signal message on the monitoring connection. Can be overridden in a derived class. Empty by default.
 
virtual void handleInput ()
 Will get called for every message on the input connection. Can be overridden in a derived class. Calls handleIncomingData by default.
 
virtual void handleOutput ()
 Will get called for every message on the output connection. Can be overridden in a derived class. Calls handleIncomingData by default.
 
virtual void handleTimeout ()
 Will get called on a timeout. Can be overridden in a derived class. Empty by default.
 
bool terminated () const
 Check if the main loop will be exited on next occasion. Can be set via the "m_terminate" flag.
 
bool checkTimer ()
 Helper function to check, if the timeout should happen.
 
void updateTimer ()
 Helper function to update the remaining time.
 
void resetTimer ()
 Helper function to reset the start time and the remaining time.
 
void handleMonitoring ()
 Handle an incoming message on the monitoring socket by either calling handleExternalSignal() or by passing on the monitor JSONs of the connections.
 
virtual void fillMonitoringJSON (std::stringstream &buffer) const
 Using the connections, fill up a buffer with the content to be monitored.
 
template<class... Args>
 ZMQHistogramOutput (unsigned int maximalUncompressedBufferSize, Args &&... args)
 Perfectly forward the given arguments to the base class initializer (and init the buffer size)
 
bool getBool (const std::string &name, int index=0) const
 
char getChar (const std::string &name, int index=0) const
 
short getShort (const std::string &name, int index=0) const
 
int getInt (const std::string &name, int index=0) const
 
long long getLong (const std::string &name, int index=0) const
 
float getFloat (const std::string &name, int index=0) const
 
double getDouble (const std::string &name, int index=0) const
 
void setBool (const std::string &name, bool value, int index=0)
 
void setChar (const std::string &name, int value, int index=0)
 
void setShort (const std::string &name, int value, int index=0)
 
void setInt (const std::string &name, int value, int index=0)
 
void setLong (const std::string &name, long long value, int index=0)
 
void setFloat (const std::string &name, float value, int index=0)
 
void setDouble (const std::string &name, double value, int index=0)
 
void addBool (const std::string &name, bool value)
 
void addChar (const std::string &name, char value)
 
void addShort (const std::string &name, short value)
 
void addInt (const std::string &name, int value)
 
void addLong (const std::string &name, long long value)
 
void addFloat (const std::string &name, float value)
 
void addDouble (const std::string &name, double value)
 
bool hasKey (const std::string &label)
 
bool operator== (const Connection &st) const
 
bool operator!= (const Connection &st) const
 
bool operator== (const Enum &e) const
 
bool operator!= (const Enum &e) const
 
bool operator== (const std::string &label) const
 
bool operator!= (const std::string &label) const
 
NSMDatagetData (const std::string &name)
 
void openData (const std::string &name, const std::string &format, int revision=-1)
 
void allocData (const std::string &name, const std::string &format, int revision)
 
template<typename T >
void addArgument (T arg)
 
void setDB (DBInterface *db, const std::string &table)
 

Variables

const int ro_summary_revision = 1
 
const int ronode_status_revision = 1
 
Mutex g_mutex
 
Cond g_cond
 

Detailed Description

Typedef Documentation

◆ DAQLogMessageList

typedef std::vector<DAQLogMessage> DAQLogMessageList

Definition at line 22 of file DAQLogDB.h.

◆ DBFieldList

typedef std::map<std::string, std::string> DBFieldList

Definition at line 21 of file DBRecord.h.

◆ DBFieldTypeList

typedef std::map<std::string, std::string> DBFieldTypeList

Definition at line 24 of file DBInterface.h.

◆ DBObjectList

typedef std::vector<DBObject> DBObjectList

Definition at line 102 of file DBObject.h.

◆ DBRecordList

typedef std::vector< DBRecord > DBRecordList

Definition at line 23 of file DBInterface.h.

◆ FifoReader

Definition at line 20 of file FifoReader.h.

◆ FifoWriter

Definition at line 20 of file FifoWriter.h.

◆ InotifyEventList

typedef std::vector<InotifyEvent> InotifyEventList

Definition at line 47 of file Inotify.h.

◆ LockGuard

Definition at line 72 of file LockGuard.h.

◆ MLockGuard

Definition at line 73 of file LockGuard.h.

◆ NSMCommunicatorList

typedef std::vector<NSMCommunicator*> NSMCommunicatorList

Definition at line 102 of file NSMCommunicator.h.

◆ NSMDataList

typedef std::vector<NSMData> NSMDataList

Definition at line 126 of file NSMData.h.

◆ NSMDataListMap

typedef std::map<std::string, NSMDataList> NSMDataListMap

Definition at line 127 of file NSMData.h.

◆ NSMDataMap

typedef std::map<std::string, NSMData> NSMDataMap

Definition at line 29 of file NSMCallback.h.

◆ NSMNodeMap

typedef std::map< std::string, NSMNode > NSMNodeMap

Definition at line 26 of file AbstractNSMCallback.h.

◆ NSMNodeMapMap

typedef std::map<std::string, NSMNodeMap> NSMNodeMapMap

Definition at line 27 of file AbstractNSMCallback.h.

◆ NSMVarList

typedef std::vector<NSMVar> NSMVarList

Definition at line 153 of file NSMVar.h.

◆ NSMVHandlerList

typedef std::map<std::string, NSMVHandler*> NSMVHandlerList

Definition at line 86 of file NSMVHandler.h.

◆ PipeReader

Definition at line 33 of file LogListener.cc.

◆ RunNumberList

typedef std::vector<RunNumber> RunNumberList

Definition at line 57 of file RunNumber.h.

◆ StringList

typedef std::vector<std::string> StringList

Definition at line 20 of file StringUtil.h.

◆ TCPSocketReader

Definition at line 20 of file TCPSocketReader.h.

◆ TCPSocketWriter

Definition at line 20 of file TCPSocketWriter.h.

◆ u_short

typedef unsigned short u_short

Definition at line 24 of file EvtSocket.h.

◆ ZMQHistoServerToFile

◆ ZMQHistoServerToRaw

◆ ZMQHistoServerToZMQ

Function Documentation

◆ addArgument()

void addArgument ( arg)
inline

Definition at line 102 of file ProcessController.h.

103 {
104 std::stringstream ss; ss << arg;
105 m_arg_v.push_back(ss.str());
106 }

◆ addBool()

void addBool ( const std::string &  name,
bool  value 
)
inline

Definition at line 191 of file AbstractDBObject.h.

192 {
193 addValue(name, &value, DBField::BOOL, 0);
194 }

◆ addChar()

void addChar ( const std::string &  name,
char  value 
)
inline

Definition at line 196 of file AbstractDBObject.h.

197 {
198 addValue(name, &value, DBField::CHAR, 0);
199 }

◆ addDouble()

void addDouble ( const std::string &  name,
double  value 
)
inline

Definition at line 221 of file AbstractDBObject.h.

222 {
223 addValue(name, &value, DBField::DOUBLE, 0);
224 }

◆ addFloat()

void addFloat ( const std::string &  name,
float  value 
)
inline

Definition at line 216 of file AbstractDBObject.h.

217 {
218 addValue(name, &value, DBField::FLOAT, 0);
219 }

◆ addInt()

void addInt ( const std::string &  name,
int  value 
)
inline

Definition at line 206 of file AbstractDBObject.h.

207 {
208 addValue(name, &value, DBField::INT, 0);
209 }

◆ addLong()

void addLong ( const std::string &  name,
long long  value 
)
inline

Definition at line 211 of file AbstractDBObject.h.

212 {
213 addValue(name, &value, DBField::LONG, 0);
214 }

◆ addOptions()

void addOptions ( po::options_description &  desc)
protectedvirtual

Override in a derived class to add the command line arguments. Do not forget to call this base function also.

Reimplemented in ZMQReadySender, ZMQAcceptor, ZMQWorker, ZMQCollector, ZMQOutputAdapter, ZMQProxyCollector, ZMQFinalCollector, ZMQFinalCollectorWithROI, ZMQDistributor, ZMQInputAdapter, ZMQHistogramToFileServer, ZMQHistogramToZMQServer, and ZMQHistogramToRawServer.

Definition at line 160 of file ZMQApp.details.h.

161 {
162 desc.add_options()("help,h", "Print this help message")("monitor", po::value<std::string>(&m_monitoringAddress)->required(),
163 "where to listen for monitoring");
164 }
std::string m_monitoringAddress
Storage for the monitoring address for the cmd arguments.
Definition: ZMQApp.h:104

◆ addShort()

void addShort ( const std::string &  name,
short  value 
)
inline

Definition at line 201 of file AbstractDBObject.h.

202 {
203 addValue(name, &value, DBField::SHORT, 0);
204 }

◆ allocData()

void allocData ( const std::string &  name,
const std::string &  format,
int  revision 
)
inline

Definition at line 117 of file NSMCallback.h.

120 {
121 m_data = NSMData(name, format, revision);
122 }

◆ checkTimer()

bool checkTimer
private

Helper function to check, if the timeout should happen.

Definition at line 195 of file ZMQApp.details.h.

196 {
197 updateTimer();
198 return m_remainingTime == 0;
199 }
int m_remainingTime
Counter for the remaining time until a timeout happens.
Definition: ZMQApp.h:106
void updateTimer()
Helper function to update the remaining time.

◆ fillMonitoringJSON()

void fillMonitoringJSON ( std::stringstream &  buffer) const
protectedvirtual

Using the connections, fill up a buffer with the content to be monitored.

Reimplemented in ZMQFinalCollectorWithROI.

Definition at line 256 of file ZMQApp.details.h.

257 {
258 buffer << "{" << std::endl;
259 buffer << "\"monitor\": " << m_monitor->getMonitoringJSON() << "," << std::endl;
260 buffer << "\"input\": " << m_input->getMonitoringJSON() << "," << std::endl;
261 buffer << "\"output\": " << m_output->getMonitoringJSON() << std::endl;
262 buffer << "}" << std::endl;
263 }
std::unique_ptr< AOutputConnection > m_output
Pointer to the output connection. Should be set in initialize.
Definition: ZMQApp.h:69
std::unique_ptr< ZMQSimpleConnection > m_monitor
Pointer to the monitoring connection. Should be set in initialize.
Definition: ZMQApp.h:71
std::unique_ptr< AInputConnection > m_input
Pointer to the input connection. Should be set in initialize.
Definition: ZMQApp.h:67

◆ getBool()

bool getBool ( const std::string &  name,
int  index = 0 
) const
inline

Definition at line 121 of file AbstractDBObject.h.

122 {
123 return getD<bool>(name, index);
124 }

◆ getChar()

char getChar ( const std::string &  name,
int  index = 0 
) const
inline

Definition at line 126 of file AbstractDBObject.h.

127 {
128 return getD<char>(name, index);
129 }

◆ getData()

NSMData & getData ( const std::string &  name)
inline

Definition at line 100 of file NSMCallback.h.

101 {
102 if (m_datas.find(name) != m_datas.end()) {
103 return m_datas[name];
104 }
105 throw (std::out_of_range("nodata registered : " + name));
106 }

◆ getDouble()

double getDouble ( const std::string &  name,
int  index = 0 
) const
inline

Definition at line 151 of file AbstractDBObject.h.

152 {
153 return getD<double>(name, index);
154 }

◆ getFloat()

float getFloat ( const std::string &  name,
int  index = 0 
) const
inline

Definition at line 146 of file AbstractDBObject.h.

147 {
148 return getD<float>(name, index);
149 }

◆ getInt()

int getInt ( const std::string &  name,
int  index = 0 
) const
inline

Definition at line 136 of file AbstractDBObject.h.

137 {
138 return getD<int>(name, index);
139 }

◆ getLong()

long long getLong ( const std::string &  name,
int  index = 0 
) const
inline

Definition at line 141 of file AbstractDBObject.h.

142 {
143 return getD<long long>(name, index);
144 }

◆ getShort()

short getShort ( const std::string &  name,
int  index = 0 
) const
inline

Definition at line 131 of file AbstractDBObject.h.

132 {
133 return getD<short>(name, index);
134 }

◆ handleExternalSignal()

void handleExternalSignal ( EMessageTypes  )
protectedvirtual

Will get called for every signal message on the monitoring connection. Can be overridden in a derived class. Empty by default.

Reimplemented in ZMQCollector, ZMQOutputAdapter, ZMQProxyCollector, ZMQFinalCollector, ZMQFinalCollectorWithROI, ZMQDistributor, ZMQInputAdapter, ZMQHistogramToFileServer, ZMQHistogramToZMQServer, and ZMQHistogramToRawServer.

Definition at line 167 of file ZMQApp.details.h.

168 {
169 }

◆ handleInput()

void handleInput
protectedvirtual

Will get called for every message on the input connection. Can be overridden in a derived class. Calls handleIncomingData by default.

Reimplemented in ZMQWorker, ZMQCollector, ZMQOutputAdapter, ZMQProxyCollector, ZMQFinalCollector, ZMQFinalCollectorWithROI, ZMQDistributor, ZMQInputAdapter, ZMQHistogramToFileServer, ZMQHistogramToZMQServer, and ZMQHistogramToRawServer.

Definition at line 172 of file ZMQApp.details.h.

173 {
174 m_input->handleIncomingData();
175 }

◆ handleMonitoring()

void handleMonitoring
private

Handle an incoming message on the monitoring socket by either calling handleExternalSignal() or by passing on the monitor JSONs of the connections.

Definition at line 232 of file ZMQApp.details.h.

233 {
234 auto monitoringMessage = m_monitor->handleIncomingData();
235
236 if (monitoringMessage->isMessage(EMessageTypes::c_newRunMessage)) {
237 handleExternalSignal(EMessageTypes::c_newRunMessage);
238 return;
239 } else if (monitoringMessage->isMessage(EMessageTypes::c_lastEventMessage)) {
240 handleExternalSignal(EMessageTypes::c_lastEventMessage);
241 return;
242 } else if (monitoringMessage->isMessage(EMessageTypes::c_terminateMessage)) {
243 handleExternalSignal(EMessageTypes::c_terminateMessage);
244 return;
245 }
246
247 std::stringstream buffer;
248 fillMonitoringJSON(buffer);
249
250 auto message = ZMQMessageFactory::createMessage(monitoringMessage->getIdentity(),
251 EMessageTypes::c_confirmMessage, buffer.str());
252 m_monitor->handleEvent(std::move(message));
253 }
static auto createMessage(const std::string &msgIdentity, const EMessageTypes msgType, const std::unique_ptr< EvtMessage > &eventMessage)
Create an ID Message out of an identity, the type and an event message.
virtual void fillMonitoringJSON(std::stringstream &buffer) const
Using the connections, fill up a buffer with the content to be monitored.
virtual void handleExternalSignal(EMessageTypes)
Will get called for every signal message on the monitoring connection. Can be overridden in a derived...

◆ handleOutput()

void handleOutput
protectedvirtual

Will get called for every message on the output connection. Can be overridden in a derived class. Calls handleIncomingData by default.

Definition at line 178 of file ZMQApp.details.h.

179 {
180 m_output->handleIncomingData();
181 }

◆ handleTimeout()

void handleTimeout
protectedvirtual

Will get called on a timeout. Can be overridden in a derived class. Empty by default.

Reimplemented in ZMQCollector, ZMQProxyCollector, ZMQFinalCollector, ZMQFinalCollectorWithROI, ZMQDistributor, ZMQInputAdapter, ZMQHistogramToFileServer, ZMQHistogramToZMQServer, and ZMQHistogramToRawServer.

Definition at line 184 of file ZMQApp.details.h.

185 {
186 }

◆ hasKey()

bool hasKey ( const std::string &  label)
inline

Definition at line 78 of file ConfigFile.h.

79 {
80 return m_value_m.find((m_dir.size() > 0) ? m_dir + "." + label : label)
81 != m_value_m.end();
82 }

◆ initFromConsole()

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 on command line.

Custom implementations should implement the addOptions function to pass the command line arguments correctly. Calls the initialize function (which should also be overridden).

Definition at line 21 of file ZMQApp.details.h.

22 {
23
24 po::options_description desc(description);
25 std::string connection_file;
26 int debugLevel(0);
27 desc.add_options()
28 ("connection-file", boost::program_options::value<std::string>(&connection_file),
29 "if given print the connection information for input/output and monitoring socket to the given filename "
30 "in json format")
31 ("debug", boost::program_options::value<int>(&debugLevel), "Enable debug logging");
32 addOptions(desc);
33
34 po::positional_options_description p;
35
36 po::variables_map vm;
37 try {
38 po::store(po::command_line_parser(argc, argv).options(desc).positional(p).run(), vm);
39 } catch (std::exception& e) {
40 B2FATAL(e.what());
41 }
42
43 if (vm.count("help")) {
44 std::cout << desc << std::endl;
45 exit(1);
46 }
47
48 try {
49 po::notify(vm);
50 } catch (std::exception& e) {
51 B2FATAL(e.what());
52 }
53
54 if (debugLevel > 0) {
55 auto& logging = LogSystem::Instance();
56 logging.getLogConfig()->setLogLevel(LogConfig::c_Debug);
57 logging.getLogConfig()->setDebugLevel(debugLevel);
58 B2DEBUG(1, "Enabled debug logging");
59 }
60
61 initialize();
62
63 if (not connection_file.empty()) {
64 B2DEBUG(1, "Write connection file" << LogVar("connection_file", connection_file));
65 nlohmann::json json;
66 try {
67 json["input"] = m_input->getEndPoint();
68 } catch (zmq::error_t& e) {
69 B2WARNING(e.what());
70 }
71 try {
72 json["output"] = m_output->getEndPoint();
73 } catch (zmq::error_t& e) {
74 B2WARNING(e.what());
75 }
76 std::ofstream connections(connection_file, std::ofstream::trunc);
77 if (!connections) {
78 B2FATAL("Cannot write connection file" << LogVar("connection_file", connection_file));
79 }
80 connections << std::setw(4) << json << std::endl;
81 }
82 }
@ c_Debug
Debug: for code development.
Definition: LogConfig.h:26
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
Definition: LogSystem.cc:31
Class to store variables with their name which were sent to the logging service.
virtual void initialize()
Override in a derived class to initialize the connections from the given command line arguments....
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...

◆ initialize()

void initialize
protectedvirtual

Override in a derived class to initialize the connections from the given command line arguments. Do not forget to call this base function also.

Reimplemented in ZMQReadySender, ZMQAcceptor, ZMQWorker, ZMQCollector, ZMQOutputAdapter, ZMQProxyCollector, ZMQFinalCollector, ZMQFinalCollectorWithROI, ZMQDistributor, ZMQInputAdapter, ZMQHistogramToFileServer, ZMQHistogramToZMQServer, and ZMQHistogramToRawServer.

Definition at line 153 of file ZMQApp.details.h.

154 {
155 m_parent.reset(new ZMQParent);
156 m_monitor.reset(new ZMQSimpleConnection(m_monitoringAddress, m_parent));
157 }
std::shared_ptr< ZMQParent > m_parent
Pointer to the ZMQParent to be used as base for all connections.
Definition: ZMQApp.h:65

◆ main()

void main

Start the main loop polling on the output and monitoring connections and eventually also on the input if the output is ready.

Calls the functions handleExternalSignal, handleInput, handleOutput and handleTimeout as described in the documentation of this class.

Definition at line 85 of file ZMQApp.details.h.

86 {
87 resetTimer();
88
89 while (not terminated()) {
90 if (not m_output->isReady()) {
91 // if the output is not ready, we can not sent anything. So lets just poll on output
92 // and monitoring until it becomes ready
93 m_monitor->log("output_state", "not_ready");
94 pollEvent(false);
95 } else {
96 // if it is ready, we can also include the input socket as long as output stays ready
97 m_monitor->log("output_state", "ready");
98 pollEvent(true);
99 }
100 }
101 }
void pollEvent(bool pollOnInput)
Poll until a single event is retreived.
bool terminated() const
Check if the main loop will be exited on next occasion. Can be set via the "m_terminate" flag.
void resetTimer()
Helper function to reset the start time and the remaining time.

◆ nsm_read_argv()

int nsm_read_argv ( int  argc,
const char **  argv,
int(*)(const char **argv)  help,
char **  argv_in,
ConfigFile config,
std::string &  name,
std::string &  username,
int  nargv 
)

Definition at line 19 of file nsm_read_argv.cc.

23 {
24 name = "nsm";
25 int argc_in = 0;
26 username = getenv("USER");
27 for (int i = 0; i < argc; i++) {
28 if (strcmp(argv[i], "-g") == 0) {
29 name = "nsm.global";
30 } else if (strcmp(argv[i], "-h") == 0) {
31 return help(argv);
32 } else if (strcmp(argv[i], "-c") == 0) {
33 if (i + 1 < argc && argv[i + 1][0] != '-') {
34 i++;
35 config.read(argv[i]);
36 }
37 } else if (strcmp(argv[i], "-n") == 0) {
38 if (i + 1 < argc && argv[i + 1][0] != '-') {
39 i++;
40 username = argv[i];
41 }
42 } else {
43 argv_in[argc_in] = new char[100];
44 strcpy(argv_in[argc_in], argv[i]);
45 argc_in++;
46 }
47 }
48 if (argc_in < nargv) {
49 help(argv);
50 exit(1);
51 }
52 return argc_in;
53 }

◆ openData()

void openData ( const std::string &  name,
const std::string &  format,
int  revision = -1 
)
inline

Definition at line 108 of file NSMCallback.h.

111 {
112 if (m_datas.find(name) == m_datas.end()) {
113 m_datas.insert(NSMDataMap::value_type(name, NSMData(name, format, revision)));
114 }
115 }

◆ operator!=() [1/3]

bool operator!= ( const Connection st) const
inline

Definition at line 55 of file Connection.h.

56 {
57 return (getId() != st.getId());
58 }

◆ operator!=() [2/3]

bool operator!= ( const Enum e) const
inline

Definition at line 54 of file Enum.h.

55 {
56 return (m_id != e.m_id);
57 }

◆ operator!=() [3/3]

bool operator!= ( const std::string &  label) const
inline

Definition at line 63 of file Enum.h.

64 {
65 return m_label != label;
66 }

◆ operator==() [1/3]

bool operator== ( const Connection st) const
inline

Definition at line 50 of file Connection.h.

51 {
52 return (getId() == st.getId());
53 }

◆ operator==() [2/3]

bool operator== ( const Enum e) const
inline

Definition at line 50 of file Enum.h.

51 {
52 return (m_id == e.m_id);
53 }

◆ operator==() [3/3]

bool operator== ( const std::string &  label) const
inline

Definition at line 59 of file Enum.h.

60 {
61 return m_label == label;
62 }

◆ pollEvent()

void pollEvent ( bool  pollOnInput)
protected

Poll until a single event is retreived.

Definition at line 104 of file ZMQApp.details.h.

105 {
106 auto reactToOutput = [this]() {
107 // Get all messages from output socket
108 while (ZMQConnection::hasMessage(m_output.get()) and not terminated()) {
109 handleOutput();
111 break;
112 }
113 }
114 };
115
116 auto reactToMonitor = [this]() {
117 // Get all messages from monitoring socket
118 while (ZMQConnection::hasMessage(m_monitor.get()) and not terminated()) {
120 }
121 };
122
123 auto reactToInput = [this]() {
124 // Get all messages from input as long output is ready
125 while (ZMQConnection::hasMessage(m_input.get()) and m_output->isReady() and not terminated()) {
126 handleInput();
128 break;
129 }
130 }
131 };
132
133 m_monitor->logTime("waiting_since");
134
135 if (pollOnInput) {
136 ZMQConnection::poll({{m_output.get(), reactToOutput}, {m_monitor.get(), reactToMonitor}, {m_input.get(), reactToInput}},
138 } else {
139 ZMQConnection::poll({{m_output.get(), reactToOutput}, {m_monitor.get(), reactToMonitor}}, m_remainingTime);
140 }
141
142 if (checkTimer() and not terminated()) {
143 B2ASSERT("There is no timeout set, but we still call the timeout() function? A bug!", m_timeout != 0);
144 m_monitor->increment("timeouts");
146 resetTimer();
147 } else {
148 updateTimer();
149 }
150 }
static bool hasMessage(const ZMQConnection *connection)
Check if the given connection as an incoming message (right now, no waiting).
static bool poll(const std::map< const ZMQConnection *, ReactorFunction > &connectionList, int timeout)
Poll on the given connections and call the attached function if a messages comes in.
bool m_monitorHasPriority
Flag to break out of the polling loop to check for monitoring messages. Except for the finalcollector...
Definition: ZMQApp.h:77
unsigned int m_timeout
If set to a value != 0, will call handleTimeout with this frequency (in seconds).
Definition: ZMQApp.h:75
void handleMonitoring()
Handle an incoming message on the monitoring socket by either calling handleExternalSignal() or by pa...
virtual void handleInput()
Will get called for every message on the input connection. Can be overridden in a derived class....
virtual void handleOutput()
Will get called for every message on the output connection. Can be overridden in a derived class....
bool checkTimer()
Helper function to check, if the timeout should happen.
virtual void handleTimeout()
Will get called on a timeout. Can be overridden in a derived class. Empty by default.

◆ resetTimer()

void resetTimer
protected

Helper function to reset the start time and the remaining time.

Definition at line 219 of file ZMQApp.details.h.

220 {
221 // if there is no timeout, we should never set the remaining time
222 if (m_timeout == 0) {
223 m_remainingTime = -1;
224 return;
225 }
226
227 m_start = std::chrono::system_clock::now();
228 m_remainingTime = m_timeout * 1000;
229 }
std::chrono::system_clock::time_point m_start
Start time for the timeout.
Definition: ZMQApp.h:108

◆ setBool()

void setBool ( const std::string &  name,
bool  value,
int  index = 0 
)
inline

Definition at line 156 of file AbstractDBObject.h.

157 {
158 setValue(name, &value, index);
159 }

◆ setChar()

void setChar ( const std::string &  name,
int  value,
int  index = 0 
)
inline

Definition at line 161 of file AbstractDBObject.h.

162 {
163 setValue(name, &value, index);
164 }

◆ setDB()

void setDB ( DBInterface db,
const std::string &  table 
)
inline

Definition at line 110 of file RCCallback.h.

111 {
112 m_db = db;
113 m_table = table;
114 }

◆ setDouble()

void setDouble ( const std::string &  name,
double  value,
int  index = 0 
)
inline

Definition at line 186 of file AbstractDBObject.h.

187 {
188 setValue(name, &value, index);
189 }

◆ setFloat()

void setFloat ( const std::string &  name,
float  value,
int  index = 0 
)
inline

Definition at line 181 of file AbstractDBObject.h.

182 {
183 setValue(name, &value, index);
184 }

◆ setInt()

void setInt ( const std::string &  name,
int  value,
int  index = 0 
)
inline

Definition at line 171 of file AbstractDBObject.h.

172 {
173 setValue(name, &value, index);
174 }

◆ setLong()

void setLong ( const std::string &  name,
long long  value,
int  index = 0 
)
inline

Definition at line 176 of file AbstractDBObject.h.

177 {
178 setValue(name, &value, index);
179 }

◆ setShort()

void setShort ( const std::string &  name,
int  value,
int  index = 0 
)
inline

Definition at line 166 of file AbstractDBObject.h.

167 {
168 setValue(name, &value, index);
169 }

◆ terminated()

bool terminated
protected

Check if the main loop will be exited on next occasion. Can be set via the "m_terminate" flag.

Definition at line 189 of file ZMQApp.details.h.

190 {
191 return not m_mainLoop.isRunning() or m_terminate;
192 }
HLTMainLoop m_mainLoop
Internal signal handler.
Definition: ZMQApp.h:102
bool m_terminate
Can be set by functions to terminate the main loop at the next possibility.
Definition: ZMQApp.h:73

◆ updateTimer()

void updateTimer
private

Helper function to update the remaining time.

Definition at line 202 of file ZMQApp.details.h.

203 {
204 // if there is no timeout, we should never update the remaining time
205 if (m_timeout == 0) {
206 m_remainingTime = -1;
207 return;
208 }
209
210 auto currentTime = std::chrono::system_clock::now();
211 auto timeDifference = std::chrono::duration_cast<std::chrono::milliseconds>(currentTime - m_start);
212 m_remainingTime = m_timeout * 1000 - timeDifference.count();
213 if (m_remainingTime < 0) {
214 m_remainingTime = 0;
215 }
216 }

◆ ZMQHistogramOutput()

ZMQHistogramOutput ( unsigned int  maximalUncompressedBufferSize,
Args &&...  args 
)

Perfectly forward the given arguments to the base class initializer (and init the buffer size)

Definition at line 85 of file ZMQHistogramOutput.h.

86 : AConnectionClass(std::forward<Args>(args)...), m_maximalUncompressedBufferSize(
87 maximalUncompressedBufferSize)
88 {
90
91 AConnectionClass::log("uncompressed_size", 0.0);
92 AConnectionClass::log("stored_identities", 0l);
93 AConnectionClass::log("histogram_clears", 0l);
94 AConnectionClass::log("last_clear", "");
95 }
std::vector< char > m_uncompressedBuffer
The buffer used during decompression.
unsigned int m_maximalUncompressedBufferSize
Paramter for the buffer size (needed during decompression)

Variable Documentation

◆ g_cond

Cond g_cond

Definition at line 37 of file stevtserver.cc.

◆ g_mutex

Mutex g_mutex

Definition at line 36 of file stevtserver.cc.

◆ ro_summary_revision

const int ro_summary_revision = 1

Definition at line 21 of file ro_summary.h.

◆ ronode_status_revision

const int ronode_status_revision = 1

Definition at line 21 of file ronode_status.h.