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