Belle II Software development
TxSocketModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <daq/dataflow/modules/TxSocketModule.h>
10
11#include <framework/datastore/DataStore.h>
12#include <framework/pcore/EvtMessage.h>
13
14using namespace std;
15using namespace Belle2;
16
17//-----------------------------------------------------------------
18// Register the Module
19//-----------------------------------------------------------------
20REG_MODULE(TxSocket);
21
22//-----------------------------------------------------------------
23// Implementation
24//-----------------------------------------------------------------
25
27{
28 //Set module properties
29 setDescription("Encode DataStore into RingBuffer");
30 // setPropertyFlags(c_Input | c_ParallelProcessingCertified);
31
32 addParam("DestHostName", m_dest, "Destination host", string("localhost"));
33 addParam("DestPort", m_port, "Destination port", 1111);
34
35 m_nsent = 0;
37
38 //Parameter definition
39 B2INFO("Tx: Constructor done.");
40}
41
42
43
44TxSocketModule::~TxSocketModule()
45{
46}
47
49{
50
51 // Open Socket
54
55 B2INFO("Tx initialized.");
56}
57
58
60{
61 B2INFO("beginRun called.");
62}
63
64
66{
67 // Stream DataStore in EvtMessage
69
70 // Send the message to Socket
71 m_sock->send(msg);
72 B2INFO("Tx: objs sent in buffer. Size = " << msg->size());
73
74 // Release EvtMessage buffer
75 delete msg;
76
77}
78
80{
81 //fill Run data
82
83 B2INFO("endRun done.");
84}
85
86
88{
89 B2INFO("terminate called");
90}
91
Stream/restore DataStore objects to/from EvtMessage.
EvtMessage * streamDataStore(bool addPersistentDurability, bool streamTransientObjects=false)
Store DataStore objects in EvtMessage.
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
Definition: DataStore.h:59
Class to manage streamed object.
Definition: EvtMessage.h:59
int size() const
Get size of message including headers.
Definition: EvtMessage.cc:94
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
DataStoreStreamer * m_streamer
DataStoreStreamer.
void initialize() override
Module functions to be called from main process.
void event() override
This method is the core of the module.
void endRun() override
This method is called if the current run ends.
EvtSocketSend * m_sock
EvtSocket.
void terminate() override
This method is called at the end of the event processing.
int m_port
Destination port.
void beginRun() override
Module functions to be called from event process.
int m_nsent
No. of sent events.
int m_compressionLevel
Compression parameter.
std::string m_dest
Destination Host.
TxSocketModule()
Constructor / Destructor.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.
STL namespace.