ACQ2XX_API
acq_transport.h
Go to the documentation of this file.
00001 /* ------------------------------------------------------------------------- */
00002 /* file acq_transport.h                                                      */
00003 /* ------------------------------------------------------------------------- */
00004 /*   Copyright (C) 2008 Peter Milne, D-TACQ Solutions Ltd
00005  *                      <Peter dot Milne at D hyphen TACQ dot com>
00006 
00007     This program is free software; you can redistribute it and/or modify
00008     it under the terms of Version 2 of the GNU General Public License
00009     as published by the Free Software Foundation;
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */
00019 /* ------------------------------------------------------------------------- */
00020 
00021 /** @file acq_transport.h Generic ACQ2xx Transport Definition. */
00022 
00023 #ifndef __ACQ_TRANSPORT_H__
00024 #define __ACQ_TRANSPORT_H__ "$Revision: 1.4 $"
00025 
00026 #include "acq_api_common.h"
00027 
00028 class Frame;
00029 
00030 class Transport {
00031         const char* id;
00032 
00033 protected:
00034         Transport(const char* _id)
00035                 :
00036         id(_id)
00037         {}
00038         /**< protected Constructor - clients should not create directly. */
00039 
00040 
00041 public:
00042         static Transport *getTransport(const char* id);
00043         /**< Factory to create Transports. 
00044          * responsibility of client to delete when done.
00045          */
00046 
00047         virtual ~Transport() {}
00048 
00049 
00050         virtual STATUS acqcmd(
00051                 const char* command, char *response, int maxresponse) = 0;
00052         /**< send an "acqcmd" (acquisition command or query) to the card.
00053          * @param command - the command (or query) to send
00054          * @param response - user buffer to collect response.
00055          * @param maxresponse - maximum response size required.
00056          */
00057         STATUS acqcmd(const char* command) {
00058                 return acqcmd(command, 0, 0);
00059         }
00060         /**< send an "acqcmd" (acquisition command) to the card */
00061 
00062         virtual STATUS acq2sh(
00063                 const char* command, char *response, int maxresponse) = 0;
00064         /**< run a remote shell command or query. 
00065          * @param command - the command (or query) to send
00066          * @param response - user buffer to collect response.
00067          * @param maxresponse - maximum response size required.
00068          */
00069         STATUS acq2sh(const char* command) {
00070                 return acqcmd(command, 0, 0);
00071         }
00072         /**< run a remote shell command */
00073 
00074         virtual STATUS waitStateChange(
00075                 int timeout, char* response, int maxresponse) = 0;
00076         /**< block until remote state changes or timeout. */
00077 
00078         virtual STATUS readChannel(
00079                 int channel, short* data,
00080                 int nsamples, int start = 0, int stride = 1) = 0;
00081         /**< read and output raw data for channel
00082          * @param channel - channel number 1..N
00083          * @param data - caller's buffer
00084          * @param nsamples - max samples to read
00085          * @param start - start sample in data set
00086          * @param stride - stride [subsample] value
00087          * @returns actual samples returned or STATUS_ERR
00088          */
00089 
00090         /** streaming interface: not all transports can do this. */
00091         virtual STATUS readStreamingFrame(Frame* frame, unsigned id) {
00092                 return STATUS_FEATURE_NOT_IMPLEMENTED;
00093         }
00094         virtual STATUS stopStreaming(void) {
00095                 return STATUS_FEATURE_NOT_IMPLEMENTED;
00096         }
00097 };
00098 
00099 
00100 #endif // __ACQ_TRANSPORT_H__