Hamlib  4.1
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 
30 class BACKEND_IMPEXP Rig
31 {
32 private:
33  RIG *theRig; // Global ref. to the rig
34 
35 protected:
36 public:
37  explicit Rig(rig_model_t rig_model);
38 
39  virtual ~Rig();
40 
41  const struct rig_caps *caps;
42 
43  // This method opens the communication port to the rig
44  void open(void);
45 
46  // This method closes the communication port to the rig
47  void close(void);
48 
49  void setConf(token_t token, const char *val);
50  void setConf(const char *name, const char *val);
51  void getConf(token_t token, char *val);
52  void getConf(const char *name, char *val);
53  token_t tokenLookup(const char *name);
54 
55  void setFreq(freq_t freq, vfo_t vfo = RIG_VFO_CURR);
56  freq_t getFreq(vfo_t vfo = RIG_VFO_CURR);
57  void setMode(rmode_t,
59  vfo_t vfo = RIG_VFO_CURR);
60 
61  rmode_t getMode(pbwidth_t&, vfo_t vfo = RIG_VFO_CURR);
62  void setVFO(vfo_t);
63  vfo_t getVFO();
64 
65  void setPTT(ptt_t ptt, vfo_t vfo = RIG_VFO_CURR);
66  ptt_t getPTT(vfo_t vfo = RIG_VFO_CURR);
67  dcd_t getDCD(vfo_t vfo = RIG_VFO_CURR);
68 
69  void setLevel(setting_t level, int vali, vfo_t vfo = RIG_VFO_CURR);
70  void setLevel(setting_t level, float valf, vfo_t vfo = RIG_VFO_CURR);
71  void getLevel(setting_t level, int& vali, vfo_t vfo = RIG_VFO_CURR);
72  void getLevel(setting_t level, float& valf, vfo_t vfo = RIG_VFO_CURR);
73  int getLevelI(setting_t level, vfo_t vfo = RIG_VFO_CURR);
74  float getLevelF(setting_t level, vfo_t vfo = RIG_VFO_CURR);
75  bool hasGetLevel(setting_t level);
76  bool hasSetLevel(setting_t level);
77 
78  void setParm(setting_t parm, int vali);
79  void setParm(setting_t parm, float valf);
80  void getParm(setting_t parm, int& vali);
81  void getParm(setting_t parm, float& valf);
82  int getParmI(setting_t parm);
83  float getParmF(setting_t parm);
84  bool hasGetParm(setting_t parm);
85  bool hasSetParm(setting_t parm);
86 
87  void setFunc(setting_t func, bool status, vfo_t vfo = RIG_VFO_CURR);
88  bool getFunc(setting_t func, vfo_t vfo = RIG_VFO_CURR);
89  bool hasGetFunc(setting_t func);
90  bool hasSetFunc(setting_t func);
91 
92  void VFOop(vfo_op_t op, vfo_t vfo = RIG_VFO_CURR);
93  bool hasVFOop(vfo_op_t op);
94 
95  void scan(scan_t scan, int ch, vfo_t vfo = RIG_VFO_CURR);
96  bool hasScan(scan_t scan);
97 
98  const char * getInfo(void);
99  pbwidth_t passbandNormal(rmode_t);
100  pbwidth_t passbandNarrow(rmode_t);
101  pbwidth_t passbandWide(rmode_t);
102 
103  void setRptrShift(rptr_shift_t rptr_shift, vfo_t vfo = RIG_VFO_CURR);
104  rptr_shift_t getRptrShift(vfo_t vfo = RIG_VFO_CURR);
105  void setRptrOffs(shortfreq_t rptr_offs, vfo_t vfo = RIG_VFO_CURR);
106  shortfreq_t getRptrOffs(vfo_t vfo = RIG_VFO_CURR);
107  void setTs(shortfreq_t ts, vfo_t vfo = RIG_VFO_CURR);
108  shortfreq_t getTs(vfo_t vfo = RIG_VFO_CURR);
109 
110  void setCTCSS(tone_t tone, vfo_t vfo = RIG_VFO_CURR);
111  tone_t getCTCSS(vfo_t vfo = RIG_VFO_CURR);
112  void setDCS(tone_t code, vfo_t vfo = RIG_VFO_CURR);
113  tone_t getDCS(vfo_t vfo = RIG_VFO_CURR);
114 
115  void setCTCSSsql(tone_t tone, vfo_t vfo = RIG_VFO_CURR);
116  tone_t getCTCSSsql(vfo_t vfo = RIG_VFO_CURR);
117  void setDCSsql(tone_t tone, vfo_t vfo = RIG_VFO_CURR);
118  tone_t getDCSsql(vfo_t vfo = RIG_VFO_CURR);
119 
120 
121  unsigned int power2mW(float power, freq_t freq, rmode_t mode);
122  float mW2power(unsigned int mwpower, freq_t freq, rmode_t mode);
123  void setTrn(int trn);
124  int getTrn(void);
125  void setBank(int bank, vfo_t vfo = RIG_VFO_CURR);
126  void setMem(int ch, vfo_t vfo = RIG_VFO_CURR);
127  int getMem(vfo_t vfo = RIG_VFO_CURR);
128 
129  void setChannel(const channel_t *chan, vfo_t vfo);
130  void getChannel(channel_t *chan, vfo_t vfo, int readOnly);
131 
132  void setPowerStat(powerstat_t status);
133  powerstat_t getPowerStat(void);
134  rmode_t RngRxModes(freq_t freq);
135  rmode_t RngTxModes(freq_t freq);
136 
137  void setSplitFreq(freq_t tx_freq, vfo_t vfo = RIG_VFO_CURR);
138  freq_t getSplitFreq(vfo_t vfo = RIG_VFO_CURR);
139  void setSplitMode(rmode_t,
141  vfo_t vfo = RIG_VFO_CURR);
142 
143  rmode_t getSplitMode(pbwidth_t&, vfo_t vfo = RIG_VFO_CURR);
144  void setSplitFreqMode(freq_t, rmode_t,
146  vfo_t vfo = RIG_VFO_CURR);
147 
148  freq_t getSplitFreqMode(rmode_t&, pbwidth_t&, vfo_t vfo = RIG_VFO_CURR);
149  void setSplitVFO(split_t split,
150  vfo_t vfo = RIG_VFO_CURR,
151  vfo_t tx_vfo = RIG_VFO_CURR);
152 
153  split_t getSplitVFO(vfo_t& tx_vfo, vfo_t vfo = RIG_VFO_CURR);
154 
155  void setRit(shortfreq_t rit, vfo_t vfo = RIG_VFO_CURR);
156  shortfreq_t getRit(vfo_t vfo = RIG_VFO_CURR);
157  void setXit(shortfreq_t xit, vfo_t vfo = RIG_VFO_CURR);
158  shortfreq_t getXit(vfo_t vfo = RIG_VFO_CURR);
159 
160  void setAnt(value_t option, ant_t ant, vfo_t vfo = RIG_VFO_CURR);
161  ant_t getAnt(ant_t &ant_rx, ant_t &ant_tx, ant_t ant, value_t &option, ant_t &ant_curr, vfo_t vfo = RIG_VFO_CURR);
162 
163  void sendDtmf(const char *digits, vfo_t vfo = RIG_VFO_CURR);
164  int recvDtmf(char *digits, vfo_t vfo = RIG_VFO_CURR);
165  void sendMorse(const char *msg, vfo_t vfo = RIG_VFO_CURR);
166 
167 
168  shortfreq_t getResolution(rmode_t mode);
169  void reset(reset_t reset);
170 
171  // callbacks available in your derived object
172  virtual int FreqEvent(vfo_t, freq_t, rig_ptr_t) const
173  {
174  return RIG_OK;
175  }
176  virtual int ModeEvent(vfo_t, rmode_t, pbwidth_t, rig_ptr_t) const
177  {
178  return RIG_OK;
179  }
180  virtual int VFOEvent(vfo_t, rig_ptr_t) const
181  {
182  return RIG_OK;
183  }
184  virtual int PTTEvent(vfo_t, ptt_t, rig_ptr_t) const
185  {
186  return RIG_OK;
187  }
188  virtual int DCDEvent(vfo_t, dcd_t, rig_ptr_t) const
189  {
190  return RIG_OK;
191  }
192 };
194 
195 
196 #ifdef __GNUG__
197 # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
198 # if HAVE_TYPEINFO
199 # include <typeinfo>
200 # endif
201 # endif
202 #endif
203 
204 #if defined(__GNUG__)
205 # if HAVE_BUILTIN_H || HAVE_GXX_BUILTIN_H || HAVE_GPP_BUILTIN_H
206 # if ETIP_NEEDS_MATH_H
207 # if ETIP_NEEDS_MATH_EXCEPTION
208 # undef exception
209 # define exception math_exception
210 # endif
211 # include <math.h>
212 # endif
213 # undef exception
214 # define exception builtin_exception
215 # if HAVE_GPP_BUILTIN_H
216 # include <gpp/builtin.h>
217 # elif HAVE_GXX_BUILTIN_H
218 # include <g++/builtin.h>
219 # else
220 # include <builtin.h>
221 # endif
222 # undef exception
223 # endif
224 #elif defined (__SUNPRO_CC)
225 # include <generic.h>
226 # include <string.h>
227 #else
228 # include <string.h>
229 #endif
230 
231 
232 extern "C" {
233 #if HAVE_VALUES_H
234 # include <values.h>
235 #endif
236 
237 #include <assert.h>
238 #include <errno.h>
239 }
240 
241 #include <iostream>
242 #if !(defined(__GNUG__)||defined(__SUNPRO_CC)||defined(_WIN32))
243 extern "C" void exit(int);
244 #endif
245 
246 
248 // Forward Declarations
249 class BACKEND_IMPEXP RigException
250 {
251 public:
252  const char *message;
253  int errorno;
254 
255  explicit RigException(const char *msg, int err)
256  : message(msg), errorno(err)
257  {};
258 
259  explicit RigException(int err)
260  : message(rigerror(err)), errorno(err)
261  {};
262 
263  explicit RigException(const char *msg)
264  : message(msg), errorno(-RIG_EINTERNAL)
265  {};
266 
267  virtual ~RigException()
268  {};
269 
270  void print() const
271  {
272  std::cerr << "Rig exception: " << message << std::endl;
273  }
274  virtual const char *classname() const
275  {
276  return "Rig";
277  }
278 };
280 
281 
282 inline void THROW(const RigException *e)
283 {
284 #if defined(__GNUG__)
285 # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
286  (*lib_error_handler)(e ? e->classname() : "", e ? e->message : "");
287 #else
288  throw *e;
289 #endif
290 #elif defined(__SUNPRO_CC)
291  genericerror(1, ((e != 0) ? (char *)(e->message) : ""));
292 #else
293 
294  if (e) {
295  std::cerr << e->message << std::endl;
296  }
297 
298  exit(0);
299 #endif
300 }
301 
302 #define THROWS(s)
303 
304 
305 #endif // _RIGCLASS_H
unsigned int vfo_t
VFO definition.
Definition: rig.h:395
uint64_t rmode_t
Radio mode.
Definition: rig.h:1119
shortfreq_t pbwidth_t
Definition: rig.h:512
split_t
Split mode.
Definition: rig.h:324
rptr_shift_t
Repeater shift type.
Definition: rig.h:314
uint64_t setting_t
Setting.
Definition: rig.h:964
powerstat_t
Radio power state.
Definition: rig.h:574
enum dcd_e dcd_t
DCD status.
scan_t
Rig Scan operation.
Definition: rig.h:636
#define RIG_VFO_CURR
currVFO – current "tunable channel"/VFO
Definition: rig.h:441
double freq_t
Frequency type,.
Definition: rig.h:335
ptt_t
PTT status.
Definition: rig.h:545
#define RIG_PASSBAND_NORMAL
Macro for bandpass to be set to normal.
Definition: rig.h:501
vfo_op_t
VFO operation.
Definition: rig.h:610
signed long shortfreq_t
Short frequency type.
Definition: rig.h:357
unsigned int tone_t
CTCSS and DCS type definition.
Definition: rig.h:201
long token_t
configuration token
Definition: rig.h:652
unsigned int ant_t
Antenna typedef.
Definition: rig.h:773
reset_t
Reset operation.
Definition: rig.h:586
@ RIG_OK
Definition: rig.h:122
@ RIG_EINTERNAL
Definition: rig.h:129
Hamlib rig data structures.
Channel structure.
Definition: rig.h:1327
The Rig structure.
Definition: rig.h:2260
Universal approach for passing values.
Definition: rig.h:828

Generated by doxygen 1.9.1

Hamlib documentation for version 4.1 -- Mon Feb 1 2021 08:00:28
Project page: http://www.hamlib.org