| 1 | /**************************************************************************** |
|---|
| 2 | |
|---|
| 3 | Copyright 2006 Virginia Polytechnic Institute and State University |
|---|
| 4 | |
|---|
| 5 | This file is part of the OSSIE AutomaticGainControl. |
|---|
| 6 | |
|---|
| 7 | OSSIE AutomaticGainControl 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 AutomaticGainControl 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 AutomaticGainControl; 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 | #ifndef AUTOMATICGAINCONTROL_IMPL_H |
|---|
| 25 | #define AUTOMATICGAINCONTROL_IMPL_H |
|---|
| 26 | |
|---|
| 27 | #include <stdlib.h> |
|---|
| 28 | #include "ossie/cf.h" |
|---|
| 29 | #include "ossie/Resource_impl.h" |
|---|
| 30 | #include "ossie/PortTypes.h" |
|---|
| 31 | #include "ossie/debug.h" |
|---|
| 32 | |
|---|
| 33 | #include "standardinterfaces/complexShort_u.h" |
|---|
| 34 | #include "standardinterfaces/complexShort_p.h" |
|---|
| 35 | |
|---|
| 36 | #include "sigproc/SigProc.h" |
|---|
| 37 | |
|---|
| 38 | /// \brief |
|---|
| 39 | /// |
|---|
| 40 | class AutomaticGainControl_i : public virtual Resource_impl |
|---|
| 41 | { |
|---|
| 42 | |
|---|
| 43 | public: |
|---|
| 44 | /// initializing constructor |
|---|
| 45 | AutomaticGainControl_i(const char *uuid, omni_condition *sem); |
|---|
| 46 | |
|---|
| 47 | /// destructor |
|---|
| 48 | ~AutomaticGainControl_i(void); |
|---|
| 49 | |
|---|
| 50 | /// |
|---|
| 51 | void start() throw (CF::Resource::StartError, CORBA::SystemException); |
|---|
| 52 | |
|---|
| 53 | /// |
|---|
| 54 | void stop() throw (CF::Resource::StopError, CORBA::SystemException); |
|---|
| 55 | |
|---|
| 56 | /// static function for omni thread |
|---|
| 57 | static void run(void *data); |
|---|
| 58 | |
|---|
| 59 | /// |
|---|
| 60 | CORBA::Object_ptr getPort( const char* portName ) throw (CF::PortSupplier::UnknownPort, CORBA::SystemException); |
|---|
| 61 | |
|---|
| 62 | /// |
|---|
| 63 | void releaseObject() throw (CF::LifeCycle::ReleaseError, CORBA::SystemException); |
|---|
| 64 | |
|---|
| 65 | /// |
|---|
| 66 | void initialize() throw (CF::LifeCycle::InitializeError, CORBA::SystemException); |
|---|
| 67 | |
|---|
| 68 | /// |
|---|
| 69 | void configure(const CF::Properties&) throw (CORBA::SystemException, CF::PropertySet::InvalidConfiguration, CF::PropertySet::PartialConfiguration); |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | private: |
|---|
| 73 | /// disallow default constructor |
|---|
| 74 | AutomaticGainControl_i(); |
|---|
| 75 | |
|---|
| 76 | /// disallow copy constructor |
|---|
| 77 | AutomaticGainControl_i(AutomaticGainControl_i&); |
|---|
| 78 | |
|---|
| 79 | /// main signal processing method |
|---|
| 80 | void run_loop(); |
|---|
| 81 | |
|---|
| 82 | /// for component shutdown |
|---|
| 83 | omni_condition *component_running; |
|---|
| 84 | |
|---|
| 85 | /// for component writer function |
|---|
| 86 | omni_thread *processing_thread; |
|---|
| 87 | |
|---|
| 88 | /// for asynchronous configure() invocation |
|---|
| 89 | omni_mutex accessPrivateData; |
|---|
| 90 | |
|---|
| 91 | // ----- list components provides and uses ports ----- |
|---|
| 92 | |
|---|
| 93 | /// output data port, \ref port_data_out "data_out" |
|---|
| 94 | standardInterfaces_i::complexShort_u *dataOut_0; |
|---|
| 95 | |
|---|
| 96 | /// input data port, \ref port_data_in "data_in" |
|---|
| 97 | standardInterfaces_i::complexShort_p *dataIn_0; |
|---|
| 98 | |
|---|
| 99 | /// \brief MetaData object |
|---|
| 100 | /// AGC updates the following properties |
|---|
| 101 | /// - signal_strength |
|---|
| 102 | standardInterfaces::MetaData *metadata; |
|---|
| 103 | |
|---|
| 104 | // ----- algorithm variables ----- |
|---|
| 105 | |
|---|
| 106 | /// low energy threshold |
|---|
| 107 | float energy_lo; |
|---|
| 108 | |
|---|
| 109 | /// high energy threshold |
|---|
| 110 | float energy_hi; |
|---|
| 111 | |
|---|
| 112 | /// attack time constant |
|---|
| 113 | float k_attack; |
|---|
| 114 | |
|---|
| 115 | /// release time constant |
|---|
| 116 | float k_release; |
|---|
| 117 | |
|---|
| 118 | /// maximum allowable gain |
|---|
| 119 | float g_max; |
|---|
| 120 | |
|---|
| 121 | /// minimum allowable gain |
|---|
| 122 | float g_min; |
|---|
| 123 | |
|---|
| 124 | /// Received signal strength level above which data will be passed |
|---|
| 125 | float rssi_pass; |
|---|
| 126 | |
|---|
| 127 | /// Counter used for sending packets once RSSI has dropped below threshold |
|---|
| 128 | short rssi_pass_packet_counter; |
|---|
| 129 | |
|---|
| 130 | }; |
|---|
| 131 | #endif |
|---|