Hamlib  1.2.14
rigclass.h
00001 /*
00002  *  Hamlib C++ bindings - API header
00003  *  Copyright (c) 2001-2002 by Stephane Fillod
00004  *
00005  *      $Id: rigclass.h,v 1.14 2008-02-18 18:18:54 dl1nc Exp $
00006  *
00007  *   This library is free software; you can redistribute it and/or modify
00008  *   it under the terms of the GNU Library General Public License as
00009  *   published by the Free Software Foundation; either version 2 of
00010  *   the License, or (at your option) any later version.
00011  *
00012  *   This program is distributed in the hope that it will be useful,
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *   GNU Library General Public License for more details.
00016  *
00017  *   You should have received a copy of the GNU Library General Public
00018  *   License along with this library; if not, write to the Free Software
00019  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020  *
00021  */
00022 
00023 #ifndef _RIGCLASS_H
00024 #define _RIGCLASS_H 1
00025 
00026 #include <hamlib/rig.h>
00027 #include <iostream>
00028 
00029 
00030 class BACKEND_IMPEXP Rig {
00031 private:
00032   RIG* theRig;  // Global ref. to the rig
00033 
00034 protected:
00035 public:
00036   Rig(rig_model_t rig_model);
00037 
00038   virtual ~Rig();
00039 
00040   const struct rig_caps *caps;
00041 
00042   // This method open the communication port to the rig
00043   void open(void);
00044 
00045   // This method close the communication port to the rig
00046   void close(void);
00047 
00048   void setConf(token_t token, const char *val);
00049   void setConf(const char *name, const char *val);
00050   void getConf(token_t token, char *val);
00051   void getConf(const char *name, char *val);
00052   token_t tokenLookup(const char *name);
00053 
00054   void setFreq(freq_t freq, vfo_t vfo = RIG_VFO_CURR);
00055   freq_t getFreq(vfo_t vfo = RIG_VFO_CURR);
00056   void setMode(rmode_t, pbwidth_t width = RIG_PASSBAND_NORMAL, vfo_t vfo = RIG_VFO_CURR);
00057   rmode_t getMode(pbwidth_t&, vfo_t vfo = RIG_VFO_CURR);
00058   void setVFO(vfo_t);
00059   vfo_t getVFO();
00060 
00061   void setPTT (ptt_t ptt, vfo_t vfo = RIG_VFO_CURR);
00062   ptt_t getPTT (vfo_t vfo = RIG_VFO_CURR);
00063   dcd_t getDCD (vfo_t vfo = RIG_VFO_CURR);
00064 
00065   void setLevel(setting_t level, int vali, vfo_t vfo = RIG_VFO_CURR);
00066   void setLevel(setting_t level, float valf, vfo_t vfo = RIG_VFO_CURR);
00067   void getLevel(setting_t level, int& vali, vfo_t vfo = RIG_VFO_CURR);
00068   void getLevel(setting_t level, float& valf, vfo_t vfo = RIG_VFO_CURR);
00069   int getLevelI(setting_t level, vfo_t vfo = RIG_VFO_CURR);
00070   float getLevelF(setting_t level, vfo_t vfo = RIG_VFO_CURR);
00071   bool hasGetLevel (setting_t level);
00072   bool hasSetLevel (setting_t level);
00073 
00074   void setParm(setting_t parm, int vali);
00075   void setParm(setting_t parm, float valf);
00076   void getParm(setting_t parm, int& vali);
00077   void getParm(setting_t parm, float& valf);
00078   int getParmI(setting_t parm);
00079   float getParmF(setting_t parm);
00080   bool hasGetParm (setting_t parm);
00081   bool hasSetParm (setting_t parm);
00082 
00083   void setFunc (setting_t func, bool status, vfo_t vfo = RIG_VFO_CURR);
00084   bool getFunc (setting_t func, vfo_t vfo = RIG_VFO_CURR);
00085   bool hasGetFunc (setting_t func);
00086   bool hasSetFunc (setting_t func);
00087 
00088   void VFOop(vfo_op_t op, vfo_t vfo = RIG_VFO_CURR);
00089   bool hasVFOop (vfo_op_t op);
00090 
00091   void scan(scan_t scan, int ch, vfo_t vfo = RIG_VFO_CURR);
00092   bool hasScan (scan_t scan);
00093 
00094   const char *getInfo (void);
00095   pbwidth_t passbandNormal (rmode_t);
00096   pbwidth_t passbandNarrow (rmode_t);
00097   pbwidth_t passbandWide (rmode_t);
00098 
00099   void setRptrShift (rptr_shift_t rptr_shift, vfo_t vfo = RIG_VFO_CURR);
00100   rptr_shift_t getRptrShift (vfo_t vfo = RIG_VFO_CURR);
00101   void setRptrOffs (shortfreq_t rptr_offs, vfo_t vfo = RIG_VFO_CURR);
00102   shortfreq_t getRptrOffs (vfo_t vfo = RIG_VFO_CURR);
00103   void setTs (shortfreq_t ts, vfo_t vfo = RIG_VFO_CURR);
00104   shortfreq_t getTs (vfo_t vfo = RIG_VFO_CURR);
00105 
00106   void setCTCSS (tone_t tone, vfo_t vfo = RIG_VFO_CURR);
00107   tone_t getCTCSS (vfo_t vfo = RIG_VFO_CURR);
00108   void setDCS (tone_t code, vfo_t vfo = RIG_VFO_CURR);
00109   tone_t getDCS (vfo_t vfo = RIG_VFO_CURR);
00110 
00111   void setCTCSSsql (tone_t tone, vfo_t vfo = RIG_VFO_CURR);
00112   tone_t getCTCSSsql (vfo_t vfo = RIG_VFO_CURR);
00113   void setDCSsql (tone_t tone, vfo_t vfo = RIG_VFO_CURR);
00114   tone_t getDCSsql (vfo_t vfo = RIG_VFO_CURR);
00115 
00116 
00117   unsigned int power2mW (float power, freq_t freq, rmode_t mode);
00118   float mW2power (unsigned int mwpower, freq_t freq, rmode_t mode);
00119   void setTrn (int trn);
00120   int getTrn (void);
00121   void setBank (int bank, vfo_t vfo = RIG_VFO_CURR);
00122   void setMem (int ch, vfo_t vfo = RIG_VFO_CURR);
00123   int getMem (vfo_t vfo = RIG_VFO_CURR);
00124 
00125   void setChannel (const channel_t *chan);
00126   void getChannel (channel_t *chan);
00127 
00128   void setPowerStat (powerstat_t status);
00129   powerstat_t getPowerStat (void);
00130   rmode_t RngRxModes (freq_t freq);
00131   rmode_t RngTxModes (freq_t freq);
00132 
00133   void setSplitFreq (freq_t tx_freq, vfo_t vfo = RIG_VFO_CURR);
00134   freq_t getSplitFreq (vfo_t vfo = RIG_VFO_CURR);
00135   void setSplitMode(rmode_t, pbwidth_t width = RIG_PASSBAND_NORMAL, vfo_t vfo = RIG_VFO_CURR);
00136   rmode_t getSplitMode(pbwidth_t&, vfo_t vfo = RIG_VFO_CURR);
00137   void setSplitVFO(split_t split, vfo_t vfo = RIG_VFO_CURR, vfo_t tx_vfo = RIG_VFO_CURR);
00138   split_t getSplitVFO(vfo_t &tx_vfo, vfo_t vfo = RIG_VFO_CURR);
00139 
00140   void setRit  (shortfreq_t rit, vfo_t vfo = RIG_VFO_CURR);
00141   shortfreq_t getRit  (vfo_t vfo = RIG_VFO_CURR);
00142   void setXit  (shortfreq_t xit, vfo_t vfo = RIG_VFO_CURR);
00143   shortfreq_t getXit  (vfo_t vfo = RIG_VFO_CURR);
00144 
00145   void setAnt  (ant_t ant, vfo_t vfo = RIG_VFO_CURR);
00146   ant_t getAnt  (vfo_t vfo = RIG_VFO_CURR);
00147 
00148   void sendDtmf  (const char *digits, vfo_t vfo = RIG_VFO_CURR);
00149   int recvDtmf  (char *digits, vfo_t vfo = RIG_VFO_CURR);
00150   void sendMorse  (const char *msg, vfo_t vfo = RIG_VFO_CURR);
00151 
00152 
00153   shortfreq_t getResolution (rmode_t mode);
00154   void reset (reset_t reset);
00155 
00156   // callbacks available in your derived object
00157   virtual int FreqEvent(vfo_t, freq_t, rig_ptr_t) const {
00158                   return RIG_OK;
00159   }
00160   virtual int ModeEvent(vfo_t, rmode_t, pbwidth_t, rig_ptr_t) const {
00161                   return RIG_OK;
00162   }
00163   virtual int VFOEvent(vfo_t, rig_ptr_t) const {
00164                   return RIG_OK;
00165   }
00166   virtual int PTTEvent(vfo_t, ptt_t, rig_ptr_t) const {
00167                   return RIG_OK;
00168   }
00169   virtual int DCDEvent(vfo_t, dcd_t, rig_ptr_t) const {
00170                   return RIG_OK;
00171   }
00172 
00173 
00174 };
00175  
00176 
00177 
00178 #ifdef __GNUG__
00179 #  if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
00180 #    if HAVE_TYPEINFO
00181 #      include <typeinfo>
00182 #    endif
00183 #  endif
00184 #endif
00185 
00186 #if defined(__GNUG__)
00187 #  if HAVE_BUILTIN_H || HAVE_GXX_BUILTIN_H || HAVE_GPP_BUILTIN_H
00188 #    if ETIP_NEEDS_MATH_H
00189 #      if ETIP_NEEDS_MATH_EXCEPTION
00190 #        undef exception
00191 #        define exception math_exception
00192 #      endif
00193 #      include <math.h>
00194 #    endif
00195 #    undef exception
00196 #    define exception builtin_exception
00197 #    if HAVE_GPP_BUILTIN_H
00198 #     include <gpp/builtin.h>
00199 #    elif HAVE_GXX_BUILTIN_H
00200 #     include <g++/builtin.h>
00201 #    else
00202 #     include <builtin.h>
00203 #    endif
00204 #    undef exception
00205 #  endif
00206 #elif defined (__SUNPRO_CC)
00207 #  include <generic.h>
00208 #  include <string.h>
00209 #else
00210 #  include <string.h>
00211 #endif
00212 
00213 
00214 extern "C" {
00215 #if HAVE_VALUES_H
00216 #  include <values.h>
00217 #endif
00218 
00219 #include <assert.h>
00220 #include <errno.h>
00221 }
00222 
00223 #include <iostream>
00224 #if !(defined(__GNUG__)||defined(__SUNPRO_CC))
00225    extern "C" void exit(int);
00226 #endif
00227 
00228 // Forward Declarations
00229 
00230 class BACKEND_IMPEXP RigException
00231 {
00232 public:
00233   const char *message;
00234   int errorno;
00235 
00236   RigException (const char* msg, int err)
00237     : message(msg), errorno (err)
00238     {};
00239 
00240   RigException (int err)
00241     : message(rigerror(err)), errorno (err)
00242     {};
00243 
00244   RigException (const char* msg)
00245     : message(msg), errorno (-RIG_EINTERNAL)
00246     {};
00247 
00248   virtual ~RigException()
00249     {};
00250 
00251   void print() const {
00252           std::cerr << "Rig exception: " << message << std::endl;
00253   }
00254   virtual const char *classname() const {
00255     return "Rig";
00256   }
00257 };
00258 
00259 inline void THROW(const RigException *e) {
00260 #if defined(__GNUG__)
00261 #  if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
00262       (*lib_error_handler)(e?e->classname():"",e?e->message:"");
00263 #else
00264       throw *e;
00265 #endif
00266 #elif defined(__SUNPRO_CC)
00267   genericerror(1, ((e != 0) ? (char *)(e->message) : ""));
00268 #else
00269   if (e)
00270     std::cerr << e->message << endl;
00271   exit(0);
00272 #endif
00273 }
00274 
00275 #define THROWS(s)
00276 
00277 
00278 #endif  // _RIGCLASS_H
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated by doxygen 1.7.5

Hamlib documentation for version 1.2.14 -- Fri Dec 23 2011 23:24:31
Project page: http://www.hamlib.org