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 17 of file DTSpy.h.

Constructor & Destructor Documentation

DTSpy::DTSpy ( )

Definition at line 18 of file DTSpy.cc.

References DTSPY_MAX_MSG, givenonce, and spybuf.

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

Definition at line 31 of file DTSpy.cc.

References DTCtcp::Connect(), and givenonce.

31  :DTCtcp(0)
32 {
33  Connect(hostaddr,port);
34  givenonce=0;
35 }
void Connect(const char *hostaddr, int port)
Definition: DTSpyHelper.cc:162
int port
Definition: DTSpyHelper.h:23
short givenonce
Definition: DTSpy.h:21
DTSpy::~DTSpy ( )

Definition at line 25 of file DTSpy.cc.

References spybuf.

26 {
27  free(spybuf);
28 }
char * spybuf
Definition: DTSpy.h:20

Member Function Documentation

int DTSpy::getBuffSize ( )

Definition at line 67 of file DTSpy.cc.

References spybuf.

Referenced by getNextBuffer().

68 {
69  unsigned short *i2ohea = (unsigned short *) (spybuf+2);
70  return *i2ohea;
71 }
char * spybuf
Definition: DTSpy.h:20
const char * DTSpy::getEventPointer ( )

Definition at line 83 of file DTSpy.cc.

References DTSPY_HEAD_SIZE, givenonce, lastpointer, and spybuf.

Referenced by DTSpyReader::fillRawData().

84 {
85  if (givenonce) return lastpointer;
87  givenonce = 1;
88  return lastpointer;
89 }
char * spybuf
Definition: DTSpy.h:20
char * lastpointer
Definition: DTSpy.h:25
short givenonce
Definition: DTSpy.h:21
#define DTSPY_HEAD_SIZE
Definition: DTSpy.cc:14
int DTSpy::getNextBuffer ( )

Definition at line 39 of file DTSpy.cc.

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

Referenced by DTSpyReader::fillRawData().

40 {
41 
42  if (!connected) return -1;
43  if (givenonce)
44  if ((lastpointer - spybuf) < getBuffSize())
45  return (getBuffSize() - (lastpointer - spybuf));
46  givenonce=0;
47 
48  memset(spybuf,0x0,DTSPY_MAX_MSG); /* init buffer */
49 
50  int howm=Receive(spybuf,DTSPY_HEAD_SIZE);
51 
52  unsigned short *i2ohea = (unsigned short *) (spybuf+2);
53  if (howm == DTSPY_HEAD_SIZE )
54  {
55  howm = Receive(spybuf+DTSPY_HEAD_SIZE,((*i2ohea) * 4)-DTSPY_HEAD_SIZE);
56 
57  // for (int ii=0; ii<12; ii++)
58  // printf("%d: %x %x %x %x \n",ii*4,spybuf[ii*4],
59  // spybuf[ii*4+1],spybuf[ii*4+2],spybuf[ii*4+3]);
60 
61  return howm+DTSPY_HEAD_SIZE;;
62  }
63  else return -1;
64 }
#define DTSPY_MAX_MSG
Definition: DTSpy.cc:15
char * spybuf
Definition: DTSpy.h:20
int Receive(char *buffer, int size)
Definition: DTSpyHelper.cc:177
int connected
Definition: DTSpyHelper.h:26
char * lastpointer
Definition: DTSpy.h:25
short givenonce
Definition: DTSpy.h:21
#define DTSPY_HEAD_SIZE
Definition: DTSpy.cc:14
int getBuffSize()
Definition: DTSpy.cc:67
int DTSpy::getRunNo ( )

Definition at line 76 of file DTSpy.cc.

References spybuf.

Referenced by DTSpyReader::fillRawData().

77 {
78  unsigned short *i2ohea = (unsigned short *) (spybuf+28);
79  return *i2ohea;
80 }
char * spybuf
Definition: DTSpy.h:20
void DTSpy::setlastPointer ( char *  data)

Definition at line 92 of file DTSpy.cc.

References lastpointer.

Referenced by DTSpyReader::fillRawData().

93 {
94  lastpointer=thep;
95 }
char * lastpointer
Definition: DTSpy.h:25

Member Data Documentation

short DTSpy::givenonce
protected

Definition at line 21 of file DTSpy.h.

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

char* DTSpy::lastpointer

Definition at line 25 of file DTSpy.h.

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

char* DTSpy::spybuf
protected

Definition at line 20 of file DTSpy.h.

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