@@ -44,13 +44,13 @@ def __init__(self, *args, **kwargs):
4444 kwds = {"style" : wx .DEFAULT_FRAME_STYLE }
4545 wx .Frame .__init__ (self , * args , ** kwds )
4646
47+ self .app_name = kwargs .get ("app_name" )
4748 self .version = kwargs .get ("version" )
4849 self .final_panel = kwargs .get ("final_panel" )
4950 self .user_config = kwargs .get ("user_config" )
5051 self .pack = kwargs .get ("pack" , "" )
5152 self .num_exp = kwargs .get ("num_exp" , 0 )
5253 self .num_metric = kwargs .get ("num_metric" , 0 )
53- self .name_benchmark = self .user_config .path_benchmark .split ("/" )[- 1 ].split ()[0 ]
5454
5555 # Indicates whether the graph is shown fully or only partly present.
5656 self .show_complete = False
@@ -83,7 +83,7 @@ def __init__(self, *args, **kwargs):
8383 metrics .append (metric .name )
8484 self .combo_metric = wx .ComboBox (self , wx .ID_ANY , choices = metrics , style = wx .CB_DROPDOWN | wx .CB_READONLY )
8585
86- self .combo_pack = wx .ComboBox (self , wx .ID_ANY , choices = sorted (self .final_panel .pmc_extract .data .keys ()), style = wx .CB_DROPDOWN | wx .CB_READONLY )
86+ self .combo_pack = wx .ComboBox (self , wx .ID_ANY , choices = sorted (self .final_panel .pmc_extract .data [ self . app_name ] .keys ()), style = wx .CB_DROPDOWN | wx .CB_READONLY )
8787 self .label_pack = wx .StaticText (self , - 1 , self .name_pack + ": " )
8888 self .label_exp = wx .StaticText (self , - 1 , _ ("Experiment" ) + ": " )
8989 self .label_metric = wx .StaticText (self , - 1 , _ ("Metric" ) + ": " )
@@ -121,15 +121,24 @@ def __init__(self, *args, **kwargs):
121121 self .fig .canvas .mpl_connect ('button_press_event' , self .on_click_graph )
122122
123123 def __set_properties (self ):
124- self .SetTitle ("PMCTrack-GUI v" + self .version + " - " + _ ("Monitoring application '{0}'" ).format (self .name_benchmark ))
124+ self .SetTitle ("PMCTrack-GUI v" + self .version + " - " + _ ("Monitoring application '{0}'" ).format (self .app_name . split ()[ 0 ] ))
125125 self .SetSize ((750 , 640 ))
126- if self .pack != "" :
126+ if self .combo_pack .GetCount () > 0 :
127+ if self .pack != "" :
127128 self .combo_pack .SetStringSelection (self .pack )
128- metric = self .user_config .experiments [self .num_exp ].metrics [self .num_metric ].name .encode ("utf-8" )
129- self .sizer_graph_staticbox .SetLabel (_ ("Showing graph with {0} {1}, experiment {2} and metric '{3}'" ).format (self .name_pack , self .pack , (self .num_exp + 1 ), metric ))
130- else :
129+ else :
130+ self .combo_pack .SetSelection (0 )
131+ self .pack = self .combo_pack .GetStringSelection ()
132+ metric = self .user_config .experiments [self .num_exp ].metrics [self .num_metric ].name .encode ("utf-8" )
133+ self .sizer_graph_staticbox .SetLabel (_ ("Showing graph with {0} {1}, experiment {2} and metric '{3}'" ).format (self .name_pack , self .pack , (self .num_exp + 1 ), metric ))
134+ else :
135+ self .SetTitle (self .GetTitle () + " " + _ ("(waiting)" ))
131136 self .button_this_window .Disable ()
132137 self .button_other_window .Disable ()
138+ self .button_change_vis_graph .Disable ()
139+ self .button_screenshot .Disable ()
140+ self .button_hide_controls .Disable ()
141+ self .button_stop_monitoring .Disable ()
133142
134143 self .combo_exp .SetSelection (self .num_exp )
135144 self .combo_metric .SetSelection (self .num_metric )
@@ -200,7 +209,7 @@ def __init_plot(self):
200209 self .canvas = FigCanvas (self , - 1 , self .fig )
201210
202211 def __draw_plot (self ):
203- graph_data = self .final_panel .pmc_extract .data [self .pack ][self .num_exp ][self .num_metric ]
212+ graph_data = self .final_panel .pmc_extract .data [self .app_name ][ self . pack ][self .num_exp ][self .num_metric ]
204213
205214 # Updates the minimum and maximum value of the graph that is displayed (only if it's worth)
206215 if len (graph_data [self .samples_draw [self .num_exp ].get (self .pack , 0 ):]) > 0 :
@@ -238,42 +247,53 @@ def __change_vis_controls(self, show):
238247 self .separator .Layout ()
239248
240249 def on_timer_update_data (self , event ):
241- packs_count = self .combo_pack .GetCount ()
242- # If a new pack (pid or cpu) is detected update the corresponding graphical controls.
243- if len (self .final_panel .pmc_extract .data ) > packs_count :
244- self .combo_pack .SetItems (sorted (self .final_panel .pmc_extract .data ))
245- if packs_count > 0 :
246- self .combo_pack .SetStringSelection (self .pack )
247- else : # If the first pack (pid or cpu) is detected as what we are currently monitoring pack.
248- self .combo_pack .SetSelection (0 )
249- self .pack = self .combo_pack .GetStringSelection ()
250- metric = self .user_config .experiments [self .num_exp ].metrics [self .num_metric ].name .encode ("utf-8" )
251- self .sizer_graph_staticbox .SetLabel (_ ("Showing graph with {0} {1}, experiment {2} and metric '{3}'" ).format (self .name_pack , self .pack , (self .num_exp + 1 ), metric ))
252- self .button_this_window .Enable ()
253- self .button_other_window .Enable ()
254-
255- if self .pack != "" :
256- num_graph_data = len (self .final_panel .pmc_extract .data [self .pack ][self .num_exp ][self .num_metric ])
257-
258- # Only if there are outstanding paint painting to the pack (pid or cpu) being displayed data.
259- if num_graph_data > self .samples_draw [self .num_exp ].get (self .pack , 0 ):
260- self .__draw_plot ()
261- self .samples_draw [self .num_exp ][self .pack ] = num_graph_data
262-
263- if self .final_panel .pmc_extract .state == 'F' :
264- self .timer_update_data .Stop ()
265- self .SetTitle (self .GetTitle () + " " + _ ("(finished)" ))
266- self .button_stop_monitoring .Disable ()
267- if len (self .final_panel .mon_frames ) > 0 and self .final_panel .mon_frames [0 ] == self :
268- self .final_panel .button_monitoring .SetLabel (_ ("Close monitoring windows" ))
269- dlg = wx .MessageDialog (parent = None , message = _ ("The application '{0}' is done." ).format (self .name_benchmark ),
270- caption = _ ("Information" ), style = wx .OK | wx .ICON_INFORMATION )
271- dlg .ShowModal ()
272- dlg .Destroy ()
273- elif self .final_panel .pmc_extract .state == 'S' :
274- self .timer_update_data .Stop ()
275- self .SetTitle (self .GetTitle () + " " + _ ("(stopped)" ))
276- self .button_stop_monitoring .SetLabel (_ ("Resume application" ))
250+ if self .final_panel .pmc_extract .error != None and len (self .user_config .applications ) == 1 :
251+ error_msg = _ ("PMCTrack error" ) + ":\n " + self .final_panel .pmc_extract .error
252+ dlg = wx .MessageDialog (parent = None , message = error_msg , caption = _ ("Error" ), style = wx .OK | wx .ICON_ERROR )
253+ if dlg .ShowModal () == wx .ID_OK :
254+ self .final_panel .StopMonitoring (False )
255+ else :
256+ packs_count = self .combo_pack .GetCount ()
257+ # If a new pack (pid or cpu) is detected update the corresponding graphical controls.
258+ if len (self .final_panel .pmc_extract .data [self .app_name ]) > packs_count :
259+ self .combo_pack .SetItems (sorted (self .final_panel .pmc_extract .data [self .app_name ]))
260+ if packs_count > 0 :
261+ self .combo_pack .SetStringSelection (self .pack )
262+ else : # If the first pack (pid or cpu) is detected as what we are currently monitoring pack.
263+ self .combo_pack .SetSelection (0 )
264+ self .pack = self .combo_pack .GetStringSelection ()
265+ metric = self .user_config .experiments [self .num_exp ].metrics [self .num_metric ].name .encode ("utf-8" )
266+ self .SetTitle ("PMCTrack-GUI v" + self .version + " - " + _ ("Monitoring application '{0}'" ).format (self .app_name .split ()[0 ]))
267+ self .sizer_graph_staticbox .SetLabel (_ ("Showing graph with {0} {1}, experiment {2} and metric '{3}'" ).format (self .name_pack , self .pack , (self .num_exp + 1 ), metric ))
268+ self .button_this_window .Enable ()
269+ self .button_other_window .Enable ()
270+ self .button_change_vis_graph .Enable ()
271+ self .button_screenshot .Enable ()
272+ self .button_hide_controls .Enable ()
273+ self .button_stop_monitoring .Enable ()
274+
275+ if self .pack != "" :
276+ num_graph_data = len (self .final_panel .pmc_extract .data [self .app_name ][self .pack ][self .num_exp ][self .num_metric ])
277+
278+ # Only if there are outstanding paint painting to the pack (pid or cpu) being displayed data.
279+ if num_graph_data > self .samples_draw [self .num_exp ].get (self .pack , 0 ):
280+ self .__draw_plot ()
281+ self .samples_draw [self .num_exp ][self .pack ] = num_graph_data
282+
283+ if self .final_panel .pmc_extract .state [self .app_name ] == 'F' :
284+ self .timer_update_data .Stop ()
285+ self .SetTitle (self .GetTitle () + " " + _ ("(finished)" ))
286+ self .button_stop_monitoring .Disable ()
287+ if len (self .final_panel .mon_frames ) > 0 and len (self .user_config .applications ) == 1 and self .final_panel .mon_frames [0 ] == self :
288+ self .final_panel .button_monitoring .SetLabel (_ ("Close monitoring windows" ))
289+ dlg = wx .MessageDialog (parent = None , message = _ ("The application '{0}' is done." ).format (self .app_name .split ()[0 ]),
290+ caption = _ ("Information" ), style = wx .OK | wx .ICON_INFORMATION )
291+ dlg .ShowModal ()
292+ dlg .Destroy ()
293+ elif self .final_panel .pmc_extract .state [self .app_name ] == 'S' :
294+ self .timer_update_data .Stop ()
295+ self .SetTitle (self .GetTitle () + " " + _ ("(stopped)" ))
296+ self .button_stop_monitoring .SetLabel (_ ("Resume application" ))
277297
278298 def on_click_this_window (self , event ):
279299 self .pack = self .combo_pack .GetStringSelection ()
@@ -282,7 +302,7 @@ def on_click_this_window(self, event):
282302 metric = self .user_config .experiments [self .num_exp ].metrics [self .num_metric ].name .encode ('utf-8' )
283303 self .sizer_graph_staticbox .SetLabel (_ ("Showing graph with {0} {1}, experiment {2} and metric '{3}'" ).format (self .name_pack , self .pack , (self .num_exp + 1 ), metric ))
284304 self .axes .set_ylabel (metric .decode ('utf-8' ))
285- graph_data = self .final_panel .pmc_extract .data [self .pack ][self .num_exp ][self .num_metric ]
305+ graph_data = self .final_panel .pmc_extract .data [self .app_name ][ self . pack ][self .num_exp ][self .num_metric ]
286306 if self .samples_draw [self .num_exp ].get (self .pack , 0 ) > 0 :
287307 self .minval = min (graph_data [0 :self .samples_draw [self .num_exp ][self .pack ]])
288308 self .maxval = max (graph_data [0 :self .samples_draw [self .num_exp ][self .pack ]])
@@ -295,7 +315,7 @@ def on_click_other_window(self, event):
295315 sel_pack = self .combo_pack .GetStringSelection ()
296316 sel_exp = self .combo_exp .GetSelection ()
297317 sel_met = self .combo_metric .GetSelection ()
298- mon_frame = MonitoringFrame (None , - 1 , "" , version = self .version , final_panel = self .final_panel , user_config = self .user_config , pack = sel_pack , num_exp = sel_exp , num_metric = sel_met )
318+ mon_frame = MonitoringFrame (None , - 1 , "" , app_name = self . app_name , version = self .version , final_panel = self .final_panel , user_config = self .user_config , pack = sel_pack , num_exp = sel_exp , num_metric = sel_met )
299319 mon_frame .Show ()
300320
301321 def on_change_experiment (self , event ):
@@ -308,7 +328,7 @@ def on_change_experiment(self, event):
308328 def on_click_graph (self , event ):
309329 if self .fig .canvas .HasCapture ():
310330 self .fig .canvas .ReleaseMouse ()
311- if self .graph_style_dialog .ShowModal () == 0 :
331+ if self .final_panel . pmc_extract . state [ self . app_name ] != "W" and self . graph_style_dialog .ShowModal () == 0 :
312332 self .axes .set_axis_bgcolor (self .graph_style_dialog .GetBgColor ())
313333 self .axes .grid (True , color = self .graph_style_dialog .GetGridColor ())
314334 self .plot_data .set_linewidth (self .graph_style_dialog .GetLineWidth ())
@@ -325,14 +345,15 @@ def on_click_change_vis_graph(self, event):
325345 self .__draw_plot ()
326346
327347 def on_click_stop_monitoring (self , event ):
328- if self .final_panel .pmc_extract .state == 'R' :
348+ if self .final_panel .pmc_extract .state [ self . app_name ] == 'R' :
329349 self .final_panel .pmc_extract .StopMonitoring ()
330- elif self .final_panel .pmc_extract .state == 'S' :
350+ elif self .final_panel .pmc_extract .state [ self . app_name ] == 'S' :
331351 self .final_panel .pmc_extract .ResumeMonitoring ()
332352 for mon_frame in self .final_panel .mon_frames :
353+ if mon_frame .app_name == self .app_name :
333354 mon_frame .timer_update_data .Start (100 )
334355 mon_frame .button_stop_monitoring .SetLabel (_ ("Stop application" ))
335- mon_frame .SetTitle ("PMCTrack-GUI v" + self .version + " - " + _ ("Monitoring application '{0}'" ).format (self .name_benchmark ))
356+ mon_frame .SetTitle ("PMCTrack-GUI v" + self .version + " - " + _ ("Monitoring application '{0}'" ).format (self .app_name . split ()[ 0 ] ))
336357
337358 def on_click_screenshot (self , event ):
338359 metric = self .user_config .experiments [self .num_exp ].metrics [self .num_metric ].name
@@ -342,7 +363,7 @@ def on_click_screenshot(self, event):
342363 self ,
343364 message = _ ("Save graph screenshot as..." ),
344365 defaultDir = os .getcwd (),
345- defaultFile = "{0}-{1}-{2}.png" .format (self .pack , self .num_exp , metric .replace (" " , "_" )),
366+ defaultFile = "{0}-{1}-{2}-{3} .png" .format (self . app_name . split ()[ 0 ], self .pack , self .num_exp , metric .replace (" " , "_" )),
346367 wildcard = file_choices ,
347368 style = wx .SAVE )
348369
@@ -357,7 +378,7 @@ def on_click_show_controls(self, event):
357378 self .__change_vis_controls (True )
358379
359380 def on_close_frame (self , event ):
360- if len (self .final_panel .mon_frames ) > 1 :
381+ if len (self .final_panel .mon_frames ) > 1 or len ( self . user_config . applications ) > 1 :
361382 self .final_panel .mon_frames .remove (self )
362383 self .graph_style_dialog .Destroy ()
363384 self .Destroy ()
0 commit comments