- 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
4 changed files with 450 additions and 645 deletions
|
@ -28,9 +28,12 @@
|
|||
#include "gui_builder.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/simulation.hh"
|
||||
|
||||
#include "backend/serializers_gatekeeper.hh"
|
||||
#include "backend/serializer.hh"
|
||||
|
||||
|
@ -43,21 +46,13 @@
|
|||
#include <gtkmm/menuitem.h>
|
||||
#include <gtkmm/scrolledwindow.h>
|
||||
#include <gtkmm/stock.h>
|
||||
#include <gtkmm/toolbutton.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace sgpem;
|
||||
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
|
||||
GuiBuilder::on_edit_preferences_activate()
|
||||
|
@ -215,6 +210,37 @@ GuiBuilder::GuiBuilder(const std::string& gladefile)
|
|||
_refXml->get_widget("MenuItem.File.SaveAs", file_saveas);
|
||||
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...
|
||||
// here -- ugly -- derive widgets and then use
|
||||
// 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"));
|
||||
|
||||
|
||||
// Random Error Generator
|
||||
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
|
||||
// Insert the schedulables TreeView custom widget
|
||||
ScrolledWindow* schedulables_sw = NULL;
|
||||
_refXml->get_widget("SchedulablesScrolledWindow", schedulables_sw);
|
||||
|
||||
SchedulablesTreeWidget* scheds_tree = manage(new SchedulablesTreeWidget());
|
||||
schedulables_sw->add(*scheds_tree);
|
||||
// we have to remember to manually show custom added widgets:
|
||||
scheds_tree->show();
|
||||
|
||||
|
||||
ResourcesWidget* resources_widget = NULL;
|
||||
_refXml->get_widget_derived("Resources.Tree", resources_widget);
|
||||
resources_widget->show();
|
||||
|
||||
|
||||
// Main simulation widget
|
||||
ScrolledWindow* simulation_window = NULL;
|
||||
_refXml->get_widget("SimulationScrolledWindow", simulation_window);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue