root/platform/USRP/trunk/USRP/src/USRP.h @ 4522

Revision 4522, 7.0 KB (checked in by jgaeddert, 6 years ago)

setting svn properties on USRP files

  • Property svn:eol-style set to native
Line 
1/****************************************************************************
2
3Copyright 2005,2006 Virginia Polytechnic Institute and State University
4
5This file is part of the OSSIE USRP Device.
6
7OSSIE USRP Device 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 USRP Device 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 USRP Device; 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 <vector>
25
26#include <omnithread.h>
27
28#include "usrp_standard.h"
29#include "usrp_dbid.h"
30#include "usrp_prims.h"
31
32#include "ossie/cf.h"
33#include "ossie/PortTypes.h"
34
35#include "standardinterfaces/complexShort_u.h"
36#include "standardinterfaces/complexShort_p.h"
37#include "standardinterfaces/Radio_Control_p.h"
38
39#include "ossie/Device_impl.h"
40
41#include "flex.h"
42#include "dbsrx.h"
43#include "tvrx.h"
44
45// Definitions for provides ports
46class USRP_i;
47
48class USRP_RX_Control_i : public standardInterfaces_i::RX_Control_p
49
50{
51
52  public:
53    USRP_RX_Control_i(USRP_i *_usrp, const char* _name, const char* _domain);
54    void set_number_of_channels(unsigned long num);
55    void get_number_of_channels(unsigned long &num);
56
57    void get_gain_range(unsigned long channel, float &gmin, float &gmax, float &gstep);
58    void set_gain(unsigned long channel, float gain);
59    void get_gain(unsigned long channel, float &gain);
60
61    void get_frequency_range(unsigned long channel, float &fmin, float &fmax, float &fstep);
62    void set_frequency(unsigned long channel, float f);
63    void get_frequency(unsigned long channel, float &f);
64
65    void start(unsigned long channel);
66    void stop(unsigned long channel);
67
68    void set_values(const CF::Properties &values);
69
70    void set_decimation_rate(unsigned long channel, unsigned long M);
71    void get_decimation_range(unsigned long channel, unsigned long &dmin, unsigned long &dmax, unsigned long &dstep);
72
73    void set_data_packet_size(unsigned long channel, unsigned long N);
74
75 private:
76    USRP_RX_Control_i();  // No default constructor
77    USRP_RX_Control_i(const USRP_RX_Control_i &); // No copying
78 
79    USRP_i *usrp;
80
81    float db_lo_freq;
82    float db_lo_offset;
83    bool lo_locked;
84
85};
86
87class USRP_TX_Control_i : public standardInterfaces_i::TX_Control_p
88
89{
90  public:
91    USRP_TX_Control_i(USRP_i *_usrp, const char* _name, const char* _domain);
92    void set_number_of_channels(unsigned long num);
93    void get_number_of_channels(unsigned long &num);
94
95    void get_gain_range(unsigned long channel, float &gmin, float &gmax, float &gstep);
96    void set_gain(unsigned long channel, float gain);
97    void get_gain(unsigned long channel, float &gain);
98
99    void get_frequency_range(unsigned long channel, float &fmin, float &fmax, float &fstep);
100    void set_frequency(unsigned long channel, float f);
101    void get_frequency(unsigned long channel, float &f);
102
103    void start(unsigned long channel);
104    void stop(unsigned long channel);
105
106    void set_values(const CF::Properties &values);
107
108    void set_interpolation_rate(unsigned long channel, unsigned long I);
109    void get_interpolation_range(unsigned long channel, unsigned long &imin, unsigned long &imax, unsigned long &istep);
110
111 private:
112    USRP_TX_Control_i();  // No default constructor
113    USRP_TX_Control_i(const USRP_TX_Control_i &); // No copying
114
115    USRP_i *usrp;
116
117    float db_lo_freq;
118    float db_lo_offset;
119    bool lo_locked;
120};
121
122class TX_data_i : public POA_standardInterfaces::complexShort
123
124{
125  public:
126    TX_data_i(USRP_i *_usrp);
127    ~TX_data_i();
128
129    void pushPacket(const PortTypes::ShortSequence &I, const PortTypes::ShortSequence &Q);
130
131 private:
132    USRP_i *usrp;
133
134    short *tx_buf;
135    unsigned int tx_buf_idx;
136    int tx_buf_len;
137
138    unsigned int tx_underruns;
139};
140
141// Definitions for uses ports
142
143// Main USRP device definition
144void rx_data_process(void *data);
145
146class USRP_i : public virtual Device_impl
147
148{
149    friend class USRP_RX_Control_i;
150    friend class USRP_TX_Control_i;
151
152    friend void rx_data_process(void *);
153
154  public:
155    USRP_i(char *id, char *label, char *profile);
156
157    static void do_rx_data_process(void *u) {((USRP_i *)u)->rx_data_process(); };
158    static void do_tx_data_process(void *u) {((USRP_i *)u)->tx_data_process(); };
159
160    // Methods from the SCA definition
161    void start() throw (CF::Resource::StartError, CORBA::SystemException);
162    void stop() throw (CF::Resource::StopError, CORBA::SystemException);
163    CORBA::Object_ptr getPort(const char* portName) throw(CF::PortSupplier::UnknownPort, CORBA::SystemException);
164    void initialize() throw (CF::LifeCycle::InitializeError, CORBA::SystemException);
165    void configure(const CF::Properties &configProperties) throw (CORBA::SystemException, CF::PropertySet::InvalidConfiguration, CF::PropertySet::PartialConfiguration);
166    void query(CF::Properties &configProperties) throw (CORBA::SystemException, CF::UnknownProperties);
167
168    void releaseObject() throw (CF::LifeCycle::ReleaseError, CORBA::SystemException);
169
170    omni_mutex rx_run;
171
172    // These mutex's protect port and usrp config operations
173    omni_mutex rx_control_access;
174    omni_mutex tx_control_access;
175
176
177 private:
178    USRP_i();  // No default constructor
179    USRP_i(const USRP_i&);  // No copying
180
181    // RX data processing thread
182    //    static void rx_data_process(void * data); ///\todo verify statis is the online way
183
184    /// Prints warning about unsupported USRP daughter boards
185    void PrintDaughterboardWarning(const char * db_name);
186
187    // Port objects
188    USRP_RX_Control_i* rx_control_port;
189    USRP_TX_Control_i* tx_control_port;
190
191    standardInterfaces_i::complexShort_u* rx_data_1_port;
192    standardInterfaces_i::complexShort_u* rx_data_2_port;
193
194    standardInterfaces_i::complexShort_p* tx_data_port;
195
196    // usrp variables
197
198    usrp_standard_rx *usrp_rx;
199    usrp_standard_tx *usrp_tx;
200
201    // Daughterboard data
202    int rx_db0;
203    int rx_db1;
204    int tx_db0;
205    int tx_db1;
206
207    db_base *rx_db0_control;
208    db_base *rx_db1_control;
209    db_base *tx_db0_control;
210    db_base *tx_db1_control;
211
212    omni_thread *rx_thread;
213    omni_thread *tx_thread;
214
215    void rx_data_process();
216    void tx_data_process();
217
218    long set_rx_packet_count;
219    long rx_packet_count;           ///< Number of packets to collect from USRP, -1 is forever
220    unsigned int rx_packet_size;    ///< Number of samples to send to clients
221    unsigned int rx_data_size;      ///< Size of words coming from USRP
222    unsigned int number_of_channels;
223    bool complex;                   ///< True for complex data from USRP
224    unsigned int rx_overruns;
225
226    bool rx_active;
227    bool tx_active;
228
229};
Note: See TracBrowser for help on using the browser.