Hamlib/c++/ampclass.cc

111 wiersze
2.6 KiB
C++
Czysty Zwykły widok Historia

2019-06-26 11:39:42 +00:00
/**
* \file src/ampclass.cc
* \brief Ham Radio Control Libraries C++ interface
* \author Stephane Fillod
* \date 2002
*
* Hamlib C++ interface is a frontend implementing wrapper functions.
*/
/*
* Hamlib C++ bindings - main file
* Copyright (c) 2002 by Stephane Fillod
* Copyright (c) 2019 by Michael Black W9MDB
*
*
* 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
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
2019-10-15 14:07:19 +00:00
//#include <hamlib/ampator.h>
2019-06-26 11:39:42 +00:00
#include <hamlib/ampclass.h>
#include <hamlib/rigclass.h>
#define CHECK_AMP(cmd) { int _retval = cmd; if (_retval != RIG_OK) \
THROW(new RigException (_retval)); }
Amplifier::Amplifier(amp_model_t amp_model)
{
theAmp = amp_init(amp_model);
if (!theAmp)
THROW(new RigException ("Amplifier initialization error"));
caps = theAmp->caps;
theAmp->state.obj = (amp_ptr_t)this;
}
Amplifier::~Amplifier()
{
theAmp->state.obj = NULL;
2019-10-15 14:07:19 +00:00
CHECK_AMP( amp_cleanup(theAmp) );
2019-06-26 11:39:42 +00:00
caps = NULL;
}
void Amplifier::open(void) {
2019-10-15 14:07:19 +00:00
CHECK_AMP( amp_open(theAmp) );
2019-06-26 11:39:42 +00:00
}
void Amplifier::close(void) {
2019-10-15 14:07:19 +00:00
CHECK_AMP( amp_close(theAmp) );
2019-06-26 11:39:42 +00:00
}
void Amplifier::setConf(token_t token, const char *val)
{
2019-10-15 14:07:19 +00:00
CHECK_AMP( amp_set_conf(theAmp, token, val) );
2019-06-26 11:39:42 +00:00
}
void Amplifier::setConf(const char *name, const char *val)
{
2019-10-15 14:07:19 +00:00
CHECK_AMP( amp_set_conf(theAmp, tokenLookup(name), val) );
2019-06-26 11:39:42 +00:00
}
void Amplifier::getConf(token_t token, char *val)
{
2019-10-15 14:07:19 +00:00
CHECK_AMP( amp_get_conf(theAmp, token, val) );
2019-06-26 11:39:42 +00:00
}
void Amplifier::getConf(const char *name, char *val)
{
2019-10-15 14:07:19 +00:00
CHECK_AMP( amp_get_conf(theAmp, tokenLookup(name), val) );
2019-06-26 11:39:42 +00:00
}
token_t Amplifier::tokenLookup(const char *name)
{
return amp_token_lookup(theAmp, name);
}
void Amplifier::reset (amp_reset_t reset)
{
2019-10-15 14:07:19 +00:00
CHECK_AMP( amp_reset(theAmp, reset) );
2019-06-26 11:39:42 +00:00
}
2019-10-15 14:07:19 +00:00
void Amplifier::setFreq(freq_t freq) {
CHECK_AMP( amp_set_freq(theAmp, freq) );
2019-06-26 11:39:42 +00:00
}
2019-10-15 14:07:19 +00:00
freq_t Amplifier::getFreq()
2019-06-26 11:39:42 +00:00
{
freq_t freq;
2019-10-15 14:07:19 +00:00
CHECK_AMP( amp_get_freq(theAmp, &freq) );
2019-06-26 11:39:42 +00:00
return freq;
}