#include <DAQC_api.hh>

Public Types | |
| typedef std::vector< DAQDChannel > | chan_list |
| list of channels: map between channel name and channel info | |
| typedef chan_list::iterator | channel_iter |
| channel list iterator | |
| typedef chan_list::const_iterator | const_channel_iter |
| channel list iterator | |
| typedef double | wait_time |
| typedef unsigned long | count_type |
Public Member Functions | |
| DAQC_api (void) | |
| virtual | ~DAQC_api (void) |
| virtual int | open (const std::string &ipaddr, int ipport, long buflen=16384)=0 |
| Connect to a server. | |
| virtual void | close ()=0 |
| virtual void | flush ()=0 |
| virtual int | AddChannel (const DAQDChannel &chns) |
| virtual int | AddChannel (const std::string &chan, chantype ty, double rate) |
| virtual int | Available (chantype typ, long gps, chan_list &list, wait_time timeout=-1)=0 |
| List all known channels. | |
| const_channel_iter | FindChannel (const std::string &chan) const |
| channel_iter | FindChannel (const std::string &chan) |
| virtual int | GetChannelData (const std::string &chan, float *data, long maxlen) const |
| Get channel data. | |
| virtual int | GetData (wait_time timeout=-1) |
| Get a data block from the server. | |
| virtual int | GetData (char **buf, wait_time timeout=-1) |
| virtual int | RequestOnlineData (double stride, wait_time timeout)=0 |
| Start reading CDS data. | |
| virtual int | RequestData (unsigned long start, unsigned long duration, wait_time timeout=-1)=0 |
| Start reading archived data. | |
| virtual void | RmChannel (const std::string &chan) |
| Remove channel from the request list. | |
| virtual void | setAbort (bool *abort) |
| Set abort button. | |
| virtual void | setDebug (int debug=1) |
| virtual void | setDebug (bool debug=true) |
| virtual int | StopWriter ()=0 |
| Stop a data writer. | |
| virtual int | Times (chantype type, unsigned long &start, unsigned long &duration, wait_time timeout=-1) |
| virtual int | WaitforData (bool poll=false)=0 |
| Wait for data. | |
| virtual bool | isOpen (void) const |
| Test open. | |
| virtual bool | isOn (void) const |
| Test if transaction in progress. | |
| const_channel_iter | chan_begin (void) const |
| const_channel_iter | chan_end (void) const |
| virtual unsigned long | nRequest (void) const |
| Number of requested channels. | |
| virtual float | Version (void) const |
Public Attributes | |
| recvBuf | mRecvBuf |
Protected Types | |
| enum | writer_type { NoWriter, NameWriter, DataWriter, FrameWriter, FastWriter, NDS2Writer } |
Protected Member Functions | |
| void | SwapHeader (void) |
| int | SwapData (void) |
| int | CVHex (const char *text, int N) |
| virtual int | RecvData (wait_time timeout=-1)=0 |
| Receive a data header and data block. | |
| virtual int | RecvFloat (float &data, wait_time timeout=-1) |
| Receive a float data word. | |
| virtual int | RecvInt (int &data, wait_time timeout=-1) |
| Receive an integer data word. | |
| virtual int | RecvRec (char *buf, long len, bool readall=false, wait_time maxwait=-1)=0 |
| virtual int | RecvReconfig (count_type len, wait_time maxwait=-1)=0 |
| virtual int | RecvStr (std::string &str, wait_time maxwait=-1) |
| Receive a string. | |
Protected Attributes | |
| thread::recursivemutex | mux |
| bool | mOpened |
| int | mDebug |
| enum DAQC_api::writer_type | mWriterType |
| int | mOffline |
| int | mVersion |
| int | mRevision |
| bool * | mAbort |
| chan_list | mRequest_List |
Classes | |
| class | recvBuf |
DAQC_api 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.
enum DAQC_api::writer_type [protected] |
Writer type enumeration. This enumerator specifies the type of data requested through the socket. It is set when a data writer is started and tested by the data read methods when they are called.
| DAQC_api::DAQC_api | ( | void | ) |
Construct an unopened socket.
| virtual DAQC_api::~DAQC_api | ( | void | ) | [virtual] |
Disconnect and close a socket.
| virtual int DAQC_api::open | ( | const std::string & | ipaddr, | |
| int | ipport, | |||
| long | buflen = 16384 | |||
| ) | [pure virtual] |
Connect to a server.
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.
Implemented in NDS1Socket, and NDS2Socket.
| virtual void DAQC_api::close | ( | ) | [pure virtual] |
Disconnect and close a socket.
Implemented in NDS1Socket, and NDS2Socket.
| virtual void DAQC_api::flush | ( | ) | [pure virtual] |
flushes the input data from the socket.
Implemented in NDS1Socket, and NDS2Socket.
| bool DAQC_api::isOpen | ( | void | ) | const [inline, virtual] |
Test open.
Test whether the socket is open.
| bool DAQC_api::isOn | ( | void | ) | const [inline, virtual] |
Test if transaction in progress.
Test whether the server is processing a request from this client.
| virtual int DAQC_api::AddChannel | ( | const DAQDChannel & | chns | ) | [virtual] |
Add a channel to the request list. All channels may be added by specifying "all" instead of a channel name.
| virtual int DAQC_api::AddChannel | ( | const std::string & | chan, | |
| chantype | ty, | |||
| double | rate | |||
| ) | [virtual] |
Add a channel to the request list. All channels may be added by specifying "all" instead of a channel name.
Reimplemented in NDS1Socket.
| virtual int DAQC_api::Available | ( | chantype | typ, | |
| long | gps, | |||
| chan_list & | list, | |||
| wait_time | timeout = -1 | |||
| ) | [pure virtual] |
List all 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.
Implemented in NDS1Socket, and NDS2Socket.
| DAQC_api::const_channel_iter DAQC_api::chan_begin | ( | void | ) | const [inline] |
Request list iterator start.
| DAQC_api::const_channel_iter DAQC_api::chan_end | ( | void | ) | const [inline] |
Request list iterator end.
| const_channel_iter DAQC_api::FindChannel | ( | const std::string & | chan | ) | const |
Find a channel in the request list.
| channel_iter DAQC_api::FindChannel | ( | const std::string & | chan | ) |
Find a channel in the request list.
| virtual int DAQC_api::GetChannelData | ( | const std::string & | chan, | |
| float * | data, | |||
| long | maxlen | |||
| ) | const [virtual] |
Get channel data.
Copy data for a specified channel to a user buffer.
| chan | Channel name | |
| data | User provided data buffer | |
| maxlen | Length of user buffer in bytes. |
| virtual int DAQC_api::GetData | ( | wait_time | timeout = -1 |
) | [virtual] |
Get a data block from the server.
Receive block of data in the CDS proprietary format. A single block of data (including the header) is received and stored in an internal buffer.
| @return | data length, or failure. |
Reimplemented in NDS1Socket, and NDS2Socket.
| virtual int DAQC_api::GetData | ( | char ** | buf, | |
| wait_time | timeout = -1 | |||
| ) | [virtual] |
Receive a block of data. Transfer the header and data into an Allocated buffer.
| unsigned long DAQC_api::nRequest | ( | void | ) | const [inline, virtual] |
Number of requested channels.
Get the number of requested channels.
| virtual int DAQC_api::RequestOnlineData | ( | double | stride, | |
| wait_time | timeout | |||
| ) | [pure 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.
| stride | Number of seconds of data to to transfer (1/16th sec -> inf). | |
| timeout | Maximum time to wait for a ewsponse (-1 = infinite) |
Implemented in NDS1Socket, and NDS2Socket.
| virtual int DAQC_api::RequestData | ( | unsigned long | start, | |
| unsigned long | duration, | |||
| wait_time | timeout = -1 | |||
| ) | [pure virtual] |
Start reading archived 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.
| start | GPS time of start of data to be read. | |
| duration | Number of seconds of data to read. | |
| timeout | Maximum time to wait for a response (-1 = infinite) |
Implemented in NDS1Socket, and NDS2Socket.
| virtual void DAQC_api::RmChannel | ( | const std::string & | chan | ) | [virtual] |
Remove channel from the request list.
Remove the specified channel from the request list.
| chan | Channel name. |
Reimplemented in NDS1Socket.
| virtual void DAQC_api::setAbort | ( | bool * | abort | ) | [virtual] |
Set abort button.
Set the abort flag. If the abort "button" is used, recv/send will periodically check its state and if it has become true, will abort the transaction. Make sure to set abort to false before calling a method that receives data or sends a request.
| virtual void DAQC_api::setDebug | ( | int | debug = 1 |
) | [virtual] |
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.
| virtual int DAQC_api::StopWriter | ( | ) | [pure virtual] |
Stop a data writer.
StopWriter effectively countermands the RequestXXX() functions.
Implemented in NDS1Socket, and NDS2Socket.
| virtual int DAQC_api::Times | ( | chantype | type, | |
| 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 in NDS1Socket, and NDS2Socket.
| float DAQC_api::Version | ( | void | ) | const [inline, virtual] |
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).
| virtual int DAQC_api::WaitforData | ( | bool | poll = false |
) | [pure virtual] |
Wait for data.
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 the return value indicating whether data are present.
| poll | If true WaitforData returns immediately. The return codes indicates whether data are available. |
Implemented in NDS1Socket, and NDS2Socket.
| void DAQC_api::SwapHeader | ( | void | ) | [protected] |
Swap all the data.
| int DAQC_api::SwapData | ( | void | ) | [protected] |
Swap all the data.
| virtual int DAQC_api::RecvData | ( | wait_time | timeout = -1 |
) | [protected, pure virtual] |
Receive a data header and data block.
Receive a data record consisting of a header record followed by a data block. The header is checked for an out-of-band message type (e.g. reconfigure block) and the return code is set accordingly. A memory buffer of correct length is allocated automatically.
| timeou | Maximum wait time |
| virtual int DAQC_api::RecvFloat | ( | float & | data, | |
| wait_time | timeout = -1 | |||
| ) | [protected, virtual] |
Receive a float data word.
Receive a float data word, swap the byte ordering if necessary and store thedata in the argument location.
| virtual int DAQC_api::RecvInt | ( | int & | data, | |
| wait_time | timeout = -1 | |||
| ) | [protected, virtual] |
Receive an integer data word.
Receive an integer data word, swap the byte ordering if necessary and store thedata in the argument location.
| virtual int DAQC_api::RecvRec | ( | char * | buf, | |
| long | len, | |||
| bool | readall = false, |
|||
| wait_time | maxwait = -1 | |||
| ) | [protected, pure virtual] |
Receive data from the socket. Up to 'len' bytes are read from the socket into '*buf'. If readall is true, RecvRec will perform as many reads as is necessary to fill 'buf'.
| virtual int DAQC_api::RecvReconfig | ( | count_type | len, | |
| wait_time | maxwait = -1 | |||
| ) | [protected, pure virtual] |
Receive a reconfigure block. A reconfigure structure of channel metadata.
| virtual int DAQC_api::RecvStr | ( | std::string & | str, | |
| wait_time | maxwait = -1 | |||
| ) | [protected, virtual] |
Receive a string.
Receive a string consisting of a 4-byte length followed by a text field.
| str | String into which input data will be stored. | |
| maxwait | Maximum wait time. |
| recvBuf DAQC_api::mRecvBuf |
Receive buffer
thread::recursivemutex DAQC_api::mux [mutable, protected] |
mutex to protect object.
bool DAQC_api::mOpened [protected] |
Socket is open and connected.
int DAQC_api::mDebug [protected] |
Debug mode was specified.
int DAQC_api::mOffline [protected] |
Offline flag sent when the writer is started.
int DAQC_api::mVersion [protected] |
Server version number.
int DAQC_api::mRevision [protected] |
Server revision number.
bool* DAQC_api::mAbort [protected] |
Abort flag
chan_list DAQC_api::mRequest_List [protected] |
Channel request list.
1.5.4