root/components/ChannelDemo/trunk/ChannelDemo/ChannelDemo.cpp @ 4249

Revision 4249, 4.4 KB (checked in by jgaeddert, 7 years ago)

fixing install path

  • Property svn:eol-style set to native
Line 
1/****************************************************************************
2
3Copyright 2006 Virginia Polytechnic Institute and State University
4
5This file is part of the OSSIE ChannelDemo.
6
7OSSIE ChannelDemo 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 ChannelDemo 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 ChannelDemo; 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 "ossie/cf.h"
27#include "ChannelDemo.h"
28//#include ossie/PortTypes.h"
29
30//#include "ossie/Resource_impl.h"
31
32ChannelDemo_i::ChannelDemo_i(const char *uuid, omni_condition *condition) : Resource_impl(uuid), component_running(condition)
33{
34    dataOut = new standardInterfaces_i::complexShort_u("outPort");
35    dataIn = new standardInterfaces_i::complexShort_p("inPort");
36
37    processing_thread = new omni_thread(process_data, (void *) this);   //Create the thread for the writer's processing function
38    processing_thread->start();    //Start the thread containing the writer's processing function
39
40}
41
42CORBA::Object_ptr ChannelDemo_i::getPort( const char* portName ) throw (CORBA::SystemException, CF::PortSupplier::UnknownPort)
43{
44    std::cout << "ChannelDemo_i getPort called with : " << portName << std::endl;
45   
46    CORBA::Object_var p;
47
48    p = dataOut->getPort(portName);
49
50    if (!CORBA::is_nil(p))
51        return p._retn();
52
53    p = dataIn->getPort(portName);
54
55    if (!CORBA::is_nil(p))
56        return p._retn();
57
58    /*exception*/
59    throw CF::PortSupplier::UnknownPort();
60}
61
62void ChannelDemo_i::start() throw (CORBA::SystemException, CF::Resource::StartError)
63{
64    std::cout << "start called on ChannelDemo" << std::endl;
65}
66
67void ChannelDemo_i::stop() throw (CORBA::SystemException, CF::Resource::StopError)
68
69    std::cout << "stop called on ChannelDemo" << std::endl;
70}
71
72void ChannelDemo_i::releaseObject() throw (CORBA::SystemException, CF::LifeCycle::ReleaseError)
73{
74    std::cout << "releaseObject called on ChannelDemo" << std::endl;
75   
76    component_running->signal();
77}
78
79void ChannelDemo_i::initialize() throw (CF::LifeCycle::InitializeError, CORBA::SystemException)
80{
81    std::cout << "initialize called on ChannelDemo" << std::endl;
82}
83
84void ChannelDemo_i::configure(const CF::Properties& props) throw (CORBA::SystemException, CF::PropertySet::InvalidConfiguration, CF::PropertySet::PartialConfiguration)
85{
86    std::cout << "configure called on ChannelDemo" << std::endl;
87   
88    std::cout << "props length : " << props.length() << std::endl;
89
90    for (unsigned int i = 0; i <props.length(); i++)
91    {
92        std::cout << "Property id : " << props[i].id << std::endl;
93
94        if (strcmp(props[i].id, "DCE:85d02594-1d91-49cf-ab93-2c533b55abe5") == 0)
95        {
96            props[i].value >>= simple;
97            att_factor = (short)simple;
98           
99        }
100
101    }
102}
103
104void process_data(void *data)
105{
106    std::cout << "ChannelDemo process_data thread started" << std::endl;
107
108    ChannelDemo_i *channel = (ChannelDemo_i *) data;
109    PortTypes::ShortSequence *I_in(NULL), *Q_in(NULL);
110    PortTypes::ShortSequence I_out, Q_out;
111    while(1)
112    {
113        channel->dataIn->getData(I_in, Q_in);
114        std::cout<<"Data is in Channel"<<std::endl;
115        std::cout<<"Applying Simple Scaling Factor of 1/"<< channel->att_factor << std::endl;
116        std::cout<<"Output from Channel is..." <<std::endl;
117        I_out.length(I_in->length());
118        Q_out.length(Q_in->length());
119        for(unsigned int i=0; i < I_out.length(); i = i+1)
120        {
121                I_out[i] = (*I_in)[i]/(channel->att_factor);   
122                Q_out[i] = (*Q_in)[i]/(channel->att_factor);
123                std::cout << "Input (" << i << ") to channel is I " << (*I_in)[i] << ", and Q " << (*Q_in)[i] << std::endl;
124                std::cout << "Output (" << i << ") from channel I " << I_out[i] << ", and Q " << Q_out[i] <<std::endl;
125        }
126        channel->dataIn->bufferEmptied();
127        std::cout<<"Channel pushing data"<<std::endl;
128        channel->dataOut->pushPacket(I_out, Q_out);
129    }
130}
131
132   
Note: See TracBrowser for help on using the browser.