- Add naive code to test Simulation from the GUI. Please note that
we need to move the "continous/non-continous" code snippet out of ConcreteSimulation and into TextualSimulation/the GUI Simulation. In fact, ConcreteSimulation is just a state machine that performs a single step and then puts itself either in paused state (if the Simulation hasn't finished) or into stopped state (if it finished) git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@945 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
aa608a1cc2
commit
1087d45628
File diff suppressed because it is too large
Load Diff
|
@ -79,11 +79,11 @@ libpyloader_la_CPPFLAGS = \
|
||||||
libpyloader_la_CXXFLAGS = \
|
libpyloader_la_CXXFLAGS = \
|
||||||
$(VISIB_HIDDEN)
|
$(VISIB_HIDDEN)
|
||||||
libpyloader_la_LIBADD = \
|
libpyloader_la_LIBADD = \
|
||||||
$(PYTHON_LDFLAGS) \
|
|
||||||
$(PYTHON_EXTRA_LIBS) \
|
$(PYTHON_EXTRA_LIBS) \
|
||||||
$(GLIBMM_LIBS) \
|
$(GLIBMM_LIBS) \
|
||||||
$(SGPEMV2_LIBS)
|
$(SGPEMV2_LIBS)
|
||||||
libpyloader_la_LDFLAGS = \
|
libpyloader_la_LDFLAGS = \
|
||||||
|
$(PYTHON_LDFLAGS) \
|
||||||
$(PYTHON_EXTRA_LDFLAGS) \
|
$(PYTHON_EXTRA_LDFLAGS) \
|
||||||
$(LT_LDFLAGS) \
|
$(LT_LDFLAGS) \
|
||||||
-version-info 0:0:0 \
|
-version-info 0:0:0 \
|
||||||
|
@ -165,7 +165,7 @@ noinst_PROGRAMS = \
|
||||||
|
|
||||||
src_testsuite_test_pyloader_CPPFLAGS = \
|
src_testsuite_test_pyloader_CPPFLAGS = \
|
||||||
-I@top_srcdir@ \
|
-I@top_srcdir@ \
|
||||||
-DSHAREDIR="\"$(sharedir)\"" \
|
-DSHAREDIR="\"$(sharedir)\"" \
|
||||||
$(PYTHON_CPPFLAGS) \
|
$(PYTHON_CPPFLAGS) \
|
||||||
$(GLIBMM_CFLAGS) \
|
$(GLIBMM_CFLAGS) \
|
||||||
$(GTHREAD_CFLAGS) \
|
$(GTHREAD_CFLAGS) \
|
||||||
|
|
|
@ -28,9 +28,12 @@
|
||||||
#include "gui_builder.hh"
|
#include "gui_builder.hh"
|
||||||
#include "graphical_preferences_editor.hh"
|
#include "graphical_preferences_editor.hh"
|
||||||
|
|
||||||
|
#include "backend/cpu_policies_gatekeeper.hh"
|
||||||
|
#include "backend/cpu_policy.hh"
|
||||||
|
#include "backend/cpu_policy_manager.hh"
|
||||||
|
|
||||||
#include "backend/history.hh"
|
#include "backend/history.hh"
|
||||||
#include "backend/simulation.hh"
|
#include "backend/simulation.hh"
|
||||||
|
|
||||||
#include "backend/serializers_gatekeeper.hh"
|
#include "backend/serializers_gatekeeper.hh"
|
||||||
#include "backend/serializer.hh"
|
#include "backend/serializer.hh"
|
||||||
|
|
||||||
|
@ -43,21 +46,13 @@
|
||||||
#include <gtkmm/menuitem.h>
|
#include <gtkmm/menuitem.h>
|
||||||
#include <gtkmm/scrolledwindow.h>
|
#include <gtkmm/scrolledwindow.h>
|
||||||
#include <gtkmm/stock.h>
|
#include <gtkmm/stock.h>
|
||||||
|
#include <gtkmm/toolbutton.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
using Gnome::Glade::Xml;
|
using Gnome::Glade::Xml;
|
||||||
|
|
||||||
void
|
|
||||||
test_me()
|
|
||||||
{
|
|
||||||
// A test for widget display:
|
|
||||||
|
|
||||||
Simulation& sim = Simulation::get_instance();
|
|
||||||
sim.get_history().add_process("goofy", 0, 0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GuiBuilder::on_edit_preferences_activate()
|
GuiBuilder::on_edit_preferences_activate()
|
||||||
|
@ -215,6 +210,37 @@ GuiBuilder::GuiBuilder(const std::string& gladefile)
|
||||||
_refXml->get_widget("MenuItem.File.SaveAs", file_saveas);
|
_refXml->get_widget("MenuItem.File.SaveAs", file_saveas);
|
||||||
file_saveas->signal_activate().connect(sigc::mem_fun(*this, &GuiBuilder::on_file_saveas_activate));
|
file_saveas->signal_activate().connect(sigc::mem_fun(*this, &GuiBuilder::on_file_saveas_activate));
|
||||||
|
|
||||||
|
|
||||||
|
// Start, pause and stop simulation from the toolbar
|
||||||
|
// TODO: can we use action groups instead of this?
|
||||||
|
Simulation& sim = Simulation::get_instance();
|
||||||
|
|
||||||
|
// FIXME: just to try; a proper way to select a policy has to be installed
|
||||||
|
CPUPoliciesGatekeeper& pgk = CPUPoliciesGatekeeper::get_instance();
|
||||||
|
CPUPolicy* policy = pgk.get_registered()[0]->get_avail_policies()[1]; // RoundRobin at the moment of writing
|
||||||
|
std::cout << "Selected policy : " << policy->get_name() << std::endl;
|
||||||
|
pgk.activate_policy(&sim.get_history(), policy);
|
||||||
|
sim.set_policy(policy);
|
||||||
|
|
||||||
|
ToolButton *toolbt_start, *toolbt_pause, *toolbt_stop;
|
||||||
|
_refXml->get_widget("ToolBar.Play", toolbt_start);
|
||||||
|
_refXml->get_widget("ToolBar.Pause", toolbt_pause);
|
||||||
|
_refXml->get_widget("ToolBar.Stop", toolbt_stop);
|
||||||
|
toolbt_start->signal_clicked().connect(sigc::mem_fun(sim, &Simulation::run));
|
||||||
|
toolbt_pause->signal_clicked().connect(sigc::mem_fun(sim, &Simulation::pause));
|
||||||
|
toolbt_stop->signal_clicked().connect(sigc::mem_fun(sim, &Simulation::stop));
|
||||||
|
// Sensitivities
|
||||||
|
toolbt_start->signal_clicked().connect(sigc::bind(sigc::mem_fun(*toolbt_stop, &ToolButton::set_sensitive), true));
|
||||||
|
toolbt_start->signal_clicked().connect(sigc::bind(sigc::mem_fun(*toolbt_pause, &ToolButton::set_sensitive), true));
|
||||||
|
toolbt_start->signal_clicked().connect(sigc::bind(sigc::mem_fun(*toolbt_start, &ToolButton::set_sensitive), false));
|
||||||
|
|
||||||
|
toolbt_pause->signal_clicked().connect(sigc::bind(sigc::mem_fun(*toolbt_pause, &ToolButton::set_sensitive), false));
|
||||||
|
|
||||||
|
toolbt_stop->signal_clicked().connect(sigc::bind(sigc::mem_fun(*toolbt_stop, &ToolButton::set_sensitive), false));
|
||||||
|
toolbt_stop->signal_clicked().connect(sigc::bind(sigc::mem_fun(*toolbt_pause, &ToolButton::set_sensitive), false));
|
||||||
|
toolbt_stop->signal_clicked().connect(sigc::bind(sigc::mem_fun(*toolbt_start, &ToolButton::set_sensitive), true));
|
||||||
|
|
||||||
|
|
||||||
// Connect extra signals (decide where to do this...
|
// Connect extra signals (decide where to do this...
|
||||||
// here -- ugly -- derive widgets and then use
|
// here -- ugly -- derive widgets and then use
|
||||||
// Glade::Xml::get_widget_derived -- better --)
|
// Glade::Xml::get_widget_derived -- better --)
|
||||||
|
@ -238,27 +264,20 @@ GuiBuilder::GuiBuilder(const std::string& gladefile)
|
||||||
about_dialog->set_logo(Gdk::Pixbuf::create_from_file(GLADEDIR "/logo.png"));
|
about_dialog->set_logo(Gdk::Pixbuf::create_from_file(GLADEDIR "/logo.png"));
|
||||||
|
|
||||||
|
|
||||||
// Random Error Generator
|
// Insert the schedulables TreeView custom widget
|
||||||
MenuItem* debug_error = NULL;
|
|
||||||
_refXml->get_widget("MenuItem.Debug.Error", debug_error);
|
|
||||||
debug_error->signal_activate().connect(sigc::ptr_fun(test_me));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Temporary code to test the Schedulables custom widget
|
|
||||||
ScrolledWindow* schedulables_sw = NULL;
|
ScrolledWindow* schedulables_sw = NULL;
|
||||||
_refXml->get_widget("SchedulablesScrolledWindow", schedulables_sw);
|
_refXml->get_widget("SchedulablesScrolledWindow", schedulables_sw);
|
||||||
|
|
||||||
SchedulablesTreeWidget* scheds_tree = manage(new SchedulablesTreeWidget());
|
SchedulablesTreeWidget* scheds_tree = manage(new SchedulablesTreeWidget());
|
||||||
schedulables_sw->add(*scheds_tree);
|
schedulables_sw->add(*scheds_tree);
|
||||||
// we have to remember to manually show custom added widgets:
|
// we have to remember to manually show custom added widgets:
|
||||||
scheds_tree->show();
|
scheds_tree->show();
|
||||||
|
|
||||||
|
|
||||||
ResourcesWidget* resources_widget = NULL;
|
ResourcesWidget* resources_widget = NULL;
|
||||||
_refXml->get_widget_derived("Resources.Tree", resources_widget);
|
_refXml->get_widget_derived("Resources.Tree", resources_widget);
|
||||||
resources_widget->show();
|
resources_widget->show();
|
||||||
|
|
||||||
|
|
||||||
// Main simulation widget
|
// Main simulation widget
|
||||||
ScrolledWindow* simulation_window = NULL;
|
ScrolledWindow* simulation_window = NULL;
|
||||||
_refXml->get_widget("SimulationScrolledWindow", simulation_window);
|
_refXml->get_widget("SimulationScrolledWindow", simulation_window);
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
// along with SGPEMv2; if not, write to the Free Software
|
// along with SGPEMv2; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
#include "gettext.h"
|
||||||
|
|
||||||
#include "schedulables_tree_widget.hh"
|
#include "schedulables_tree_widget.hh"
|
||||||
#include "backend/history.hh"
|
#include "backend/history.hh"
|
||||||
#include "backend/simulation.hh"
|
#include "backend/simulation.hh"
|
||||||
|
@ -239,6 +241,8 @@ SchedulablesTreeWidget::on_button_press_event(GdkEventButton* event)
|
||||||
break;
|
break;
|
||||||
case htype_subrequest:
|
case htype_subrequest:
|
||||||
removes = "<menuitem action='RemoveSubrequest'/>";
|
removes = "<menuitem action='RemoveSubrequest'/>";
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
adds += "<menuitem action='AddProcess'/>";
|
adds += "<menuitem action='AddProcess'/>";
|
||||||
|
@ -265,8 +269,7 @@ SchedulablesTreeWidget::on_button_press_event(GdkEventButton* event)
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SchedulablesTreeWidget::_update_expanded_vector(Gtk::TreeView* treeview,
|
SchedulablesTreeWidget::_update_expanded_vector(Gtk::TreeView*, const Gtk::TreeModel::Path& path)
|
||||||
const Gtk::TreeModel::Path& path)
|
|
||||||
{
|
{
|
||||||
_expanded_rows.push_back(path.to_string());
|
_expanded_rows.push_back(path.to_string());
|
||||||
}
|
}
|
||||||
|
@ -347,12 +350,11 @@ SchedulablesTreeWidget::update(const History& history)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore expanded rows
|
// Restore expanded rows
|
||||||
for(vector<Glib::ustring>::iterator it = _expanded_rows.begin(); it != _expanded_rows.end(); ++it)
|
for(Iseq<vector<Glib::ustring>::const_iterator> it = const_iseq(_expanded_rows); it; ++it)
|
||||||
expand_row(Gtk::TreeModel::Path(*it), false);
|
expand_row(Gtk::TreeModel::Path(*it), false);
|
||||||
|
|
||||||
// We can clear it now, since until next update we won't need it.
|
// We can clear it now, since until next update we won't need it.
|
||||||
_expanded_rows.clear();
|
_expanded_rows.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue