- Make the schedulables widget do something useful, now that I know it was the simulation widget, not the schedulables one which completely put KO my system...
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@889 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
0b4db098eb
commit
09ad981251
|
@ -110,9 +110,10 @@ GuiBuilder::GuiBuilder(const std::string& gladefile)
|
||||||
// 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);
|
||||||
SimulationWidget* simulation_widget = manage(new SimulationWidget());
|
// FIXME completely f***s up my system!
|
||||||
simulation_window->add(*simulation_widget);
|
//SimulationWidget* simulation_widget = manage(new SimulationWidget());
|
||||||
simulation_widget->show();
|
//simulation_window->add(*simulation_widget);
|
||||||
|
//simulation_widget->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,12 @@
|
||||||
#include "backend/history.hh"
|
#include "backend/history.hh"
|
||||||
#include "backend/simulation.hh"
|
#include "backend/simulation.hh"
|
||||||
#include "backend/process.hh"
|
#include "backend/process.hh"
|
||||||
|
#include "backend/thread.hh"
|
||||||
|
#include "backend/resource.hh"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gtkmm/entry.h>
|
#include <gtkmm/entry.h>
|
||||||
#include <gtkmm/spinbutton.h>
|
#include <gtkmm/spinbutton.h>
|
||||||
|
@ -36,46 +40,40 @@ using namespace Glib;
|
||||||
using Gnome::Glade::Xml;
|
using Gnome::Glade::Xml;
|
||||||
|
|
||||||
SchedulablesTreeWidget::SchedulablesTreeWidget() :
|
SchedulablesTreeWidget::SchedulablesTreeWidget() :
|
||||||
_add_process_dialog_glade(Xml::create(GLADEDIR "/add-process-dialog.glade"))
|
_add_process_dialog_glade(Xml::create(GLADEDIR "/add-process-dialog.glade")),
|
||||||
|
_add_thread_dialog_glade(Xml::create(GLADEDIR "/add-thread-dialog.glade"))
|
||||||
|
|
||||||
{
|
{
|
||||||
_columns.add(_main_column);
|
_columns.add(_main_column);
|
||||||
|
_columns.add(_types_column);
|
||||||
_columns.add(_handles_column);
|
_columns.add(_handles_column);
|
||||||
_model = TreeStore::create(_columns);
|
_model = TreeStore::create(_columns);
|
||||||
|
|
||||||
set_model(_model);
|
set_model(_model);
|
||||||
|
|
||||||
/** JUST A BIT OF DATA FOR TESTING **/
|
|
||||||
|
|
||||||
//Gtk::TreeModel::Row row1 = *(_model->append());
|
|
||||||
//row1[_main_column] = ustring("ciccio");
|
|
||||||
|
|
||||||
// Gtk::TreeModel::Row row2 = *(_model->append());
|
|
||||||
// row2[_main_column] = ustring("pippo");
|
|
||||||
|
|
||||||
append_column("schedulables", _main_column);
|
append_column("schedulables", _main_column);
|
||||||
//invisible
|
//invisible
|
||||||
|
// append_column("handles", _types_column);
|
||||||
// append_column("handles", _handles_column);
|
// append_column("handles", _handles_column);
|
||||||
|
|
||||||
/** POPUP MENU **/
|
/** POPUP MENU **/
|
||||||
|
|
||||||
_action_group = Gtk::ActionGroup::create();
|
_action_group = Gtk::ActionGroup::create();
|
||||||
|
|
||||||
// _action_group->add( Gtk::Action::create("ContextMenu", "Schedulables") );
|
|
||||||
// _action_group->add( Gtk::Action::create("Add Process", Gtk::Stock::NEW),
|
|
||||||
// sigc::mem_fun(*this, &SchedulablesTreeWidget::on_action_file_new) );
|
|
||||||
_action_group->add( Gtk::Action::create("AddProcess", "Add Process"),
|
_action_group->add( Gtk::Action::create("AddProcess", "Add Process"),
|
||||||
sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_add_process) );
|
sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_add_process) );
|
||||||
//_action_group->add( Gtk::Action::create("Quit", Gtk::Stock::QUIT),
|
|
||||||
// sigc::mem_fun(*this, &SchedulablesTreeWidget::on_action_file_quit) );
|
_action_group->add( Gtk::Action::create("AddThread", "Add Thread"),
|
||||||
|
sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_add_thread) );
|
||||||
|
|
||||||
_UIManager = Gtk::UIManager::create();
|
_UIManager = Gtk::UIManager::create();
|
||||||
_UIManager->insert_action_group(_action_group);
|
_UIManager->insert_action_group(_action_group);
|
||||||
|
|
||||||
Glib::ustring ui_info =
|
Glib::ustring ui_info =
|
||||||
"<ui>"
|
"<ui>"
|
||||||
" <popup name='PopupMenu'>"
|
" <popup name='PopupMenu'>"
|
||||||
// " <menuitem action='ContextMenu'/>"
|
|
||||||
" <menuitem action='AddProcess'/>"
|
" <menuitem action='AddProcess'/>"
|
||||||
|
" <menuitem action='AddThread'/>"
|
||||||
" </popup>"
|
" </popup>"
|
||||||
"</ui>";
|
"</ui>";
|
||||||
|
|
||||||
|
@ -84,8 +82,10 @@ SchedulablesTreeWidget::SchedulablesTreeWidget() :
|
||||||
|
|
||||||
/** DIALOGS **/
|
/** DIALOGS **/
|
||||||
_add_process_dialog_glade->get_widget("AddProcessDialog", _add_process_dialog);
|
_add_process_dialog_glade->get_widget("AddProcessDialog", _add_process_dialog);
|
||||||
|
_add_thread_dialog_glade->get_widget("AddThreadDialog", _add_thread_dialog);
|
||||||
//FIXME why do I need to call this? Is it reasonable?
|
//FIXME why do I need to call this? Is it reasonable?
|
||||||
_add_process_dialog->hide();
|
_add_process_dialog->hide();
|
||||||
|
_add_thread_dialog->hide();
|
||||||
|
|
||||||
set_headers_visible(false);
|
set_headers_visible(false);
|
||||||
|
|
||||||
|
@ -119,15 +119,62 @@ SchedulablesTreeWidget::update(const History& history)
|
||||||
|
|
||||||
_model->clear();
|
_model->clear();
|
||||||
|
|
||||||
for(unsigned int i = 0; i < processes.size(); ++i)
|
// TODO use the new sequence iterator, it's been made for
|
||||||
|
// something!!!
|
||||||
|
for(unsigned int pi = 0; pi < processes.size(); ++pi)
|
||||||
{
|
{
|
||||||
Process& p = *processes[i];
|
Process& p = *processes[pi];
|
||||||
|
|
||||||
TreeModel::Row row = *(_model->append());
|
TreeModel::Row prow = *(_model->append());
|
||||||
row[_main_column] = p.get_name();
|
prow[_main_column] = p.get_name();
|
||||||
row[_handles_column] = &p;
|
prow[_types_column] = htype_process;
|
||||||
}
|
prow[_handles_column] = &p;
|
||||||
|
|
||||||
|
std::vector<Thread*> threads = p.get_threads();
|
||||||
|
|
||||||
|
for(unsigned int ti = 0; ti < threads.size(); ++ti)
|
||||||
|
{
|
||||||
|
Thread& t = *threads[ti];
|
||||||
|
|
||||||
|
TreeModel::Row trow = *(_model->append(prow.children()));
|
||||||
|
|
||||||
|
trow[_main_column] = t.get_name();
|
||||||
|
trow[_types_column] = htype_thread;
|
||||||
|
trow[_handles_column] = &t;
|
||||||
|
|
||||||
|
std::vector<Request*> requests = t.get_requests();
|
||||||
|
|
||||||
|
for(unsigned int ri = 0; ri < requests.size(); ++ri)
|
||||||
|
{
|
||||||
|
Request& r = *requests[ri];
|
||||||
|
|
||||||
|
TreeModel::Row rrow = *(_model->append(trow.children()));
|
||||||
|
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << "request " << ri + 1;
|
||||||
|
|
||||||
|
rrow[_main_column] = oss.str();
|
||||||
|
rrow[_types_column] = htype_request;
|
||||||
|
rrow[_handles_column] = &r;
|
||||||
|
|
||||||
|
std::vector<SubRequest*> subrequests = r.get_subrequests();
|
||||||
|
|
||||||
|
for(unsigned int sri = 0; sri < subrequests.size(); ++sri)
|
||||||
|
{
|
||||||
|
SubRequest& sr = *subrequests[sri];
|
||||||
|
|
||||||
|
TreeModel::Row srrow = *(_model->append(rrow.children()));
|
||||||
|
|
||||||
|
// we are sure the key is valid, or no?
|
||||||
|
Resource& res = *(history.get_last_environment().get_resources().find(sr.get_resource_key())->second);
|
||||||
|
|
||||||
|
srrow[_main_column] = res.get_name();
|
||||||
|
srrow[_types_column] = htype_subrequest;
|
||||||
|
srrow[_handles_column] = &sr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -151,3 +198,40 @@ SchedulablesTreeWidget::_on_add_process()
|
||||||
_add_process_dialog->hide();
|
_add_process_dialog->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SchedulablesTreeWidget::_on_add_thread()
|
||||||
|
{
|
||||||
|
TreeModel::iterator sel = get_selection()->get_selected();
|
||||||
|
|
||||||
|
if(!sel)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const void* p_handle = (*sel)[_handles_column];
|
||||||
|
HandleType type = (*sel)[_types_column];
|
||||||
|
Process* p = reinterpret_cast<Process*>(const_cast<void*>(p_handle));
|
||||||
|
|
||||||
|
if(p == NULL || type != htype_process)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(_add_thread_dialog->run() == RESPONSE_OK)
|
||||||
|
{
|
||||||
|
Entry* name_entry;
|
||||||
|
SpinButton* cpu_time_spin;
|
||||||
|
SpinButton* arrival_time_spin;
|
||||||
|
SpinButton* base_priority_spin;
|
||||||
|
|
||||||
|
_add_thread_dialog_glade->get_widget("Name.Entry", name_entry);
|
||||||
|
_add_thread_dialog_glade->get_widget("CpuTime.Spin", cpu_time_spin);
|
||||||
|
_add_thread_dialog_glade->get_widget("ArrivalTime.Spin", arrival_time_spin);
|
||||||
|
_add_thread_dialog_glade->get_widget("BasePriority.Spin", base_priority_spin);
|
||||||
|
|
||||||
|
Simulation::get_instance().get_history().add_thread(name_entry->get_text(),
|
||||||
|
*p,
|
||||||
|
cpu_time_spin->get_value_as_int(),
|
||||||
|
arrival_time_spin->get_value_as_int(),
|
||||||
|
base_priority_spin->get_value_as_int());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
_add_thread_dialog->hide();
|
||||||
|
}
|
||||||
|
|
|
@ -50,17 +50,30 @@ namespace sgpem
|
||||||
bool on_button_press_event(GdkEventButton* event);
|
bool on_button_press_event(GdkEventButton* event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
enum HandleType
|
||||||
|
{
|
||||||
|
htype_process,
|
||||||
|
htype_thread,
|
||||||
|
htype_request,
|
||||||
|
htype_subrequest,
|
||||||
|
htype_undefined
|
||||||
|
};
|
||||||
|
|
||||||
void _on_add_process();
|
void _on_add_process();
|
||||||
|
void _on_add_thread();
|
||||||
|
|
||||||
Glib::RefPtr<Gtk::TreeStore> _model;
|
Glib::RefPtr<Gtk::TreeStore> _model;
|
||||||
Gtk::TreeModelColumnRecord _columns;
|
Gtk::TreeModelColumnRecord _columns;
|
||||||
Gtk::TreeModelColumn<Glib::ustring> _main_column;
|
Gtk::TreeModelColumn<Glib::ustring> _main_column;
|
||||||
|
Gtk::TreeModelColumn<HandleType> _types_column;
|
||||||
Gtk::TreeModelColumn<void*> _handles_column;
|
Gtk::TreeModelColumn<void*> _handles_column;
|
||||||
Glib::RefPtr<Gtk::ActionGroup> _action_group;
|
Glib::RefPtr<Gtk::ActionGroup> _action_group;
|
||||||
Glib::RefPtr<Gtk::UIManager> _UIManager;
|
Glib::RefPtr<Gtk::UIManager> _UIManager;
|
||||||
Gtk::Menu* _menu;
|
Gtk::Menu* _menu;
|
||||||
Glib::RefPtr<Gnome::Glade::Xml> _add_process_dialog_glade;
|
Glib::RefPtr<Gnome::Glade::Xml> _add_process_dialog_glade;
|
||||||
|
Glib::RefPtr<Gnome::Glade::Xml> _add_thread_dialog_glade;
|
||||||
Gtk::Dialog* _add_process_dialog;
|
Gtk::Dialog* _add_process_dialog;
|
||||||
|
Gtk::Dialog* _add_thread_dialog;
|
||||||
};
|
};
|
||||||
|
|
||||||
} //~ namespace sgpem
|
} //~ namespace sgpem
|
||||||
|
|
Loading…
Reference in New Issue