00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 PKG = 'qualification'
00039
00040 import roslib; roslib.load_manifest(PKG)
00041 from qualification.qual_frame import PlotsPanel
00042 from qualification.test import SubTest
00043 from qualification.result import SubTestResult
00044
00045 import wx
00046 from wx import xrc
00047 from wx import html
00048
00049 import os
00050 import rospy
00051
00052 from pr2_self_test_msgs.srv import TestResult, TestResultResponse
00053
00054
00055 def make_waiting_page():
00056 return '<html><H2 align=center>Waiting for Test Data...</H2></html>'
00057
00058 class QualDisplayFrame(wx.Frame):
00059 def __init__(self, parent):
00060 wx.Frame.__init__(self, parent, wx.ID_ANY, "Qualification Display")
00061
00062
00063 xrc_path = os.path.join(roslib.packages.get_pkg_dir(PKG), 'xrc/gui.xrc')
00064 xrc_res = xrc.XmlResource(xrc_path)
00065
00066 self._shutdown_timer = wx.Timer(self, wx.ID_ANY)
00067 self.Bind(wx.EVT_TIMER, self._on_shutdown_timer, self._shutdown_timer)
00068 self._shutdown_timer.Start(10)
00069
00070 self._plots_panel = PlotsPanel(self, xrc_res, self)
00071 self._plots_panel.show_waiting(make_waiting_page())
00072
00073 sizer = wx.BoxSizer(wx.HORIZONTAL)
00074 self.SetSizer(sizer)
00075 sizer.Add(self._plots_panel, 1, wx.EXPAND)
00076
00077 self._result_service = rospy.Service('test_result', TestResult, self.subtest_callback)
00078
00079
00080 def _on_shutdown_timer(self, event):
00081 if rospy.is_shutdown():
00082 self.Close(True)
00083
00084 def subtest_callback(self, msg):
00085 wx.CallAfter(self._st_data, msg)
00086 return TestResultResponse()
00087
00088 def _st_data(self, msg):
00089 self._result_service.shutdown()
00090 self._result_service = None
00091
00092 test = SubTest(os.path.join(roslib.packages.get_pkg_dir(PKG), 'N/A'), 1, "Qual Test")
00093 result = SubTestResult(test, msg)
00094 self._plots_panel.show_plots(result.make_result_page(),
00095 True)
00096
00097
00098 def retry_subtest(self, notes):
00099 self.subtest_result(False, notes)
00100
00101 def subtest_result(self, ok, notes):
00102 are_you_sure = wx.MessageDialog(self,
00103 "This will clear the results window for the next result. Are you sure you want to clear the window? Press OK to clear.",
00104 "Clear Window?",
00105 wx.OK|wx.CANCEL)
00106 if (are_you_sure.ShowModal() != wx.ID_OK):
00107 return
00108
00109
00110 self._plots_panel.show_waiting(make_waiting_page())
00111 self._result_service = rospy.Service('test_result', TestResult, self.subtest_callback)
00112
00113
00114 def cancel(self):
00115 are_you_sure = wx.MessageDialog(self, "Are you sure you want to quit?", "Confirm shut down",
00116 wx.OK|wx.CANCEL)
00117 if are_you_sure.ShowModal() != wx.ID_OK:
00118 return
00119
00120 self.Close(True)
00121
00122 class QualDisplayApp(wx.App):
00123 def OnInit(self):
00124 from qualification.result_dir import check_qual_result_dir
00125 if not check_qual_result_dir():
00126 wx.MessageBox("Unable to write to the temporary results directory. This will cause weird problems. Open a terminal and type, \"sudo rm /tmp/* -rf\" to remove the offending directory.",
00127 "Unable to Write Results", wx.OK|wx.ICON_ERROR, None)
00128 return False
00129
00130 self._frame = QualDisplayFrame(None)
00131 self._frame.SetSize(wx.Size(700, 900))
00132 self._frame.Layout()
00133
00134 self._frame.Show(True)
00135
00136 return True
00137
00138 if __name__ == '__main__':
00139 rospy.init_node('qual_display', anonymous=True)
00140 try:
00141 app = QualDisplayApp()
00142 app.MainLoop()
00143 except KeyboardInterrupt:
00144 pass
00145 except Exception, e:
00146 import traceback
00147 traceback.print_exc()