Belle II Software development
RevSock2Rb Class Reference

Public Member Functions

 RevSock2Rb (std::string rbuf, std::string src, int port, std::string shmname, int id)
 Constuctor and Destructor.
 
int ReceiveEvent (void)
 Event function.
 
int Reconnect (int ntry)
 Reconnect.
 

Private Attributes

RingBufferm_rbuf
 
REvtSocketRecvm_sock
 
RFFlowStatm_flow
 
char * m_evtbuf
 

Detailed Description

Definition at line 24 of file RevSock2Rb.h.

Constructor & Destructor Documentation

◆ RevSock2Rb()

RevSock2Rb ( std::string  rbuf,
std::string  src,
int  port,
std::string  shmname,
int  id 
)

Constuctor and Destructor.

Definition at line 16 of file RevSock2Rb.cc.

17{
18 // m_rbuf = new RingBuffer(rbuf.c_str(), RBUFSIZE);
19 m_rbuf = new RingBuffer(rbuf.c_str());
20 m_sock = new REvtSocketRecv(src, port);
21 m_evtbuf = new char[MAXEVTSIZE];
22 m_flow = new RFFlowStat((char*)shmname.c_str(), id, m_rbuf);
23
24}
Class to manage a Ring Buffer placed in an IPC shared memory.
Definition: RingBuffer.h:39

◆ ~RevSock2Rb()

~RevSock2Rb ( void  )

Definition at line 26 of file RevSock2Rb.cc.

27{
28 delete m_sock;
29 delete m_rbuf;
30}

Member Function Documentation

◆ ReceiveEvent()

int ReceiveEvent ( void  )

Event function.

Definition at line 32 of file RevSock2Rb.cc.

33{
34 // Get a record from socket
35 EvtMessage* msg = m_sock->recv();
36 if (msg == NULL) {
37 return 0;
38 }
39 // B2INFO ( "Rx: got an event from Socket, size=" << msg->size() );
40 if (msg->type() == MSG_TERMINATE) {
41 return 0;
42 // Flag End Of File !!!!!
43 // return msg->type(); // EOF
44 }
45 m_flow->log(msg->size());
46
47 // Put the message in ring buffer
48 int stat = 0;
49 for (;;) {
50 stat = m_rbuf->insq((int*)msg->buffer(), msg->paddedSize());
51 if (stat >= 0) break;
52 // usleep(100);
53 usleep(20);
54 }
55 delete msg;
56 return stat;
57}
Class to manage streamed object.
Definition: EvtMessage.h:59
int paddedSize() const
Same as size(), but as size of an integer array.
Definition: EvtMessage.cc:99
ERecordType type() const
Get record type.
Definition: EvtMessage.cc:114
char * buffer()
Get buffer address.
Definition: EvtMessage.cc:76
int size() const
Get size of message including headers.
Definition: EvtMessage.cc:94
int insq(const int *buf, int size, bool checkTx=false)
Append a buffer to the RingBuffer.
Definition: RingBuffer.cc:189

◆ Reconnect()

int Reconnect ( int  ntry)

Reconnect.

Definition at line 59 of file RevSock2Rb.cc.

60{
61 return (m_sock->sock())->reconnect(ntimes);
62}

Member Data Documentation

◆ m_evtbuf

char* m_evtbuf
private

Definition at line 40 of file RevSock2Rb.h.

◆ m_flow

RFFlowStat* m_flow
private

Definition at line 39 of file RevSock2Rb.h.

◆ m_rbuf

RingBuffer* m_rbuf
private

Definition at line 37 of file RevSock2Rb.h.

◆ m_sock

REvtSocketRecv* m_sock
private

Definition at line 38 of file RevSock2Rb.h.


The documentation for this class was generated from the following files: