Skip to content

Commit

Permalink
fixed #92
Browse files Browse the repository at this point in the history
  • Loading branch information
dwlee committed Apr 22, 2014
1 parent 6da86b9 commit a02affa
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 34 deletions.
18 changes: 10 additions & 8 deletions rocon_qt_app_manager/src/rocon_qt_app_manager/qt_app_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#rqt
from qt_gui.plugin import Plugin


##############################################################################
# QtAppManager
##############################################################################
Expand Down Expand Up @@ -69,20 +68,21 @@ def __init__(self, context):
self.current_app = None
self.current_captured_robot = None

self._get_name_space()
self._get_name_spaces()

def _change_namespace(self, event):
self.qt_app_manager_info._get_apps(self._widget.namespace_cbox.currentText(), '/list_apps')
self.qt_app_manager_info._get_apps(self._widget.namespace_cbox.currentText())
self.qt_app_manager_info._set_update_status(self._widget.namespace_cbox.currentText())
pass

def _get_name_space(self):
for namespace in self.qt_app_manager_info._get_namespace():
ns = namespace[:namespace.find('list_apps')]
def _get_name_spaces(self):
for namespace in self.qt_app_manager_info._get_namespaces():
ns = namespace[:namespace.find('list_rapps')]
self._widget.namespace_cbox.addItem(ns)
self.qt_app_manager_info._get_apps(self._widget.namespace_cbox.currentText(), '/list_apps')
self.qt_app_manager_info._get_apps(self._widget.namespace_cbox.currentText())
self.qt_app_manager_info._set_update_status(self._widget.namespace_cbox.currentText())

def _exit(self):
print "Exit"
pass

def _start_app(self):
Expand All @@ -98,7 +98,9 @@ def _stop_app(self):
pass

def _update_app_list(self):
self._widget.app_info_text.clear()
self._widget.app_tree_widget.clear()
self.apps = {}
apps = self.qt_app_manager_info.apps
for k in apps.values():
app = QTreeWidgetItem(self._widget.app_tree_widget)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import rocon_python_comms
#rocon
from rocon_std_msgs.msg import Remapping
from rocon_app_manager_msgs.msg import AppList
from rocon_app_manager_msgs.srv import StartApp
from rocon_app_manager_msgs.srv import StopApp
from rocon_app_manager_msgs.srv import GetAppList
from rocon_app_manager_msgs.msg import Status
from rocon_app_manager_msgs.srv import StartRapp
from rocon_app_manager_msgs.srv import StopRapp
from rocon_app_manager_msgs.srv import GetRappList

##############################################################################
# QtAppManagerInfo
Expand All @@ -28,7 +28,8 @@ def __init__(self):
self.apps = {}
self.running_apps = {}
self._update_apps_callback = None
#rospy.Subscriber('/app_manager/app_list', AppList, self._update_apps)
self.current_namespace = ''
self.current_subscriber = None

def _update_apps(self, data):
"""
Expand All @@ -39,34 +40,47 @@ def _update_apps(self, data):
"""
self.apps = {}
self.running_apps = {}
for app in data.available_apps:
for app in data.available_rapps:
self.apps[app] = {}
self.apps[app]["running"] = False
self.apps[app]["status"] = app.status
self.apps[app]["name"] = app.name
self.apps[app]["display_name"] = app.display_name
self.apps[app]["description"] = app.description
self.apps[app]["compatibility"] = app.compatibility
self.apps[app]["icon"] = app.icon
self.apps[app]["pairing_clients"] = app.pairing_clients
self.apps[app]["required_capabilities"] = app.required_capabilities
for app in data.running_apps:
for app in data.running_rapps:
self.running_apps[app] = {}
self.running_apps[app]["running"] = True
self.running_apps[app]["status"] = app.status
self.running_apps[app]["name"] = app.name
self.running_apps[app]["display_name"] = app.display_name
self.running_apps[app]["description"] = app.description
self.running_apps[app]["compatibility"] = app.compatibility
self.running_apps[app]["icon"] = app.icon
self.running_apps[app]["pairing_clients"] = app.pairing_clients
self.running_apps[app]["required_capabilities"] = app.required_capabilities
#Call update callback
self._update_apps_callback()

def _get_namespace(self):
get_app_list_service_names = rocon_python_comms.find_service('rocon_app_manager_msgs/GetAppList', timeout=rospy.rostime.Duration(5.0), unique=False)
def _update_app_status(self, data):
self._get_apps(self.current_namespace)

def _set_update_status(self, namespace):
if self.current_subscriber:
self.current_subscriber.unregister()
self.current_subscriber = None
self.current_subscriber = rospy.Subscriber(namespace + 'status', Status, self._update_app_status)
self.current_namespace = namespace

def _get_namespaces(self):
"""
Getting the name space with running the app
@return name space list
@type list
"""
get_app_list_service_names = rocon_python_comms.find_service('rocon_app_manager_msgs/GetRappList', timeout=rospy.rostime.Duration(5.0), unique=False)
return get_app_list_service_names

def _get_apps(self, namespace, service_name):
def _get_apps(self, namespace):
"""
Getting the app list using service calling
@param namespace: namespace of running app
Expand All @@ -75,11 +89,19 @@ def _get_apps(self, namespace, service_name):
@param service_name: service_name
@type String
"""
service_handle = rospy.ServiceProxy(namespace + service_name, GetAppList)
service_handle = rospy.ServiceProxy(namespace + 'list_rapps', GetRappList)
self._update_apps(service_handle())
pass

def _get_app_info(self, app):
"""
Getting the app information to html type
@param app: information of app
@type dict
@return the app information
@type String
"""

app_info = "<html>"
app_info += "<p>-------------------------------------------</p>"
for info_key in app.keys():
Expand All @@ -102,14 +124,13 @@ def _start_app(self, namespace, app_name):
#not yet
remapping = Remapping()

service_handle = rospy.ServiceProxy(namespace + 'start_app', StartApp)
service_handle = rospy.ServiceProxy(namespace + 'start_rapp', StartRapp)
call_result = service_handle(app_name, [remapping, ])
call_result_html = "<html>"
call_result_html += "<p>-------------------------------------------</p>"
call_result_html += "<p><b>started: </b>" + str(call_result.started) + "</p>"
call_result_html += "<p><b>error_code: </b>" + str(call_result.error_code) + "</p>"
call_result_html += "<p><b>message: </b>" + call_result.message + "</p>"
call_result_html += "<p><b>app_namespace: </b>" + call_result.app_namespace + "</p>"
call_result_html += "</html>"
return call_result_html

Expand All @@ -120,7 +141,7 @@ def _stop_app(self, namespace):
@param namespace: name space of running app
@type String
"""
service_handle = rospy.ServiceProxy(namespace + 'stop_app', StopApp)
service_handle = rospy.ServiceProxy(namespace + 'stop_rapp', StopRapp)
call_result = service_handle()
call_result_html = "<html>"
call_result_html += "<p>-------------------------------------------</p>"
Expand Down
7 changes: 0 additions & 7 deletions rocon_qt_app_manager/ui/qt_app_manager.ui
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="test_btn">
<property name="text">
<string>Test</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down

0 comments on commit a02affa

Please sign in to comment.