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

Generated by doxygen 1.8.17

Hamlib documentation for version 3.3 -- Wed Jan 29 2020 00:00:00
Project page: http://www.hamlib.org