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 (int port)
 
 DTCtcp (int sock, int opt)
 
 DTCtcp (DTCtcp *)
 
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::DTSpy ( )

Definition at line 17 of file DTSpy.cc.

References DTSPY_MAX_MSG, givenonce, and spybuf.

17  : DTCtcp(0) {
18  spybuf = (char *)malloc(DTSPY_MAX_MSG);
19  givenonce = 0;
20 }
#define DTSPY_MAX_MSG
Definition: DTSpy.cc:15
char * spybuf
Definition: DTSpy.h:17
short givenonce
Definition: DTSpy.h:18
DTSpy::DTSpy ( char *  hostaddr,
int  port 
)

Definition at line 24 of file DTSpy.cc.

References DTCtcp::Connect(), and givenonce.

24  : DTCtcp(0) {
25  Connect(hostaddr, port);
26  givenonce = 0;
27 }
void Connect(const char *hostaddr, int port)
Definition: DTSpyHelper.cc:133
int port
Definition: DTSpyHelper.h:20
short givenonce
Definition: DTSpy.h:18
DTSpy::~DTSpy ( )

Definition at line 22 of file DTSpy.cc.

References spybuf.

22 { free(spybuf); }
char * spybuf
Definition: DTSpy.h:17

Member Function Documentation

int DTSpy::getBuffSize ( )

Definition at line 55 of file DTSpy.cc.

References spybuf.

Referenced by getNextBuffer().

55  {
56  unsigned short *i2ohea = (unsigned short *)(spybuf + 2);
57  return *i2ohea;
58 }
char * spybuf
Definition: DTSpy.h:17
const char * DTSpy::getEventPointer ( )

Definition at line 65 of file DTSpy.cc.

References DTSPY_HEAD_SIZE, givenonce, lastpointer, and spybuf.

Referenced by DTSpyReader::fillRawData().

65  {
66  if (givenonce)
67  return lastpointer;
69  givenonce = 1;
70  return lastpointer;
71 }
char * spybuf
Definition: DTSpy.h:17
char * lastpointer
Definition: DTSpy.h:21
short givenonce
Definition: DTSpy.h:18
#define DTSPY_HEAD_SIZE
Definition: DTSpy.cc:14
int DTSpy::getNextBuffer ( )

Definition at line 29 of file DTSpy.cc.

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

Referenced by DTSpyReader::fillRawData().

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 }
#define DTSPY_MAX_MSG
Definition: DTSpy.cc:15
char * spybuf
Definition: DTSpy.h:17
int Receive(char *buffer, int size)
Definition: DTSpyHelper.cc:145
int connected
Definition: DTSpyHelper.h:23
char * lastpointer
Definition: DTSpy.h:21
short givenonce
Definition: DTSpy.h:18
#define DTSPY_HEAD_SIZE
Definition: DTSpy.cc:14
int getBuffSize()
Definition: DTSpy.cc:55
int DTSpy::getRunNo ( )

Definition at line 60 of file DTSpy.cc.

References spybuf.

Referenced by DTSpyReader::fillRawData().

60  {
61  unsigned short *i2ohea = (unsigned short *)(spybuf + 28);
62  return *i2ohea;
63 }
char * spybuf
Definition: DTSpy.h:17
void DTSpy::setlastPointer ( char *  data)

Definition at line 73 of file DTSpy.cc.

References lastpointer.

Referenced by DTSpyReader::fillRawData().

73 { lastpointer = thep; }
char * lastpointer
Definition: DTSpy.h:21

Member Data Documentation

short DTSpy::givenonce
protected

Definition at line 18 of file DTSpy.h.

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

char* DTSpy::lastpointer

Definition at line 21 of file DTSpy.h.

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

char* DTSpy::spybuf
protected

Definition at line 17 of file DTSpy.h.

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