mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-09-28 16:16:48 -04:00
da1b6ab5b3
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3247 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
183 lines
4.0 KiB
C++
183 lines
4.0 KiB
C++
/*
|
|
* Hamlib C++ bindings - API header
|
|
* Copyright (c) 2001-2002 by Stephane Fillod
|
|
*
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*
|
|
*/
|
|
|
|
#ifndef _RIGCLASS_H
|
|
#define _RIGCLASS_H 1
|
|
|
|
#include <hamlib/rig.h>
|
|
#include <iostream>
|
|
|
|
|
|
class BACKEND_IMPEXP Rig {
|
|
private:
|
|
RIG* theRig; // Global ref. to the rig
|
|
|
|
protected:
|
|
public:
|
|
Rig(rig_model_t rig_model);
|
|
|
|
virtual ~Rig();
|
|
|
|
const struct rig_caps *caps;
|
|
|
|
// This method open the communication port to the rig
|
|
int open(void);
|
|
|
|
// This method close the communication port to the rig
|
|
int close(void);
|
|
|
|
int setConf(const char *name, const char *val);
|
|
token_t tokenLookup(const char *name);
|
|
|
|
int setFreq(freq_t freq, vfo_t vfo = RIG_VFO_CURR);
|
|
freq_t getFreq(vfo_t vfo = RIG_VFO_CURR);
|
|
int setMode(rmode_t, pbwidth_t width = RIG_PASSBAND_NORMAL, vfo_t vfo = RIG_VFO_CURR);
|
|
rmode_t getMode(pbwidth_t&, vfo_t vfo = RIG_VFO_CURR);
|
|
int setVFO(vfo_t);
|
|
vfo_t getVFO();
|
|
|
|
int setPTT (ptt_t ptt, vfo_t vfo = RIG_VFO_CURR);
|
|
ptt_t getPTT (vfo_t vfo = RIG_VFO_CURR);
|
|
|
|
// callbacks available in your derived object
|
|
virtual int FreqEvent(vfo_t, freq_t, rig_ptr_t) const {
|
|
return RIG_OK;
|
|
}
|
|
virtual int ModeEvent(vfo_t, rmode_t, pbwidth_t, rig_ptr_t) const {
|
|
return RIG_OK;
|
|
}
|
|
virtual int VFOEvent(vfo_t, rig_ptr_t) const {
|
|
return RIG_OK;
|
|
}
|
|
virtual int PTTEvent(vfo_t, ptt_t, rig_ptr_t) const {
|
|
return RIG_OK;
|
|
}
|
|
virtual int DCDEvent(vfo_t, dcd_t, rig_ptr_t) const {
|
|
return RIG_OK;
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
# if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
|
|
# if HAVE_TYPEINFO
|
|
# include <typeinfo>
|
|
# endif
|
|
# endif
|
|
#endif
|
|
|
|
#if defined(__GNUG__)
|
|
# if HAVE_BUILTIN_H || HAVE_GXX_BUILTIN_H || HAVE_GPP_BUILTIN_H
|
|
# if ETIP_NEEDS_MATH_H
|
|
# if ETIP_NEEDS_MATH_EXCEPTION
|
|
# undef exception
|
|
# define exception math_exception
|
|
# endif
|
|
# include <math.h>
|
|
# endif
|
|
# undef exception
|
|
# define exception builtin_exception
|
|
# if HAVE_GPP_BUILTIN_H
|
|
# include <gpp/builtin.h>
|
|
# elif HAVE_GXX_BUILTIN_H
|
|
# include <g++/builtin.h>
|
|
# else
|
|
# include <builtin.h>
|
|
# endif
|
|
# undef exception
|
|
# endif
|
|
#elif defined (__SUNPRO_CC)
|
|
# include <generic.h>
|
|
# include <string.h>
|
|
#else
|
|
# include <string.h>
|
|
#endif
|
|
|
|
|
|
extern "C" {
|
|
#if HAVE_VALUES_H
|
|
# include <values.h>
|
|
#endif
|
|
|
|
#include <assert.h>
|
|
#include <errno.h>
|
|
}
|
|
|
|
#include <iostream>
|
|
#if !(defined(__GNUG__)||defined(__SUNPRO_CC))
|
|
extern "C" void exit(int);
|
|
#endif
|
|
|
|
// Forward Declarations
|
|
|
|
class BACKEND_IMPEXP RigException
|
|
{
|
|
public:
|
|
const char *message;
|
|
int errorno;
|
|
|
|
RigException (const char* msg, int err)
|
|
: message(msg), errorno (err)
|
|
{};
|
|
|
|
RigException (int err)
|
|
: message(rigerror(err)), errorno (err)
|
|
{};
|
|
|
|
RigException (const char* msg)
|
|
: message(msg), errorno (-RIG_EINTERNAL)
|
|
{};
|
|
|
|
virtual ~RigException()
|
|
{};
|
|
|
|
void print() const {
|
|
std::cerr << "Rig exception: " << message << std::endl;
|
|
}
|
|
virtual const char *classname() const {
|
|
return "Rig";
|
|
}
|
|
};
|
|
|
|
inline void THROW(const RigException *e) {
|
|
#if defined(__GNUG__)
|
|
# if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
|
|
(*lib_error_handler)(e?e->classname():"",e?e->message:"");
|
|
#else
|
|
throw *e;
|
|
#endif
|
|
#elif defined(__SUNPRO_CC)
|
|
genericerror(1, ((e != 0) ? (char *)(e->message) : ""));
|
|
#else
|
|
if (e)
|
|
std::cerr << e->message << endl;
|
|
exit(0);
|
|
#endif
|
|
}
|
|
|
|
#define THROWS(s)
|
|
|
|
|
|
#endif // _RIGCLASS_H
|