commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r7164 - gnuradio/branches/developers/jcorgan/t127/usrp


From: jcorgan
Subject: [Commit-gnuradio] r7164 - gnuradio/branches/developers/jcorgan/t127/usrpdb/src
Date: Thu, 13 Dec 2007 19:41:48 -0700 (MST)

Author: jcorgan
Date: 2007-12-13 19:41:48 -0700 (Thu, 13 Dec 2007)
New Revision: 7164

Added:
   gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_base.i
Modified:
   gnuradio/branches/developers/jcorgan/t127/usrpdb/src/Makefile.am
   gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_basic_tx.py
   gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_base.h
   gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.cc
   gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.h
   gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.i
Log:
Basic tx class done, passes Python QA.

Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/Makefile.am
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/Makefile.am    
2007-12-14 01:58:41 UTC (rev 7163)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/Makefile.am    
2007-12-14 02:41:48 UTC (rev 7164)
@@ -33,6 +33,7 @@
 
 LOCAL_IFILES =                                 \
        usrpdb.i                        \
+       usrpdb_base.i                   \
        usrpdb_basic_tx.i               \
        usrpdb_hwa.i                    \
        usrpdb_hwa_qa.i

Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_basic_tx.py
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_basic_tx.py 
2007-12-14 01:58:41 UTC (rev 7163)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_basic_tx.py 
2007-12-14 02:41:48 UTC (rev 7164)
@@ -33,9 +33,30 @@
        self.db = None
        self.hwa = None
 
-    def test_000_set_gain(self):
+    def test_000_freq_range(self):
+       expected_range = (-89999998976.0, 89999998976, 1e-6)
+       freq_range = self.db.freq_range()
+       self.assertFloatTuplesAlmostEqual(freq_range, expected_range, 5)
+
+    def test_001_set_freq(self):
+       actual_baseband_freq = self.db.set_freq(1e6)
+       self.assertEqual(actual_baseband_freq, 0.0)
+
+    def test_002_gain_range(self):
+       expected_range = (-20.0, 0, 0.2)
+       gain_range = self.db.gain_range()
+       self.assertFloatTuplesAlmostEqual(gain_range, expected_range, 5)
+
+    def test_003_set_gain(self):
        self.db.set_gain(-10.0) 
        self.assertEqual(self.hwa.dac_pga_gain(), -10.0)
-    
+
+    def test_004_set_gain_bad(self):
+       self.assertRaises(ValueError,
+           lambda: self.db.set_gain(10.0))     
+
+    def test_005_is_quadrature(self):
+       self.assertTrue(self.db.is_quadrature())
+           
 if __name__ == '__main__':
     gr_unittest.main ()

Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_base.h
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_base.h  
2007-12-14 01:58:41 UTC (rev 7163)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_base.h  
2007-12-14 02:41:48 UTC (rev 7164)
@@ -24,6 +24,7 @@
 #define INCLUDED_USRPDB_BASE_H
 
 #include <usrpdb_hwa.h>
+#include <vector>
 
 class usrpdb_base 
 {
@@ -36,9 +37,9 @@
 
   // These methods MUST be overridden in derived classes
   // (they raised NotImplemented exceptions in old db_base.py)
-  virtual void freq_range(float &min, float &max, float &step) = 0;
-  virtual void gain_range(float &min, float &max, float &step) = 0;
-  virtual void set_freq(float target_freq, float &actual_baseband_freq) = 0;
+  virtual std::vector<float> freq_range() = 0;
+  virtual float set_freq(float target_freq) = 0;
+  virtual std::vector<float> gain_range() = 0;
   virtual void set_gain(float gain) = 0;
   virtual bool is_quadrature() = 0;
 

Added: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_base.i
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_base.i          
                (rev 0)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_base.i  
2007-12-14 02:41:48 UTC (rev 7164)
@@ -0,0 +1,28 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+%include "usrpdb_base.h"
+%include <std_vector.i>
+
+namespace std {
+  %template() vector<float>;
+}
\ No newline at end of file

Modified: 
gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.cc
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.cc     
2007-12-14 01:58:41 UTC (rev 7163)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.cc     
2007-12-14 02:41:48 UTC (rev 7164)
@@ -27,11 +27,6 @@
 #include <usrpdb_basic_tx.h>
 #include <stdexcept>
 
-// BasicTX boards report they can do essentially anything
-const static float s_freq_min  = -90e9;
-const static float s_freq_max  =  90e9;
-const static float s_freq_step =   1e-6;
-
 usrpdb_basic_tx_sptr
 usrpdb_make_basic_tx(usrpdb_hwa_sptr hwa)
 {
@@ -44,28 +39,33 @@
   // nop
 }
 
-void
-usrpdb_basic_tx::freq_range(float &min, float &max, float &step)
+std::vector<float>
+usrpdb_basic_tx::freq_range()
 {
-  min = s_freq_min;
-  max = s_freq_max;
-  step = s_freq_step;
+  // BasicTX boards report they can do essentially anything
+  std::vector<float> result(3);
+  result[0] = -90e9;
+  result[1] = 90e9;
+  result[2] = 1e-6;
+  return result;
 }
 
-void
-usrpdb_basic_tx::set_freq(float target_freq, float &actual_baseband_freq)
+float
+usrpdb_basic_tx::set_freq(float target_freq)
 {
   // BasicTX boards don't have an LO, so they always return 0.0 as result
-  actual_baseband_freq = 0.0;
+  return 0.0;
 }
 
-void
-usrpdb_basic_tx::gain_range(float &min, float &max, float &step)
+std::vector<float>
+usrpdb_basic_tx::gain_range()
 {
-  // BasicTX boards have no gain, but report the DAC PGA setting
-  min = d_hwa->dac_pga_min();
-  max = d_hwa->dac_pga_max();
-  step = d_hwa->dac_pga_db_per_step();
+  // BasicTX boards have no gain, but report the DAC PGA settings
+  std::vector<float> result(3);
+  result[0] = d_hwa->dac_pga_min();
+  result[1] = d_hwa->dac_pga_max();
+  result[2] = d_hwa->dac_pga_db_per_step();
+  return result;
 }
 
 void

Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.h
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.h      
2007-12-14 01:58:41 UTC (rev 7163)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.h      
2007-12-14 02:41:48 UTC (rev 7164)
@@ -40,9 +40,9 @@
 public:
   virtual ~usrpdb_basic_tx();
 
-  virtual void freq_range(float &min, float &max, float &step);
-  virtual void set_freq(float target_freq, float &actual_baseband_freq);
-  virtual void gain_range(float &min, float &max, float &step);
+  virtual std::vector<float> freq_range();
+  virtual float set_freq(float target_freq);
+  virtual std::vector<float> gain_range();
   virtual void set_gain(float gain);
   virtual bool is_quadrature();
 };

Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.i
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.i      
2007-12-14 01:58:41 UTC (rev 7163)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.i      
2007-12-14 02:41:48 UTC (rev 7164)
@@ -24,7 +24,7 @@
 #include <usrpdb_basic_tx.h>
 %}
 
-%include "usrpdb_base.h"
+%include "usrpdb_base.i"
 
 class usrpdb_basic_tx;
 typedef boost::shared_ptr<usrpdb_basic_tx> usrpdb_basic_tx_sptr;
@@ -42,10 +42,10 @@
 public:
   ~usrpdb_basic_tx();
 
-  void freq_range(float &min, float &max, float &step);
-  void set_freq(float target_freq, float &actual_baseband_freq);
-  void gain_range(float &min, float &max, float &step);
-  void set_gain(float gain);
+  std::vector<float> freq_range();
+  float set_freq(float target_freq);
+  std::vector<float> gain_range();
+  void set_gain(float gain) throw (std::invalid_argument);
   bool is_quadrature();
 };
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]