Exemplo n.º 1
0
 def on_add_variable(self, event):
     var_name = self.choice_var.GetStringSelection()
     if var_name != "":
         # Add a graph with default values to the monitor server
         servers.get_monitor_server().addgraph(
             str(var_name), 0.1, 0.0, 1.0,0.0,0.0,1.0 )
         # Add graph bar for the new graph
         self.__add_graph_bar(var_name)
Exemplo n.º 2
0
 def __del__(self):
     # Disable sampling
     servers.get_monitor_server().setdisplayactivated(False)
     servers.get_monitor_server().setsamplingactivated(False)
     # Release refresh stats timer
     if self.stats_timer is not None:
         self.stats_timer.Stop()
         self.stats_timer = None
Exemplo n.º 3
0
 def __on_change_params(self, event):
     graph_index = self.get_graph_index()
     color = format.byte_rgb_2_unit_rgba( self.color.GetColour().Get() )
     servers.get_monitor_server().setgraphparameters(
         graph_index,
         float( self.int_frequency.get_value() ) / 1000.0,
         self.slider_smooth.get_value(),
         color[0], color[1], color[2], color[3]
         )
Exemplo n.º 4
0
 def update_current_stats(self):
     monitor_server = servers.get_monitor_server()
     if monitor_server.getnumgraphs() > 0 and self.stats_enabled:
         min, max, mean, last = monitor_server.getcurrentgraphstats()
         self.float_min.SetLabel( str(round(min, 4)) )
         self.float_max.SetLabel( str(round(max, 4)) )
         self.float_mean.SetLabel( str(round(mean, 4)) )
         self.float_last.SetLabel( str(round(last, 4)) )
Exemplo n.º 5
0
 def __set_properties(self):
     # Get graph parameters from the monitor server
     graph_index = self.get_graph_index()
     monitor = servers.get_monitor_server()
     frequency, smooth, r,g,b,a = monitor.getgraphparameters( graph_index )
     enabled = monitor.getgraphactive( graph_index )
     # Fill controls with the graph parameters
     self.checkbox_enable.SetValue( enabled )
     self.color.SetValue( format.unit_rgb_2_byte_rgb((r,g,b)) )
     self.int_frequency.set_value( int(frequency*1000) )
     self.slider_smooth.set_value( smooth )
Exemplo n.º 6
0
 def __set_properties(self):
     self.SetSize((700, 300))
     self.win_graphs.SetScrollRate(10, 10)
     
     # Enable sampling
     servers.get_monitor_server().setsamplingactivated(True)
     servers.get_monitor_server().setdisplayactivated(True)
     
     # Fill the variable choice control with all variables
     var = pynebula.lookup('/sys/var').gethead()
     while var != None:
         name = var.getname()
         self.choice_var.Append(name)
         var = var.getsucc()
     
     # Global history period
     monitor_server = servers.get_monitor_server()
     self.int_period.set_value( int(monitor_server.gethistoryperiod()) )
     
     # Check/uncheck display buttons
     self.button_show.SetValue( monitor_server.getdisplayactivated() )
     self.button_fullscreen.SetValue( monitor_server.getfullscreen() )
Exemplo n.º 7
0
 def on_remove_variable(self, event):
     # Remove graph from the stats selector combo control
     graphbar = event.GetEventObject().GetParent()
     graph_index = graphbar.get_graph_index()
     self.combo_current.Delete( graph_index )
     if self.combo_current.GetCount() == 0:
         self.stats_enabled = False
     
     # Remove graph from the monitor server
     servers.get_monitor_server().removegraph( graph_index )
     
     # Stop catching the remove graph event for the removed graph
     self.Unbind(wx.EVT_BUTTON, graphbar)
     
     # Remove graph bar control
     self.Freeze()
     self.graphs.remove(graphbar)
     self.sizer_graphs.Detach(graphbar)
     graphbar.Destroy()
     graphbar = None
     self.win_graphs.GetSizer().Fit(self.win_graphs)
     self.win_graphs.GetSizer().SetVirtualSizeHints(self.win_graphs)
     self.Layout()
     self.Thaw()
Exemplo n.º 8
0
 def __init__(self, parent):
     togwin.ChildToggableDialog.__init__(
         self, "Variable monitor", parent
         )
     self.stats_enabled = False
     
     self.win_graphs = wx.ScrolledWindow(self, -1, style=wx.SUNKEN_BORDER|wx.TAB_TRAVERSAL)
     self.label_current = wx.StaticText(self, -1, "Current graph stats:")
     self.combo_current = wx.ComboBox(self, -1, style=wx.CB_READONLY)
     self.label_min = wx.StaticText(self, -1, "Min:")
     self.float_min = wx.StaticText(self, -1, "", size=(50,-1))
     self.label_max = wx.StaticText(self, -1, "Max:")
     self.float_max = wx.StaticText(self, -1, "", size=(50,-1))
     self.label_mean = wx.StaticText(self, -1, "Mean:")
     self.float_mean = wx.StaticText(self, -1, "", size=(50,-1))
     self.label_last = wx.StaticText(self, -1, "Last:")
     self.float_last = wx.StaticText(self, -1, "", size=(50,-1))
     self.line1 = wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL)
     self.label_var = wx.StaticText(self, -1, "Variable to monitorize:")
     self.choice_var = wx.ComboBox(self, -1, style=wx.CB_READONLY|wx.CB_SORT)
     self.button_add = wx.Button(self, -1, "Add variable")
     self.line2 = wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL)
     self.label_period = wx.StaticText(self, -1, "Global history period:")
     self.int_period = intctrl.IntCtrl(
         self, value=10, min=1, max=99, limited=True,
         size=wx.Size(40,-1), style=wx.TE_RIGHT
         )
     self.label_seconds = wx.StaticText(self, -1, "seconds")
     self.line3 = wx.StaticLine(self, -1, style=wx.LI_VERTICAL)
     self.button_show = wx.ToggleButton(self, -1, "Show graphs")
     self.button_fullscreen = wx.ToggleButton(self, -1, "Fullscreen")
     self.graphs = []
     
     self.__set_properties()
     self.__do_layout()
     self.__bind_events()
     
     # Add current graph found in the monitor server
     monitor_server = servers.get_monitor_server()
     for i in range( monitor_server.getnumgraphs() ):
         self.__add_graph_bar( monitor_server.getgraphvarname(i) )
     
     # Timer to update the current graph stats
     self.stats_timer = wx.PyTimer(self.update_current_stats)
     self.stats_timer.Start(50)
Exemplo n.º 9
0
 def __on_toggle_enable(self, event):
     graph_index = self.get_graph_index()
     servers.get_monitor_server().setgraphactive( graph_index,
         event.IsChecked() )
Exemplo n.º 10
0
 def on_toggle_fullscreen(self, event):
     servers.get_monitor_server().setfullscreen(
         self.button_fullscreen.GetValue() )
Exemplo n.º 11
0
 def on_toggle_show(self, event):
     servers.get_monitor_server().setdisplayactivated(
         self.button_show.GetValue() )
Exemplo n.º 12
0
 def on_change_period(self, event):
     servers.get_monitor_server().sethistoryperiod(
         float( self.int_period.get_value() ) )
Exemplo n.º 13
0
 def on_choose_graph(self, event):
     if self.combo_current.GetSelection() != wx.NOT_FOUND:
         servers.get_monitor_server().setcurrentgraph(
             self.combo_current.GetSelection() )
         self.stats_enabled = True