| 1 | /**************************************************************************** |
|---|
| 2 | |
|---|
| 3 | Copyright 2005,2006 Virginia Polytechnic Institute and State University |
|---|
| 4 | |
|---|
| 5 | This file is part of the OSSIE Decimator. |
|---|
| 6 | |
|---|
| 7 | OSSIE Decimator is free software; you can redistribute it and/or modify |
|---|
| 8 | it under the terms of the GNU General Public License as published by |
|---|
| 9 | the Free Software Foundation; either version 2 of the License, or |
|---|
| 10 | (at your option) any later version. |
|---|
| 11 | |
|---|
| 12 | OSSIE Decimator is distributed in the hope that it will be useful, |
|---|
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | GNU General Public License for more details. |
|---|
| 16 | |
|---|
| 17 | You should have received a copy of the GNU General Public License |
|---|
| 18 | along with OSSIE Decimator; if not, write to the Free Software |
|---|
| 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | ****************************************************************************/ |
|---|
| 23 | |
|---|
| 24 | #include <fstream> |
|---|
| 25 | |
|---|
| 26 | #include "ossie/cf.h" |
|---|
| 27 | #include "ossie/PortTypes.h" |
|---|
| 28 | #include "ossie/debug.h" |
|---|
| 29 | |
|---|
| 30 | #include "standardinterfaces/complexShort.h" |
|---|
| 31 | #include "standardinterfaces/complexShort_u.h" |
|---|
| 32 | #include "standardinterfaces/complexShort_p.h" |
|---|
| 33 | |
|---|
| 34 | #include "sigproc/SigProc.h" |
|---|
| 35 | |
|---|
| 36 | #include "ossie/Resource_impl.h" |
|---|
| 37 | |
|---|
| 38 | class Decimator_i; |
|---|
| 39 | |
|---|
| 40 | // Definitions for provides ports |
|---|
| 41 | |
|---|
| 42 | // USRP test component definition |
|---|
| 43 | class Decimator_i : public virtual Resource_impl |
|---|
| 44 | |
|---|
| 45 | { |
|---|
| 46 | public: |
|---|
| 47 | Decimator_i(const char *uuid, omni_condition *sem); |
|---|
| 48 | |
|---|
| 49 | static void do_run_decimation(void *data) { ((Decimator_i *)data)->run_decimation(); }; |
|---|
| 50 | |
|---|
| 51 | void start() throw (CF::Resource::StartError, CORBA::SystemException); |
|---|
| 52 | void stop() throw (CF::Resource::StopError, CORBA::SystemException); |
|---|
| 53 | CORBA::Object_ptr getPort(const char* portName) throw(CF::PortSupplier::UnknownPort, CORBA::SystemException); |
|---|
| 54 | void initialize() throw (CF::LifeCycle::InitializeError, CORBA::SystemException); |
|---|
| 55 | void query (CF::Properties & configProperties) |
|---|
| 56 | throw (CF::UnknownProperties, CORBA::SystemException); |
|---|
| 57 | void configure(const CF::Properties&) throw (CORBA::SystemException, CF::PropertySet::InvalidConfiguration, CF::PropertySet::PartialConfiguration); |
|---|
| 58 | void releaseObject() throw (CF::LifeCycle::ReleaseError, CORBA::SystemException); |
|---|
| 59 | |
|---|
| 60 | private: |
|---|
| 61 | Decimator_i(); // No default constructor |
|---|
| 62 | Decimator_i(Decimator_i&); // No copying |
|---|
| 63 | |
|---|
| 64 | void run_decimation(); |
|---|
| 65 | |
|---|
| 66 | // For component shutdown |
|---|
| 67 | omni_condition *component_running; |
|---|
| 68 | |
|---|
| 69 | omni_thread *processing_thread; |
|---|
| 70 | |
|---|
| 71 | // For decimation operation |
|---|
| 72 | float *h; ///< Array for filter coefficients |
|---|
| 73 | unsigned int len_h; ///< Length of filter |
|---|
| 74 | |
|---|
| 75 | /// Automatically calculate filter coefficients? This will only happen |
|---|
| 76 | /// if length of the filter coefficient property is zero |
|---|
| 77 | bool calculateFilterCoefficients; |
|---|
| 78 | |
|---|
| 79 | unsigned int M; // Decimation factor |
|---|
| 80 | unsigned int sample_count; |
|---|
| 81 | unsigned int previous_length; // Length of previous input sequence |
|---|
| 82 | |
|---|
| 83 | SigProc::fir_filter *i_filter, * q_filter; // Signal processing object pointers |
|---|
| 84 | |
|---|
| 85 | short f2s(float r); // convert float to short with clipping |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | // Data out port |
|---|
| 89 | standardInterfaces_i::complexShort_u* dataOut; |
|---|
| 90 | standardInterfaces_i::complexShort_p* dataIn; |
|---|
| 91 | |
|---|
| 92 | // debugging |
|---|
| 93 | std::ofstream *outFile; |
|---|
| 94 | }; |
|---|