In file daqsocket.h:

class DAQSocket

The DAQD socket class

Inheritance:


Public Fields

typedef std::pair <int, int> rate_bps_pair
pair representing data rate (in Hz) & byte per sample
typedef std::map <std::string, rate_bps_pair> channellist
list of channels: map between channel name and rate/pbs pair
typedef channellist::iterator Channel_iter
channel list iterator
channellist mChannel
List of channel names to be read

Public Methods

DAQSocket ()
Construct an unopened socket
explicit DAQSocket (const char* ipaddr, int ipport = DAQD_PORT, int RcvBufferLen = 16384)
Create a socket and connect it to a server
~DAQSocket ()
Disconnect and close a socket
int open (const char* ipaddr, int ipport = DAQD_PORT, int RcvBufferLen = 16384)
Open an existing socket and connect it to a server
void close ()
Disconnect and close a socket
void flush ()
flushes the input data from the socket
bool isOpen () const
true if socket is open and connected
int StopWriter ()
Stop a data writer
int RequestFrames ()
Start reading frame data
int RequestOnlineData (bool fast = false, long timeout = -1)
Start reading CDS data
int RequestData (unsigned long start, unsigned long duration, long timeout = -1)
Start reading CDS data
int RequestTrend (unsigned long start, unsigned long duration, bool mintrend = false, long timeout = -1)
Start reading CDS trend data
int RequestNames (long timeout = -1)
Start reading file names
int WaitforData (bool poll = false)
Wait for data to arrive
int AddChannel (const char* chan, rate_bps_pair rb = rate_bps_pair (0, 0))
Add a channel to the request list
void RmChannel (const char* chan)
Remove a channel from the request list
int GetData (char* buf, int len, long timeout = -1)
Receive block of data in the CDS proprietary format
int GetData (char** buf, long timeout = -1)
Receive block of data in the CDS proprietary format
int GetName (char *buf, int len)
Receive a file name
int GetFrame (char *buf, int len)
Receive a data frame
int Available (DAQDChannel list[], int N)
List all known channels
void setDebug (bool debug=true)
Set debug mode
bool TestOpen (void)
Test that connection is open
float Version (void)
Get the server version ID

Documentation

The DAQD socket class. DAQSocket 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.
typedef std::pair <int, int> rate_bps_pair
pair representing data rate (in Hz) & byte per sample

typedef std::map <std::string, rate_bps_pair> channellist
list of channels: map between channel name and rate/pbs pair

typedef channellist::iterator Channel_iter
channel list iterator

channellist mChannel
List of channel names to be read

DAQSocket()
Construct an unopened socket

explicit DAQSocket(const char* ipaddr, int ipport = DAQD_PORT, int RcvBufferLen = 16384)
Create a socket and connect it to a server. The network address argument has the same syntax as that passed to DAQSocket::open().

~DAQSocket()
Disconnect and close a socket

int open(const char* ipaddr, int ipport = DAQD_PORT, int RcvBufferLen = 16384)
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.

void close()
Disconnect and close a socket

void flush()
flushes the input data from the socket

bool isOpen() const
true if socket is open and connected

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

int 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 RequestOnlineData(bool fast = false, long timeout = -1)
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.

int RequestData(unsigned long start, unsigned long duration, long timeout = -1)
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.

int RequestTrend(unsigned long start, unsigned long duration, bool mintrend = false, long 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.

int RequestNames(long timeout = -1)
Start reading file names. The network data server is requested to start a name writer task.

int WaitforData(bool poll = false)
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.

int AddChannel(const char* chan, rate_bps_pair rb = rate_bps_pair (0, 0))
Add a channel to the request list. All channels may be added by specifying "all" instead of a channel name.

void RmChannel(const char* chan)
Remove a channel from the request list

int GetData(char* buf, int len, long timeout = -1)
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.

int GetData(char** buf, long timeout = -1)
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. A buffer of the correct length will be allocated and returned automatically. The caller is reponsible for deallocation using delete[].

int GetName(char *buf, int 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 GetFrame(char *buf, int 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.

int Available(DAQDChannel list[], int N)
List all known channels. The names, sample rates, etc. of all channels known by the server are copied into the channel list. The list is preallocated by the caller with N entries. Available() returns the number of entries found or -1 if an error occurred. If the number of entries is greater than N, only the first N are copied to list;

void setDebug(bool debug=true)
Set debug mode. Setting debug mode to true causes the following to be printed to cout: all request text, the status code and reply text for each request, the header of each data block received and the length of each data/text block received and its buffer size.

bool TestOpen(void)
Test that connection is open. This is the only means of testing whether the creator was able to connect to a socket.

float Version(void)
Get the server version ID. The version and revision numbers of the server software are returned in a single float as (Version + 0.01*Revision).


This class has no child classes.

alphabetic index hierarchy of classes


Please send questions and comments to sigg_d@ligo-wa.caltech.edu


generated by doc++