diff options
Diffstat (limited to 'tools/gr-usrptest/python/labview_control')
-rw-r--r-- | tools/gr-usrptest/python/labview_control/CMakeLists.txt | 28 | ||||
-rw-r--r-- | tools/gr-usrptest/python/labview_control/__init__.py | 14 | ||||
-rw-r--r-- | tools/gr-usrptest/python/labview_control/lv_control.py | 87 |
3 files changed, 129 insertions, 0 deletions
diff --git a/tools/gr-usrptest/python/labview_control/CMakeLists.txt b/tools/gr-usrptest/python/labview_control/CMakeLists.txt new file mode 100644 index 000000000..924df5479 --- /dev/null +++ b/tools/gr-usrptest/python/labview_control/CMakeLists.txt @@ -0,0 +1,28 @@ +# Copyright 2011 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. + +######################################################################## +# Install python sources +######################################################################## +GR_PYTHON_INSTALL( + FILES + __init__.py + lv_control.py DESTINATION ${GR_PYTHON_DIR}/usrptest/labview_control +) + diff --git a/tools/gr-usrptest/python/labview_control/__init__.py b/tools/gr-usrptest/python/labview_control/__init__.py new file mode 100644 index 000000000..28d2fe03b --- /dev/null +++ b/tools/gr-usrptest/python/labview_control/__init__.py @@ -0,0 +1,14 @@ +""" +usrptest.labview_control +====================================== + +Contents +-------- + +Subpackages +----------- +:: + +The existance of the file turns the folder into a Python module. + +""" diff --git a/tools/gr-usrptest/python/labview_control/lv_control.py b/tools/gr-usrptest/python/labview_control/lv_control.py new file mode 100644 index 000000000..27407a07c --- /dev/null +++ b/tools/gr-usrptest/python/labview_control/lv_control.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python +from labview_automation.client import LabVIEWClient + +class vst_siggen: + def __init__(self,host,vi_base_path,rio_device): + self._host = host + self._path = vi_base_path + self._rio = rio_device + self._caller = lv_caller(host,2552,vi_base_path) + + def __del__(self): + self.disconnect() + + def set_freq(self, freq): + self._caller.vst_set_freq(self._rio,freq) + + def disconnect(self): + try: + self._caller.vst_disconnect(self._rio) + except: + pass + + +class executive_switch: + def __init__(self,host,vi_base_path,device_name): + self._host = host + self._path = vi_base_path + self._device = device_name + self._caller = lv_caller(host,2552,vi_base_path) + + def __del__(self): + self.disconnect_all() + + def connect_ports(self, port0, port1): + self._caller.switch_connect_ports(self._device,port0,port1) + + def disconnect_all(self): + try: + self._caller.switch_disconnect_all(self._device) + except: + pass + + + +class lv_caller: + def __init__(self, host, port, vi_base_path): + self._host = host + self._port = port + self._client = LabVIEWClient(host, port) + self._path = vi_base_path + + def vst_disconnect(self, rio_device): + with self._client as c: + control_values = { + "rio_device": rio_device, + } + result = c.run_vi_synchronous("".join([self._path,"vst_disconnect.vi"]),control_values) + return result + + def vst_set_freq(self, rio_device, freq): + with self._client as c: + control_values = { + "rio_device": rio_device, + "cw_freq": freq, + "power": 0, + } + result = c.run_vi_synchronous("".join([self._path,"vst_set_freq.vi"]),control_values) + return result + + def switch_connect_ports(self, switch_device, port0, port1): + with self._client as c: + control_values = { + "virtual_switch": switch_device, + "chan0": port0, + "chan1": port1, + } + result = c.run_vi_synchronous("".join([self._path,"switch_connect_ports.vi"]),control_values) + return result + + + def switch_disconnect_all(self, switch_device): + with self._client as c: + control_values = { + "virtual_switch": switch_device, + } + result = c.run_vi_synchronous("".join([self._path,"switch_disconnect.vi"]),control_values) + return result |