CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Protected Attributes
DTSpy Class Reference

#include <DTSpy.h>

Inheritance diagram for DTSpy:
DTCtcp

Public Member Functions

 DTSpy ()
 
 DTSpy (char *hostaddr, int port)
 
int getBuffSize ()
 
const char * getEventPointer ()
 
int getNextBuffer ()
 
int getRunNo ()
 
void setlastPointer (char *data)
 
 ~DTSpy ()
 
- Public Member Functions inherited from DTCtcp
DTCtcpAccept ()
 
unsigned long addr ()
 
void Connect (const char *hostaddr, int port)
 
void Connect (unsigned long hostaddr, int port)
 
int Disconnect ()
 
 DTCtcp ()
 
 DTCtcp (DTCtcp *)
 
 DTCtcp (int port)
 
 DTCtcp (int sock, int opt)
 
short Id ()
 
int Receive (char *buffer, int size)
 
int Send (char *buffer, int size)
 
 ~DTCtcp ()
 

Public Attributes

char * lastpointer
 

Protected Attributes

short givenonce
 
char * spybuf
 
- Protected Attributes inherited from DTCtcp
struct sockaddr_in clientAddr
 
int connected
 
struct sockaddr_in myaddr
 
int port
 
int sock
 

Detailed Description

Definition at line 15 of file DTSpy.h.

Constructor & Destructor Documentation

◆ DTSpy() [1/2]

DTSpy::DTSpy ( )

Definition at line 17 of file DTSpy.cc.

17  : DTCtcp(0) {
18  spybuf = (char *)malloc(DTSPY_MAX_MSG);
19  givenonce = 0;
20 }

References DTSPY_MAX_MSG, givenonce, and spybuf.

◆ DTSpy() [2/2]

DTSpy::DTSpy ( char *  hostaddr,
int  port 
)

Definition at line 24 of file DTSpy.cc.

24  : DTCtcp(0) {
25  Connect(hostaddr, port);
26  givenonce = 0;
27 }

References DTCtcp::Connect(), givenonce, and DTCtcp::port.

◆ ~DTSpy()

DTSpy::~DTSpy ( )

Definition at line 22 of file DTSpy.cc.

22 { free(spybuf); }

References spybuf.

Member Function Documentation

◆ getBuffSize()

int DTSpy::getBuffSize ( )

Definition at line 55 of file DTSpy.cc.

55  {
56  unsigned short *i2ohea = (unsigned short *)(spybuf + 2);
57  return *i2ohea;
58 }

References spybuf.

Referenced by getNextBuffer().

◆ getEventPointer()

const char * DTSpy::getEventPointer ( )

Definition at line 65 of file DTSpy.cc.

65  {
66  if (givenonce)
67  return lastpointer;
69  givenonce = 1;
70  return lastpointer;
71 }

References DTSPY_HEAD_SIZE, givenonce, lastpointer, and spybuf.

Referenced by DTSpyReader::fillRawData().

◆ getNextBuffer()

int DTSpy::getNextBuffer ( )

Definition at line 29 of file DTSpy.cc.

29  {
30  if (!connected)
31  return -1;
32  if (givenonce)
33  if ((lastpointer - spybuf) < getBuffSize())
34  return (getBuffSize() - (lastpointer - spybuf));
35  givenonce = 0;
36 
37  memset(spybuf, 0x0, DTSPY_MAX_MSG); /* init buffer */
38 
39  int howm = Receive(spybuf, DTSPY_HEAD_SIZE);
40 
41  unsigned short *i2ohea = (unsigned short *)(spybuf + 2);
42  if (howm == DTSPY_HEAD_SIZE) {
43  howm = Receive(spybuf + DTSPY_HEAD_SIZE, ((*i2ohea) * 4) - DTSPY_HEAD_SIZE);
44 
45  // for (int ii=0; ii<12; ii++)
46  // printf("%d: %x %x %x %x \n",ii*4,spybuf[ii*4],
47  // spybuf[ii*4+1],spybuf[ii*4+2],spybuf[ii*4+3]);
48 
49  return howm + DTSPY_HEAD_SIZE;
50  ;
51  } else
52  return -1;
53 }

References DTCtcp::connected, DTSPY_HEAD_SIZE, DTSPY_MAX_MSG, getBuffSize(), givenonce, lastpointer, DTCtcp::Receive(), and spybuf.

Referenced by DTSpyReader::fillRawData().

◆ getRunNo()

int DTSpy::getRunNo ( )

Definition at line 60 of file DTSpy.cc.

60  {
61  unsigned short *i2ohea = (unsigned short *)(spybuf + 28);
62  return *i2ohea;
63 }

References spybuf.

Referenced by DTSpyReader::fillRawData().

◆ setlastPointer()

void DTSpy::setlastPointer ( char *  data)

Definition at line 73 of file DTSpy.cc.

73 { lastpointer = thep; }

References lastpointer.

Referenced by DTSpyReader::fillRawData().

Member Data Documentation

◆ givenonce

short DTSpy::givenonce
protected

Definition at line 18 of file DTSpy.h.

Referenced by DTSpy(), getEventPointer(), and getNextBuffer().

◆ lastpointer

char* DTSpy::lastpointer

Definition at line 21 of file DTSpy.h.

Referenced by getEventPointer(), getNextBuffer(), and setlastPointer().

◆ spybuf

char* DTSpy::spybuf
protected

Definition at line 17 of file DTSpy.h.

Referenced by DTSpy(), getBuffSize(), getEventPointer(), getNextBuffer(), getRunNo(), and ~DTSpy().

DTSpy::getBuffSize
int getBuffSize()
Definition: DTSpy.cc:55
DTSPY_HEAD_SIZE
#define DTSPY_HEAD_SIZE
Definition: DTSpy.cc:14
DTSpy::spybuf
char * spybuf
Definition: DTSpy.h:17
DTCtcp::port
int port
Definition: DTSpyHelper.h:20
DTSpy::lastpointer
char * lastpointer
Definition: DTSpy.h:21
DTSPY_MAX_MSG
#define DTSPY_MAX_MSG
Definition: DTSpy.cc:15
DTCtcp::connected
int connected
Definition: DTSpyHelper.h:23
DTSpy::givenonce
short givenonce
Definition: DTSpy.h:18
DTCtcp::Connect
void Connect(const char *hostaddr, int port)
Definition: DTSpyHelper.cc:133
DTCtcp::DTCtcp
DTCtcp()
Definition: DTSpyHelper.cc:15
DTCtcp::Receive
int Receive(char *buffer, int size)
Definition: DTSpyHelper.cc:145