diff options
Diffstat (limited to 'gnuradio-runtime')
30 files changed, 7 insertions, 4177 deletions
diff --git a/gnuradio-runtime/CMakeLists.txt b/gnuradio-runtime/CMakeLists.txt index 75410abbb0..1f942429a0 100644 --- a/gnuradio-runtime/CMakeLists.txt +++ b/gnuradio-runtime/CMakeLists.txt @@ -60,18 +60,6 @@ GR_SET_GLOBAL(GNURADIO_RUNTIME_PYTHONPATH ${GNURADIO_RUNTIME_PYTHONPATH}) # Register controlport component ######################################################################## -if(ENABLE_STATIC_LIBS) - set(NOT_STATIC_LIBS False) - message(STATUS "ControlPort is incompatible with static library builds. Disabling.") -else(ENABLE_STATIC_LIBS) - set(NOT_STATIC_LIBS True) -endif(ENABLE_STATIC_LIBS) - -FIND_PACKAGE(ICE-3.5) # check for ICE 3.5 -if(NOT ICE_FOUND) - message(STATUS "ICE 3.5 not found. Looking for 3.4") - FIND_PACKAGE(ICE) # checks for version 3.4 -endif(NOT ICE_FOUND) FIND_PACKAGE(SWIG) if(SWIG_FOUND) @@ -88,9 +76,7 @@ GR_REGISTER_COMPONENT("gr-ctrlport" ENABLE_GR_CTRLPORT Boost_FOUND SWIG_FOUND SWIG_VERSION_CHECK - ICE_FOUND ENABLE_GNURADIO_RUNTIME - NOT_STATIC_LIBS ) ######################################################################## @@ -183,22 +169,4 @@ install( COMPONENT "runtime_devel" ) -######################################################################## -# Setup ControlPort preferences file and installation information -######################################################################## -if(ENABLE_GR_CTRLPORT) - -SET(GR_PKG_CTRL_EXAMPLES_DIR ${GR_PKG_DATA_DIR}/examples/ctrlport) - -SET(GR_PKG_CTRL_SLICE_DIR ${GR_PKG_DATA_DIR}/ctrlport) -file(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX}/${GR_PKG_CTRL_SLICE_DIR} slicedir) - -install( - FILES ctrlport.conf.example - DESTINATION ${SYSCONFDIR}/${CMAKE_PROJECT_NAME} - COMPONENT "gnuradio_runtime" -) - -endif(ENABLE_GR_CTRLPORT) - endif(ENABLE_GNURADIO_RUNTIME) diff --git a/gnuradio-runtime/ctrlport.conf.example b/gnuradio-runtime/ctrlport.conf.example deleted file mode 100644 index dc61673ea5..0000000000 --- a/gnuradio-runtime/ctrlport.conf.example +++ /dev/null @@ -1,30 +0,0 @@ -## Use this to create an endpoint used to export ControlPort. -## -## A typical configuation would be to specify using a particular -## interface (determined from the IP address) and port number: -## -## ControlPort.Endpoints=tcp -h 192.168.1.1 -p 9000 -## -## A similar endpoint without the port number stated will pick a -## random, free port: -## -## ControlPort.Endpoints=tcp -h 192.168.1.1 -## -## ICE has some wildcard capabilities, as well. The following tells -## ICE to use all available interfaces: -## -## ControlPort.Endpoints=tcp -h * -## -## Using 'default' for the host will use what 'hostname' resolves to. -## -## For more details: -## http://doc.zeroc.com/display/Ice/Proxy+and+Endpoint+Syntax -## http://www.zeroc.com/doc/Ice-3.2.1/manual/ProxyEndpointRef.51.2.html - -# ControlPort.Endpoints = tcp -t 300 -h 127.0.0.1 -p 23456 - - -## Set a default hostname (or IP) if no '-h' is used in the Endpoint -## configuration - -#Ice.Default.Host = myhost diff --git a/gnuradio-runtime/ctrlport.conf.in b/gnuradio-runtime/ctrlport.conf.in deleted file mode 100644 index 5c31a04516..0000000000 --- a/gnuradio-runtime/ctrlport.conf.in +++ /dev/null @@ -1,6 +0,0 @@ -# This file contains system wide configuration data for GNU Radio. -# You may override any setting on a per-user basis by editing -# ~/.gnuradio/config.conf - -[ctrlport] -ice_directory=@slicedir@ diff --git a/gnuradio-runtime/gnuradio-runtime.conf.in b/gnuradio-runtime/gnuradio-runtime.conf.in index 0996fb21aa..6ac9d27783 100644 --- a/gnuradio-runtime/gnuradio-runtime.conf.in +++ b/gnuradio-runtime/gnuradio-runtime.conf.in @@ -30,11 +30,10 @@ debug_file = stderr [PerfCounters] on = False -export = True +export = False clock = thread #clock = monotonic [ControlPort] on = False edges_list = False -config = # @CMAKE_INSTALL_PREFIX@/etc/gnuradio/ctrlport.conf diff --git a/gnuradio-runtime/include/gnuradio/CMakeLists.txt b/gnuradio-runtime/include/gnuradio/CMakeLists.txt index a72ea1ed88..3fc2fe7bd8 100644 --- a/gnuradio-runtime/include/gnuradio/CMakeLists.txt +++ b/gnuradio-runtime/include/gnuradio/CMakeLists.txt @@ -72,20 +72,14 @@ install(FILES types.h sys_pri.h unittests.h - ice_application_base.h - IcePy_Communicator.h - ice_server_template.h rpccallbackregister_base.h rpcmanager_base.h rpcmanager.h - rpcpmtconverters_ice.h rpcregisterhelpers.h rpcserver_aggregator.h rpcserver_base.h rpcserver_booter_aggregator.h rpcserver_booter_base.h - rpcserver_booter_ice.h - rpcserver_ice.h rpcserver_selector.h ${CMAKE_CURRENT_BINARY_DIR}/logger.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio diff --git a/gnuradio-runtime/include/gnuradio/IcePy_Communicator.h b/gnuradio-runtime/include/gnuradio/IcePy_Communicator.h deleted file mode 100644 index 2dd0cc7bba..0000000000 --- a/gnuradio-runtime/include/gnuradio/IcePy_Communicator.h +++ /dev/null @@ -1,35 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#ifndef ICEPY_COMMUNICATOR_H -#define ICEPY_COMMUNICATOR_H - -#include <Ice/CommunicatorF.h> -#include <gnuradio/api.h> - -namespace IcePy -{ - -extern PyTypeObject CommunicatorType; - -GR_RUNTIME_API bool initCommunicator(PyObject*); - -GR_RUNTIME_API Ice::CommunicatorPtr getCommunicator(PyObject*); - -GR_RUNTIME_API PyObject* createCommunicator(const Ice::CommunicatorPtr&); -GR_RUNTIME_API PyObject* getCommunicatorWrapper(const Ice::CommunicatorPtr&); - -} - -extern "C" PyObject* IcePy_initialize(PyObject*, PyObject*); -extern "C" PyObject* IcePy_initializeWithProperties(PyObject*, PyObject*); -extern "C" PyObject* IcePy_initializeWithLogger(PyObject*, PyObject*); -extern "C" PyObject* IcePy_initializeWithPropertiesAndLogger(PyObject*, PyObject*); - -#endif diff --git a/gnuradio-runtime/include/gnuradio/ice_application_base.h b/gnuradio-runtime/include/gnuradio/ice_application_base.h deleted file mode 100644 index 126327151a..0000000000 --- a/gnuradio-runtime/include/gnuradio/ice_application_base.h +++ /dev/null @@ -1,231 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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. - */ - -#ifndef ICE_APPLICATION_BASE_H -#define ICE_APPLICATION_BASE_H - -#ifdef HAVE_WINDOWS_H -#include <winsock2.h> -#include <sys/time.h> -#endif - -#include <gnuradio/api.h> -#include <gnuradio/prefs.h> -#include <Ice/Ice.h> -#include <boost/thread.hpp> -#include <boost/thread/mutex.hpp> -#include <stdio.h> -#include <iostream> -#include <set> -#include <string> -#include <stdio.h> - -namespace { - static const unsigned int ICEAPPLICATION_ACTIVATION_TIMEOUT_MS(600); -}; - -class GR_RUNTIME_API ice_application_common : public Ice::Application -{ - public: - template<typename TserverBase, typename TserverClass> friend class ice_application_base; - static boost::shared_ptr<ice_application_common> Instance(); - ~ice_application_common() {;} - static int d_reacquire_attributes; - - protected: - static bool d_main_called; - static bool d_have_ice_config; - static std::string d_endpointStr; - static boost::shared_ptr<boost::thread> d_thread; - ice_application_common() {;} - int run(int, char*[]); -}; - -template<typename TserverBase, typename TserverClass> -class ice_application_base -{ -public: - boost::shared_ptr<ice_application_common> d_application; - ice_application_base(TserverClass* _this); - ~ice_application_base() {;} - - static TserverBase* i(); - static const std::vector<std::string> endpoints(); - -protected: - bool have_ice_config() { return d_application->d_have_ice_config; } - void set_endpoint(const std::string& endpoint) { d_application->d_endpointStr = endpoint;} - - //this one is the key... overwrite in templated/inherited variants - virtual TserverBase* i_impl() = 0; - - //tools for the i_impl... - //tell it when it has to resync with the communicator - virtual bool reacquire_sync(); - virtual void sync_reacquire(); - - static TserverClass* d_this; - - int d_reacquire; - //static int d_reacquire_attributes; - -private: - void starticeexample(); - - bool application_started(); - - int run(int, char*[]); - - static void kickoff(); -}; - -template<typename TserverBase, typename TserverClass> -TserverClass* ice_application_base<TserverBase, TserverClass>::d_this(0); - -//template<typename TserverBase, typename TserverClass> -//int ice_application_base<TserverBase, TserverClass>::d_reacquire_attributes(0); - -template<typename TserverBase, typename TserverClass> -ice_application_base<TserverBase, TserverClass>::ice_application_base(TserverClass* _this) - : d_reacquire(0) -{ - //d_reacquire_attributes = 0; - d_this = _this; - d_application = ice_application_common::Instance(); -} - -template<typename TserverBase, typename TserverClass> -void ice_application_base<TserverBase, TserverClass>::starticeexample() -{ - char* argv[2]; - argv[0] = (char*)""; - - std::string conffile = gr::prefs::singleton()->get_string("ControlPort", "config", ""); - - if(conffile.size() > 0) { - std::stringstream iceconf; - ice_application_common::d_have_ice_config = true; - ice_application_common::d_main_called = true; - iceconf << conffile; - d_application->main(0, argv, iceconf.str().c_str()); - } - else { - ice_application_common::d_have_ice_config = false; - ice_application_common::d_main_called = true; - d_application->main(0, argv); - } -} - -template<typename TserverBase, typename TserverClass> -void ice_application_base<TserverBase, TserverClass>::kickoff() -{ - static bool run_once = false; - - //if(!d_this->application_started()) { - if(!run_once) { - ++d_this->d_application->d_reacquire_attributes; - - ice_application_common::d_thread = boost::shared_ptr<boost::thread> - (new boost::thread(boost::bind(&ice_application_base::starticeexample, d_this))); - - ::timespec timer_ts, rem_ts; - timer_ts.tv_sec = 0; timer_ts.tv_nsec = ICEAPPLICATION_ACTIVATION_TIMEOUT_MS*1000; - - int iter = 0; - while(!d_this->application_started()) { - #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) - ::Sleep(timer_ts.tv_nsec / 1000000); - #else - ::nanosleep(&timer_ts, &rem_ts); - #endif - if(!d_this->application_started()) - std::cout << "@"; - if(iter++ > 100) { - std::cout << "ice_application_base::kickoff(), timeout waiting to get communicator() d_application->main() might have failed?!" << std::endl;; - break; - } - } - - run_once = true; - } - - return; -} - - -template<typename TserverBase, typename TserverClass> -bool ice_application_base<TserverBase, TserverClass>::reacquire_sync() -{ - return (d_this->d_reacquire != d_application->d_reacquire_attributes); -} - -template<typename TserverBase, typename TserverClass> -void ice_application_base<TserverBase, TserverClass>::sync_reacquire() -{ - d_this->d_reacquire = d_application->d_reacquire_attributes; -} - - -template<typename TserverBase, typename TserverClass> -const std::vector<std::string> ice_application_base<TserverBase, TserverClass>::endpoints() -{ - std::vector<std::string> ep; ep.push_back(d_this->d_application->d_endpointStr); return ep; -} - -template<typename TserverBase, typename TserverClass> -TserverBase* ice_application_base<TserverBase, TserverClass>::i() -{ - //printf("indacall\n"); - - assert(d_this != 0); - if(!d_this->application_started()) { - //printf("anotherkickoff\n"); - kickoff(); - } - //printf("donekickedoff\n"); - - /*else if(!d_proxy) { - d_proxy = d_this->i_impl(); - assert(d_proxy != 0); - }*/ - - return d_this->i_impl(); -} - -/*template<typename TserverBase, typename TserverClass> - int ice_application_base<TserverBase, TserverClass>::run(int argc, char* argv[]) { - int implreturn(run_impl(argc, argv)); - ice_application_base<TserverBase, TserverClass>::communicator()->waitForShutdown(); - return implreturn; - }*/ - -template<typename TserverBase, typename TImplClass> -bool ice_application_base<TserverBase, TImplClass>::application_started() -{ - return ice_application_base<TserverBase, TImplClass>::d_this->d_application->communicator(); -} - -/*template<typename TserverBase, typename TImplClass> -int ice_application_base<TserverBase, TImplClass>::run_impl(int argc, char* argv[]) { return EXIT_SUCCESS; } -*/ - -#endif diff --git a/gnuradio-runtime/include/gnuradio/ice_server_template.h b/gnuradio-runtime/include/gnuradio/ice_server_template.h deleted file mode 100644 index 5e77d29265..0000000000 --- a/gnuradio-runtime/include/gnuradio/ice_server_template.h +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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. - */ - -#ifndef ICE_SERVER_TEMPLATE_H -#define ICE_SERVER_TEMPLATE_H - -#include <gnuradio/rpcserver_ice.h> -#include <gnuradio/ice_application_base.h> -#include <iostream> - -template<typename TserverBase, typename TserverClass, typename TImplClass, typename TIceClass> -class ice_server_template : public ice_application_base<TserverBase, TImplClass> -{ -public: - ice_server_template(TImplClass* _this, - const std::string& contolPortName, - const std::string& endpointName); - ~ice_server_template(); - -protected: - //virtual bool application_started(); - TserverBase* i_impl(); - friend class ice_application_base<TserverBase, TImplClass>; - -private: - //virtual int run_impl(int, char*[]); - Ice::ObjectAdapterPtr d_adapter; - TserverBase* d_iceserver; - const std::string d_contolPortName, d_endpointName; -}; - -template<typename TserverBase, typename TserverClass, typename TImplClass, typename TIceClass> -ice_server_template<TserverBase, TserverClass, TImplClass, TIceClass>::ice_server_template - (TImplClass* _this, const std::string& controlPortName, const std::string& endpointName) - : ice_application_base<TserverBase, TImplClass>(_this), - d_iceserver(0), - d_contolPortName(controlPortName), - d_endpointName(endpointName) -{;} - -template<typename TserverBase, typename TserverClass, typename TImplClass, typename TIceClass> -ice_server_template<TserverBase, TserverClass,TImplClass, TIceClass>::~ice_server_template() -{ - if(d_adapter) { - d_adapter->deactivate(); - delete(d_iceserver); - d_adapter = 0; - } -} - -template<typename TserverBase, typename TserverClass, typename TImplClass, typename TIceClass> -TserverBase* ice_server_template<TserverBase, TserverClass, TImplClass, TIceClass>::i_impl() -{ - if(ice_application_base<TserverBase, TImplClass>::d_this->reacquire_sync()) { - d_adapter = (ice_application_base<TserverBase, TImplClass>::d_this->have_ice_config()) ? - ice_application_base<TserverBase, TImplClass>::d_this->d_this->d_application->communicator()->createObjectAdapter(d_contolPortName) : - ice_application_base<TserverBase, TImplClass>::d_this->d_this->d_application->communicator()->createObjectAdapterWithEndpoints(d_contolPortName,"tcp -h *"); - - TserverClass* server_ice(new TserverClass()); - TIceClass obj(server_ice); - - Ice::Identity id(ice_application_base<TserverBase, TImplClass>::d_this->d_this->d_application->communicator()->stringToIdentity(d_endpointName)); - d_adapter->add(obj, id); - d_adapter->activate(); - ice_application_base<TserverBase, TImplClass>::d_this->set_endpoint(ice_application_common::communicator()->proxyToString(d_adapter->createDirectProxy(id))); - - std::cout << std::endl << "Ice Radio Endpoint: " - << ice_server_template<TserverBase, TserverClass, TImplClass, TIceClass>::endpoints()[0] - << std::endl; - - d_iceserver = (TserverBase*) server_ice; - ice_application_base<TserverBase, TImplClass>::d_this->sync_reacquire(); - } - - return d_iceserver; -} - -#endif /* ICE_SERVER_TEMPLATE_H */ diff --git a/gnuradio-runtime/include/gnuradio/pycallback_object.h b/gnuradio-runtime/include/gnuradio/pycallback_object.h index 989aed1d00..85a883c3d3 100644 --- a/gnuradio-runtime/include/gnuradio/pycallback_object.h +++ b/gnuradio-runtime/include/gnuradio/pycallback_object.h @@ -22,8 +22,6 @@ #include <iostream> #include <gnuradio/rpcregisterhelpers.h> -#include <gnuradio/ice_application_base.h> -#include <gnuradio/IcePy_Communicator.h> #include <pythread.h> #include <boost/format.hpp> @@ -32,19 +30,6 @@ enum pyport_t { PYPORT_FLOAT }; -class Instance -{ -public: - static boost::shared_ptr<ice_application_common> get_application() - { - return ice_application_common::Instance(); - } - static Ice::CommunicatorPtr get_swig_communicator() - { - return get_application()->communicator(); - } -}; - int pycallback_object_count = 500; // a simple to-PMT converter template class-function diff --git a/gnuradio-runtime/include/gnuradio/rpcpmtconverters_ice.h b/gnuradio-runtime/include/gnuradio/rpcpmtconverters_ice.h deleted file mode 100644 index 8b2c52890b..0000000000 --- a/gnuradio-runtime/include/gnuradio/rpcpmtconverters_ice.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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. - */ - -#ifndef RPCPMTCONVERTERS_ICE_H -#define RPCPMTCONVERTERS_ICE_H - -#include <pmt/pmt.h> -#include <gnuradio.h> - -namespace rpcpmtconverter -{ - pmt::pmt_t to_pmt(const GNURadio::KnobPtr& knob, const Ice::Current& c); - GNURadio::KnobPtr from_pmt(const pmt::pmt_t& knob, const Ice::Current& c); -} - -#endif /* RPCPMTCONVERTERS_ICE_H */ diff --git a/gnuradio-runtime/include/gnuradio/rpcserver_booter_ice.h b/gnuradio-runtime/include/gnuradio/rpcserver_booter_ice.h deleted file mode 100644 index 9c64095bb0..0000000000 --- a/gnuradio-runtime/include/gnuradio/rpcserver_booter_ice.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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. - */ - -#ifndef RPCSERVER_BOOTER_ICE_H -#define RPCSERVER_BOOTER_ICE_H - -#include <gnuradio/rpcserver_booter_base.h> -#include <gnuradio/ice_server_template.h> -#include <gnuradio.h> - -class rpcserver_base; -class rpcserver_ice; - -class rpcserver_booter_ice : public virtual rpcserver_booter_base, - public virtual ice_server_template<rpcserver_base, rpcserver_ice, - rpcserver_booter_ice, GNURadio::ControlPortPtr> -{ -public: - rpcserver_booter_ice(); - ~rpcserver_booter_ice(); - - rpcserver_base* i(); - const std::string & type() {return d_type;} - const std::vector<std::string> endpoints(); - -private: - std::string d_type; -}; - -#endif /* RPCSERVER_BOOTER_ICE_H */ diff --git a/gnuradio-runtime/include/gnuradio/rpcserver_ice.h b/gnuradio-runtime/include/gnuradio/rpcserver_ice.h deleted file mode 100644 index 260c7f06b5..0000000000 --- a/gnuradio-runtime/include/gnuradio/rpcserver_ice.h +++ /dev/null @@ -1,228 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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. - */ - -#ifndef RPCSERVER_ICE_H -#define RPCSERVER_ICE_H - -#include <gnuradio/rpcserver_base.h> -#include <gnuradio/rpcpmtconverters_ice.h> -#include <string> -#include <sstream> -#include <map> -#include <gnuradio.h> -#include <Ice/Exception.h> -#include <boost/format.hpp> - -class rpcserver_ice : public virtual rpcserver_base, public GNURadio::ControlPort -{ -public: - rpcserver_ice(); - virtual ~rpcserver_ice(); - - void registerConfigureCallback(const std::string &id, const configureCallback_t callback); - void unregisterConfigureCallback(const std::string &id); - - void registerQueryCallback(const std::string &id, const queryCallback_t callback); - void unregisterQueryCallback(const std::string &id); - - virtual void set(const GNURadio::KnobMap&, const Ice::Current&); - - GNURadio::KnobMap get(const GNURadio::KnobIDList&, const Ice::Current&); - - GNURadio::KnobMap getRe(const GNURadio::KnobIDList&, const Ice::Current&); - - GNURadio::KnobPropMap properties(const GNURadio::KnobIDList&, const Ice::Current&); - - virtual void shutdown(const Ice::Current&); - -private: - typedef std::map<std::string, configureCallback_t> ConfigureCallbackMap_t; - ConfigureCallbackMap_t d_setcallbackmap; - - typedef std::map<std::string, queryCallback_t> QueryCallbackMap_t; - QueryCallbackMap_t d_getcallbackmap; - - template<typename T, typename TMap> struct set_f - : public std::unary_function<T,void> - { - set_f(const Ice::Current& _c, TMap& _setcallbackmap, const priv_lvl_t& _cur_priv) : - c(_c), d_setcallbackmap(_setcallbackmap), cur_priv(_cur_priv) - {;} - - void operator()(const T& p) - { - ConfigureCallbackMap_t::const_iterator iter(d_setcallbackmap.find(p.first)); - if(iter != d_setcallbackmap.end()) { - if(cur_priv <= iter->second.priv) { - (*iter->second.callback).post(pmt::PMT_NIL, rpcpmtconverter::to_pmt(p.second,c)); - } - else { - std::cout << "Key " << p.first << " requires PRIVLVL <= " - << iter->second.priv << " to set, currently at: " - << cur_priv << std::endl; - } - } - else { - throw IceUtil::NullHandleException(__FILE__, __LINE__); - } - } - - const Ice::Current& c; - TMap& d_setcallbackmap; - const priv_lvl_t& cur_priv; - }; - - template<typename T, typename TMap> - struct get_f : public std::unary_function<T,void> - { - get_f(const Ice::Current& _c, TMap& _getcallbackmap, - const priv_lvl_t& _cur_priv, GNURadio::KnobMap& _outknobs) : - c(_c), d_getcallbackmap(_getcallbackmap), cur_priv(_cur_priv), outknobs(_outknobs) - {} - - void operator()(const T& p) - { - QueryCallbackMap_t::const_iterator iter(d_getcallbackmap.find(p)); - if(iter != d_getcallbackmap.end()) { - if(cur_priv <= iter->second.priv) { - outknobs[p] = rpcpmtconverter::from_pmt((*iter->second.callback).retrieve(), c); - } - else { - std::cout << "Key " << iter->first << " requires PRIVLVL: <= " - << iter->second.priv << " to get, currently at: " - << cur_priv << std::endl; - } - } - else { - std::stringstream ss; - ss << "Ctrlport Key called with unregistered key (" << p << ")\n"; - std::cout << ss.str(); - throw IceUtil::IllegalArgumentException(__FILE__,__LINE__,ss.str().c_str()); - } - } - - const Ice::Current& c; - TMap& d_getcallbackmap; - const priv_lvl_t& cur_priv; - GNURadio::KnobMap& outknobs; - }; - - template<typename T, typename TMap, typename TKnobMap> - struct get_all_f : public std::unary_function<T,void> - { - get_all_f(const Ice::Current& _c, TMap& _getcallbackmap, - const priv_lvl_t& _cur_priv, TKnobMap& _outknobs) : - c(_c), d_getcallbackmap(_getcallbackmap), cur_priv(_cur_priv), outknobs(_outknobs) - {;} - - void operator()(const T& p) - { - if(cur_priv <= p.second.priv) { - outknobs[p.first] = rpcpmtconverter::from_pmt(p.second.callback->retrieve(), c); - } - else { - std::cout << "Key " << p.first << " requires PRIVLVL <= " - << p.second.priv << " to get, currently at: " - << cur_priv << std::endl; - } - } - - const Ice::Current& c; - TMap& d_getcallbackmap; - const priv_lvl_t& cur_priv; - TKnobMap& outknobs; - }; - - template<typename T, typename TMap, typename TKnobMap> - struct properties_all_f : public std::unary_function<T,void> - { - properties_all_f(const Ice::Current& _c, QueryCallbackMap_t& _getcallbackmap, - const priv_lvl_t& _cur_priv, GNURadio::KnobPropMap& _outknobs) : - c(_c), d_getcallbackmap(_getcallbackmap), cur_priv(_cur_priv), outknobs(_outknobs) - {;} - - void operator()(const T& p) - { - if(cur_priv <= p.second.priv) { - GNURadio::KnobProp prop;//(new GNURadio::KnobProp()); - prop.type = GNURadio::KNOBDOUBLE; - prop.units = p.second.units; - prop.description = p.second.description; - prop.min = rpcpmtconverter::from_pmt(p.second.min, c); - prop.max = rpcpmtconverter::from_pmt(p.second.max, c); - prop.display = static_cast<uint32_t>(p.second.display); - outknobs[p.first] = prop; - } - else { - std::cout << "Key " << p.first << " requires PRIVLVL <= " - << p.second.priv << " to get, currently at: " - << cur_priv << std::endl; - } - } - - const Ice::Current& c; - TMap& d_getcallbackmap; - const priv_lvl_t& cur_priv; - TKnobMap& outknobs; - }; - - template<class T, typename TMap, typename TKnobMap> - struct properties_f : public std::unary_function<T,void> - { - properties_f(const Ice::Current& _c, TMap& _getcallbackmap, - const priv_lvl_t& _cur_priv, TKnobMap& _outknobs) : - c(_c), d_getcallbackmap(_getcallbackmap), cur_priv(_cur_priv), outknobs(_outknobs) - {;} - - void operator()(const T& p) - { - typename TMap::const_iterator iter(d_getcallbackmap.find(p)); - if(iter != d_getcallbackmap.end()) { - if(cur_priv <= iter->second.priv) { - GNURadio::KnobProp prop; - prop.type = GNURadio::KNOBDOUBLE; - prop.units = iter->second.units; - prop.description = iter->second.description; - prop.min = rpcpmtconverter::from_pmt(iter->second.min, c); - prop.max = rpcpmtconverter::from_pmt(iter->second.max, c); - prop.display = static_cast<uint32_t>(iter->second.display); - //outknobs[iter->first] = prop; - outknobs[p] = prop; - } - else { - std::cout << "Key " << iter->first << " requires PRIVLVL: <= " << - iter->second.priv << " to get, currently at: " << cur_priv << std::endl; - } - } - else { - throw IceUtil::NullHandleException(__FILE__, __LINE__); - } - } - - const Ice::Current& c; - TMap& d_getcallbackmap; - const priv_lvl_t& cur_priv; - TKnobMap& outknobs; - }; -}; - -#endif /* RPCSERVER_ICE_H */ diff --git a/gnuradio-runtime/include/gnuradio/rpcserver_selector.h b/gnuradio-runtime/include/gnuradio/rpcserver_selector.h index f45e919b0b..8a14f78d99 100644 --- a/gnuradio-runtime/include/gnuradio/rpcserver_selector.h +++ b/gnuradio-runtime/include/gnuradio/rpcserver_selector.h @@ -23,9 +23,9 @@ #ifndef RPCSERVER_SELECTOR #define RPCSERVER_SELECTOR -#define RPCSERVER_ENABLED +//#define RPCSERVER_ENABLED -#define RPCSERVER_ICE +//#define RPCSERVER_ICE //#define RPCSERVER_ERLANG //#define RPCSERVER_XMLRPC diff --git a/gnuradio-runtime/lib/controlport/CMakeLists.txt b/gnuradio-runtime/lib/controlport/CMakeLists.txt index bd46659eb2..c41d87b1f7 100644 --- a/gnuradio-runtime/lib/controlport/CMakeLists.txt +++ b/gnuradio-runtime/lib/controlport/CMakeLists.txt @@ -19,44 +19,24 @@ if(ENABLE_GR_CTRLPORT) -include_directories(${ICE_INCLUDE_DIR}) - # Add definition so we can compile in ControlPort to the blocks. ADD_DEFINITIONS(-DGR_CTRLPORT) -######################################################################## -# Run ICE To compile Slice files -######################################################################## -EXECUTE_PROCESS( - COMMAND "${ICE_SLICE2CPP}" "-I${CMAKE_CURRENT_SOURCE_DIR}" - "--output-dir=${CMAKE_CURRENT_BINARY_DIR}/" - "${CMAKE_CURRENT_SOURCE_DIR}/gnuradio.ice" - ) - list(APPEND gnuradio_runtime_sources - ${CMAKE_CURRENT_SOURCE_DIR}/ice_application_base.cc ${CMAKE_CURRENT_SOURCE_DIR}/rpcmanager.cc - ${CMAKE_CURRENT_SOURCE_DIR}/rpcpmtconverters_ice.cc ${CMAKE_CURRENT_SOURCE_DIR}/rpcserver_aggregator.cc ${CMAKE_CURRENT_SOURCE_DIR}/rpcserver_booter_aggregator.cc - ${CMAKE_CURRENT_SOURCE_DIR}/rpcserver_booter_ice.cc - ${CMAKE_CURRENT_SOURCE_DIR}/rpcserver_ice.cc ${CMAKE_CURRENT_SOURCE_DIR}/rpcserver_selector.cc ) -# Append generated file in build directory -list(APPEND gnuradio_runtime_sources - ${CMAKE_CURRENT_BINARY_DIR}/gnuradio.cpp -) - ######################################################################## # Add controlport stuff to gnuradio-runtime ######################################################################## include_directories(${CMAKE_CURRENT_BINARY_DIR}) -list(APPEND gnuradio_runtime_libs - ${ICE_LIBRARIES} -) +# Add any required libraries here +#list(APPEND gnuradio_runtime_libs +#) endif(ENABLE_GR_CTRLPORT) diff --git a/gnuradio-runtime/lib/controlport/ICE_LICENSE b/gnuradio-runtime/lib/controlport/ICE_LICENSE deleted file mode 100644 index 51ab60d453..0000000000 --- a/gnuradio-runtime/lib/controlport/ICE_LICENSE +++ /dev/null @@ -1,54 +0,0 @@ -Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved. - -This copy of Ice is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License version 2 as -published by the Free Software Foundation. - -Ice 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 version -2 along with this program; if not, see http://www.gnu.org/licenses. - -Linking Ice statically or dynamically with other software (such as a -library, module or application) is making a combined work based on Ice. -Thus, the terms and conditions of the GNU General Public License version -2 cover this combined work. - -If such software can only be used together with Ice, then not only the -combined work but the software itself is a work derived from Ice and as -such shall be licensed under the terms of the GNU General Public License -version 2. This includes the situation where Ice is only being used -through an abstraction layer. - -As a special exception to the above, ZeroC grants to the contributors for -the following projects the permission to license their Ice-based software -under the terms of the GNU Lesser General Public License (LGPL) version -2.1 or of the BSD license: - - - Orca Robotics (http://orca-robotics.sourceforge.net) - - - Mumble (http://mumble.sourceforge.net) - -This exception does not extend to the parts of Ice used by these -projects, or to any other derived work: as a whole, any work based on Ice -shall be licensed under the terms and conditions of the GNU General -Public License version 2. - -You may also combine Ice with any software not derived from Ice, provided -the license of such software is compatible with the GNU General Public -License version 2. In addition, as a special exception, ZeroC grants you -permission to combine Ice with: - - - the OpenSSL library, or with a modified version of the OpenSSL library - that uses the same license as OpenSSL - - - any library not derived from Ice and licensed under the terms of - the Apache License, version 2.0 - (http://www.apache.org/licenses/LICENSE-2.0.html) - -If you modify this copy of Ice, you may extend any of the exceptions -provided above to your version of Ice, but you are not obligated to -do so. diff --git a/gnuradio-runtime/lib/controlport/frontend.ice b/gnuradio-runtime/lib/controlport/frontend.ice deleted file mode 100644 index e4d346dba0..0000000000 --- a/gnuradio-runtime/lib/controlport/frontend.ice +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright 2013 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 <gnuradio.ice> - -[["python:package:gnuradio.ctrlport"]] -module GNURadio { - module Frontend { - - // primitive types - dictionary<string, string> StrStrDict; - dictionary<string, string> TunerArgs; - struct F32Range - { - float min; - float max; - }; - - // exception types - exception NotSupported {}; - exception InvalidSetting { string msg; }; - exception ReceiverFailure { string msg; }; - exception NotExist {}; - - - // Status Types - struct TunerStatus { - float freq; - float rate; - int a2dbits; - float gain; - F32Range gainrange; - bool isInverted; - StrStrDict info; - }; - - struct StreamInfo { - string uri; - StrStrDict info; - }; - - struct ReceiverInfo { - string uid; - string name; - StrStrDict info; - }; - - struct ChannelStatus { - string uid; - string name; - bool active; - float freq; - float bandwidth; - bool isComplex; - StrStrDict info; - }; - - struct ChannelizerStatus { - string uid; - string name; - StrStrDict info; - }; - - // Interfaces - interface Component { - void setName(string newName); - }; - - interface AbstractReceiver extends Component { - idempotent ReceiverInfo getReceiverInfo(); - }; - - interface Tuner extends Component { - TunerStatus configureTuner(TunerArgs args) throws ReceiverFailure, InvalidSetting; - idempotent TunerStatus status(); - idempotent float setGain(float gain) throws ReceiverFailure, NotSupported, InvalidSetting; - idempotent bool setInversion(bool inverted) throws ReceiverFailure, NotSupported, InvalidSetting; - idempotent float setCenterFreq(float freq) throws ReceiverFailure, NotSupported, InvalidSetting; - idempotent float setBandwidth(float bw) throws ReceiverFailure, NotSupported, InvalidSetting; - idempotent void setInfo(string k, string v) throws ReceiverFailure, NotSupported, InvalidSetting; - }; - - interface Channel extends Tuner { - void start(); - void stop(); - void destroyChannel() throws NotSupported; - idempotent bool active(); - idempotent ChannelStatus channelStat(); - idempotent StreamInfo stream(); - idempotent bool setComplex(bool complex) throws ReceiverFailure, NotSupported, InvalidSetting; - idempotent void setStreamInfo(string k, string v) throws ReceiverFailure, NotSupported, InvalidSetting; - }; - - sequence<Tuner*> TunerSeq; - sequence<Channel*> ChannelSeq; - - interface Channelizer extends AbstractReceiver { - idempotent ChannelizerStatus status(); - idempotent Tuner* getTuner(); - idempotent ChannelSeq getChannels(); - idempotent ChannelSeq getActiveChannels(); - idempotent ChannelSeq getInactiveChannels(); - Channel* createChannel(float freq, float bw, StrStrDict args) throws NotSupported; - }; - - sequence<Channelizer*> ChannelizerSeq; - - interface Receiver extends AbstractReceiver { - idempotent ChannelizerSeq getInputs(); - idempotent Channel* getChannelByID(string id) throws NotExist; - idempotent Channelizer* getChannelizerByID(string id) throws NotExist; - idempotent void setInfo(string k, string v) throws ReceiverFailure, NotSupported, InvalidSetting; - }; - - }; - - module Booter { - dictionary<string, string> WaveformArgs; - exception WaveformRunningError { - string waveformClass; - float centerFrequencyHz; - }; - exception SignalSourceError {string msg; }; - interface WaveformBooter extends Frontend::Receiver, ControlPort { - string launchWaveform(string waveformClass, WaveformArgs args) - throws WaveformRunningError, SignalSourceError; - WaveformArgMap getDriverEnum(); - WaveformArgMap getSourceInfo(); - idempotent bool waveformRunning(); - idempotent string getWaveformClass(); - }; - }; -}; diff --git a/gnuradio-runtime/lib/controlport/gnuradio.ice b/gnuradio-runtime/lib/controlport/gnuradio.ice deleted file mode 100644 index 01db91b7be..0000000000 --- a/gnuradio-runtime/lib/controlport/gnuradio.ice +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2012 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. - */ - -[["python:package:gnuradio.ctrlport"]] - -#ifndef GNURADIO_DEBUG -#define GNURADIO_DEBUG - -module GNURadio { - -struct complex { - float re; - float im; -}; - -class Knob {}; -class KnobB extends Knob { bool value; }; -class KnobC extends Knob { byte value; }; -class KnobI extends Knob { int value; }; -class KnobT extends Knob { short value; }; -class KnobF extends Knob { float value; }; -class KnobD extends Knob { double value; }; -class KnobL extends Knob { long value; }; -class KnobS extends Knob { string value; }; -class KnobZ extends Knob { complex value; }; - -sequence<bool> VectorB; sequence<byte> VectorC; -sequence<int> VectorI; sequence<float> VectorF; -sequence<double> VectorD; sequence<string> VectorS; -sequence<long> VectorL; sequence<short> VectorT; - -class KnobVecB extends Knob { VectorB value; }; -class KnobVecC extends Knob { VectorC value; }; -class KnobVecI extends Knob { VectorI value; }; -class KnobVecT extends Knob { VectorT value; }; -class KnobVecF extends Knob { VectorF value; }; -class KnobVecD extends Knob { VectorD value; }; -class KnobVecL extends Knob { VectorL value; }; -class KnobVecS extends Knob { VectorS value; }; - -enum KnobType { KNOBBOOL, KNOBCHAR, KNOBINT, KNOBFLOAT, - KNOBDOUBLE, KNOBSTRING, KNOBLONG, KNOBVECBOOL, - KNOBVECCHAR, KNOBVECINT, KNOBVECFLOAT, KNOBVECDOUBLE, - KNOBVECSTRING, KNOBVECLONG, KNOBSHORT}; - -const int DISPNULL = 0x0000; -const int DISPTIME = 0x0001; -const int DISPXY = 0x0002; -const int DISPPSD = 0x0004; -const int DISPSPEC = 0x0008; -const int DISPRAST = 0x0010; -const int DISPOPTCPLX = 0x0100; -const int DISPOPTLOG = 0x0200; -const int DISPOPTSTEM = 0x0400; -const int DISPOPTSTRIP = 0x0800; -const int DISPOPTSCATTER = 0x1000; - -struct KnobProp { - KnobType type; - string units; - string description; - int display; - Knob min; - Knob max; - Knob defaultvalue; -}; - -sequence<string> KnobIDList; -dictionary<string, Knob> KnobMap; -dictionary<string, KnobProp> KnobPropMap; -dictionary<string, string> WaveformArgMap; - -interface StreamReceiver { - void push(VectorC data); -}; - -interface ControlPort { - void set(KnobMap knobs); - idempotent KnobMap get(KnobIDList knobs); - idempotent KnobMap getRe(KnobIDList knobs); - idempotent KnobPropMap properties(KnobIDList knobs); - void shutdown(); -}; - -}; - -#endif diff --git a/gnuradio-runtime/lib/controlport/ice_application_base.cc b/gnuradio-runtime/lib/controlport/ice_application_base.cc deleted file mode 100644 index b390c77c84..0000000000 --- a/gnuradio-runtime/lib/controlport/ice_application_base.cc +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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 <gnuradio/ice_application_base.h> - -int ice_application_common::d_reacquire_attributes(0); -bool ice_application_common::d_main_called(false); -bool ice_application_common::d_have_ice_config(false); -boost::shared_ptr<boost::thread> ice_application_common::d_thread; -std::string ice_application_common::d_endpointStr(""); - -boost::shared_ptr<ice_application_common> -ice_application_common::Instance() -{ - static boost::shared_ptr<ice_application_common> - instance(new ice_application_common()); - return instance; -} - -int ice_application_common::run(int, char**) -{ - communicator()->waitForShutdown(); - return EXIT_SUCCESS; -} diff --git a/gnuradio-runtime/lib/controlport/rpcpmtconverters_ice.cc b/gnuradio-runtime/lib/controlport/rpcpmtconverters_ice.cc deleted file mode 100644 index 1477ae2c8d..0000000000 --- a/gnuradio-runtime/lib/controlport/rpcpmtconverters_ice.cc +++ /dev/null @@ -1,151 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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 <gnuradio/rpcpmtconverters_ice.h> -#include <Ice/Ice.h> -#include <gnuradio.h> - -GNURadio::KnobPtr -rpcpmtconverter::from_pmt(const pmt::pmt_t& knob, const Ice::Current& c) -{ - if(pmt::is_real(knob)) { - return new GNURadio::KnobD(Ice::Double(pmt::to_double(knob))); - } - else if(pmt::is_symbol(knob)) { - std::string stuff = pmt::symbol_to_string(knob); - return new GNURadio::KnobS(stuff); - } - else if(pmt::is_integer(knob)) { - return new GNURadio::KnobI(pmt::to_long(knob)); - } - else if(pmt::is_bool(knob)) { - return new GNURadio::KnobB(pmt::to_bool(knob)); - } - else if(pmt::is_uint64(knob)) { - return new GNURadio::KnobL(pmt::to_uint64(knob)); - } - else if(pmt::is_complex(knob)) { - std::complex<double> tmp = pmt::to_complex(knob); - GNURadio::complex cpx; - cpx.re = tmp.real(); - cpx.im = tmp.imag(); - return new GNURadio::KnobZ(cpx); - } - else if(pmt::is_c32vector(knob)) { // c32 sent as interleaved floats - size_t size(pmt::length(knob)); - const float* start((const float*) pmt::c32vector_elements(knob,size)); - return new GNURadio::KnobVecF(std::vector<float>(start,start+size*2)); - } - else if (pmt::is_s32vector(knob)) { - size_t size(pmt::length(knob)); - const int* start((const int*) pmt::s32vector_elements(knob,size)); - return new GNURadio::KnobVecI(std::vector<int>(start,start+size)); - } - else if (pmt::is_s16vector(knob)) { - size_t size(pmt::length(knob)); - const short* start((const short*) pmt::s16vector_elements(knob,size)); - return new GNURadio::KnobVecT(std::vector<short>(start,start+size)); - } - else if(pmt::is_f32vector(knob)) { - size_t size(pmt::length(knob)); - const float* start((const float*) pmt::f32vector_elements(knob,size)); - return new GNURadio::KnobVecF(std::vector<float>(start,start+size)); - } - else if (pmt::is_u8vector(knob)) { - size_t size(pmt::length(knob)); - const uint8_t* start((const uint8_t*) pmt::u8vector_elements(knob,size)); - return new GNURadio::KnobVecC(std::vector<Ice::Byte>(start,start+size)); - } - else if (pmt::is_s8vector(knob)) { - size_t size(pmt::length(knob)); - const int8_t* start((const int8_t*) pmt::s8vector_elements(knob,size)); - return new GNURadio::KnobVecC(std::vector<Ice::Byte>(start,start+size)); - } - else { - std::cerr << "Error: Don't know how to handle Knob Type (from): " << std::endl; assert(0);} - //TODO: VECTORS!!! - return new GNURadio::Knob(); -} - -pmt::pmt_t -rpcpmtconverter::to_pmt(const GNURadio::KnobPtr& knob, const Ice::Current& c) -{ - std::string id(knob->ice_id(c).substr(12)); - if(id == "KnobD") { - GNURadio::KnobDPtr k(GNURadio::KnobDPtr::dynamicCast(knob)); - return pmt::mp(k->value); - } - else if(id == "KnobF") { - GNURadio::KnobFPtr k(GNURadio::KnobFPtr::dynamicCast(knob)); - return pmt::mp(k->value); - } - else if(id == "KnobI") { - GNURadio::KnobIPtr k(GNURadio::KnobIPtr::dynamicCast(knob)); - return pmt::mp(k->value); - } - else if(id == "KnobT") { - GNURadio::KnobTPtr k(GNURadio::KnobTPtr::dynamicCast(knob)); - return pmt::mp(k->value); - } - else if(id == "KnobS") { - GNURadio::KnobSPtr k(GNURadio::KnobSPtr::dynamicCast(knob)); - return pmt::string_to_symbol(k->value); - } - else if(id == "KnobB") { - GNURadio::KnobBPtr k(GNURadio::KnobBPtr::dynamicCast(knob)); - if((k->value == true) || (k->value > 0)) - return pmt::PMT_T; - else - return pmt::PMT_F; - } - else if(id == "KnobC") { - GNURadio::KnobCPtr k(GNURadio::KnobCPtr::dynamicCast(knob)); - return pmt::mp(k->value); - } - else if(id == "KnobL") { - GNURadio::KnobLPtr k(GNURadio::KnobLPtr::dynamicCast(knob)); - return pmt::mp((long)k->value); - } - else if(id == "KnobZ") { - GNURadio::KnobZPtr k(GNURadio::KnobZPtr::dynamicCast(knob)); - std::complex<double> cpx(k->value.re, k->value.im); - return pmt::from_complex(cpx); - } - else if(id == "KnobVecC") { - GNURadio::KnobVecCPtr k(GNURadio::KnobVecCPtr::dynamicCast(knob)); - return pmt::init_u8vector(k->value.size(), &k->value[0]); - } - else if(id == "KnobVecI") { - GNURadio::KnobVecIPtr k(GNURadio::KnobVecIPtr::dynamicCast(knob)); - return pmt::init_s32vector(k->value.size(), &k->value[0]); - } - //else if(id == "KnobVecF") { - // GNURadio::KnobVecFPtr k(GNURadio::KnobVecFPtr::dynamicCast(knob)); - // return pmt::mp(k->value); - //TODO: FLOAT!!! - //TODO: VECTORS!!! - else { - std::cerr << "Error: Don't know how to handle Knob Type: " << id << std::endl; assert(0); - } - - return pmt::pmt_t(); -} diff --git a/gnuradio-runtime/lib/controlport/rpcserver_booter_ice.cc b/gnuradio-runtime/lib/controlport/rpcserver_booter_ice.cc deleted file mode 100644 index f60a218747..0000000000 --- a/gnuradio-runtime/lib/controlport/rpcserver_booter_ice.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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 <gnuradio/rpcserver_ice.h> -#include <gnuradio/rpcserver_booter_ice.h> - -namespace { - static const char* const CONTROL_PORT_CLASS("ice"); - static const char* const CONTROL_PORT_NAME("ControlPort"); - static const char* const ENDPOINT_NAME("gnuradio"); -}; - -rpcserver_booter_ice::rpcserver_booter_ice() : - ice_server_template<rpcserver_base, rpcserver_ice, - rpcserver_booter_ice, GNURadio::ControlPortPtr> - (this, std::string(CONTROL_PORT_NAME), std::string(ENDPOINT_NAME)), - d_type(std::string(CONTROL_PORT_CLASS)) -{;} - -rpcserver_booter_ice::~rpcserver_booter_ice() -{;} - -rpcserver_base* -rpcserver_booter_ice::i() -{ - return ice_server_template<rpcserver_base, rpcserver_ice, - rpcserver_booter_ice, GNURadio::ControlPortPtr>::i(); -} - -const std::vector<std::string> -rpcserver_booter_ice::endpoints() -{ - return ice_server_template<rpcserver_base, rpcserver_ice, - rpcserver_booter_ice, GNURadio::ControlPortPtr>::endpoints(); -} diff --git a/gnuradio-runtime/lib/controlport/rpcserver_ice.cc b/gnuradio-runtime/lib/controlport/rpcserver_ice.cc deleted file mode 100644 index cba6be578e..0000000000 --- a/gnuradio-runtime/lib/controlport/rpcserver_ice.cc +++ /dev/null @@ -1,192 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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 <gnuradio/rpcserver_ice.h> -#include <IceUtil/IceUtil.h> -#include <Ice/Ice.h> -#include <iostream> -#include <sstream> -#include <stdexcept> -#include <pmt/pmt.h> -#include <boost/xpressive/xpressive.hpp> - -#define DEBUG 0 - -using namespace rpcpmtconverter; - -rpcserver_ice::rpcserver_ice() -{} - -rpcserver_ice::~rpcserver_ice() -{} - -void -rpcserver_ice::registerConfigureCallback(const std::string &id, - const configureCallback_t callback) -{ - { - ConfigureCallbackMap_t::const_iterator iter(d_setcallbackmap.find(id)); - if(iter != d_setcallbackmap.end()) { - std::stringstream s; - s << "rpcserver_ice:: rpcserver_ice ERROR registering set, already registered: " - << id << std::endl; - throw std::runtime_error(s.str().c_str()); - } - } - - if(DEBUG) - std::cout << "rpcserver_ice registering set: " << id << std::endl; - - d_setcallbackmap.insert(ConfigureCallbackMap_t::value_type(id, callback)); -} - -void -rpcserver_ice::unregisterConfigureCallback(const std::string &id) -{ - ConfigureCallbackMap_t::iterator iter(d_setcallbackmap.find(id)); - if(iter == d_setcallbackmap.end()) { - std::stringstream s; - s << "rpcserver_ice:: rpcserver_ice ERROR unregistering set, not registered: " - << id << std::endl; - throw std::runtime_error(s.str().c_str()); - } - - if(DEBUG) - std::cout << "rpcserver_ice unregistering set: " << id << std::endl; - - d_setcallbackmap.erase(iter); -} - -void -rpcserver_ice::registerQueryCallback(const std::string &id, - const queryCallback_t callback) -{ - { - QueryCallbackMap_t::const_iterator iter(d_getcallbackmap.find(id)); - if(iter != d_getcallbackmap.end()) { - std::stringstream s; - s << "rpcserver_ice:: rpcserver_ice ERROR registering get, already registered: " - << id << std::endl; - throw std::runtime_error(s.str().c_str()); - } - } - - if(DEBUG) - std::cout << "rpcserver_ice registering get: " << id << std::endl; - - d_getcallbackmap.insert(QueryCallbackMap_t::value_type(id, callback)); -} - -void -rpcserver_ice::unregisterQueryCallback(const std::string &id) -{ - QueryCallbackMap_t::iterator iter(d_getcallbackmap.find(id)); - if(iter == d_getcallbackmap.end()) { - std::stringstream s; - s << "rpcserver_ice:: rpcserver_ice ERROR unregistering get, registered: " - << id << std::endl; - throw std::runtime_error(s.str().c_str()); - } - - if(DEBUG) - std::cout << "rpcserver_ice unregistering get: " << id << std::endl; - - d_getcallbackmap.erase(iter); -} - -void -rpcserver_ice::set(const GNURadio::KnobMap& knobs, const Ice::Current& c) -{ - std::for_each(knobs.begin(), knobs.end(), - set_f<GNURadio::KnobMap::value_type,ConfigureCallbackMap_t> - (c, d_setcallbackmap, cur_priv)); -} - -GNURadio::KnobMap -rpcserver_ice::getRe(const GNURadio::KnobIDList& knobs, const Ice::Current& c) -{ - GNURadio::KnobMap outknobs; - - if(knobs.size() == 0) { - std::for_each(d_getcallbackmap.begin(), d_getcallbackmap.end(), - get_all_f<QueryCallbackMap_t::value_type, QueryCallbackMap_t, GNURadio::KnobMap> - (c, d_getcallbackmap, cur_priv, outknobs)); - } - else { - QueryCallbackMap_t::iterator it; - for(it = d_getcallbackmap.begin(); it != d_getcallbackmap.end(); it++){ - for(size_t j=0; j<knobs.size(); j++){ - const boost::xpressive::sregex re(boost::xpressive::sregex::compile(knobs[j])); - if(boost::xpressive::regex_match(it->first, re)){ - get_f<GNURadio::KnobIDList::value_type, QueryCallbackMap_t> - (c, d_getcallbackmap, cur_priv, outknobs)(it->first); - break; - } - } - } - } - return outknobs; -} - -GNURadio::KnobMap -rpcserver_ice::get(const GNURadio::KnobIDList& knobs, const Ice::Current& c) -{ - GNURadio::KnobMap outknobs; - - if(knobs.size() == 0) { - std::for_each(d_getcallbackmap.begin(), d_getcallbackmap.end(), - get_all_f<QueryCallbackMap_t::value_type, QueryCallbackMap_t, GNURadio::KnobMap> - (c, d_getcallbackmap, cur_priv, outknobs)); - } - else { - std::for_each(knobs.begin(), knobs.end(), - get_f<GNURadio::KnobIDList::value_type, QueryCallbackMap_t> - (c, d_getcallbackmap, cur_priv, outknobs)); - } - return outknobs; -} - -GNURadio::KnobPropMap -rpcserver_ice::properties(const GNURadio::KnobIDList& knobs, const Ice::Current& c) -{ - GNURadio::KnobPropMap outknobs; - - if(knobs.size() == 0) { - std::for_each(d_getcallbackmap.begin(), d_getcallbackmap.end(), - properties_all_f<QueryCallbackMap_t::value_type, - QueryCallbackMap_t,GNURadio::KnobPropMap>(c, d_getcallbackmap, cur_priv, outknobs)); - } - else { - std::for_each(knobs.begin(), knobs.end(), - properties_f<GNURadio::KnobIDList::value_type, - QueryCallbackMap_t, GNURadio::KnobPropMap>(c, d_getcallbackmap, cur_priv, outknobs)); - } - return outknobs; -} - -void -rpcserver_ice::shutdown(const Ice::Current& c) -{ - if(DEBUG) - std::cout << "Shutting down..." << std::endl; - c.adapter->getCommunicator()->shutdown(); -} diff --git a/gnuradio-runtime/lib/controlport/rpcserver_selector.cc b/gnuradio-runtime/lib/controlport/rpcserver_selector.cc index d515e78963..692f151958 100644 --- a/gnuradio-runtime/lib/controlport/rpcserver_selector.cc +++ b/gnuradio-runtime/lib/controlport/rpcserver_selector.cc @@ -27,8 +27,7 @@ bool rpcmanager::make_aggregator(false); #ifdef RPCSERVER_ICE - #include <gnuradio/rpcserver_booter_ice.h> - rpcmanager::rpcserver_booter_register_helper<rpcserver_booter_ice> boot_ice; + #error TODO ICE #endif #ifdef RPCSERVER_ERLANG diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/CMakeLists.txt b/gnuradio-runtime/python/gnuradio/ctrlport/CMakeLists.txt index 80806341ea..1d5a292429 100644 --- a/gnuradio-runtime/python/gnuradio/ctrlport/CMakeLists.txt +++ b/gnuradio-runtime/python/gnuradio/ctrlport/CMakeLists.txt @@ -20,62 +20,6 @@ ######################################################################## include(GrPython) -EXECUTE_PROCESS( - COMMAND ${ICE_SLICE2PY} -I${CMAKE_SOURCE_DIR}/gnuradio-runtime/lib/controlport - --output-dir=${CMAKE_BINARY_DIR}/gnuradio-runtime/python - ${CMAKE_SOURCE_DIR}/gnuradio-runtime/lib/controlport/gnuradio.ice -) - -EXECUTE_PROCESS( - COMMAND ${ICE_SLICE2PY} -I${CMAKE_SOURCE_DIR}/gnuradio-runtime/lib/controlport - --output-dir=${CMAKE_BINARY_DIR}/gnuradio-runtime/python - ${CMAKE_SOURCE_DIR}/gnuradio-runtime/lib/controlport/frontend.ice -) - -EXECUTE_PROCESS( - COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/gnuradio-runtime/python/gnuradio/__init__.py -) - -GR_PYTHON_INSTALL( - FILES - ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py - ${CMAKE_CURRENT_SOURCE_DIR}/IceRadioClient.py - DESTINATION ${GR_PYTHON_DIR}/gnuradio/ctrlport/ - COMPONENT "runtime_python" -) - -# We don't want to install these in the root Python directory, but we -# aren't given a choice based on the way slice2py generates the -# information. -GR_PYTHON_INSTALL( - FILES - ${CMAKE_BINARY_DIR}/gnuradio-runtime/python/gnuradio_ice.py - ${CMAKE_BINARY_DIR}/gnuradio-runtime/python/frontend_ice.py - DESTINATION ${GR_PYTHON_DIR} - COMPONENT "runtime_python" -) - -GR_PYTHON_INSTALL( - FILES - ${CMAKE_CURRENT_BINARY_DIR}/GNURadio/__init__.py - DESTINATION ${GR_PYTHON_DIR}/gnuradio/ctrlport/GNURadio - COMPONENT "runtime_python" -) - -GR_PYTHON_INSTALL( - FILES - ${CMAKE_CURRENT_BINARY_DIR}/GNURadio/Booter/__init__.py - DESTINATION ${GR_PYTHON_DIR}/gnuradio/ctrlport/GNURadio/Booter - COMPONENT "runtime_python" -) - -GR_PYTHON_INSTALL( - FILES - ${CMAKE_CURRENT_BINARY_DIR}/GNURadio/Frontend/__init__.py - DESTINATION ${GR_PYTHON_DIR}/gnuradio/ctrlport/GNURadio/Frontend - COMPONENT "runtime_python" -) - install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/icon.png @@ -90,13 +34,3 @@ GR_PYTHON_INSTALL( DESTINATION ${GR_PYTHON_DIR}/gnuradio/ctrlport/ COMPONENT "runtime_python" ) - -GR_PYTHON_INSTALL( - FILES - ${CMAKE_CURRENT_SOURCE_DIR}/gr-ctrlport-monitor - ${CMAKE_CURRENT_SOURCE_DIR}/gr-perf-monitorx - ${CMAKE_CURRENT_SOURCE_DIR}/gr-ctrlport-curses - DESTINATION ${GR_RUNTIME_DIR} - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE - COMPONENT "runtime_python" -) diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/IceRadioClient.py b/gnuradio-runtime/python/gnuradio/ctrlport/IceRadioClient.py deleted file mode 100644 index 87998f7911..0000000000 --- a/gnuradio-runtime/python/gnuradio/ctrlport/IceRadioClient.py +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2012 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. -# - -import Ice, Glacier2 -from PyQt4 import QtGui, QtCore -import sys, time, Ice -from gnuradio import gr -from gnuradio.ctrlport import GNURadio - -class IceRadioClient(Ice.Application): - def __init__(self, parentClass): - self.parentClass = parentClass - - def getRadio(self, host, port): - radiostr = "gnuradio -t:tcp -h " + host + " -p " + port + " -t 3000" - base = self.communicator().stringToProxy(radiostr).ice_twoway() - radio = GNURadio.ControlPortPrx.checkedCast(base) - - if not radio: - sys.stderr.write("{0} : invalid proxy.\n".format(args[0])) - return None - - return radio - - def run(self,args): - if len(args) < 2: - print "useage: [glacierinstance glacierhost glacierport] host port" - return - if len(args) == 8: - self.useglacier = True - guser = args[1] - gpass = args[2] - ginst = args[3] - ghost = args[4] - gport = args[5] - host = args[6] - port = args[7] - else: - self.useglacier = False - host = args[1] - port = args[2] - if(port == "-p"): - port = args[3] - - if self.useglacier: - gstring = ginst + "/router -t:tcp -h " + ghost + " -p " + gport - print "GLACIER: {0}".format(gstring) - - setrouter = Glacier2.RouterPrx.checkedCast(self.communicator().stringToProxy(gstring)) - self.communicator().setDefaultRouter(setrouter) - defaultRouter = self.communicator().getDefaultRouter() - #defaultRouter = self.communicator().stringToProxy(gstring) - if not defaultRouter: - print self.appName() + ": no default router set" - return 1 - else: - print str(defaultRouter) - router = Glacier2.RouterPrx.checkedCast(defaultRouter) - if not router: - print self.appName() + ": configured router is not a Glacier2 router" - return 1 - - while True: - print "This demo accepts any user-id / password combination." - if not guser == '' and not gpass == '': - id = guser - pw = gpass - else: - id = raw_input("user id: ") - pw = raw_input("password: ") - - try: - router.createSession(id, pw) - break - except Glacier2.PermissionDeniedException, ex: - print "permission denied:\n" + ex.reason - - radio = self.getRadio(host, port) - if(radio is None): - return 1 - - app = QtGui.QApplication(sys.argv) - ex = self.parentClass(radio, port, self) - ex.show(); - app.exec_() diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/__init__.py b/gnuradio-runtime/python/gnuradio/ctrlport/__init__.py index cfb30ce850..8f33d65bbc 100644 --- a/gnuradio-runtime/python/gnuradio/ctrlport/__init__.py +++ b/gnuradio-runtime/python/gnuradio/ctrlport/__init__.py @@ -20,8 +20,6 @@ # The presence of this file turns this directory into a Python package -import Ice, IcePy - # import swig generated symbols into the ctrlport namespace #from ctrlport_swig import * from monitor import * diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/gr-ctrlport-curses b/gnuradio-runtime/python/gnuradio/ctrlport/gr-ctrlport-curses deleted file mode 100755 index f40c87a6d8..0000000000 --- a/gnuradio-runtime/python/gnuradio/ctrlport/gr-ctrlport-curses +++ /dev/null @@ -1,268 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2012 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. -# - -import threading -import curses -import os, sys, time -from optparse import OptionParser - -import Ice -from gnuradio.ctrlport import GNURadio - -ENTER = chr(10) -UP_ARROW = chr(65) -DOWN_ARROW = chr(66) - -class modem_monitor(threading.Thread): - def __init__(self, cb_live, cb_exit, interface): - threading.Thread.__init__(self) - self.cb_live = cb_live - self.cb_exit = cb_exit - - self.running = True - - def __del__(self): - rx.close() - - def run(self): - while self.running: - time.sleep(0.5) - - def shutdown(self): - self.running = False - self.rx.close() - - def cb(self,contents): - (op, sep, payload) = contents.partition(":") - if(op == "live"): - print "live" - self.cb_live(payload) - elif(op == "exit"): - self.cb_exit(payload) - else: - print "unknown op arrived! garbage on multicast adx?" - -class modem_window(threading.Thread): - def __init__(self, locator): - threading.Thread.__init__(self) - self.locator = locator - - # curses init - self.win = curses.newwin(30,100,4,4) - - # Ice/GRCP init - self.comm = Ice.initialize() - proxy = self.comm.stringToProxy(locator) - self.radio = GNURadio.ControlPortPrx.checkedCast(proxy) - self.updateKnobs() - - # GUI init - self.running = True - self.ssel = 0 - self.start() - #self.updateGUI() - - # input loop - while(self.running): - self.getInput() - - # wait for update thread exit - self.join() - - def updateKnobs(self): - self.knobs = self.radio.get([]) - - def getInput(self): - a = self.win.getch() - if(a <= 256): - a = chr(a) - if(a == 'q'): - self.running = False - elif(a == UP_ARROW): - self.ssel = max(self.ssel-1, 0) - self.updateGUI() - elif(a == DOWN_ARROW): - self.ssel = max(min(self.ssel+1, len(self.knobs.keys())-1),0) - self.updateGUI() - self.updateGUI() - - def updateGUI(self): - self.win.clear() - self.win.border(0) - self.win.addstr(1, 2, "Modem Statistics :: %s"%(self.locator)) - self.win.addstr(2, 2, "---------------------------------------------------") - - maxnb = 0 - maxk = 0 - for k in self.knobs.keys(): - (nb,k) = k.split("::", 2) - maxnb = max(maxnb,len(nb)) - maxk = max(maxk,len(k)) - - offset = 3 - keys = self.knobs.keys() - keys.sort() - for k in keys: - (nb,sk) = k.split("::", 2) - v = self.knobs[k].value - sv = str(v) - if(len(sv) > 20): - sv = sv[0:20] - props = 0 - if(self.ssel == offset-3): - props = props | curses.A_REVERSE - self.win.addstr(offset, 2, "%s %s %s" % \ - (nb.rjust(maxnb," "), sk.ljust(maxk," "), sv),props) - offset = offset + 1 - self.win.refresh() - - def run(self): - while(self.running): - self.updateKnobs() - self.updateGUI() - time.sleep(1) - -class monitor_gui: - def __init__(self, interfaces, options): - - locator = None - - # Extract options into a locator - if(options.host and options.port): - locator = "{0} -t:{1} -h {2} -p {3}".format( - options.app, options.protocol, - options.host, options.port) - - # Set up GUI - self.locators = {} - - self.mode = 0 # modem index screen (modal keyboard input) - self.lsel = 0 # selected locator - self.scr = curses.initscr() - self.updateGUI() - - # Kick off initial monitors - self.monitors = [] - for i in interfaces: - self.monitors.append( modem_monitor(self.addModem, self.delModem, i) ) - self.monitors[-1].start() - - if not ((locator == None) or (locator == "")): - self.addModem(locator) - - # wait for user input - while(True): - self.getInput() - - def addModem(self, locator): - if(not self.locators.has_key(locator)): - self.locators[locator] = {} - self.locators[locator]["update_time"] = time.time() - self.locators[locator]["status"] = "live" - - self.updateGUI(); - - def delModem(self, locator): - #if(self.locators.has_key(locator)): - if(not self.locators.has_key(locator)): - self.locators[locator] = {} - self.locators[locator]["update_time"] = time.time() - self.locators[locator]["status"] = "exit" - - self.updateGUI() - - def updateGUI(self): - if(self.mode == 0): #redraw locators - self.scr.clear() - self.scr.border(0) - self.scr.addstr(1, 2, " GRCP-Curses Modem Monitor :: (A)dd (R)efresh, (Q)uit, ...") - for i in range(len(self.locators.keys())): - locator = self.locators.keys()[i] - lhash = self.locators[locator] - #self.scr.addstr(3+i, 5, locator + str(lhash)) - props = 0 - if(self.lsel == i): - props = props | curses.A_REVERSE - self.scr.addstr(3+i, 5, locator + str(lhash), props) - self.scr.refresh() - - def connectGUI(self): - self.scr.clear() - self.scr.addstr(1, 1, "Connect to radio:") - locator = self.scr.getstr(200) - self.addModem(locator) - self.updateGUI() - - def getInput(self): - a = self.scr.getch() - self.scr.addstr(20, 2, "got key (%d) " % (int(a))) - if(a <= 256): - a = chr(a) - if(a =='r'): - self.updateGUI() - elif(a == 'q'): - self.shutdown() - elif(a == 'a'): - self.connectGUI() - elif(a == UP_ARROW): - self.lsel = max(self.lsel-1, 0) - self.updateGUI() - elif(a == DOWN_ARROW): - self.lsel = max(min(self.lsel+1, len(self.locators.keys())-1),0) - self.updateGUI() - elif(a == ENTER): - try: - locator = self.locators.keys()[self.lsel] - self.mode = 1 - mwin = modem_window(locator) - self.mode = 0 - # pop up a new modem display ... - self.updateGUI() - except: - pass - - def shutdown(self): - curses.endwin() - os._exit(0) - -if __name__ == "__main__": - parser = OptionParser() - parser.add_option("-H", "--host", type="string", - help="Hostname of ControlPort server.") - parser.add_option("-p", "--port", type="int", - help="Port number of host's ControlPort endpoint.") - parser.add_option("-i", "--interfaces", type="string", - action="append", default=["lo"], - help="Interfaces to use. [default=%default]") - parser.add_option("-P", "--protocol", type="string", default="tcp", - help="Type of protocol to use (usually tcp). [default=%default]") - parser.add_option("-a", "--app", type="string", default="gnuradio", - help="Name of application [default=%default]") - (options, args) = parser.parse_args() - - if((options.host == None) ^ (options.port == None)): - print "Please set both a hostname and a port number.\n" - parser.print_help() - sys.exit(1) - - mg = monitor_gui(options.interfaces, options) - diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/gr-ctrlport-monitor b/gnuradio-runtime/python/gnuradio/ctrlport/gr-ctrlport-monitor deleted file mode 100755 index 76dd2e5bc1..0000000000 --- a/gnuradio-runtime/python/gnuradio/ctrlport/gr-ctrlport-monitor +++ /dev/null @@ -1,752 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2012,2013 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. -# - -from gnuradio import gr, ctrlport - -from PyQt4 import QtCore,Qt -import PyQt4.QtGui as QtGui -import os, sys, time, struct - -import Ice -from gnuradio.ctrlport.IceRadioClient import * -from gnuradio.ctrlport.GrDataPlotter import * -from gnuradio.ctrlport import GNURadio - -class RateDialog(QtGui.QDialog): - def __init__(self, delay, parent=None): - super(RateDialog, self).__init__(parent) - self.gridLayout = QtGui.QGridLayout(self) - self.setWindowTitle("Update Delay (ms)"); - self.delay = QtGui.QLineEdit(self); - self.delay.setText(str(delay)); - self.buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel) - self.gridLayout.addWidget(self.delay); - self.gridLayout.addWidget(self.buttonBox); - self.buttonBox.accepted.connect(self.accept) - self.buttonBox.rejected.connect(self.reject) - def accept(self): - self.done(1); - def reject(self): - self.done(0); - -class MAINWindow(QtGui.QMainWindow): - def minimumSizeHint(self): - return Qtgui.QSize(800,600) - - def __init__(self, radio, port, interface): - - super(MAINWindow, self).__init__() - self.updateRate = 1000; - self.conns = [] - self.plots = [] - self.knobprops = [] - self.interface = interface - - self.mdiArea = QtGui.QMdiArea() - self.mdiArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) - self.mdiArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) - self.setCentralWidget(self.mdiArea) - - self.mdiArea.subWindowActivated.connect(self.updateMenus) - self.windowMapper = QtCore.QSignalMapper(self) - self.windowMapper.mapped[QtGui.QWidget].connect(self.setActiveSubWindow) - - self.createActions() - self.createMenus() - self.createToolBars() - self.createStatusBar() - self.updateMenus() - - self.setWindowTitle("GNU Radio Control Port Monitor") - self.setUnifiedTitleAndToolBarOnMac(True) - - self.newCon(radio, port) - icon = QtGui.QIcon(ctrlport.__path__[0] + "/icon.png" ) - self.setWindowIcon(icon) - - # Locally turn off ControlPort export from GR. This prevents - # our GR-based plotters from launching their own ControlPort - # instance (and possibly causing a port collision if one has - # been specified). - os.environ['GR_CONF_CONTROLPORT_ON'] = 'False' - - def setUpdateRate(self,nur): - self.updateRate = int(nur); - for c in self.conns: - c.updateRate = self.updateRate; - c.timer.setInterval(self.updateRate); - - def newCon(self, radio=None, port=None): - child = MForm(radio, port, len(self.conns), self.updateRate, self) - if(child.radio is not None): - child.setWindowTitle(str(child.radio)) - self.mdiArea.addSubWindow(child) - child.showMaximized() - self.conns.append(child) - self.plots.append([]) - - def propertiesMenu(self, key, radio, uid): - r = str(radio).split(" ") - title = "{0}:{1}".format(r[3], r[5]) - - props = radio.properties([key]) - - pmin,pmax = get_minmax(props[key]) - - # Use display option mask of item to set up available plot - # types and default options. - disp = self.knobprops[uid][key].display - cplx = disp & gr.DISPOPTCPLX | disp & gr.DISPXY - strip = disp & gr.DISPOPTSTRIP - stem = disp & gr.DISPOPTSTEM - log = disp & gr.DISPOPTLOG - scatter = disp & gr.DISPOPTSCATTER - - def newUpdaterProxy(): - self.newUpdater(key, radio) - - def newPlotterFProxy(): - self.newPlotF(key, uid, title, pmin, pmax, - log, strip, stem) - - def newPlotterCProxy(): - self.newPlotC(key, uid, title, pmin, pmax, - log, strip, stem) - - def newPlotterConstProxy(): - self.newPlotConst(key, uid, title, pmin, pmax, - scatter, strip) - - def newPlotterPsdFProxy(): - self.newPlotPsdF(key, uid, title) - - def newPlotterPsdCProxy(): - self.newPlotPsdC(key, uid, title) - - def newPlotterRasterFProxy(): - self.newPlotRasterF(key, uid, title, pmin, pmax) - - def newPlotterRasterBProxy(): - self.newPlotRasterB(key, uid, title, pmin, pmax) - - menu = QtGui.QMenu(self) - menu.setTitle("Item Actions") - menu.setTearOffEnabled(False) - - # object properties - menu.addAction("Properties", newUpdaterProxy) - - # displays available - if(cplx == 0): - menu.addAction("Plot Time", newPlotterFProxy) - menu.addAction("Plot PSD", newPlotterPsdFProxy) - menu.addAction("Plot Raster (real)", newPlotterRasterFProxy) - #menu.addAction("Plot Raster (bits)", newPlotterRasterBProxy) - else: - menu.addAction("Plot Time", newPlotterCProxy) - menu.addAction("Plot PSD", newPlotterPsdCProxy) - menu.addAction("Plot Constellation", newPlotterConstProxy) - - menu.popup(QtGui.QCursor.pos()) - - def newUpdater(self, key, radio): - updater = UpdaterWindow(key, radio, None) - updater.setWindowTitle("Updater: " + key) - updater.setModal(False) - updater.exec_() - - def newSub(self, e): - tag = str(e.text(0)) - tree = e.treeWidget().parent() - uid = tree.uid - knobprop = self.knobprops[uid][tag] - - r = str(tree.radio).split(" ") - title = "{0}:{1}".format(r[3], r[5]) - pmin,pmax = get_minmax(knobprop) - - disp = knobprop.display - if(disp & gr.DISPTIME): - strip = disp & gr.DISPOPTSTRIP - stem = disp & gr.DISPOPTSTEM - log = disp & gr.DISPOPTLOG - if(disp & gr.DISPOPTCPLX == 0): - self.newPlotF(tag, uid, title, pmin, pmax, - log, strip, stem) - else: - self.newPlotC(tag, uid, title, pmin, pmax, - log, strip, stem) - - elif(disp & gr.DISPXY): - scatter = disp & gr.DISPOPTSCATTER - self.newPlotConst(tag, uid, title, pmin, pmax, scatter) - - elif(disp & gr.DISPPSD): - if(disp & gr.DISPOPTCPLX == 0): - self.newPlotPsdF(tag, uid, title) - else: - self.newPlotPsdC(tag, uid, title) - - def startDrag(self, e): - drag = QtGui.QDrag(self) - mime_data = QtCore.QMimeData() - - tag = str(e.text(0)) - tree = e.treeWidget().parent() - knobprop = self.knobprops[tree.uid][tag] - disp = knobprop.display - iscomplex = (disp & gr.DISPOPTCPLX) or (disp & gr.DISPXY) - - if(disp != gr.DISPNULL): - data = "PlotData:::{0}:::{1}".format(tag, iscomplex) - else: - data = "OtherData:::{0}:::{1}".format(tag, iscomplex) - - mime_data.setText(data) - drag.setMimeData(mime_data) - - drop = drag.start() - - def createPlot(self, plot, uid, title): - plot.start() - self.plots[uid].append(plot) - - self.mdiArea.addSubWindow(plot) - plot.setWindowTitle("{0}: {1}".format(title, plot.name())) - self.connect(plot.qwidget(), - QtCore.SIGNAL('destroyed(QObject*)'), - self.destroyPlot) - - # when the plot is updated via drag-and-drop, we need to be - # notified of the new qwidget that's created so we can - # properly destroy it. - plot.plotupdated.connect(self.plotUpdated) - - plot.show() - - def plotUpdated(self, q): - # the plot has been updated with a new qwidget; make sure this - # gets dies to the destroyPlot function. - for i, plots in enumerate(self.plots): - for p in plots: - if(p == q): - #plots.remove(p) - #plots.append(q) - self.connect(q.qwidget(), - QtCore.SIGNAL('destroyed(QObject*)'), - self.destroyPlot) - break - - def destroyPlot(self, obj): - for plots in self.plots: - for p in plots: - if p.qwidget() == obj: - plots.remove(p) - break - - def newPlotConst(self, tag, uid, title="", pmin=None, pmax=None, - scatter=False, stripchart=False): - plot = GrDataPlotterConst(tag, 32e6, pmin, pmax, stripchart) - plot.scatter(scatter) - self.createPlot(plot, uid, title) - - def newPlotF(self, tag, uid, title="", pmin=None, pmax=None, - logy=False, stripchart=False, stem=False): - plot = GrDataPlotterF(tag, 32e6, pmin, pmax, stripchart) - plot.semilogy(logy) - plot.stem(stem) - self.createPlot(plot, uid, title) - - def newPlotC(self, tag, uid, title="", pmin=None, pmax=None, - logy=False, stripchart=False, stem=False): - plot = GrDataPlotterC(tag, 32e6, pmin, pmax, stripchart) - plot.semilogy(logy) - plot.stem(stem) - self.createPlot(plot, uid, title) - - def newPlotPsdF(self, tag, uid, title="", pmin=None, pmax=None): - plot = GrDataPlotterPsdF(tag, 32e6, pmin, pmax) - self.createPlot(plot, uid, title) - - def newPlotPsdC(self, tag, uid, title="", pmin=None, pmax=None): - plot = GrDataPlotterPsdC(tag, 32e6, pmin, pmax) - self.createPlot(plot, uid, title) - - def newPlotRasterF(self, tag, uid, title="", pmin=None, pmax=None): - plot = GrTimeRasterF(tag, 32e6, pmin, pmax) - self.createPlot(plot, uid, title) - - def newPlotRasterB(self, tag, uid, title="", pmin=None, pmax=None): - plot = GrTimeRasterB(tag, 32e6, pmin, pmax) - self.createPlot(plot, uid, title) - - def update(self, knobs, uid): - #sys.stderr.write("KNOB KEYS: {0}\n".format(knobs.keys())) - for plot in self.plots[uid]: - data = [] - for n in plot.knobnames: - d = knobs[n].value - if(type(d) == GNURadio.complex): - d = [d.re, d.im] - - # If it's a byte stream, Python thinks it's a string. - # Unpack and convert to floats for plotting. - if(type(d) == str and n.find('probe2_b') == 0): - d = struct.unpack(len(d)*'b', d) - d = [float(di) for di in d] - - data.append(d) - plot.update(data) - plot.stop() - plot.wait() - plot.start() - - def setActiveSubWindow(self, window): - if window: - self.mdiArea.setActiveSubWindow(window) - - - def createActions(self): - self.newConAct = QtGui.QAction("&New Connection", - self, shortcut=QtGui.QKeySequence.New, - statusTip="Create a new file", triggered=self.newCon) - - self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q", - statusTip="Exit the application", - triggered=QtGui.qApp.closeAllWindows) - - self.closeAct = QtGui.QAction("Cl&ose", self, shortcut="Ctrl+F4", - statusTip="Close the active window", - triggered=self.mdiArea.closeActiveSubWindow) - - self.closeAllAct = QtGui.QAction("Close &All", self, - statusTip="Close all the windows", - triggered=self.mdiArea.closeAllSubWindows) - - self.urAct = QtGui.QAction("Update Rate", self, shortcut="F5", - statusTip="Change Update Rate", - triggered=self.updateRateShow) - - qks = QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_T); - self.tileAct = QtGui.QAction("&Tile", self, - statusTip="Tile the windows", - triggered=self.mdiArea.tileSubWindows, - shortcut=qks) - - qks = QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_C); - self.cascadeAct = QtGui.QAction("&Cascade", self, - statusTip="Cascade the windows", shortcut=qks, - triggered=self.mdiArea.cascadeSubWindows) - - self.nextAct = QtGui.QAction("Ne&xt", self, - shortcut=QtGui.QKeySequence.NextChild, - statusTip="Move the focus to the next window", - triggered=self.mdiArea.activateNextSubWindow) - - self.previousAct = QtGui.QAction("Pre&vious", self, - shortcut=QtGui.QKeySequence.PreviousChild, - statusTip="Move the focus to the previous window", - triggered=self.mdiArea.activatePreviousSubWindow) - - self.separatorAct = QtGui.QAction(self) - self.separatorAct.setSeparator(True) - - self.aboutAct = QtGui.QAction("&About", self, - statusTip="Show the application's About box", - triggered=self.about) - - self.aboutQtAct = QtGui.QAction("About &Qt", self, - statusTip="Show the Qt library's About box", - triggered=QtGui.qApp.aboutQt) - - def createMenus(self): - self.fileMenu = self.menuBar().addMenu("&File") - self.fileMenu.addAction(self.newConAct) - self.fileMenu.addAction(self.urAct) - self.fileMenu.addSeparator() - self.fileMenu.addAction(self.exitAct) - - self.windowMenu = self.menuBar().addMenu("&Window") - self.updateWindowMenu() - self.windowMenu.aboutToShow.connect(self.updateWindowMenu) - - self.menuBar().addSeparator() - - self.helpMenu = self.menuBar().addMenu("&Help") - self.helpMenu.addAction(self.aboutAct) - self.helpMenu.addAction(self.aboutQtAct) - - def updateRateShow(self): - askrate = RateDialog(self.updateRate, self); - if askrate.exec_(): - ur = float(str(askrate.delay.text())); - self.setUpdateRate(ur); - return; - else: - return; - - def createToolBars(self): - self.fileToolBar = self.addToolBar("File") - self.fileToolBar.addAction(self.newConAct) - self.fileToolBar.addAction(self.urAct) - - self.fileToolBar = self.addToolBar("Window") - self.fileToolBar.addAction(self.tileAct) - self.fileToolBar.addAction(self.cascadeAct) - - def createStatusBar(self): - self.statusBar().showMessage("Ready") - - - def activeMdiChild(self): - activeSubWindow = self.mdiArea.activeSubWindow() - if activeSubWindow: - return activeSubWindow.widget() - return None - - def updateMenus(self): - hasMdiChild = (self.activeMdiChild() is not None) - self.closeAct.setEnabled(hasMdiChild) - self.closeAllAct.setEnabled(hasMdiChild) - self.tileAct.setEnabled(hasMdiChild) - self.cascadeAct.setEnabled(hasMdiChild) - self.nextAct.setEnabled(hasMdiChild) - self.previousAct.setEnabled(hasMdiChild) - self.separatorAct.setVisible(hasMdiChild) - - def updateWindowMenu(self): - self.windowMenu.clear() - self.windowMenu.addAction(self.closeAct) - self.windowMenu.addAction(self.closeAllAct) - self.windowMenu.addSeparator() - self.windowMenu.addAction(self.tileAct) - self.windowMenu.addAction(self.cascadeAct) - self.windowMenu.addSeparator() - self.windowMenu.addAction(self.nextAct) - self.windowMenu.addAction(self.previousAct) - self.windowMenu.addAction(self.separatorAct) - - def about(self): - about_info = \ -'''Copyright 2012 Free Software Foundation, Inc.\n -This program is part of GNU Radio.\n -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.\n -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.\n -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.''' - - QtGui.QMessageBox.about(None, "gr-ctrlport-monitor", about_info) - - -class ConInfoDialog(QtGui.QDialog): - def __init__(self, parent=None): - super(ConInfoDialog, self).__init__(parent) - - self.gridLayout = QtGui.QGridLayout(self) - - - self.host = QtGui.QLineEdit(self); - self.port = QtGui.QLineEdit(self); - self.host.setText("localhost"); - self.port.setText("43243"); - - self.buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel) - - self.gridLayout.addWidget(self.host); - self.gridLayout.addWidget(self.port); - self.gridLayout.addWidget(self.buttonBox); - - self.buttonBox.accepted.connect(self.accept) - self.buttonBox.rejected.connect(self.reject) - - - def accept(self): - self.done(1); - - def reject(self): - self.done(0); - - -class UpdaterWindow(QtGui.QDialog): - def __init__(self, key, radio, parent): - QtGui.QDialog.__init__(self, parent) - - self.key = key; - self.radio = radio - - self.resize(300,200) - self.layout = QtGui.QVBoxLayout() - - self.props = radio.properties([key])[key] - info = str(self.props) - - self.infoLabel = QtGui.QLabel(info) - self.layout.addWidget(self.infoLabel) - - # Test here to make sure that a 'set' function exists - try: - a = radio.set(radio.get([key])) - has_set = True - except Ice.UnknownException: - has_set = False - - if(has_set is False): - self.cancelButton = QtGui.QPushButton("Ok") - self.cancelButton.connect(self.cancelButton, QtCore.SIGNAL('clicked()'), self.reject) - - self.buttonlayout = QtGui.QHBoxLayout() - self.buttonlayout.addWidget(self.cancelButton) - self.layout.addLayout(self.buttonlayout) - - else: # we have a set function - self.textInput = QtGui.QLineEdit() - self.layout.addWidget(self.textInput) - - self.applyButton = QtGui.QPushButton("Apply") - self.setButton = QtGui.QPushButton("OK") - self.cancelButton = QtGui.QPushButton("Cancel") - - rv = radio.get([key]) - val = rv[key].value - if(type(val) == GNURadio.complex): - val = val.re + val.im*1j - - self.textInput.setText(str(val)) - self.sv = rv[key] - - self.applyButton.connect(self.applyButton, QtCore.SIGNAL('clicked()'), self._apply) - self.setButton.connect(self.setButton, QtCore.SIGNAL('clicked()'), self._set) - self.cancelButton.connect(self.cancelButton, QtCore.SIGNAL('clicked()'), self.reject) - - self.is_num = ((type(self.sv.value)==float) or (type(self.sv.value)==int)) - if(self.is_num): - self.sliderlayout = QtGui.QHBoxLayout() - - self.slider = QtGui.QSlider(QtCore.Qt.Horizontal) - - self.sliderlayout.addWidget(QtGui.QLabel(str(self.props.min.value))) - self.sliderlayout.addWidget(self.slider) - self.sliderlayout.addWidget(QtGui.QLabel(str(self.props.max.value))) - - self.steps = 10000 - self.valspan = self.props.max.value - self.props.min.value - - self.slider.setRange(0, 10000) - self._set_slider_value(self.sv.value) - - self.connect(self.slider, QtCore.SIGNAL("sliderReleased()"), self._slide) - - self.layout.addLayout(self.sliderlayout) - else: - self._set_slider_value = None - - self.buttonlayout = QtGui.QHBoxLayout() - self.buttonlayout.addWidget(self.applyButton) - self.buttonlayout.addWidget(self.setButton) - self.buttonlayout.addWidget(self.cancelButton) - self.layout.addLayout(self.buttonlayout) - - # set layout and go... - self.setLayout(self.layout) - - def _set_slider_value(self, val): - self.slider.setValue(self.steps*(val-self.props.min.value)/self.valspan) - - def _slide(self): - val = (self.slider.value()*self.valspan + self.props.min.value)/float(self.steps) - self.textInput.setText(str(val)) - - def _apply(self): - if(type(self.sv.value) == str): - val = str(self.textInput.text()) - elif(type(self.sv.value) == int): - val = int(round(float(self.textInput.text()))) - elif(type(self.sv.value) == float): - val = float(self.textInput.text()) - elif(type(self.sv.value) == GNURadio.complex): - t = str(self.textInput.text()) - t = complex(t.strip("(").strip(")").replace(" ", "")) - val = GNURadio.complex() - val.re = t.real - val.im = t.imag - else: - sys.stderr.write("set type not supported! ({0})\n".format(type(self.sv.value))) - return - - self.sv.value = val - km = {} - km[self.key] = self.sv - self.radio.set(km) - if self._set_slider_value: - self._set_slider_value(self.sv.value) - - def _set(self): - self._apply() - self.done(0) - - -class MForm(QtGui.QWidget): - def update(self): - try: - st = time.time(); - knobs = self.radio.get([]); - ft = time.time(); - latency = ft-st; - self.parent.statusBar().showMessage("Current GNU Radio Control Port Query Latency: %f ms"%(latency*1000)) - - except Exception, e: - sys.stderr.write("ctrlport-monitor: radio.get threw exception ({0}).\n".format(e)) - if(type(self.parent) is MAINWindow): - # Find window of connection - remove = [] - for p in self.parent.mdiArea.subWindowList(): - if self.parent.conns[self.uid] == p.widget(): - remove.append(p) - - # Find any subplot windows of connection - for p in self.parent.mdiArea.subWindowList(): - for plot in self.parent.plots[self.uid]: - if plot.qwidget() == p.widget(): - remove.append(p) - - # Clean up local references to these - self.parent.conns.remove(self.parent.conns[self.uid]) - self.parent.plots.remove(self.parent.plots[self.uid]) - - # Remove subwindows for connection and plots - for r in remove: - self.parent.mdiArea.removeSubWindow(r) - - # Clean up self - self.close() - else: - sys.exit(1) - return - - tableitems = knobs.keys() - - #UPDATE TABLE: - try: - self.table.updateItems(knobs, self.knobprops) - except: - self.knobprops = self.radio.properties([]) - - #UPDATE PLOTS - self.parent.update(knobs, self.uid) - - - def __init__(self, radio=None, port=None, uid=0, updateRate=2000, parent=None): - - super(MForm, self).__init__() - - if(radio == None or port == None): - askinfo = ConInfoDialog(self); - if askinfo.exec_(): - host = str(askinfo.host.text()); - port = str(askinfo.port.text()); - radio = parent.interface.getRadio(host, port) - else: - self.radio = None - return - - self.uid = uid - self.parent = parent - self.horizontalLayout = QtGui.QVBoxLayout(self) - self.gridLayout = QtGui.QGridLayout() - - self.radio = radio - self.knobprops = self.radio.properties([]) - self.parent.knobprops.append(self.knobprops) - self.resize(775,500) - self.timer = QtCore.QTimer() - self.constupdatediv = 0 - self.tableupdatediv = 0 - plotsize=250 - - # make table - self.table = GrDataPlotterValueTable(uid, self, 0, 0, 400, 200) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) - self.table.treeWidget.setSizePolicy(sizePolicy) - self.table.treeWidget.setEditTriggers(QtGui.QAbstractItemView.EditKeyPressed) - self.table.treeWidget.setSortingEnabled(True) - self.table.treeWidget.setDragEnabled(True) - - # add things to layouts - self.horizontalLayout.addWidget(self.table.treeWidget) - - # set up timer - self.connect(self.timer, QtCore.SIGNAL('timeout()'), self.update) - self.updateRate = updateRate; - self.timer.start(self.updateRate) - - # set up context menu .. - self.table.treeWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) - self.table.treeWidget.customContextMenuRequested.connect(self.openMenu) - - # Set up double-click to launch default plotter - self.connect(self.table.treeWidget, - QtCore.SIGNAL('itemDoubleClicked(QTreeWidgetItem*, int)'), - self.parent.newSub); - - # Allow drag/drop event from table item to plotter - self.connect(self.table.treeWidget, - QtCore.SIGNAL('itemPressed(QTreeWidgetItem*, int)'), - self.parent.startDrag) - - def openMenu(self, pos): - index = self.table.treeWidget.selectedIndexes() - item = self.table.treeWidget.itemFromIndex(index[0]) - itemname = str(item.text(0)) - self.parent.propertiesMenu(itemname, self.radio, self.uid) - - -def get_minmax(p): - pmin = p.min.value - pmax = p.max.value - - # Find min/max or real or imag for GNURadio::complex - if(type(pmin) == GNURadio.complex): - pmin = min(pmin.re, pmin.im) - if(type(pmax) == GNURadio.complex): - pmax = max(pmax.re, pmax.im) - - # If it's a byte stream, Python thinks it's a string. - if(type(pmin) == str): - pmin = struct.unpack('b', pmin)[0] - if(type(pmax) == str): - pmax = struct.unpack('b', pmax)[0] - - if pmin == []: - pmin = None - else: - pmin = 1.1*float(pmin) - if pmax == []: - pmax = None - else: - pmax = 1.1*float(pmax) - - return pmin, pmax - -class MyClient(IceRadioClient): - def __init__(self): - IceRadioClient.__init__(self, MAINWindow) - -sys.exit(MyClient().main(sys.argv)) diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitor b/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitor deleted file mode 100755 index 612eb66063..0000000000 --- a/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitor +++ /dev/null @@ -1,591 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2012-2013 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. -# - -from gnuradio import gr, ctrlport - -from PyQt4 import QtCore,Qt,Qwt5 -import PyQt4.QtGui as QtGui -import sys, time, re, pprint -import itertools -import scipy - -import Ice -from gnuradio.ctrlport.IceRadioClient import * -from gnuradio.ctrlport.GrDataPlotter import * -from gnuradio.ctrlport import GNURadio - -class MAINWindow(QtGui.QMainWindow): - def minimumSizeHint(self): - return QtGui.QSize(800,600) - - def __init__(self, radio, port, interface): - - super(MAINWindow, self).__init__() - self.conns = [] - self.plots = [] - self.knobprops = [] - self.interface = interface - - self.mdiArea = QtGui.QMdiArea() - self.mdiArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) - self.mdiArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) - self.setCentralWidget(self.mdiArea) - - self.mdiArea.subWindowActivated.connect(self.updateMenus) - self.windowMapper = QtCore.QSignalMapper(self) - self.windowMapper.mapped[QtGui.QWidget].connect(self.setActiveSubWindow) - - self.createActions() - self.createMenus() - self.createToolBars() - self.createStatusBar() - self.updateMenus() - - self.setWindowTitle("GNU Radio Performance Monitor") - self.setUnifiedTitleAndToolBarOnMac(True) - - self.newCon(radio, port) - icon = QtGui.QIcon(ctrlport.__path__[0] + "/icon.png" ) - self.setWindowIcon(icon) - - def newCon(self, radio=None, port=None): - child = MForm(radio, port, len(self.conns), self) - if(child.radio is not None): - child.setWindowTitle(str(child.radio)) - horizbar = QtGui.QScrollArea() - horizbar.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) - horizbar.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) - horizbar.setWidget(child) - self.mdiArea.addSubWindow(horizbar) - self.mdiArea.currentSubWindow().showMaximized() - - self.conns.append(child) - self.plots.append([]) - - def newUpdater(self, key, radio): - updater = UpdaterWindow(key, radio, None) - updater.setWindowTitle("Updater: " + key) - updater.setModal(False) - updater.exec_() - - def update(self, knobs, uid): - #sys.stderr.write("KNOB KEYS: {0}\n".format(knobs.keys())) - for plot in self.plots[uid]: - data = knobs[plot.name()].value - plot.update(data) - plot.stop() - plot.wait() - plot.start() - - def setActiveSubWindow(self, window): - if window: - self.mdiArea.setActiveSubWindow(window) - - - def createActions(self): - self.newConAct = QtGui.QAction("&New Connection", - self, shortcut=QtGui.QKeySequence.New, - statusTip="Create a new file", triggered=self.newCon) - - self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q", - statusTip="Exit the application", - triggered=QtGui.qApp.closeAllWindows) - - self.closeAct = QtGui.QAction("Cl&ose", self, shortcut="Ctrl+F4", - statusTip="Close the active window", - triggered=self.mdiArea.closeActiveSubWindow) - - self.closeAllAct = QtGui.QAction("Close &All", self, - statusTip="Close all the windows", - triggered=self.mdiArea.closeAllSubWindows) - - - qks = QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_T); - self.tileAct = QtGui.QAction("&Tile", self, - statusTip="Tile the windows", - triggered=self.mdiArea.tileSubWindows, - shortcut=qks) - - qks = QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_C); - self.cascadeAct = QtGui.QAction("&Cascade", self, - statusTip="Cascade the windows", shortcut=qks, - triggered=self.mdiArea.cascadeSubWindows) - - self.nextAct = QtGui.QAction("Ne&xt", self, - shortcut=QtGui.QKeySequence.NextChild, - statusTip="Move the focus to the next window", - triggered=self.mdiArea.activateNextSubWindow) - - self.previousAct = QtGui.QAction("Pre&vious", self, - shortcut=QtGui.QKeySequence.PreviousChild, - statusTip="Move the focus to the previous window", - triggered=self.mdiArea.activatePreviousSubWindow) - - self.separatorAct = QtGui.QAction(self) - self.separatorAct.setSeparator(True) - - self.aboutAct = QtGui.QAction("&About", self, - statusTip="Show the application's About box", - triggered=self.about) - - self.aboutQtAct = QtGui.QAction("About &Qt", self, - statusTip="Show the Qt library's About box", - triggered=QtGui.qApp.aboutQt) - - def createMenus(self): - self.fileMenu = self.menuBar().addMenu("&File") - self.fileMenu.addAction(self.newConAct) - self.fileMenu.addSeparator() - self.fileMenu.addAction(self.exitAct) - - self.windowMenu = self.menuBar().addMenu("&Window") - self.updateWindowMenu() - self.windowMenu.aboutToShow.connect(self.updateWindowMenu) - - self.menuBar().addSeparator() - - self.helpMenu = self.menuBar().addMenu("&Help") - self.helpMenu.addAction(self.aboutAct) - self.helpMenu.addAction(self.aboutQtAct) - - def createToolBars(self): - self.fileToolBar = self.addToolBar("File") - self.fileToolBar.addAction(self.newConAct) - - self.fileToolBar = self.addToolBar("Window") - self.fileToolBar.addAction(self.tileAct) - self.fileToolBar.addAction(self.cascadeAct) - - def createStatusBar(self): - self.statusBar().showMessage("Ready") - - - def activeMdiChild(self): - activeSubWindow = self.mdiArea.activeSubWindow() - if activeSubWindow: - return activeSubWindow.widget() - return None - - def updateMenus(self): - hasMdiChild = (self.activeMdiChild() is not None) - self.closeAct.setEnabled(hasMdiChild) - self.closeAllAct.setEnabled(hasMdiChild) - self.tileAct.setEnabled(hasMdiChild) - self.cascadeAct.setEnabled(hasMdiChild) - self.nextAct.setEnabled(hasMdiChild) - self.previousAct.setEnabled(hasMdiChild) - self.separatorAct.setVisible(hasMdiChild) - - def updateWindowMenu(self): - self.windowMenu.clear() - self.windowMenu.addAction(self.closeAct) - self.windowMenu.addAction(self.closeAllAct) - self.windowMenu.addSeparator() - self.windowMenu.addAction(self.tileAct) - self.windowMenu.addAction(self.cascadeAct) - self.windowMenu.addSeparator() - self.windowMenu.addAction(self.nextAct) - self.windowMenu.addAction(self.previousAct) - self.windowMenu.addAction(self.separatorAct) - - def about(self): - about_info = \ -'''Copyright 2012 Free Software Foundation, Inc.\n -This program is part of GNU Radio.\n -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.\n -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.\n -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.''' - - QtGui.QMessageBox.about(None, "gr-ctrlport-monitor", about_info) - - -class ConInfoDialog(QtGui.QDialog): - def __init__(self, parent=None): - super(ConInfoDialog, self).__init__(parent) - - self.gridLayout = QtGui.QGridLayout(self) - - - self.host = QtGui.QLineEdit(self); - self.port = QtGui.QLineEdit(self); - self.host.setText("localhost"); - self.port.setText("43243"); - - self.buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | - QtGui.QDialogButtonBox.Cancel) - - self.gridLayout.addWidget(self.host); - self.gridLayout.addWidget(self.port); - self.gridLayout.addWidget(self.buttonBox); - - self.buttonBox.accepted.connect(self.accept) - self.buttonBox.rejected.connect(self.reject) - - - def accept(self): - self.done(1); - - def reject(self): - self.done(0); - - -class UpdaterWindow(QtGui.QDialog): - def __init__(self, key, radio, parent): - QtGui.QDialog.__init__(self, parent) - - self.key = key; - self.radio = radio - - self.resize(300,200) - self.layout = QtGui.QVBoxLayout() - - self.props = radio.properties([key])[key] - info = str(self.props) - - self.infoLabel = QtGui.QLabel(info) - self.layout.addWidget(self.infoLabel) - - self.cancelButton = QtGui.QPushButton("Ok") - self.cancelButton.connect(self.cancelButton, QtCore.SIGNAL('clicked()'), self.reject) - - self.buttonlayout = QtGui.QHBoxLayout() - self.buttonlayout.addWidget(self.cancelButton) - self.layout.addLayout(self.buttonlayout) - - # set layout and go... - self.setLayout(self.layout) - - def _set_slider_value(self, val): - self.slider.setValue(self.steps*(val-self.props.min.value)/self.valspan) - - def _slide(self): - val = (self.slider.value()*self.valspan + self.props.min.value)/float(self.steps) - self.textInput.setText(str(val)) - - def _apply(self): - if(type(self.sv.value) == str): - val = str(self.textInput.text()) - elif(type(self.sv.value) == int): - val = int(round(float(self.textInput.text()))) - elif(type(self.sv.value) == float): - val = float(self.textInput.text()) - else: - sys.stderr.write("set type not supported! ({0})\n".format(type(self.sv.value))) - sys.exit(-1) - - self.sv.value = val - km = {} - km[self.key] = self.sv - self.radio.set(km) - self._set_slider_value(self.sv.value) - - def _set(self): - self._apply() - self.done(0) - - -def build_edge_graph(sources, sinks, edges): - ''' - Starting from the sources, walks through all of the edges to find - the next connected block. The output is stored in 'allblocks' - where each row starts with a source and follows one path down - until it terminates in either a sink or as an input to a block - that is part of another chain. - ''' - def find_edge(src, sinks, edges, row, col): - #print "\n\nAll blocks: " - #printer.pprint(allblocks) - #print "\nLooking for: ", src - - src0 = src.split(":")[0] - if(src0 in sinks): - if(len(allblocks) <= row): - allblocks.append(col*[""]) - allblocks[row].append(src) - return row+1 - - for edge in edges: - if(re.match(src0, edge)): - s = edge.split("->")[0] - b = edge.split("->")[1] - if(len(allblocks) <= row): - allblocks.append(col*[""]) - allblocks[row].append(s) - #print "Source: {0} Sink: {1}".format(s, b) - row = find_edge(b, sinks, edges, row, col+1) - return row - - # Recursively get all edges as a matrix of source->sink - n = 0 - allblocks = [] - for src in sources: - n = find_edge(src, sinks, edges, n, 0) - - # Sort by longest list - allblocks = sorted(allblocks, key=len) - allblocks.reverse() - - # Make all rows same length by padding '' in front of sort rows - maxrowlen = len(allblocks[0]) - for i,a in enumerate(allblocks): - rowlen = len(a) - allblocks[i] = (maxrowlen-rowlen)*[''] + a - - # Dedup rows - allblocks = sorted(allblocks) - allblocks = list(k for k,_ in itertools.groupby(allblocks)) - allblocks.reverse() - - return allblocks - - -class MForm(QtGui.QWidget): - def update(self): - try: - st = time.time() - knobs = self.radio.get([b[0] for b in self.block_dict]) - - ft = time.time() - latency = ft-st - self.parent.statusBar().showMessage("Current GNU Radio Control Port Query Latency: %f ms"%\ - (latency*1000)) - - except Exception, e: - sys.stderr.write("ctrlport-monitor: radio.get threw exception ({0}).\n".format(e)) - if(type(self.parent) is MAINWindow): - # Find window of connection - remove = [] - for p in self.parent.mdiArea.subWindowList(): - if self.parent.conns[self.uid] == p.widget(): - remove.append(p) - - # Find any subplot windows of connection - for p in self.parent.mdiArea.subWindowList(): - for plot in self.parent.plots[self.uid]: - if plot.qwidget() == p.widget(): - remove.append(p) - - # Clean up local references to these - self.parent.conns.remove(self.parent.conns[self.uid]) - self.parent.plots.remove(self.parent.plots[self.uid]) - - # Remove subwindows for connection and plots - for r in remove: - self.parent.mdiArea.removeSubWindow(r) - - # Clean up self - self.close() - else: - sys.exit(1) - return - - #UPDATE TABLE: - self.updateItems(knobs) - - #UPDATE PLOTS - self.parent.update(knobs, self.uid) - - def updateItems(self, knobs): - for b in self.block_dict: - if(knobs[b[0]].ice_id.im_class == GNURadio.KnobVecF): - b[1].setText("{0:.4f}".format(knobs[b[0]].value[b[2]])) - else: - b[1].setText("{0:.4f}".format(knobs[b[0]].value)) - - def __init__(self, radio=None, port=None, uid=0, parent=None): - - super(MForm, self).__init__() - - if(radio == None or port == None): - askinfo = ConInfoDialog(self); - if askinfo.exec_(): - host = str(askinfo.host.text()); - port = str(askinfo.port.text()); - radio = parent.interface.getRadio(host, port) - else: - self.radio = None - return - - self.uid = uid - self.parent = parent - self.layout = QtGui.QGridLayout(self) - self.layout.setSizeConstraint(QtGui.QLayout.SetFixedSize) - - self.radio = radio - self.knobprops = self.radio.properties([]) - self.parent.knobprops.append(self.knobprops) - self.resize(775,500) - self.timer = QtCore.QTimer() - self.constupdatediv = 0 - self.tableupdatediv = 0 - plotsize=250 - - - # Set up the graph of blocks - input_name = lambda x: x+"::avg input % full" - output_name = lambda x: x+"::avg output % full" - wtime_name = lambda x: x+"::avg work time" - nout_name = lambda x: x+"::avg noutput_items" - nprod_name = lambda x: x+"::avg nproduced" - - tmplist = [] - knobs = self.radio.get([]) - edgelist = None - for k in knobs: - propname = k.split("::") - blockname = propname[0] - keyname = propname[1] - if(keyname == "edge list"): - edgelist = knobs[k].value - elif(blockname not in tmplist): - # only take gr_blocks (no hier_block2) - if(knobs.has_key(input_name(blockname))): - tmplist.append(blockname) - - if not edgelist: - sys.stderr.write("Could not find list of edges from flowgraph. " + \ - "Make sure the option 'edges_list' is enabled " + \ - "in the ControlPort configuration.\n\n") - sys.exit(1) - - edges = edgelist.split("\n")[0:-1] - producers = [] - consumers = [] - for e in edges: - _e = e.split("->") - producers.append(_e[0]) - consumers.append(_e[1]) - - # Get producers and consumers as sets while ignoring the - # ports. - prods = set(map(lambda x: x.split(":")[0], producers)) - cons = set(map(lambda x: x.split(":")[0], consumers)) - - # Split out all blocks, sources, and sinks based on how they - # appear as consumers and/or producers. - blocks = prods.intersection(cons) - sources = prods.difference(blocks) - sinks = cons.difference(blocks) - - nblocks = len(prods) + len(cons) - - allblocks = build_edge_graph(sources, sinks, edges) - nrows = len(allblocks) - ncols = len(allblocks[0]) - - col_width = 120 - - self.block_dict = [] - - for row, blockrow in enumerate(allblocks): - for col, block in enumerate(blockrow): - if(block == ''): - continue - - bgroup = QtGui.QGroupBox(block) - playout = QtGui.QFormLayout() - bgroup.setLayout(playout) - self.layout.addWidget(bgroup, row, 2*col) - - blockname = block.split(":")[0] - - name = wtime_name(blockname) - wtime = knobs[name].value - newtime = QtGui.QLineEdit() - newtime.setMinimumWidth(col_width) - newtime.setText("{0:.4f}".format(wtime)) - self.block_dict.append((name, newtime)) - - name = nout_name(blockname) - nout = knobs[name].value - newnout = QtGui.QLineEdit() - newnout.setText("{0:.4f}".format(nout)) - newnout.setMinimumWidth(col_width) - self.block_dict.append((name, newnout)) - - name = nprod_name(blockname) - nprod = knobs[name].value - newnprod = QtGui.QLineEdit() - newnprod.setMinimumWidth(col_width) - newnprod.setText("{0:.4f}".format(nprod)) - self.block_dict.append((name, newnprod)) - - playout.addRow("Work time", newtime) - playout.addRow("noutput_items", newnout) - playout.addRow("nproduced", newnprod) - - if blockname in blocks or blockname in sources: - # Add a buffer between blocks - buffgroup = QtGui.QGroupBox("Buffer") - bufflayout = QtGui.QFormLayout() - buffgroup.setLayout(bufflayout) - self.layout.addWidget(buffgroup, row, 2*col+1) - - i = int(block.split(":")[1]) - name = output_name(blockname) - obuff = knobs[name].value - for i,o in enumerate(obuff): - newobuff = QtGui.QLineEdit() - newobuff.setMinimumWidth(col_width) - newobuff.setText("{0:.4f}".format(o)) - self.block_dict.append((name, newobuff, i)) - bufflayout.addRow("Out Buffer {0}".format(i), - newobuff) - - if blockname in blocks or blockname in sinks: - item = self.layout.itemAtPosition(row, 2*col-1) - if(item): - buffgroup = item.widget() - bufflayout = buffgroup.layout() - else: - buffgroup = QtGui.QGroupBox("Buffer") - bufflayout = QtGui.QFormLayout() - buffgroup.setLayout(bufflayout) - self.layout.addWidget(buffgroup, row, 2*col-1) - - i = int(block.split(":")[1]) - name = input_name(blockname) - ibuff = knobs[name].value[i] - newibuff = QtGui.QLineEdit() - newibuff.setMinimumWidth(col_width) - newibuff.setText("{0:.4f}".format(ibuff)) - self.block_dict.append((name, newibuff, i)) - bufflayout.addRow("In Buffer {0}".format(i), - newibuff) - - # set up timer - self.timer = QtCore.QTimer() - self.connect(self.timer, QtCore.SIGNAL('timeout()'), self.update) - self.timer.start(1000) - - def openMenu(self, pos): - index = self.table.treeWidget.selectedIndexes() - item = self.table.treeWidget.itemFromIndex(index[0]) - itemname = str(item.text(0)) - self.parent.propertiesMenu(itemname, self.radio, self.uid) - - -class MyClient(IceRadioClient): - def __init__(self): - IceRadioClient.__init__(self, MAINWindow) - -sys.exit(MyClient().main(sys.argv)) diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx b/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx deleted file mode 100755 index 369922cbbf..0000000000 --- a/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx +++ /dev/null @@ -1,849 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2012-2013 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. -# - -import random,math,operator -import networkx as nx; -import matplotlib -matplotlib.use("Qt4Agg"); -import matplotlib.pyplot as plt -from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas -from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar -from matplotlib.figure import Figure - -from gnuradio import gr, ctrlport - -from PyQt4 import QtCore,Qt,Qwt5 -import PyQt4.QtGui as QtGui -import sys, time, re, pprint -import itertools - -import Ice -from gnuradio.ctrlport.IceRadioClient import * -from gnuradio.ctrlport.GrDataPlotter import * -from gnuradio.ctrlport import GNURadio - -class MAINWindow(QtGui.QMainWindow): - def minimumSizeHint(self): - return QtGui.QSize(800,600) - - def __init__(self, radio, port, interface): - - super(MAINWindow, self).__init__() - self.conns = [] - self.plots = [] - self.knobprops = [] - self.interface = interface - - self.mdiArea = QtGui.QMdiArea() - self.mdiArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) - self.mdiArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) - self.setCentralWidget(self.mdiArea) - - self.mdiArea.subWindowActivated.connect(self.updateMenus) - self.windowMapper = QtCore.QSignalMapper(self) - self.windowMapper.mapped[QtGui.QWidget].connect(self.setActiveSubWindow) - - self.createActions() - self.createMenus() - self.createToolBars() - self.createStatusBar() - self.updateMenus() - - self.setWindowTitle("GNU Radio Performance Monitor") - self.setUnifiedTitleAndToolBarOnMac(True) - - self.newCon(radio, port) - icon = QtGui.QIcon(ctrlport.__path__[0] + "/icon.png" ) - self.setWindowIcon(icon) - - def newSubWindow(self, window, title): - child = window; - child.setWindowTitle(title) - self.mdiArea.addSubWindow(child) - self.conns.append(child) - child.show(); - self.mdiArea.currentSubWindow().showMaximized() - - - def newCon(self, radio=None, port=None): - child = MForm(radio, port, len(self.conns), self) - if(child.radio is not None): - child.setWindowTitle(str(child.radio)) -# horizbar = QtGui.QScrollArea() -# horizbar.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) -# horizbar.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) -# horizbar.setWidget(child) -# self.mdiArea.addSubWindow(horizbar) - self.mdiArea.addSubWindow(child) - self.mdiArea.currentSubWindow().showMaximized() - - self.conns.append(child) - self.plots.append([]) - - def update(self, knobs, uid): - #sys.stderr.write("KNOB KEYS: {0}\n".format(knobs.keys())) - for plot in self.plots[uid]: - data = knobs[plot.name()].value - plot.update(data) - plot.stop() - plot.wait() - plot.start() - - def setActiveSubWindow(self, window): - if window: - self.mdiArea.setActiveSubWindow(window) - - - def createActions(self): - self.newConAct = QtGui.QAction("&New Connection", - self, shortcut=QtGui.QKeySequence.New, - statusTip="Create a new file", triggered=self.newCon) - - self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q", - statusTip="Exit the application", - triggered=QtGui.qApp.closeAllWindows) - - self.closeAct = QtGui.QAction("Cl&ose", self, shortcut="Ctrl+F4", - statusTip="Close the active window", - triggered=self.mdiArea.closeActiveSubWindow) - - self.closeAllAct = QtGui.QAction("Close &All", self, - statusTip="Close all the windows", - triggered=self.mdiArea.closeAllSubWindows) - - qks = QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_T); - self.tileAct = QtGui.QAction("&Tile", self, - statusTip="Tile the windows", - triggered=self.mdiArea.tileSubWindows, - shortcut=qks) - - qks = QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_C); - self.cascadeAct = QtGui.QAction("&Cascade", self, - statusTip="Cascade the windows", shortcut=qks, - triggered=self.mdiArea.cascadeSubWindows) - - self.nextAct = QtGui.QAction("Ne&xt", self, - shortcut=QtGui.QKeySequence.NextChild, - statusTip="Move the focus to the next window", - triggered=self.mdiArea.activateNextSubWindow) - - self.previousAct = QtGui.QAction("Pre&vious", self, - shortcut=QtGui.QKeySequence.PreviousChild, - statusTip="Move the focus to the previous window", - triggered=self.mdiArea.activatePreviousSubWindow) - - self.separatorAct = QtGui.QAction(self) - self.separatorAct.setSeparator(True) - - self.aboutAct = QtGui.QAction("&About", self, - statusTip="Show the application's About box", - triggered=self.about) - - self.aboutQtAct = QtGui.QAction("About &Qt", self, - statusTip="Show the Qt library's About box", - triggered=QtGui.qApp.aboutQt) - - def createMenus(self): - self.fileMenu = self.menuBar().addMenu("&File") - self.fileMenu.addAction(self.newConAct) - self.fileMenu.addSeparator() - self.fileMenu.addAction(self.exitAct) - - self.windowMenu = self.menuBar().addMenu("&Window") - self.updateWindowMenu() - self.windowMenu.aboutToShow.connect(self.updateWindowMenu) - - self.menuBar().addSeparator() - - self.helpMenu = self.menuBar().addMenu("&Help") - self.helpMenu.addAction(self.aboutAct) - self.helpMenu.addAction(self.aboutQtAct) - - def createToolBars(self): - self.fileToolBar = self.addToolBar("File") - self.fileToolBar.addAction(self.newConAct) - - self.fileToolBar = self.addToolBar("Window") - self.fileToolBar.addAction(self.tileAct) - self.fileToolBar.addAction(self.cascadeAct) - - def createStatusBar(self): - self.statusBar().showMessage("Ready") - - - def activeMdiChild(self): - activeSubWindow = self.mdiArea.activeSubWindow() - if activeSubWindow: - return activeSubWindow.widget() - return None - - def updateMenus(self): - hasMdiChild = (self.activeMdiChild() is not None) - self.closeAct.setEnabled(hasMdiChild) - self.closeAllAct.setEnabled(hasMdiChild) - self.tileAct.setEnabled(hasMdiChild) - self.cascadeAct.setEnabled(hasMdiChild) - self.nextAct.setEnabled(hasMdiChild) - self.previousAct.setEnabled(hasMdiChild) - self.separatorAct.setVisible(hasMdiChild) - - def updateWindowMenu(self): - self.windowMenu.clear() - self.windowMenu.addAction(self.closeAct) - self.windowMenu.addAction(self.closeAllAct) - self.windowMenu.addSeparator() - self.windowMenu.addAction(self.tileAct) - self.windowMenu.addAction(self.cascadeAct) - self.windowMenu.addSeparator() - self.windowMenu.addAction(self.nextAct) - self.windowMenu.addAction(self.previousAct) - self.windowMenu.addAction(self.separatorAct) - - def about(self): - about_info = \ -'''Copyright 2012 Free Software Foundation, Inc.\n -This program is part of GNU Radio.\n -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.\n -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.\n -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.''' - - QtGui.QMessageBox.about(None, "gr-ctrlport-monitor", about_info) - - -class ConInfoDialog(QtGui.QDialog): - def __init__(self, parent=None): - super(ConInfoDialog, self).__init__(parent) - - self.gridLayout = QtGui.QGridLayout(self) - - - self.host = QtGui.QLineEdit(self); - self.port = QtGui.QLineEdit(self); - self.host.setText("localhost"); - self.port.setText("43243"); - - self.buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | - QtGui.QDialogButtonBox.Cancel) - - self.gridLayout.addWidget(self.host); - self.gridLayout.addWidget(self.port); - self.gridLayout.addWidget(self.buttonBox); - - self.buttonBox.accepted.connect(self.accept) - self.buttonBox.rejected.connect(self.reject) - - - def accept(self): - self.done(1); - - def reject(self): - self.done(0); - - -class DataTable(QtGui.QWidget): - def update(self): - print "update" - - def __init__(self, radio, G): - QtGui.QWidget.__init__( self) - - self.layout = QtGui.QVBoxLayout(self); - self.hlayout = QtGui.QHBoxLayout(); - self.layout.addLayout(self.hlayout); - - self.G = G; - self.radio = radio; - - self._keymap = None - - # Create a combobox to set the type of statistic we want. - self._statistic = "Instantaneous" - self._statistics_table = {"Instantaneous": "", - "Average": "avg ", - "Variance": "var "} - self.stattype = QtGui.QComboBox() - self.stattype.addItem("Instantaneous") - self.stattype.addItem("Average") - self.stattype.addItem("Variance") - self.stattype.setMaximumWidth(200) - self.hlayout.addWidget(self.stattype); - self.stattype.currentIndexChanged.connect(self.stat_changed) - - # Create a checkbox to toggle sorting of graphs - self._sort = False - self.checksort = QtGui.QCheckBox("Sort") - self.checksort.setCheckState(self._sort) - self.hlayout.addWidget(self.checksort); - self.checksort.stateChanged.connect(self.checksort_changed) - - # set up table - self.perfTable = Qt.QTableWidget(); - self.perfTable.setColumnCount(2) - self.perfTable.verticalHeader().hide(); - self.perfTable.setHorizontalHeaderLabels( ["Block Name", "Percent Runtime"] ); - self.perfTable.horizontalHeader().setStretchLastSection(True); - self.perfTable.setSortingEnabled(True) - nodes = self.G.nodes(data=True) - - # set up plot - self.f = plt.figure(figsize=(10,8), dpi=90) - self.sp = self.f.add_subplot(111); - self.sp.autoscale_view(True,True,True); - self.sp.set_autoscale_on(True) - self.canvas = FigureCanvas(self.f) - - # set up tabs - self.tabber = QtGui.QTabWidget(); - self.layout.addWidget(self.tabber); - self.tabber.addTab(self.perfTable,"Table View"); - self.tabber.addTab(self.canvas, "Graph View"); - - # set up timer - self.timer = QtCore.QTimer() - self.connect(self.timer, QtCore.SIGNAL('timeout()'), self.update) - self.timer.start(500) - - for i in range(0,len(nodes)): - self.perfTable.setItem( - i,0, - Qt.QTableWidgetItem(nodes[i][0])) - - def table_update(self,data): - for k in data.keys(): - weight = data[k] - existing = self.perfTable.findItems(str(k),QtCore.Qt.MatchFixedString) - if(len(existing) == 0): - i = self.perfTable.rowCount(); - self.perfTable.setRowCount( i+1) - self.perfTable.setItem( i,0, Qt.QTableWidgetItem(str(k))) - self.perfTable.setItem( i,1, Qt.QTableWidgetItem(str(weight))) - else: - self.perfTable.setItem( self.perfTable.row(existing[0]),1, Qt.QTableWidgetItem(str(weight))) - - def stat_changed(self, index): - self._statistic = str(self.stattype.currentText()) - - def checksort_changed(self, state): - self._sort = state > 0 - -class DataTableBuffers(DataTable): - def __init__(self, radio, G): - DataTable.__init__(self,radio,G) - self.perfTable.setHorizontalHeaderLabels( ["Block Name", "Percent Buffer Full"] ); - - def update(self): - nodes = self.G.nodes(); - - # get buffer fullness for all blocks - kl = map(lambda x: "%s::%soutput %% full" % \ - (x, self._statistics_table[self._statistic]), - nodes); - buf_knobs = self.radio.get(kl) - - # strip values out of ctrlport response - buffer_fullness = dict(zip( - map(lambda x: x.split("::")[0], buf_knobs.keys()), - map(lambda x: x.value, buf_knobs.values()))) - - blockport_fullness = {} - for blk in buffer_fullness: - for port in range(0,len(buffer_fullness[blk])): - blockport_fullness["%s:%d"%(blk,port)] = buffer_fullness[blk][port]; - - self.table_update(blockport_fullness); - - if(self._sort): - sorted_fullness = sorted(blockport_fullness.iteritems(), key=operator.itemgetter(1)) - self._keymap = map(operator.itemgetter(0), sorted_fullness) - else: - if self._keymap: - sorted_fullness = len(self._keymap)*['',] - for b in blockport_fullness: - sorted_fullness[self._keymap.index(b)] = (b, blockport_fullness[b]) - else: - sorted_fullness = blockport_fullness.items() - - self.sp.clear(); - plt.figure(self.f.number) - plt.subplot(111); - self.sp.bar(range(0,len(sorted_fullness)), map(lambda x: x[1], sorted_fullness), - alpha=0.5) - self.sp.set_ylabel("% Buffers Full"); - self.sp.set_xticks( map(lambda x: x+0.5, range(0,len(sorted_fullness)))) - self.sp.set_xticklabels( map(lambda x: " " + x, map(lambda x: x[0], sorted_fullness)), - rotation="vertical", verticalalignment="bottom" ) - self.canvas.draw(); - self.canvas.show(); - -class DataTableRuntimes(DataTable): - def __init__(self, radio, G): - DataTable.__init__(self,radio,G) - #self.perfTable.setRowCount(len( self.G.nodes() )) - - def update(self): - nodes = self.G.nodes(); - - # get work time for all blocks - kl = map(lambda x: "%s::%swork time" % \ - (x, self._statistics_table[self._statistic]), - nodes); - wrk_knobs = self.radio.get(kl) - - # strip values out of ctrlport response - total_work = sum(map(lambda x: x.value, wrk_knobs.values())) - if(total_work == 0): - total_work = 1 - work_times = dict(zip( - map(lambda x: x.split("::")[0], wrk_knobs.keys()), - map(lambda x: x.value/total_work, wrk_knobs.values()))) - - # update table view - self.table_update(work_times) - - if(self._sort): - sorted_work = sorted(work_times.iteritems(), key=operator.itemgetter(1)) - self._keymap = map(operator.itemgetter(0), sorted_work) - else: - if self._keymap: - sorted_work = len(self._keymap)*['',] - for b in work_times: - sorted_work[self._keymap.index(b)] = (b, work_times[b]) - else: - sorted_work = work_times.items() - - self.sp.clear(); - plt.figure(self.f.number) - plt.subplot(111); - self.sp.bar(range(0,len(sorted_work)), map(lambda x: x[1], sorted_work), - alpha=0.5) - self.sp.set_ylabel("% Runtime"); - self.sp.set_xticks( map(lambda x: x+0.5, range(0,len(sorted_work)))) - self.sp.set_xticklabels( map(lambda x: " " + x[0], sorted_work), - rotation="vertical", verticalalignment="bottom" ) - - self.canvas.draw(); - self.canvas.show(); - -class MForm(QtGui.QWidget): - def update(self): - try: - try: - # update current clock type - self.prevent_clock_change = True; - kl1 = None; - if(self.clockKey == None): - kl1 = self.radio.getRe([".*perfcounter_clock"]) - else: - kl1 = self.radio.get([self.clockKey]); - self.clockKey = kl1.keys()[0]; - self.currClock = kl1[self.clockKey].value; - self.clockSelIdx = self.clocks.values().index(self.currClock); - self.clockSel.setCurrentIndex(self.clockSelIdx); - self.prevent_clock_change = False; - except: - print "WARNING: Failed to get current clock setting!" - - nodes_stream = self.G_stream.nodes(); - nodes_msg = self.G_msg.nodes(); - - # get current buffer depths of all output buffers - kl = map(lambda x: "%s::%soutput %% full" % \ - (x, self._statistics_table[self._statistic]), - nodes_stream); - - st = time.time() - buf_knobs = self.radio.get(kl) - td1 = time.time() - st; - - # strip values out of ctrlport response - buf_vals = dict(zip( - map(lambda x: x.split("::")[0], buf_knobs.keys()), - map(lambda x: x.value, buf_knobs.values()))) - - # get work time for all blocks - kl = map(lambda x: "%s::%swork time" % \ - (x, self._statistics_table[self._statistic]), - nodes_stream); - st = time.time() - wrk_knobs = self.radio.get(kl) - td2 = time.time() - st; - - # strip values out of ctrlport response - total_work = sum(map(lambda x: x.value, wrk_knobs.values())) - if(total_work == 0): - total_work = 1 - work_times = dict(zip( - map(lambda x: x.split("::")[0], wrk_knobs.keys()), - map(lambda x: x.value/total_work, wrk_knobs.values()))) - work_times_padded = dict(zip( - self.G.nodes(), - [0.1]*len(self.G.nodes()))) - work_times_padded.update(work_times) - - for n in nodes_stream: - # ne is the list of edges away from this node! - ne = self.G.edges([n],True); - #for e in ne: # iterate over edges from this block - for e in ne: # iterate over edges from this block - # get the right output buffer/port weight for each edge - sourceport = e[2]["sourceport"]; - if(e[2]["type"] == "stream"): - newweight = buf_vals[n][sourceport] - e[2]["weight"] = newweight; - - for n in nodes_msg: - ne = self.G.edges([n],True); - for e in ne: # iterate over edges from this block - sourceport = e[2]["sourceport"]; - if(e[2]["type"] == "msg"): - #newweight = buf_vals[n][sourceport] - newweight = 0.01; - e[2]["weight"] = newweight; - - # set updated weights - #self.node_weights = map(lambda x: 20+2000*work_times[x], nodes_stream); - self.node_weights = map(lambda x: 20+2000*work_times_padded[x], self.G.nodes()); - self.edge_weights = map(lambda x: 100.0*x[2]["weight"], self.G.edges(data=True)); - - # draw graph updates - self.updateGraph(); - - latency = td1 + td2; - self.parent.statusBar().showMessage("Current GNU Radio Control Port Query Latency: %f ms"%\ - (latency*1000)) - - except Exception, e: - sys.stderr.write("ctrlport-monitor: radio.get threw exception ({0}).\n".format(e)) - if(type(self.parent) is MAINWindow): - # Find window of connection - remove = [] - for p in self.parent.mdiArea.subWindowList(): - if self.parent.conns[self.uid] == p.widget(): - remove.append(p) - - # Remove subwindows for connection and plots - for r in remove: - self.parent.mdiArea.removeSubWindow(r) - - # Clean up self - self.close() - else: - sys.exit(1) - return - - def rtt(self): - self.parent.newSubWindow( DataTableRuntimes(self.radio, self.G_stream), "Runtime Table" ); - - def bpt(self): - self.parent.newSubWindow( DataTableBuffers(self.radio, self.G_stream), "Buffers Table" ); - - def resetPCs(self): - knob = GNURadio.KnobB() - knob.value = False - km = {} - for b in self.blocks_list: - km[b + "::reset_perf_counters"] = knob - k = self.radio.set(km) - - def toggleFlowgraph(self): - if self.pauseFGAct.isChecked(): - self.pauseFlowgraph() - else: - self.unpauseFlowgraph() - - def pauseFlowgraph(self): - knob = GNURadio.KnobB() - knob.value = False - km = {} - km[self.top_block + "::lock"] = knob - km[self.top_block + "::stop"] = knob - k = self.radio.set(km) - - def unpauseFlowgraph(self): - knob = GNURadio.KnobB() - knob.value = False - km = {} - km[self.top_block + "::unlock"] = knob - k = self.radio.set(km) - - def stat_changed(self, index): - self._statistic = str(self.stattype.currentText()) - - def update_clock(self, clkidx): - if(self.prevent_clock_change): - return; - idx = self.clockSel.currentIndex(); - clk = self.clocks.values()[idx] -# print "UPDATE CLOCK!!! %d -> %d"%(idx,clk); - k = self.radio.get([self.clockKey]); - k[self.clockKey].value = clk; - km = {}; - km[self.clockKey] = k[self.clockKey]; - self.radio.set(km); - - def __init__(self, radio=None, port=None, uid=0, parent=None): - - super(MForm, self).__init__() - - if(radio == None or port == None): - askinfo = ConInfoDialog(self); - if askinfo.exec_(): - host = str(askinfo.host.text()); - port = str(askinfo.port.text()); - radio = parent.interface.getRadio(host, port) - else: - self.radio = None - return - - - self.uid = uid - self.parent = parent - - self.layoutTop = QtGui.QVBoxLayout(self) - self.ctlBox = QtGui.QHBoxLayout(); - self.layout = QtGui.QHBoxLayout() - - self.layoutTop.addLayout(self.ctlBox); - self.layoutTop.addLayout(self.layout); - - self.rttAct = QtGui.QAction("Runtime Table", - self, statusTip="Runtime Table", triggered=self.rtt) - self.rttBut = Qt.QToolButton() - self.rttBut.setDefaultAction(self.rttAct); - self.ctlBox.addWidget(self.rttBut); - - self.bptAct = QtGui.QAction("Buffer Table", - self, statusTip="Buffer Table", triggered=self.bpt) - self.bptBut = Qt.QToolButton() - self.bptBut.setDefaultAction(self.bptAct); - self.ctlBox.addWidget(self.bptBut); - - self.resetPCsAct = QtGui.QAction("Reset", self, - statusTip="Reset all Performance Counters", - triggered=self.resetPCs) - self.resetPCsBut = Qt.QToolButton() - self.resetPCsBut.setDefaultAction(self.resetPCsAct); - self.ctlBox.addWidget(self.resetPCsBut); - - self.pauseFGAct = QtGui.QAction("Pause", self, - statusTip="Pause the Flowgraph", - triggered=self.toggleFlowgraph) - self.pauseFGAct.setCheckable(True) - self.pauseFGBut = Qt.QToolButton() - self.pauseFGBut.setDefaultAction(self.pauseFGAct); - self.ctlBox.addWidget(self.pauseFGBut); - - self.prevent_clock_change = True; - self.clockKey = None; - self.clocks = {"MONOTONIC":1, "THREAD":3}; - self.clockSel = QtGui.QComboBox(self); - map(lambda x: self.clockSel.addItem(x), self.clocks.keys()); - self.ctlBox.addWidget(self.clockSel); - self.clockSel.currentIndexChanged.connect(self.update_clock); - self.prevent_clock_change = False; - - self._statistic = "Instantaneous" - self._statistics_table = {"Instantaneous": "", - "Average": "avg ", - "Variance": "var "} - self.stattype = QtGui.QComboBox() - self.stattype.addItem("Instantaneous") - self.stattype.addItem("Average") - self.stattype.addItem("Variance") - self.stattype.setMaximumWidth(200) - self.ctlBox.addWidget(self.stattype); - self.stattype.currentIndexChanged.connect(self.stat_changed) - -# self.setLayout(self.layout); - - self.radio = radio - self.knobprops = self.radio.properties([]) - self.parent.knobprops.append(self.knobprops) - - self.timer = QtCore.QTimer() - self.constupdatediv = 0 - self.tableupdatediv = 0 - plotsize=250 - - - # Set up the graph of blocks - input_name = lambda x: x+"::avg input % full" - output_name = lambda x: x+"::avg output % full" - wtime_name = lambda x: x+"::avg work time" - nout_name = lambda x: x+"::avg noutput_items" - nprod_name = lambda x: x+"::avg nproduced" - - tmplist = [] - knobs = self.radio.get([]) - edgelist = None - msgedgelist = None - for k in knobs: - propname = k.split("::") - blockname = propname[0] - keyname = propname[1] - if(keyname == "edge list"): - edgelist = knobs[k].value - self.top_block = blockname - elif(keyname == "msg edges list"): - msgedgelist = knobs[k].value - elif(blockname not in tmplist): - # only take gr_blocks (no hier_block2) - if(knobs.has_key(input_name(blockname))): - tmplist.append(blockname) - - - if not edgelist: - sys.stderr.write("Could not find list of edges from flowgraph. " + \ - "Make sure the option 'edges_list' is enabled " + \ - "in the ControlPort configuration.\n\n") - sys.exit(1) - - self.blocks_list = tmplist - edges = edgelist.split("\n")[0:-1] - msgedges = msgedgelist.split("\n")[0:-1] - - edgepairs_stream = []; - edgepairs_msg = []; - - # add stream connections - for e in edges: - _e = e.split("->") - edgepairs_stream.append( (_e[0].split(":")[0], _e[1].split(":")[0], - {"type":"stream", "sourceport":int(_e[0].split(":")[1])}) ); - - # add msg connections - for e in msgedges: - _e = e.split("->") - edgepairs_msg.append( (_e[0].split(":")[0], _e[1].split(":")[0], - {"type":"msg", "sourceport":_e[0].split(":")[1]}) ); - - self.G = nx.MultiDiGraph(); - self.G_stream = nx.MultiDiGraph(); - self.G_msg = nx.MultiDiGraph(); - - self.G.add_edges_from(edgepairs_stream); - self.G.add_edges_from(edgepairs_msg); - - self.G_stream.add_edges_from(edgepairs_stream); - self.G_msg.add_edges_from(edgepairs_msg); - - n_edges = self.G.edges(data=True); - for e in n_edges: - e[2]["weight"] = 5+random.random()*10; - - self.G.clear(); - self.G.add_edges_from(n_edges); - - - self.f = plt.figure(figsize=(10,8), dpi=90) - self.sp = self.f.add_subplot(111); - self.sp.autoscale_view(True,True,True); - self.sp.set_autoscale_on(True) - - self.canvas = FigureCanvas(self.f) - self.layout.addWidget(self.canvas); - - self.pos = nx.graphviz_layout(self.G); - #self.pos = nx.pygraphviz_layout(self.G); - #self.pos = nx.spectral_layout(self.G); - #self.pos = nx.circular_layout(self.G); - #self.pos = nx.shell_layout(self.G); - #self.pos = nx.spring_layout(self.G); - - # generate weights and plot - self.update(); - - # set up timer - self.timer = QtCore.QTimer() - self.connect(self.timer, QtCore.SIGNAL('timeout()'), self.update) - self.timer.start(1000) - - # Set up mouse callback functions to move blocks around. - self._grabbed = False - self._current_block = '' - self.f.canvas.mpl_connect('button_press_event', - self.button_press) - self.f.canvas.mpl_connect('motion_notify_event', - self.mouse_move) - self.f.canvas.mpl_connect('button_release_event', - self.button_release) - - def button_press(self, event): - x, y = event.xdata, event.ydata - thrsh = 100 - - if(x is not None and y is not None): - nearby = map(lambda z: math.sqrt( math.pow(x-z[0],2) + math.pow(y-z[1],2)), self.pos.values()) - i = nearby.index(min(nearby)) - if(abs(self.pos.values()[i][0] - x) < thrsh and - abs(self.pos.values()[i][1]-y) < thrsh): - self._current_block = self.pos.keys()[i] - #print "MOVING BLOCK: ", self._current_block - #print "CUR POS: ", self.pos.values()[i] - self._grabbed = True - - def mouse_move(self, event): - if self._grabbed: - x, y = event.xdata, event.ydata - if(x is not None and y is not None): - #print "NEW POS: ", (x,y) - self.pos[self._current_block] = (x,y) - self.updateGraph(); - - def button_release(self, event): - self._grabbed = False - - - def openMenu(self, pos): - index = self.table.treeWidget.selectedIndexes() - item = self.table.treeWidget.itemFromIndex(index[0]) - itemname = str(item.text(0)) - self.parent.propertiesMenu(itemname, self.radio, self.uid) - - def updateGraph(self): - - self.canvas.updateGeometry() - self.sp.clear(); - plt.figure(self.f.number) - plt.subplot(111); - nx.draw(self.G, self.pos, - edge_color=self.edge_weights, - node_color='#A0CBE2', - width=map(lambda x: 3+math.log(x), self.edge_weights), - node_shape="s", - node_size=self.node_weights, - #edge_cmap=plt.cm.Blues, - edge_cmap=plt.cm.Reds, - ax=self.sp, - arrows=False - ) - nx.draw_networkx_labels(self.G, self.pos, - font_size=12) - - self.canvas.draw(); - self.canvas.show(); - -class MyClient(IceRadioClient): - def __init__(self): - IceRadioClient.__init__(self, MAINWindow) - -sys.exit(MyClient().main(sys.argv)) diff --git a/gnuradio-runtime/swig/CMakeLists.txt b/gnuradio-runtime/swig/CMakeLists.txt index 06ccc751be..ca9ddd4039 100644 --- a/gnuradio-runtime/swig/CMakeLists.txt +++ b/gnuradio-runtime/swig/CMakeLists.txt @@ -70,8 +70,6 @@ endif(ENABLE_GR_LOG) if(ENABLE_GR_CTRLPORT) ADD_DEFINITIONS(-DGR_CTRLPORT) list(APPEND GR_SWIG_FLAGS -DGR_CTRLPORT) - list(APPEND GR_SWIG_LIBRARIES ${ICE_LIBRARIES}) - list(APPEND GR_SWIG_INCLUDE_DIRS ${ICE_INCLUDE_DIR}) endif(ENABLE_GR_CTRLPORT) set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/runtime_swig_doc.i) |