CMS 3D CMS Logo

Public Member Functions | Public Attributes | Protected Attributes

DTSpy Class Reference

#include <DTSpy.h>

Inheritance diagram for DTSpy:
DTCtcp

List of all members.

Public Member Functions

 DTSpy ()
 DTSpy (char *hostaddr, int port)
int getBuffSize ()
const char * getEventPointer ()
int getNextBuffer ()
int getRunNo ()
void setlastPointer (char *data)
 ~DTSpy ()

Public Attributes

char * lastpointer

Protected Attributes

short givenonce
char * spybuf

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.

            :DTCtcp(0)
{
  spybuf=(char *)malloc(DTSPY_MAX_MSG);
  givenonce=0;
}
DTSpy::DTSpy ( char *  hostaddr,
int  port 
)

Definition at line 31 of file DTSpy.cc.

References DTCtcp::Connect(), and givenonce.

                                   :DTCtcp(0)
{
     Connect(hostaddr,port);
     givenonce=0;
}
DTSpy::~DTSpy ( )

Definition at line 25 of file DTSpy.cc.

References spybuf.

{
  free(spybuf);
}

Member Function Documentation

int DTSpy::getBuffSize ( )

Definition at line 67 of file DTSpy.cc.

References spybuf.

Referenced by getNextBuffer().

{
        unsigned short *i2ohea = (unsigned short *) (spybuf+2);
        return *i2ohea;
}
const char * DTSpy::getEventPointer ( )

Definition at line 83 of file DTSpy.cc.

References DTSPY_HEAD_SIZE, givenonce, lastpointer, and spybuf.

Referenced by DTSpyReader::fillRawData().

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().

{

        if (!connected) return -1;
        if (givenonce)
                if ((lastpointer - spybuf) < getBuffSize())
                        return (getBuffSize() - (lastpointer - spybuf));
        givenonce=0;

        memset(spybuf,0x0,DTSPY_MAX_MSG); /* init buffer */
    
        int howm=Receive(spybuf,DTSPY_HEAD_SIZE);
        
        unsigned short *i2ohea = (unsigned short *) (spybuf+2);
        if (howm == DTSPY_HEAD_SIZE ) 
         {
                howm = Receive(spybuf+DTSPY_HEAD_SIZE,((*i2ohea) * 4)-DTSPY_HEAD_SIZE);

               // for (int ii=0; ii<12; ii++)
               //       printf("%d: %x %x %x %x \n",ii*4,spybuf[ii*4],
               //             spybuf[ii*4+1],spybuf[ii*4+2],spybuf[ii*4+3]);

                return howm+DTSPY_HEAD_SIZE;;
         }
         else return -1;
}
int DTSpy::getRunNo ( )

Definition at line 76 of file DTSpy.cc.

References spybuf.

Referenced by DTSpyReader::fillRawData().

{
    unsigned short *i2ohea = (unsigned short *) (spybuf+28);
    return *i2ohea;
}
void DTSpy::setlastPointer ( char *  data)

Definition at line 92 of file DTSpy.cc.

References lastpointer.

Referenced by DTSpyReader::fillRawData().

{
  lastpointer=thep;
}

Member Data Documentation

short DTSpy::givenonce [protected]

Definition at line 21 of file DTSpy.h.

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

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().