Belle II Software development
RawRevSock2Rb Class Reference

Public Member Functions

 RawRevSock2Rb (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

Belle2::RingBufferm_rbuf
 
Belle2::RSocketRecvm_sock
 
Belle2::RFFlowStatm_flow
 
char * m_evtbuf
 
int * m_buf
 

Detailed Description

Definition at line 19 of file RawRevSock2Rb.h.

Constructor & Destructor Documentation

◆ RawRevSock2Rb()

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

Constuctor and Destructor.

Definition at line 17 of file RawRevSock2Rb.cc.

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

◆ ~RawRevSock2Rb()

~RawRevSock2Rb ( void  )

Definition at line 28 of file RawRevSock2Rb.cc.

29{
30 delete m_sock;
31 delete m_rbuf;
32}

Member Function Documentation

◆ ReceiveEvent()

int ReceiveEvent ( void  )

Event function.

Definition at line 34 of file RawRevSock2Rb.cc.

35{
36 // Get a record from socket
37 int bufsize = m_sock->get_wordbuf(m_buf, MAXBUFSIZE);
38
39 if (bufsize <= 0) {
40 return 0;
41 }
42 m_flow->log(bufsize * 4);
43
44 // Put the message in ring buffer
45 int stat = 0;
46 for (;;) {
47 stat = m_rbuf->insq(m_buf, bufsize);
48 if (stat >= 0) break;
49 // usleep(100);
50 usleep(20);
51 }
52 return stat;
53}
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 55 of file RawRevSock2Rb.cc.

56{
57 return m_sock->reconnect(ntimes);
58}

Member Data Documentation

◆ m_buf

int* m_buf
private

Definition at line 36 of file RawRevSock2Rb.h.

◆ m_evtbuf

char* m_evtbuf
private

Definition at line 35 of file RawRevSock2Rb.h.

◆ m_flow

Belle2::RFFlowStat* m_flow
private

Definition at line 34 of file RawRevSock2Rb.h.

◆ m_rbuf

Belle2::RingBuffer* m_rbuf
private

Definition at line 32 of file RawRevSock2Rb.h.

◆ m_sock

Belle2::RSocketRecv* m_sock
private

Definition at line 33 of file RawRevSock2Rb.h.


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