/****************************************************************************
Copyright 2006 Virginia Polytechnic Institute and State University
This file is part of the OSSIE AM_Demod.
OSSIE AM_Demod is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
OSSIE AM_Demod 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with OSSIE AM_Demod; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
****************************************************************************/
#include <iostream>
#include <string.h>
#include "ossie/cf.h"
#include "ossie/ossieSupport.h"
#include "AM_Demod.h"
#include "port_impl.h"
AM_Demod_i::AM_Demod_i(const char *uuid, omni_condition *con) : Resource_impl(uuid)
{
component_running = con;
inPort0_servant = new dataIn_complexShort_i();
inPort0_var = inPort0_servant->_this();
outPort0_servant = new dataOut_stereoSound_i();
outPort0_var = outPort0_servant->_this();
outPort1_servant = new dataOut_USRP_RX_Control_i();
outPort1_var = outPort1_servant->_this();
}
AM_Demod_i::~AM_Demod_i(void)
{
delete inPort0_servant;
delete outPort0_servant;
delete outPort1_servant;
}
CORBA::Object_ptr AM_Demod_i::getPort( const char* _id ) throw (CORBA::SystemException, CF::PortSupplier::UnknownPort)
{
if (strcmp(_id,"AM_in") == 0)
return inPort0_var;
if (strcmp(_id,"soundOut") == 0)
return outPort0_var;
if (strcmp(_id,"USRP_Rx_Control") == 0)
return outPort1_var;
}
void AM_Demod_i::start() throw (CORBA::SystemException, CF::Resource::StartError)
{
// This section is added from FM_XCVR_Control for controlling the USRP RX parameters
std::cout << "Start AM_Control" << std::endl;
outPort1_servant->set_number_of_channels(1);
USRP_RX_Control_port->set_frequency(0, 467.7125e6); // These parameters need to be changed for AM
USRP_RX_Control_port->set_decimation_rate(0, 256);
USRP_RX_Control_port->set_data_packet_size(0, 16384);
float gmin, gmax, gstep;
USRP_RX_Control_port->get_gain_range(0, gmin, gmax, gstep);
USRP_RX_Control_port->set_gain(0, gmax);
CF::Properties rx_config;
rx_config.length(1);
rx_config[0].id = CORBA::string_dup("SET_RX_ANT_1");
rx_config[0].value <<= (CORBA::ULong) 1;
USRP_RX_Control_port->set_values(rx_config);
USRP_RX_Control_port->start(0);
}
void AM_Demod_i::stop() throw (CORBA::SystemException, CF::Resource::StopError)
{
std::cout << "Stop USRP_RX" << std::endl;
USRP_RX_Control_port->stop(0);
}
void AM_Demod_i::releaseObject() throw (CORBA::SystemException, CF::LifeCycle::ReleaseError)
{
// Clear the component running condition so main shuts down everything
component_running->signal();
}