Hamlib  3.0.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
rigclass.h
1 /*
2  * Hamlib C++ bindings - API header
3  * Copyright (c) 2001-2002 by Stephane Fillod
4  *
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  *
20  */
21 
22 #ifndef _RIGCLASS_H
23 #define _RIGCLASS_H 1
24 
25 #include <hamlib/rig.h>
26 #include <iostream>
27 
28 
29 class BACKEND_IMPEXP Rig {
30 private:
31  RIG* theRig; // Global ref. to the rig
32 
33 protected:
34 public:
35  Rig(rig_model_t rig_model);
36 
37  virtual ~Rig();
38 
39  const struct rig_caps *caps;
40 
41  // This method open the communication port to the rig
42  void open(void);
43 
44  // This method close the communication port to the rig
45  void close(void);
46 
47  void setConf(token_t token, const char *val);
48  void setConf(const char *name, const char *val);
49  void getConf(token_t token, char *val);
50  void getConf(const char *name, char *val);
51  token_t tokenLookup(const char *name);
52 
53  void setFreq(freq_t freq, vfo_t vfo = RIG_VFO_CURR);
54  freq_t getFreq(vfo_t vfo = RIG_VFO_CURR);
55  void setMode(rmode_t, pbwidth_t width = RIG_PASSBAND_NORMAL, vfo_t vfo = RIG_VFO_CURR);
56  rmode_t getMode(pbwidth_t&, vfo_t vfo = RIG_VFO_CURR);
57  void setVFO(vfo_t);
58  vfo_t getVFO();
59 
60  void setPTT (ptt_t ptt, vfo_t vfo = RIG_VFO_CURR);
61  ptt_t getPTT (vfo_t vfo = RIG_VFO_CURR);
62  dcd_t getDCD (vfo_t vfo = RIG_VFO_CURR);
63 
64  void setLevel(setting_t level, int vali, vfo_t vfo = RIG_VFO_CURR);
65  void setLevel(setting_t level, float valf, vfo_t vfo = RIG_VFO_CURR);
66  void getLevel(setting_t level, int& vali, vfo_t vfo = RIG_VFO_CURR);
67  void getLevel(setting_t level, float& valf, vfo_t vfo = RIG_VFO_CURR);
68  int getLevelI(setting_t level, vfo_t vfo = RIG_VFO_CURR);
69  float getLevelF(setting_t level, vfo_t vfo = RIG_VFO_CURR);
70  bool hasGetLevel (setting_t level);
71  bool hasSetLevel (setting_t level);
72 
73  void setParm(setting_t parm, int vali);
74  void setParm(setting_t parm, float valf);
75  void getParm(setting_t parm, int& vali);
76  void getParm(setting_t parm, float& valf);
77  int getParmI(setting_t parm);
78  float getParmF(setting_t parm);
79  bool hasGetParm (setting_t parm);
80  bool hasSetParm (setting_t parm);
81 
82  void setFunc (setting_t func, bool status, vfo_t vfo = RIG_VFO_CURR);
83  bool getFunc (setting_t func, vfo_t vfo = RIG_VFO_CURR);
84  bool hasGetFunc (setting_t func);
85  bool hasSetFunc (setting_t func);
86 
87  void VFOop(vfo_op_t op, vfo_t vfo = RIG_VFO_CURR);
88  bool hasVFOop (vfo_op_t op);
89 
90  void scan(scan_t scan, int ch, vfo_t vfo = RIG_VFO_CURR);
91  bool hasScan (scan_t scan);
92 
93  const char *getInfo (void);
94  pbwidth_t passbandNormal (rmode_t);
95  pbwidth_t passbandNarrow (rmode_t);
96  pbwidth_t passbandWide (rmode_t);
97 
98  void setRptrShift (rptr_shift_t rptr_shift, vfo_t vfo = RIG_VFO_CURR);
99  rptr_shift_t getRptrShift (vfo_t vfo = RIG_VFO_CURR);
100  void setRptrOffs (shortfreq_t rptr_offs, vfo_t vfo = RIG_VFO_CURR);
101  shortfreq_t getRptrOffs (vfo_t vfo = RIG_VFO_CURR);
102  void setTs (shortfreq_t ts, vfo_t vfo = RIG_VFO_CURR);
103  shortfreq_t getTs (vfo_t vfo = RIG_VFO_CURR);
104 
105  void setCTCSS (tone_t tone, vfo_t vfo = RIG_VFO_CURR);
106  tone_t getCTCSS (vfo_t vfo = RIG_VFO_CURR);
107  void setDCS (tone_t code, vfo_t vfo = RIG_VFO_CURR);
108  tone_t getDCS (vfo_t vfo = RIG_VFO_CURR);
109 
110  void setCTCSSsql (tone_t tone, vfo_t vfo = RIG_VFO_CURR);
111  tone_t getCTCSSsql (vfo_t vfo = RIG_VFO_CURR);
112  void setDCSsql (tone_t tone, vfo_t vfo = RIG_VFO_CURR);
113  tone_t getDCSsql (vfo_t vfo = RIG_VFO_CURR);
114 
115 
116  unsigned int power2mW (float power, freq_t freq, rmode_t mode);
117  float mW2power (unsigned int mwpower, freq_t freq, rmode_t mode);
118  void setTrn (int trn);
119  int getTrn (void);
120  void setBank (int bank, vfo_t vfo = RIG_VFO_CURR);
121  void setMem (int ch, vfo_t vfo = RIG_VFO_CURR);
122  int getMem (vfo_t vfo = RIG_VFO_CURR);
123 
124  void setChannel (const channel_t *chan);
125  void getChannel (channel_t *chan);
126 
127  void setPowerStat (powerstat_t status);
128  powerstat_t getPowerStat (void);
129  rmode_t RngRxModes (freq_t freq);
130  rmode_t RngTxModes (freq_t freq);
131 
132  void setSplitFreq (freq_t tx_freq, vfo_t vfo = RIG_VFO_CURR);
133  freq_t getSplitFreq (vfo_t vfo = RIG_VFO_CURR);
134  void setSplitMode(rmode_t, pbwidth_t width = RIG_PASSBAND_NORMAL, vfo_t vfo = RIG_VFO_CURR);
135  rmode_t getSplitMode(pbwidth_t&, vfo_t vfo = RIG_VFO_CURR);
136  void setSplitVFO(split_t split, vfo_t vfo = RIG_VFO_CURR, vfo_t tx_vfo = RIG_VFO_CURR);
137  split_t getSplitVFO(vfo_t &tx_vfo, vfo_t vfo = RIG_VFO_CURR);
138 
139  void setRit (shortfreq_t rit, vfo_t vfo = RIG_VFO_CURR);
140  shortfreq_t getRit (vfo_t vfo = RIG_VFO_CURR);
141  void setXit (shortfreq_t xit, vfo_t vfo = RIG_VFO_CURR);
142  shortfreq_t getXit (vfo_t vfo = RIG_VFO_CURR);
143 
144  void setAnt (ant_t ant, vfo_t vfo = RIG_VFO_CURR);
145  ant_t getAnt (vfo_t vfo = RIG_VFO_CURR);
146 
147  void sendDtmf (const char *digits, vfo_t vfo = RIG_VFO_CURR);
148  int recvDtmf (char *digits, vfo_t vfo = RIG_VFO_CURR);
149  void sendMorse (const char *msg, vfo_t vfo = RIG_VFO_CURR);
150 
151 
152  shortfreq_t getResolution (rmode_t mode);
153  void reset (reset_t reset);
154 
155  // callbacks available in your derived object
156  virtual int FreqEvent(vfo_t, freq_t, rig_ptr_t) const {
157  return RIG_OK;
158  }
159  virtual int ModeEvent(vfo_t, rmode_t, pbwidth_t, rig_ptr_t) const {
160  return RIG_OK;
161  }
162  virtual int VFOEvent(vfo_t, rig_ptr_t) const {
163  return RIG_OK;
164  }
165  virtual int PTTEvent(vfo_t, ptt_t, rig_ptr_t) const {
166  return RIG_OK;
167  }
168  virtual int DCDEvent(vfo_t, dcd_t, rig_ptr_t) const {
169  return RIG_OK;
170  }
171 
172 
173 };
174 
175 
176 
177 #ifdef __GNUG__
178 # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
179 # if HAVE_TYPEINFO
180 # include <typeinfo>
181 # endif
182 # endif
183 #endif
184 
185 #if defined(__GNUG__)
186 # if HAVE_BUILTIN_H || HAVE_GXX_BUILTIN_H || HAVE_GPP_BUILTIN_H
187 # if ETIP_NEEDS_MATH_H
188 # if ETIP_NEEDS_MATH_EXCEPTION
189 # undef exception
190 # define exception math_exception
191 # endif
192 # include <math.h>
193 # endif
194 # undef exception
195 # define exception builtin_exception
196 # if HAVE_GPP_BUILTIN_H
197 # include <gpp/builtin.h>
198 # elif HAVE_GXX_BUILTIN_H
199 # include <g++/builtin.h>
200 # else
201 # include <builtin.h>
202 # endif
203 # undef exception
204 # endif
205 #elif defined (__SUNPRO_CC)
206 # include <generic.h>
207 # include <string.h>
208 #else
209 # include <string.h>
210 #endif
211 
212 
213 extern "C" {
214 #if HAVE_VALUES_H
215 # include <values.h>
216 #endif
217 
218 #include <assert.h>
219 #include <errno.h>
220 }
221 
222 #include <iostream>
223 #if !(defined(__GNUG__)||defined(__SUNPRO_CC))
224  extern "C" void exit(int);
225 #endif
226 
227 // Forward Declarations
228 
229 class BACKEND_IMPEXP RigException
230 {
231 public:
232  const char *message;
233  int errorno;
234 
235  RigException (const char* msg, int err)
236  : message(msg), errorno (err)
237  {};
238 
239  RigException (int err)
240  : message(rigerror(err)), errorno (err)
241  {};
242 
243  RigException (const char* msg)
244  : message(msg), errorno (-RIG_EINTERNAL)
245  {};
246 
247  virtual ~RigException()
248  {};
249 
250  void print() const {
251  std::cerr << "Rig exception: " << message << std::endl;
252  }
253  virtual const char *classname() const {
254  return "Rig";
255  }
256 };
257 
258 inline void THROW(const RigException *e) {
259 #if defined(__GNUG__)
260 # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
261  (*lib_error_handler)(e?e->classname():"",e?e->message:"");
262 #else
263  throw *e;
264 #endif
265 #elif defined(__SUNPRO_CC)
266  genericerror(1, ((e != 0) ? (char *)(e->message) : ""));
267 #else
268  if (e)
269  std::cerr << e->message << endl;
270  exit(0);
271 #endif
272 }
273 
274 #define THROWS(s)
275 
276 
277 #endif // _RIGCLASS_H
Definition: rigclass.h:29
unsigned long setting_t
Setting.
Definition: rig.h:706
double freq_t
Frequency type, Frequency type unit in Hz, able to hold SHF frequencies.
Definition: rig.h:276
const char * rigerror(int errnum)
get string describing the error code
Definition: rig.c:250
long token_t
configuration token
Definition: rig.h:501
scan_t
Rig Scan operation.
Definition: rig.h:486
int rig_model_t
Convenience type definition for rig model.
Definition: riglist.h:540
enum rig_status_e status
Definition: rig.h:1134
powerstat_t
Radio power state.
Definition: rig.h:427
signed long shortfreq_t
Short frequency type Frequency in Hz restricted to 31bits, suitable for offsets, shifts, etc..
Definition: rig.h:287
int ant_t
Antenna number.
Definition: rig.h:569
unsigned int tone_t
CTCSS and DCS type definition.
Definition: rig.h:158
shortfreq_t pbwidth_t
Passband width, in Hz.
Definition: rig.h:374
Channel structure.
Definition: rig.h:936
vfo_op_t
VFO operation.
Definition: rig.h:460
rptr_shift_t
Repeater shift type.
Definition: rig.h:258
Rig data structure.
Definition: rig.h:1128
#define RIG_VFO_CURR
currVFO – current "tunable channel"/VFO
Definition: rig.h:325
reset_t
Reset operation.
Definition: rig.h:436
Definition: rigclass.h:229
Definition: rig.h:85
Hamlib rig data structures.
rmode_t
Radio mode.
Definition: rig.h:786
split_t
Split mode.
Definition: rig.h:267
ptt_t
PTT status.
Definition: rig.h:403
int vfo_t
VFO definition.
Definition: rig.h:317
The Rig structure.
Definition: rig.h:1511
Definition: rig.h:92
enum dcd_e dcd_t
DCD status.

Generated by doxygen 1.8.8

Hamlib documentation for version 3.0.1 -- Wed Jan 13 2016 15:05:23
Project page: http://www.hamlib.org