NDS1Socket Class Reference
[NDS client API]

The DAQD socket class. More...

#include <NDS1Socket.hh>

Inheritance diagram for NDS1Socket:

DAQC_api

List of all members.

Public Member Functions

 NDS1Socket (void)
 NDS1Socket (const std::string &ipaddr, int ipport=DAQD_PORT, long RcvBufferLen=16384)
 ~NDS1Socket (void)
int open (const std::string &ipaddr, int ipport=DAQD_PORT, long RecvBufferLen=16384)
void close ()
void flush ()
int AddChannel (const std::string &chan, chantype ty, double rate)
int Available (std::vector< DAQDChannel > &list, wait_time timeout=-1)
 List known channels.
int Available (chantype chant, long gps, std::vector< DAQDChannel > &list, wait_time timeout=-1)
 List known channels.
int GetData (wait_time timeout=-1)
 Receive block of data in the CDS proprietary format.
long GetFrame (char *buf, long len)
long GetName (char *buf, long len)
int RequestData (unsigned long start, unsigned long duration, wait_time timeout=-1)
 Start reading CDS data.
int RequestFrames ()
int RequestNames (wait_time timeout=-1)
int RequestOnlineData (double stride=1.0, wait_time timeout=-1)
int RequestTrend (unsigned long start, unsigned long duration, bool mintrend=false, wait_time timeout=-1)
void RmChannel (const std::string &chan)
int StopWriter (void)
int Times (chantype chtyp, unsigned long &start, unsigned long &duration, wait_time timeout=-1)
int TimesTrend (unsigned long &start, unsigned long &duration, bool mintrend=false, wait_time timeout=-1)
int WaitforData (bool poll)


Detailed Description

The DAQD socket class.

NDS1Socket provides a client interface to the Network Data Server. The server provides data in the CDS proprietary format or as standard frames. The interface may also be used to list channel names, or to specify the channels to be read in.

Author:
John Zweizig and Daniel Sigg
Version:
1.2; last modified March 5, 2008

Constructor & Destructor Documentation

NDS1Socket::NDS1Socket ( void   ) 

Construct an unopened socket.

NDS1Socket::NDS1Socket ( const std::string &  ipaddr,
int  ipport = DAQD_PORT,
long  RcvBufferLen = 16384 
) [explicit]

Create a socket and connect it to a server. The network address argument has the same syntax as that passed to NDS1Socket::open().

NDS1Socket::~NDS1Socket ( void   ) 

Disconnect and close a socket.


Member Function Documentation

int NDS1Socket::open ( const std::string &  ipaddr,
int  ipport = DAQD_PORT,
long  RecvBufferLen = 16384 
) [virtual]

Open an existing socket and connect it to a server. The argument, ipaddr, specifies the IP address of the node on which the network data server is running. It may be specified either as a symbolic name or as four numeric fields separated by dots. open() returns zero if successful, a positive non-zero error code if one was returned by DAQD or -1.

Implements DAQC_api.

void NDS1Socket::close (  )  [virtual]

Disconnect and close a socket.

Implements DAQC_api.

void NDS1Socket::flush (  )  [virtual]

flushes the input data from the socket.

Implements DAQC_api.

int NDS1Socket::AddChannel ( const std::string &  chan,
chantype  ty,
double  rate 
) [virtual]

Add a channel to the request list.

Reimplemented from DAQC_api.

int NDS1Socket::Available ( std::vector< DAQDChannel > &  list,
wait_time  timeout = -1 
)

List known channels.

The names, sample rates, etc. of all channels known by the server are copied into the channel vector. Available() returns the number of entries found or -1 if an error occurred.

Parameters:
list Vector to receive channel information.
timeout Maximum wait time.
Returns:
Number of channels or -1 if an error occurred.

int NDS1Socket::Available ( chantype  chant,
long  gps,
std::vector< DAQDChannel > &  list,
wait_time  timeout = -1 
) [virtual]

List known channels.

The names, sample rates, etc. of all channels known by the server are copied into the channel vector. Available() returns the number of entries found or -1 if an error occurred.

