Commit 6b1f677c authored by Mathias Ettinger's avatar Mathias Ettinger

Removed probes tab from manager

parent 4e8d8b02
This diff is collapsed.
......@@ -48,7 +48,6 @@ from opensand_manager_gui.view.window_view import WindowView
from opensand_manager_gui.view.conf_event import ConfEvent
from opensand_manager_gui.view.resource_event import ResourceEvent
from opensand_manager_gui.view.run_event import RunEvent
from opensand_manager_gui.view.probe_event import ProbeEvent
from opensand_manager_gui.view.tool_event import ToolEvent
from opensand_manager_gui.view.event_handler import EventResponseHandler
from opensand_manager_gui.view.popup.infos import error_popup, \
......@@ -98,13 +97,10 @@ class View(WindowView):
self._eventresource.update_view)
self._eventtool = ToolEvent(self.get_current(),
self._model, self._log)
self._eventprobe = ProbeEvent(self.get_current(),
self._model, self._log)
self._eventconf.activate(False)
self._eventresource.activate(False)
self._eventtool.activate(False)
self._eventprobe.activate(False)
except ProbeException:
self._log.warning("Probe tab was disabled")
self._ui.get_widget("probe_tab").set_sensitive(False)
......@@ -119,13 +115,11 @@ class View(WindowView):
self._current_page = self._ui.get_widget('notebook').get_current_page()
self._pages = \
{
self._pages = {
'run' : 0,
'conf' : 2,
'resources' : 1,
'tools' : 3,
'probes': 4,
}
# update the window title
......@@ -148,7 +142,6 @@ class View(WindowView):
self._eventconf,
self._eventresource,
self._eventtool,
self._eventprobe,
self._log)
# start event response handler
......@@ -208,8 +201,6 @@ class View(WindowView):
self._eventrun.close()
self._log.debug("View: close tool view")
self._eventtool.close()
self._log.debug("View: close probe view")
self._eventprobe.close()
self._log.debug("View: closed")
if self._event_response_handler.is_alive():
self._log.debug("Run Event: join response event handler")
......@@ -269,10 +260,6 @@ class View(WindowView):
"please deploy the missing component(s), "
"they will be automatically detected")
if not self._model.is_collector_functional():
self._log.warning("The OpenSAND collector is not known. "
"The probes will not be available.")
# check if some components are running
state = self._model.is_running()
# if at least one application is started at manager startup,
......@@ -304,12 +291,7 @@ class View(WindowView):
if self._current_page == self._pages['run']:
gobject.idle_add(self._eventrun.refresh,
priority=gobject.PRIORITY_HIGH_IDLE+20)
# Update simulation state for the probe view
gobject.idle_add(self._eventprobe.simu_state_changed,
priority=gobject.PRIORITY_HIGH_IDLE+20)
# restart timer
return True
......@@ -376,8 +358,6 @@ class View(WindowView):
self._eventresource.activate(False)
if self._eventtool is not None:
self._eventtool.activate(False)
if self._eventprobe is not None:
self._eventprobe.activate(False)
elif page_num == self._pages['conf']:
if self._eventrun is not None:
self._eventrun.activate(False)
......@@ -387,8 +367,6 @@ class View(WindowView):
self._eventresource.activate(False)
if self._eventtool is not None:
self._eventtool.activate(False)
if self._eventprobe is not None:
self._eventprobe.activate(False)
elif page_num == self._pages['resources']:
if self._eventrun is not None:
self._eventrun.activate(False)
......@@ -399,8 +377,6 @@ class View(WindowView):
self._eventresource.update_view()
if self._eventtool is not None:
self._eventtool.activate(False)
if self._eventprobe is not None:
self._eventprobe.activate(False)
elif page_num == self._pages['tools']:
if self._eventconf is not None:
self._eventconf.activate(False)
......@@ -410,19 +386,6 @@ class View(WindowView):
self._eventrun.activate(False)
if self._eventtool is not None:
self._eventtool.activate(True)
if self._eventprobe is not None:
self._eventprobe.activate(False)
elif page_num == self._pages['probes']:
if self._eventconf is not None:
self._eventconf.activate(False)
if self._eventresource is not None:
self._eventresource.activate(False)
if self._eventrun is not None:
self._eventrun.activate(False)
if self._eventtool is not None:
self._eventtool.activate(False)
if self._eventprobe is not None:
self._eventprobe.activate(True)
def run(self):
""" start gobject loops """
......@@ -497,7 +460,6 @@ class View(WindowView):
else:
self.set_title("OpenSAND Manager - [%s]" % folder)
# reload the configuration
self._eventprobe.scenario_changed()
try:
self._eventconf.update_view()
self._eventconf.read_conf_free_spot()
......@@ -631,7 +593,6 @@ class View(WindowView):
def set_default_run(self):
""" reset the run value """
self._model.set_run("")
self._eventprobe.run_changed()
def on_window_key_press_event(self, source=None, event=None):
""" callback called on keyboard press """
......@@ -651,8 +612,6 @@ class View(WindowView):
""" called when the environment plane program list changes """
gobject.idle_add(self._eventrun.simu_program_list_changed,
programs_dict)
gobject.idle_add(self._eventprobe.simu_program_list_changed,
programs_dict)
def on_new_program_log(self, program, name, level, message):
""" called when an environment plane log is received """
......@@ -661,8 +620,7 @@ class View(WindowView):
def on_new_probe_value(self, probe, timestamp, value):
""" called when a new probe value is received """
gobject.idle_add(self._eventprobe.new_probe_value,
probe, timestamp, value)
pass
##### TEST #####
......
......@@ -42,16 +42,14 @@ from opensand_manager_gui.view.popup.progress_dialog import ProgressDialog
class EventResponseHandler(threading.Thread):
""" Get response events from hosts controllers """
def __init__(self, event_manager_response,
run_view, conf_view, resource_view, tool_view,
probe_view, manager_log):
def __init__(self, event_manager_response, run_view,
conf_view, resource_view, tool_view, manager_log):
threading.Thread.__init__(self)
self.setName("EventResponseHandler")
self._run_view = run_view
self._conf_view = conf_view
self._resource_view = resource_view
self._tool_view = tool_view
self._probe_view = probe_view
self._event_manager_response = event_manager_response
self._log = manager_log
self._prog_dialog = None
......@@ -113,8 +111,6 @@ class EventResponseHandler(threading.Thread):
# enable back the 'stop opensand' button
gobject.idle_add(self._run_view.disable_start_button, False,
priority=gobject.PRIORITY_HIGH_IDLE+20)
gobject.idle_add(self._probe_view.simu_state_changed,
priority=gobject.PRIORITY_HIGH_IDLE+20)
# check if everything went fine
while self._run_view.is_running() and idx < 10:
idx += 1
......@@ -141,8 +137,6 @@ class EventResponseHandler(threading.Thread):
# update the label of the 'start/stop opensand' button
gobject.idle_add(self._run_view.set_start_stop_button,
priority=gobject.PRIORITY_HIGH_IDLE+20)
gobject.idle_add(self._probe_view.simu_state_changed,
priority=gobject.PRIORITY_HIGH_IDLE+20)
# enable all the buttons
gobject.idle_add(self._run_view.disable_start_button, False,
priority=gobject.PRIORITY_HIGH_IDLE+20)
......@@ -157,9 +151,6 @@ class EventResponseHandler(threading.Thread):
text = self._event_manager_response.get_text()
gobject.idle_add(self.on_probe_transfer_progress,
False)
if text == 'done':
self._probe_view.simu_data_available()
# TODO: if text == 'fail':
elif event_type == 'quit':
# quit event
......
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#
#
# OpenSAND is an emulation testbed aiming to represent in a cost effective way a
# satellite telecommunication system for research and engineering activities.
#
#
# Copyright © 2019 TAS
#
#
# This file is part of the OpenSAND testbed.
#
#
# OpenSAND is free software : you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY, without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see http://www.gnu.org/licenses/.
#
#
# Author: Vincent Duvert / Viveris Technologies <vduvert@toulouse.viveris.com>
"""
config_collection_dialog.py - Dialog allowing to enable and disable probes
"""
import gtk
import gobject
from opensand_manager_gui.view.window_view import WindowView
(ACTIVE, NAME, PROG_ID, ID) = range(4)
class ConfigCollectionDialog(WindowView):
""" an advanced configuration window """
def __init__(self, model, manager_log, sel_controller):
WindowView.__init__(self, None, 'config_collection_window')
self._dlg = self._ui.get_widget('config_collection_window')
self._dlg.set_title("Configure probes collection - OpenSAND Manager")
self._dlg.set_icon_name(gtk.STOCK_PREFERENCES)
widget = self._ui.get_widget('config_collection_scroll')
self._listview = gtk.TreeView()
widget.add(self._listview)
widget.show_all()
self._sel_controller = sel_controller
self._model = model
self._log = manager_log
self._shown = False
self._programs = {}
self._probe_store = gtk.TreeStore(gobject.TYPE_BOOLEAN,
gobject.TYPE_STRING,
gobject.TYPE_INT,
gobject.TYPE_INT)
self._listview.set_model(self._probe_store)
self._listview.get_selection().set_mode(gtk.SELECTION_NONE)
column_text = gtk.TreeViewColumn("Probe")
self._listview.append_column(column_text)
cellrenderer_toggle = gtk.CellRendererToggle()
column_text.pack_start(cellrenderer_toggle, False)
column_text.add_attribute(cellrenderer_toggle, "active", ACTIVE)
cellrenderer_toggle.connect("toggled", self._cell_toggled)
cellrenderer_text = gtk.CellRendererText()
column_text.pack_start(cellrenderer_text, True)
column_text.add_attribute(cellrenderer_text, "text", NAME)
def show(self):
""" show the window """
if self._shown:
self._dlg.present()
return
self._shown = True
self._sel_controller.register_collection_dialog(self)
self._dlg.show()
def hide(self):
""" hide the window """
if not self._shown:
return
self._sel_controller.register_collection_dialog(None)
self._shown = False
self._dlg.hide()
def update_list(self, program_dict):
""" update the probe list shown by the window """
self._programs = program_dict
self._probe_store.clear()
for program in self._programs.itervalues():
parent = self._probe_store.append(None, [True, program.name,
program.ident, -1])
for probe in program.get_probes():
if not probe.enabled:
# probes are not all active, untick box
self._probe_store.set_value(parent, ACTIVE, False)
self._probe_store.append(parent, [probe.enabled,
probe.full_name.split('.', 1)[1],
probe.program.ident,
probe.ident])
def _cell_toggled(self, _, path):
""" a window cell has been toggled """
it = self._probe_store.get_iter(path)
parent = self._probe_store.iter_parent(it)
if parent is None:
# program name, get the active value
val = not self._probe_store.get_value(it, ACTIVE)
self._probe_store.set_value(it, ACTIVE, val)
for idx in range(self._probe_store.iter_n_children(it)):
child = self._probe_store.iter_nth_child(it, idx)
self._probe_toggled(child, it, val)
return
self._probe_toggled(it, parent)
def _probe_toggled(self, it, parent, val=None):
""" a probe has been toggled """
new_value = val
if val is None:
new_value = not self._probe_store.get_value(it, ACTIVE)
prog_id = self._probe_store.get_value(it, PROG_ID)
probe_id = self._probe_store.get_value(it, ID)
probe = self._programs[prog_id].get_probe(probe_id)
was_hidden = False
if probe.displayed:
was_hidden = True
probe.displayed = False
probe.enabled = new_value
self._probe_store.set(it, ACTIVE, new_value)
# update parent box
# if this one is False untick
# TODO see gtk.TreeModel.row_has_child_toggled !!
if new_value is False:
self._probe_store.set_value(parent, ACTIVE, False)
else: # we need to check if there is a child that is not activated
# first set active
self._probe_store.set_value(parent, ACTIVE, True)
for idx in range(self._probe_store.iter_n_children(parent)):
child = self._probe_store.iter_nth_child(parent, idx)
if not self._probe_store.get_value(child, ACTIVE):
# one is not active, untick box
self._probe_store.set_value(parent, ACTIVE, False)
self._sel_controller.probe_enabled_changed(probe, was_hidden)
def on_config_collection_window_delete_event(self, _widget, _event):
""" the window close button was clicked """
self.hide()
return True
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#
#
# OpenSAND is an emulation testbed aiming to represent in a cost effective way a
# satellite telecommunication system for research and engineering activities.
#
#
# Copyright © 2019 TAS
#
#
# This file is part of the OpenSAND testbed.
#
#
# OpenSAND is free software : you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY, without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see http://www.gnu.org/licenses/.
#
#
# Author: Julien BERNARD / <jbernard@toulouse.viveris.com>
"""
run_dialog.py - OpenSAND manager scenario dialog
"""
import os
import gtk
import gobject
from opensand_manager_core.utils import ST, GW, SAT
from opensand_manager_gui.view.popup.infos import error_popup
from opensand_manager_gui.view.window_view import WindowView
MAX_ST = 5
class RunDialog(WindowView):
""" dialog to get the scenario to load """
def __init__(self, scenario, run):
WindowView.__init__(self, None, 'run_dialog')
self._dlg = self._ui.get_widget('run_dialog')
self._dlg.set_keep_above(True)
self._dlg.set_modal(True)
self._dlg.set_icon_name(gtk.STOCK_PREFERENCES)
# add available runs into combo box
self._has_runs = self.populate(scenario, run)
def go(self):
""" run the window """
# run the dialog and store the response
run = None
if self._has_runs:
self._dlg.present()
result = self._dlg.run()
if result == 0:
widget = self._ui.get_widget("run_box")
model = widget.get_model()
active = widget.get_active_iter()
run = model.get_value(active, 0)
else:
error_popup("No runs found in the current scenario.")
self._dlg.destroy()
return run
def populate(self, scenario, run):
""" add run elements into the combo box """
# the list of directories to ignore
ignore = [SAT,'tools', 'plugins', 'modcod']
for i in range(MAX_ST + 1):
ignore.append(ST + str(i))
for i in [0, 10]:
ignore.append(GW + str(i))
list_id = 0
active_id = 0
store = gtk.ListStore(gobject.TYPE_STRING)
content = os.listdir(scenario)
for path in sorted(content):
if os.path.isdir(os.path.join(scenario, path)) and \
path not in ignore:
store.append([path])
if path == run:
active_id = list_id
list_id += 1
widget = self._ui.get_widget("run_box")
widget.set_model(store)
cell = gtk.CellRendererText()
widget.pack_start(cell, True)
widget.add_attribute(cell, 'text', 0)
widget.set_active(active_id)
return list_id > 0
def on_run_dialog_delete_event(self, source=None, event=None):
""" delete-event on window """
self.close()
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#
#
# OpenSAND is an emulation testbed aiming to represent in a cost effective way a
# satellite telecommunication system for research and engineering activities.
#
#
# Copyright © 2019 TAS
#
#
# This file is part of the OpenSAND testbed.
#
#
# OpenSAND is free software : you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY, without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see http://www.gnu.org/licenses/.
#
#
# Author: Vincent Duvert / Viveris Technologies <vduvert@toulouse.viveris.com>
"""
probe_display.py - handles the display of probe values on graphs.
"""
from collections import deque
from matplotlib.backends.backend_gtkagg import FigureCanvasGTK
from matplotlib.ticker import FormatStrFormatter
import gobject
import matplotlib.pyplot as plt
import random
GRAPH_MAX_POINTS = 30
TIME_FORMATTER = FormatStrFormatter('%.1f')
VALUE_FORMATTER = FormatStrFormatter('%2.8g')
class ProbeGraph(object):
"""
Represents the graph for a probe
"""
def __init__(self, display, program_name, probe_name, unit):
self._display = display
probe_name = probe_name.replace("_", " ").replace(".", ": ")
self._title = "[%s] %s" % (program_name, probe_name)
if unit:
self._title += " (%s)" % unit
self._index = 0
self._times = deque(maxlen=GRAPH_MAX_POINTS)
self._values = deque(maxlen=GRAPH_MAX_POINTS)
self._axes = None
self._xaxis = None
self._yaxis = None
self._color = random.choice("bgrcmyk")
self._plot_type = "default"
self._dirty = False
def setup(self, axes, direct_values=None):
"""
Sets up the graph display.
"""
self._axes = axes
self._xaxis = axes.get_xaxis()
self._yaxis = axes.get_yaxis()
if direct_values is not None:
times, self._values = direct_values
self._times = [time / 1000.0 for time in times]
self._redraw()
def update(self):
"""
Updates the graph display to take new values into account
"""
if not self._dirty:
return False
self._redraw()
self._dirty = False
return True
def add_value(self, time, value):
"""
Appends a value to the graph
"""
self._times.append(time / 1000.0)
self._values.append(value)
self._dirty = True
def _redraw(self):
"""
Plots the current values
"""
self._axes.cla()
x = list(self._times)
y = list(self._values)
if not self._dirty:
# add fake values for best print, taking absolute minimum value
# on ordinates allows getting correct scale in any case
# TODO if some values are computed on stats, ignore these
try:
x.insert(0, x[0] - 1)
x.insert(0, 0)
y.insert(0, min(y, key=abs))
y.insert(0, min(y, key=abs))
except (ValueError, IndexError):
pass
try:
xmin, xmax = min(x), max(x)
ymin, ymax = min(y), max(y)
except ValueError:
xmin, xmax, ymin, ymax = (0, 0, 0, 0)
if xmin == xmax:
xmax = xmin + 1
if ymin == ymax:
ymax = ymin + 1
rymin = ymin - ((ymax - ymin) * 0.1)
rymax = ymax + ((ymax - ymin) * 0.1)
self._axes.set_title(self._title, size="small")
self._xaxis.set_major_formatter(TIME_FORMATTER)
self._yaxis.set_major_formatter(VALUE_FORMATTER)
try:
if self._plot_type == 'dot':
pl = self._axes.plot(x, y, 'o', 2, color=self._color)
elif self._plot_type == 'dotline':
pl = self._axes.plot(x, y, 'o-', 2, color=self._color)
elif self._plot_type == 'step':
pl = self._axes.plot(x, y, ls='steps', lw=2, c=self._color)
else: #line by default
self._axes.plot(x, y, '-', 2, color=self._color)
except ValueError:
# TODO find why this append
size = min(len(x), len(y))
while len(x) > size:
x.pop(0)
while len(y) > size:
y.pop(0)
self._axes.axis([xmin, xmax, rymin, rymax])
def set_plot_type(self, plot_type):
self._plot_type = plot_type
@property
def index(self):
"""
Get graph index
"""
return self._index
@index.setter
def index(self, value):
"""
Set the index value
"""
self._index = value
class ProbeDisplay(object):
"""
Handler for the graph display.
"""
def __init__(self, parent_box):
self._displayed_probes = {}
self._num_graphs = 0
self._plot_type = "dot"
self._fig = plt.figure()
self._fig.subplots_adjust(hspace=0.8)
self._canvas = FigureCanvasGTK(self._fig)
parent_box.pack_start(self._canvas, True, True)
self._canvas.show()
self._probe_data = {}
self._reset = False