$search
00001 00002 # Software License Agreement (BSD License) 00003 # 00004 # Copyright (c) 2008, Willow Garage, Inc. 00005 # All rights reserved. 00006 # 00007 # Redistribution and use in source and binary forms, with or without 00008 # modification, are permitted provided that the following conditions 00009 # are met: 00010 # 00011 # * Redistributions of source code must retain the above copyright 00012 # notice, this list of conditions and the following disclaimer. 00013 # * Redistributions in binary form must reproduce the above 00014 # copyright notice, this list of conditions and the following 00015 # disclaimer in the documentation and/or other materials provided 00016 # with the distribution. 00017 # * Neither the name of the Willow Garage nor the names of its 00018 # contributors may be used to endorse or promote products derived 00019 # from this software without specific prior written permission. 00020 # 00021 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 # POSSIBILITY OF SUCH DAMAGE. 00033 00034 import roslib; roslib.load_manifest('generic_dashboard') 00035 import rospy 00036 00037 import wx 00038 from status_control import * 00039 from os import path 00040 import rxtools.cppwidgets as rxtools 00041 from generic_control import GenericControl 00042 00043 class RosoutFrame(wx.Frame): 00044 def __init__(self, parent, id, title): 00045 wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(800, 600)) 00046 00047 self.Bind(wx.EVT_CLOSE, self.on_close) 00048 00049 self._rosout_panel = rxtools.RosoutPanel(self) 00050 00051 def get_panel(self): 00052 return self._rosout_panel 00053 00054 def on_close(self, evt): 00055 self.Hide() 00056 00057 class RosoutControl(StatusControl): 00058 def __init__(self, parent): 00059 StatusControl.__init__(self, parent, path.join(roslib.packages.get_pkg_dir('generic_dashboard'), "icons/"), 00060 'rosout', True, {'stale': 'grey', 'ok': 'green', 'warn': 'yellow', 'error': 'red'}, 'stale') 00061 self.SetToolTip(wx.ToolTip("Rosout")) 00062 00063 self._rosout_frame = RosoutFrame(parent, wx.ID_ANY, "Rosout") 00064 self._rosout_frame.Hide() 00065 self._rosout_frame.Center() 00066 self.Bind(wx.EVT_BUTTON, self.on_rosout_clicked) 00067 00068 def on_rosout_clicked(self, evt): 00069 self._rosout_frame.Show() 00070 self._rosout_frame.Raise() 00071 00072 def update(self): 00073 summary_dur = 30.0 00074 if (rospy.get_time() < 30.0): 00075 summary_dur = rospy.get_time() - 1.0 00076 00077 if (summary_dur < 0): 00078 summary_dur = 0.0 00079 00080 summary = self._rosout_frame.get_panel().getMessageSummary(summary_dur) 00081 00082 if (summary.fatal or summary.error): 00083 self.set_status('error') 00084 elif (summary.warn): 00085 self.set_status('warn') 00086 else: 00087 self.set_status('ok') 00088 00089 00090 tooltip = "" 00091 if (summary.fatal): 00092 tooltip += "\nFatal: %s"%(summary.fatal) 00093 if (summary.error): 00094 tooltip += "\nError: %s"%(summary.error) 00095 if (summary.warn): 00096 tooltip += "\nWarn: %s"%(summary.warn) 00097 if (summary.info): 00098 tooltip += "\nInfo: %s"%(summary.info) 00099 if (summary.debug): 00100 tooltip += "\nDebug: %s"%(summary.debug) 00101 00102 if (len(tooltip) == 0): 00103 tooltip = "Rosout: no recent activity" 00104 else: 00105 tooltip = "Rosout: recent activity:" + tooltip 00106 00107 if (tooltip != self.GetToolTip().GetTip()): 00108 self.SetToolTip(wx.ToolTip(tooltip)) 00109 self.Refresh() 00110