Parameters:
chant Channel type selection
gps Valid time for channels.
list Vector to receive channel information.
timeout Maximum wait time.
Returns:
Number of channels or -1 if an error occurred.

Implements DAQC_api.

int NDS1Socket::GetData ( wait_time  timeout = -1  )  [virtual]

Receive block of data in the CDS proprietary format.

A single block of data (including the header) is received and copied into the specified buffer. The data length (excluding the header) is returned. GetData() returns -1 if an error is detected, or 0 if an end-of file record is found.

Parameters:
timeout Maximum wait time for data.
Returns:
data length, negative on error

Reimplemented from DAQC_api.

long NDS1Socket::GetFrame ( char *  buf,
long  len 
)

Receive a data frame. A single data frame is received and copied to the specified buffer. The length of the Frame data is returned. GetFrame() returns -1 in case of an error or 0 if a trailer (end of file) block is received.

long NDS1Socket::GetName ( char *  buf,
long  len 
)

Receive a file name. The next frame file name written by the NDS is copied to buf and the data length is returned. The GetName returns -1 if a name-writer hasn't been started, if the data buffer is too short, or if an error occurs in reading the data. GetData waits for a new message if one is not available from the socket.

int NDS1Socket::RequestData ( unsigned long  start,
unsigned long  duration,
wait_time  timeout = -1 
) [virtual]

Start reading CDS data.

The network data server is requested to start a net-writer task for past data. Start time and duration are given in GPS seconds. Only channels explicitly specified by AddChannel() will be written.

Parameters:
start Start time
duration Number of seconds of data to fetch.
timout Maximum response wait time
Returns:
Request status code.

Implements DAQC_api.

int NDS1Socket::RequestFrames (  ) 

Start reading frame data. The network data server is requested to start a frame writer task. Only channels explicitly specified by AddChannel() will be written.

int NDS1Socket::RequestNames ( wait_time  timeout = -1  ) 

Start reading file names. The network data server is requested to start a name writer task.

int NDS1Socket::RequestOnlineData ( double  stride = 1.0,
wait_time  timeout = -1 
) [virtual]

Start reading CDS data. The network data server is requested to start a net-writer task. Only channels explicitly specified by AddChannel() will be written.

Implements DAQC_api.

int NDS1Socket::RequestTrend ( unsigned long  start,
unsigned long  duration,
bool  mintrend = false,
wait_time  timeout = -1 
)

Start reading CDS trend data. The network data server is requested to start a trend net-writer task. Start time and duration are given in GPS seconds. Only channels explicitly specified by AddChannel() will be written.

void NDS1Socket::RmChannel ( const std::string &  chan  )  [virtual]

Remove the specified channel or all channels if "all" specified.

Reimplemented from DAQC_api.

int NDS1Socket::StopWriter ( void   )  [virtual]

Stop a data writer. This function effectively countermands the RequestXXX() functions. StopWriter returns either the server response code or -1 if no writer has been requested.

Implements DAQC_api.

int NDS1Socket::Times ( chantype  chtyp,
unsigned long &  start,
unsigned long &  duration,
wait_time  timeout = -1 
) [virtual]

Known time intervals. The network data server is requested to return start time and duration of the data stored on disk.

Reimplemented from DAQC_api.

int NDS1Socket::TimesTrend ( unsigned long &  start,
unsigned long &  duration,
bool  mintrend = false,
wait_time  timeout = -1 
)

Known time intervals of trend data. The network data server is requested to return start time and duration of the trend data stored on disk.

int NDS1Socket::WaitforData ( bool  poll  )  [virtual]

Wait for data to arrive. Execution is blocked until data are available to the socket. This can be used to wait for data after a request has been made. The calling function can then e.g. allocate a buffer before calling GetData(), GetName() or GetFrame(). If poll is true the function returns immediately with 1 if data is ready, or 0 if not.

Implements DAQC_api.


The documentation for this class was generated from the following file:
Generated on Sun Mar 8 19:21:12 2009 for dmt by  doxygen 1.5.4