All pastes #163492 Raw Edit

Someone

public text v1 · immutable
·published 2006-09-07 16:15 UTC
rendered paste body
/****************************************************************************

Copyright 2006 Virginia Polytechnic Institute and State University

This file is part of the OSSIE USRP_Ctrl.

OSSIE USRP_Ctrl 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 USRP_Ctrl 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 USRP_Ctrl; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

****************************************************************************/


#include <iostream>

#include "USRP_Ctrl.h"

#include "port_impl.h"

USRP_Ctrl_i::USRP_Ctrl_i(const char *uuid, omni_condition *con) : Resource_impl(uuid)
{
    component_running = con;


    outPort0_servant = new dataOut_RX_Control_i();
    outPort0_var = outPort0_servant->_this();
    outPort1_servant = new dataOut_TX_Control_i();
    outPort1_var = outPort1_servant->_this();

}


USRP_Ctrl_i::~USRP_Ctrl_i(void)
{

    delete outPort0_servant;
    delete outPort1_servant;

}

CORBA::Object_ptr USRP_Ctrl_i::getPort( const char* _id ) throw (CORBA::SystemException, CF::PortSupplier::UnknownPort)
{

    if (strcmp(_id,"USRP_RX_Ctrl") == 0)
        return outPort0_var;
    if (strcmp(_id,"USRP_TX_Ctrl") == 0)
        return outPort1_var;

}

void USRP_Ctrl_i::start() throw (CORBA::SystemException, CF::Resource::StartError)
{

    outPort0_servant->set_number_of_channels(1);
    outPort0_servant->set_frequency(0, 2.412e9);
    outPort0_servant->set_decimation_rate(0, 256);
    outPort0_servant->set_data_packet_size(0, 16384);

    float gmin, gmax, gstep;
    outPort0_servant->get_gain_range(0, &gmin, &gmax, &gstep);
    outPort0_servant->set_gain(0, gmax);
	
	char *value_identifier = "SET_RX_ANT_1";

    outPort0_servant->set_values(value_identifier, 1);

    outPort0_servant->start(0);

//     outPort1_servant->set_number_of_channels(1);
//     outPort1_servant->set_interpolation_rate(0, 512);
//     outPort1_servant->set_frequency(0, 2.423e9);
// 
//     outPort1_servant->start(0);

}

void USRP_Ctrl_i::stop() throw (CORBA::SystemException, CF::Resource::StopError)
{

    std::cout << "Stop RX" << std::endl;

    outPort0_servant->stop(0);

//     std::cout << "Stop TX " << std::endl;
//     outPort1_servant->stop(0);

}

void USRP_Ctrl_i::releaseObject() throw (CORBA::SystemException, CF::LifeCycle::ReleaseError)
{
    // Clear the component running condition so main shuts down everything
    component_running->signal();
}