Classes | |
| struct | DAQDChannel |
| Channel data-base entry. More... | |
| struct | DAQDRecHdr |
| DAQD header record. More... | |
| class | DAQC_api |
| The DAQD socket class. More... | |
| struct | DAQDChannel |
| Channel data-base entry. More... | |
| struct | DAQDRecHdr |
| DAQD header record. More... | |
| class | DAQSocket |
| The DAQD socket class. More... | |
| class | NDS1Socket |
| The DAQD socket class. More... | |
| class | NDS2Socket |
| The DAQD socket class. More... | |
DAQC_api* nds(0);
//--------- Construct a concrete DAQC_api socket with
nds = new NDS1Socket;
//--------- or with
nds = new NDS2Socket;
//--------- Open a socket to the specified server port.
const char* servername = "nds-server:port";
nds.open(servername);
if (!nds.TestOpen()) fail("Open failed!");
//--------- Specify the channel to be read.
const char* chan = "channel name";
if (!nds.AddChannel(chan)) fail("Add channel failed!");
if (nds.RequestOnlineData()) fail("Data Request failed");
//--------- Specify the channel to be read.
float* Samples = new float[data_len];
while (1) {
int nData = nds.GetData((char*) Samples, data_len);
if (nData <= 0) break;
... Process data ...
}
| Function | DAQSocket method | NDS command |
| Get data from specified time | RequestData | start net-writer <start> <duration> [{"channel" ...} | all]; |
| Get file names | RequestNames | start name-writer all; |
| Get available channel list | Available | status channels [2]; |
| Get fast online data | RequestOnlineData | start fast-writer [{"channel" ...} | all]; |
| Get slow online data | RequestOnlineData | start net-writer [{"channel" ...} | all]; |
| Get trend data | RequestTrendData | start trend [60] net-writer <start> <duration> [{"channel" ...} | all]; |
| Stop a net-writer | StopWriter | kill net-writer nnnnnnnn; |
The data trasfer protocol is as follows. After connecting to the nds server, the client sends a command. The commands corresponding to each DAQSocket method are listed above. The syntax of the comands are:
<command> [{<channel-1> [<rate-1>] [... <channel-n> [<rate-n>]]}];
A typical online NDS client would do the following:
//--------- Construct a DAQD socket
DAQSocket nds;
//--------- Open a socket to the specified server port.
const char* servername = "nds-server:port";
nds.open(servername);
if (!nds.TestOpen()) fail("Open failed!");
//--------- Specify the channel to be read.
const char* chan = "channel name";
if (!nds.AddChannel(chan)) fail("Add channel failed!");
if (nds.RequestOnlineData()) fail("Data Request failed");
//--------- Specify the channel to be read.
float* Samples = new float[data_len];
while (1) {
int nData = nds.GetData((char*) Samples, data_len);
if (nData <= 0) break;
... Process data ...
}
| Function | DAQSocket method | NDS command |
| Get data from specified time | RequestData | start net-writer <start> <duration> [{"channel" ...} | all]; |
| Get file names | RequestNames | start name-writer all; |
| Get available channel list | Available | status channels [2]; |
| Get fast online data | RequestOnlineData | start fast-writer [{"channel" ...} | all]; |
| Get slow online data | RequestOnlineData | start net-writer [{"channel" ...} | all]; |
| Get trend data | RequestTrendData | start trend [60] net-writer <start> <duration> [{"channel" ...} | all]; |
| Stop a net-writer | StopWriter | kill net-writer nnnnnnnn; |
A typical online NDS client would do the following:
//--------- Construct a DAQD socket
DAQSocket nds;
//--------- Open a socket to the specified server port.
const char* servername = "nds-server:port";
nds.open(servername);
if (!nds.TestOpen()) fail("Open failed!");
//--------- Specify the channel to be read.
const char* chan = "channel name";
if (!nds.AddChannel(chan)) fail("Add channel failed!");
if (nds.RequestOnlineData()) fail("Data Request failed");
//--------- Specify the channel to be read.
float* Samples = new float[data_len];
while (1) {
int nData = nds.GetData((char*) Samples, data_len);
if (nData <= 0) break;
... Process data ...
}
The protocol rules are similar to the classic nds server protocol. Each request (including the authentication message) result in a 4 hex digit response code that indicates the status of the request. The
The syntax implemented by this interface is:
| Function | NDS2Socket method | NDS2 command |
| Get data from specified time | RequestData | get-data <start> <duration> [<stride>] {<channel-desc> ...}; |
| Get available channel list | Available | get-channels [<gps>] [<chan-type>] ; |
| Get continuous stream of online data. | RequestOnlineData | get-online-data [[<duration>] <stride>] {"channel"...}; |
| Quit session | StopWriter | quit; |
A typical online NDS2 client would do the following:
//--------- Construct a DAQD socket
NDS2Socket nds;
//--------- Open a socket to the specified server port.
const char* servername = "nds-server";
int port(31200);
nds.open(servername, port);
if (!nds.isOpen()) fail("Open failed!");
//--------- Specify the channel to be read.
const char* chan = "channel name";
if (!nds.AddChannel(chan, 0.0, _undefined)) fail("Add channel failed!");
if (nds.RequestData(gpsStart, gpsEnd, 2.0)) fail("Data Request failed");
//--------- Specify the channel to be read.
float* Samples = new float[data_len];
while (1) {
int nData = nds.GetChannelData(chan, Samples, data_len);
if (nData <= 0) break;
... Process data ...
}
1.5.4