root/ossiedev/branches/mcarrick/ossiedev-trunk/components/CarrierDataSource/CarrierDataSource.cpp @ 9308

Revision 9308, 4.2 KB (checked in by mcarrick, 4 years ago)

re-generated waveform, changed to complex short, stripped FPGA interface code

Line 
1/****************************************************************************
2
3Copyright 2007 Virginia Polytechnic Institute and State University
4
5This file is part of the OSSIE CarrierDataSource.
6
7OSSIE CarrierDataSource is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12OSSIE CarrierDataSource is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OSSIE CarrierDataSource; if not, write to the Free Software
19Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
21****************************************************************************/
22
23
24#include <string>
25#include <iostream>
26#include "CarrierDataSource.h"
27
28CarrierDataSource_i::CarrierDataSource_i(const char *uuid, omni_condition *condition) :
29    Resource_impl(uuid), component_running(condition)
30{
31    dataOut_0 = new standardInterfaces_i::complexShort_u("dataOut");
32
33    //Create the thread for the writer's processing function
34    processing_thread = new omni_thread(Run, (void *) this);
35
36    //Start the thread containing the writer's processing function
37    processing_thread->start();
38
39    thread_started = false;
40
41}
42
43CarrierDataSource_i::~CarrierDataSource_i(void)
44{   
45    delete dataOut_0;
46}
47
48// Static function for omni thread
49void CarrierDataSource_i::Run( void * data )
50{
51    ((CarrierDataSource_i*)data)->ProcessData();
52}
53
54CORBA::Object_ptr CarrierDataSource_i::getPort( const char* portName ) throw (
55    CORBA::SystemException, CF::PortSupplier::UnknownPort)
56{
57    DEBUG(3, CarrierDataSource, "getPort() invoked with " << portName)
58   
59    CORBA::Object_var p;
60
61    p = dataOut_0->getPort(portName);
62
63    if (!CORBA::is_nil(p))
64        return p._retn();
65
66    /*exception*/
67    throw CF::PortSupplier::UnknownPort();
68}
69
70void CarrierDataSource_i::start() throw (CORBA::SystemException,
71    CF::Resource::StartError)
72{
73    DEBUG(3, CarrierDataSource, "start() invoked")
74
75    omni_mutex_lock l(processing_mutex);
76    if (false == thread_started){
77        thread_started = true;    //initialize
78        //Create the thread for the writer's processing function
79        processing_thread = new omni_thread(Run, (void *) this);
80        //Start the thread containing the writer's processing function
81        processing_thread->start();
82    }
83}
84
85void CarrierDataSource_i::stop() throw (CORBA::SystemException, CF::Resource::StopError)
86
87    DEBUG(3, CarrierDataSource, "stop() invoked")
88    omni_mutex_lock l(processing_mutex);
89    thread_started=false;
90}
91
92void CarrierDataSource_i::releaseObject() throw (CORBA::SystemException,
93    CF::LifeCycle::ReleaseError)
94{
95    DEBUG(3, CarrierDataSource, "releaseObject() invoked")
96   
97    component_running->signal();
98}
99
100void CarrierDataSource_i::initialize() throw (CF::LifeCycle::InitializeError,
101    CORBA::SystemException)
102{
103    DEBUG(3, CarrierDataSource, "initialize() invoked")
104}
105
106void CarrierDataSource_i::configure(const CF::Properties& props)
107throw (CORBA::SystemException,
108    CF::PropertySet::InvalidConfiguration,
109    CF::PropertySet::PartialConfiguration)
110{
111    DEBUG(3, CarrierDataSource, "configure() invoked")
112   
113    std::cout << "props length : " << props.length() << std::endl;
114
115    for (unsigned int i = 0; i <props.length(); i++)
116    {
117        std::cout << "Property id : " << props[i].id << std::endl;
118
119    }
120}
121
122void CarrierDataSource_i::ProcessData()
123{
124    DEBUG(3, CarrierDataSource, "ProcessData() invoked")
125
126    PortTypes::ShortSequence I_out_0, Q_out_0;
127
128    int len = 512;
129
130    I_out_0.length(len); //must define length of output
131    Q_out_0.length(len); //must define length of output
132
133    for (unsigned int i = 0; i < I_out_0.length(); i++)
134    {
135        I_out_0[i] = 0;
136        Q_out_0[i] = 0;
137    }
138
139    while(continue_processing()) {
140        dataOut_0->pushPacket(I_out_0, Q_out_0);
141        usleep(50*1000);
142    }
143}
144
145bool CarrierDataSource_i::continue_processing(void)
146{
147    omni_mutex_lock l(processing_mutex);
148    return thread_started;
149}
150
Note: See TracBrowser for help on using the browser.