- modified holt_widget to show processes or threads
- updated test-holt_widget to show processes or threads git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@930 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
8911016da8
commit
2ff804ecbe
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include "cairo_elements.hh"
|
#include "cairo_elements.hh"
|
||||||
#include "backend/history.hh"
|
#include "backend/history.hh"
|
||||||
#include "backend/process.hh"
|
#include "backend/schedulable.hh"
|
||||||
#include "backend/resource.hh"
|
#include "backend/resource.hh"
|
||||||
#include "backend/simulation.hh"
|
#include "backend/simulation.hh"
|
||||||
#include "backend/string_utils.hh"
|
#include "backend/string_utils.hh"
|
||||||
|
@ -151,35 +151,39 @@ Vec2 HoltResource::get_intersection_to(Vec2 pt)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HoltProcess::HoltProcess(const Process& process, Vec2 pt)
|
HoltSchedulable::HoltSchedulable(const Schedulable& schedulable, Vec2 pt)
|
||||||
: HoltNode(pt)
|
: HoltNode(pt)
|
||||||
{
|
{
|
||||||
_process = &process;
|
_schedulable = &schedulable;
|
||||||
}
|
}
|
||||||
|
|
||||||
HoltProcess::~HoltProcess()
|
HoltSchedulable::~HoltSchedulable()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void HoltProcess::draw(cairo_t *cr)
|
void HoltSchedulable::draw(cairo_t *cr)
|
||||||
{
|
{
|
||||||
cairo_save(cr); // save context state
|
cairo_save(cr); // save context state
|
||||||
|
|
||||||
// draw circle
|
// draw circle
|
||||||
cairo_arc (cr, _pos.real(), _pos.imag(), _radius, 0, 2 * M_PI);
|
cairo_arc (cr, _pos.real(), _pos.imag(), _radius, 0, 2 * M_PI);
|
||||||
// filling
|
// filling
|
||||||
switch(_process->get_state())
|
switch(_schedulable->get_state())
|
||||||
{
|
{
|
||||||
case Schedulable::state_running:
|
case Schedulable::state_running:
|
||||||
cairo_set_source_rgb (cr, 0.5, 1, 0.5);
|
//cairo_set_source_rgb (cr, 0.5, 1, 0.5);
|
||||||
|
cairo_set_source_rgb (cr, 0, 1, 0);
|
||||||
break;
|
break;
|
||||||
case Schedulable::state_ready:
|
case Schedulable::state_ready:
|
||||||
cairo_set_source_rgb (cr, 1, 1, 0.5);
|
// cairo_set_source_rgb (cr, 1, 1, 0.5);
|
||||||
|
cairo_set_source_rgb (cr, 1, 1, 0);
|
||||||
break;
|
break;
|
||||||
case Schedulable::state_blocked:
|
case Schedulable::state_blocked:
|
||||||
cairo_set_source_rgb (cr, 1, 0.5, 0.5);
|
// cairo_set_source_rgb (cr, 1, 0.5, 0.5);
|
||||||
|
cairo_set_source_rgb (cr, 1, 0, 0);
|
||||||
break;
|
break;
|
||||||
case Schedulable::state_future:
|
case Schedulable::state_future:
|
||||||
|
// cairo_set_source_rgb (cr, 0.5, 0.5, 1);
|
||||||
cairo_set_source_rgb (cr, 0.5, 0.5, 1);
|
cairo_set_source_rgb (cr, 0.5, 0.5, 1);
|
||||||
break;
|
break;
|
||||||
case Schedulable::state_terminated:
|
case Schedulable::state_terminated:
|
||||||
|
@ -195,10 +199,10 @@ void HoltProcess::draw(cairo_t *cr)
|
||||||
cairo_clip_preserve (cr);
|
cairo_clip_preserve (cr);
|
||||||
// draw text
|
// draw text
|
||||||
cairo_text_extents_t extents;
|
cairo_text_extents_t extents;
|
||||||
cairo_text_extents(cr, _process->get_name().c_str(), &extents);
|
cairo_text_extents(cr, _schedulable->get_name().c_str(), &extents);
|
||||||
// cairo_move_to(cr, xpos - _radius, ypos - _radius + extents.height);
|
// cairo_move_to(cr, xpos - _radius, ypos - _radius + extents.height);
|
||||||
cairo_move_to(cr, _pos.real() - extents.width/2, _pos.imag() + extents.height/2);
|
cairo_move_to(cr, _pos.real() - extents.width/2, _pos.imag() + extents.height/2);
|
||||||
cairo_show_text(cr, _process->get_name().c_str());
|
cairo_show_text(cr, _schedulable->get_name().c_str());
|
||||||
cairo_reset_clip (cr); // reset clip region
|
cairo_reset_clip (cr); // reset clip region
|
||||||
|
|
||||||
// stroke all
|
// stroke all
|
||||||
|
@ -206,7 +210,7 @@ void HoltProcess::draw(cairo_t *cr)
|
||||||
cairo_restore(cr); // restore context state
|
cairo_restore(cr); // restore context state
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2 HoltProcess::get_intersection_to(Vec2 pt)
|
Vec2 HoltSchedulable::get_intersection_to(Vec2 pt)
|
||||||
{
|
{
|
||||||
Vec2 final = _pos;
|
Vec2 final = _pos;
|
||||||
Vec2 segment = pt - _pos;
|
Vec2 segment = pt - _pos;
|
||||||
|
@ -221,7 +225,7 @@ Vec2 HoltProcess::get_intersection_to(Vec2 pt)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HoltRequest::HoltRequest(HoltProcess& hp, HoltResource& hr, Request::state state)
|
HoltRequest::HoltRequest(HoltSchedulable& hp, HoltResource& hr, Request::state state)
|
||||||
: _hp(&hp),
|
: _hp(&hp),
|
||||||
_hr(&hr),
|
_hr(&hr),
|
||||||
_state(state)
|
_state(state)
|
||||||
|
@ -295,6 +299,7 @@ HoltWidget::HoltWidget(Simulation& simulation)
|
||||||
_n_proc(0),
|
_n_proc(0),
|
||||||
_n_res(0),
|
_n_res(0),
|
||||||
_radius(20),
|
_radius(20),
|
||||||
|
_show_threads(false),
|
||||||
_arrange_mode(arrange_horizontal)
|
_arrange_mode(arrange_horizontal)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -329,7 +334,7 @@ HoltWidget::set_radius(double radius)
|
||||||
double old_radius = _radius;
|
double old_radius = _radius;
|
||||||
if(radius>0)
|
if(radius>0)
|
||||||
_radius = radius;
|
_radius = radius;
|
||||||
resize_redraw();
|
// resize_redraw();
|
||||||
return old_radius;
|
return old_radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,13 +350,14 @@ HoltWidget::set_arrange_mode(arrange_mode mode)
|
||||||
arrange_mode old_mode = _arrange_mode;
|
arrange_mode old_mode = _arrange_mode;
|
||||||
_arrange_mode = mode;
|
_arrange_mode = mode;
|
||||||
arrange();
|
arrange();
|
||||||
resize_redraw();
|
// resize_redraw();
|
||||||
return old_mode;
|
return old_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
HoltWidget::arrange()
|
HoltWidget::arrange()
|
||||||
{
|
{
|
||||||
|
std::cout << "HoltWidget::arrange" << endl;
|
||||||
// cout << "START:" << endl;
|
// cout << "START:" << endl;
|
||||||
// _x_req = 0;
|
// _x_req = 0;
|
||||||
// _y_req = 0;
|
// _y_req = 0;
|
||||||
|
@ -371,7 +377,7 @@ HoltWidget::arrange()
|
||||||
{
|
{
|
||||||
int sx = _draw_w; // get_width();
|
int sx = _draw_w; // get_width();
|
||||||
int sy = _draw_h; // get_height();
|
int sy = _draw_h; // get_height();
|
||||||
int nelem = _holt_resources.size()+_holt_processes.size();
|
int nelem = _holt_resources.size()+_holt_schedulables.size();
|
||||||
if(sx<=sy)
|
if(sx<=sy)
|
||||||
inc = Vec2(sx/2-2*_radius, 0);
|
inc = Vec2(sx/2-2*_radius, 0);
|
||||||
else
|
else
|
||||||
|
@ -423,10 +429,10 @@ HoltWidget::arrange()
|
||||||
inc = Vec2(0, 3*_radius);
|
inc = Vec2(0, 3*_radius);
|
||||||
}
|
}
|
||||||
typedef HoltProcesses::const_iterator holt_proc_iterator;
|
typedef HoltProcesses::const_iterator holt_proc_iterator;
|
||||||
holt_proc_iterator piter = _holt_processes.begin();
|
holt_proc_iterator piter = _holt_schedulables.begin();
|
||||||
while(piter!=_holt_processes.end())
|
while(piter!=_holt_schedulables.end())
|
||||||
{
|
{
|
||||||
HoltProcess* hp = (*piter);
|
HoltSchedulable* hp = (*piter);
|
||||||
// cout << "p-A) pos=" << pos << " cen=" << cen << " inc=" << inc << " mul=" << mul << endl;
|
// cout << "p-A) pos=" << pos << " cen=" << cen << " inc=" << inc << " mul=" << mul << endl;
|
||||||
hp->set_position(pos);
|
hp->set_position(pos);
|
||||||
hp->set_radius(_radius);
|
hp->set_radius(_radius);
|
||||||
|
@ -452,9 +458,29 @@ HoltWidget::arrange()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
HoltWidget::get_show_threads()
|
||||||
|
{
|
||||||
|
return _show_threads;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
HoltWidget::set_show_threads(bool show)
|
||||||
|
{
|
||||||
|
bool old_show = _show_threads;
|
||||||
|
_show_threads = show;
|
||||||
|
// resize_redraw();
|
||||||
|
return old_show;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
HoltWidget::update(const Simulation& changed_simulation)
|
HoltWidget::update(const Simulation& changed_simulation)
|
||||||
{
|
{
|
||||||
|
std::cout << "HoltWidget::update - Simulation" << endl;
|
||||||
// Force redraw
|
// Force redraw
|
||||||
//redraw();
|
//redraw();
|
||||||
acquire();
|
acquire();
|
||||||
|
@ -465,6 +491,7 @@ HoltWidget::update(const Simulation& changed_simulation)
|
||||||
void
|
void
|
||||||
HoltWidget::update(const History& changed_history)
|
HoltWidget::update(const History& changed_history)
|
||||||
{
|
{
|
||||||
|
std::cout << "HoltWidget::update - History" << endl;
|
||||||
// Force redraw
|
// Force redraw
|
||||||
//redraw();
|
//redraw();
|
||||||
//acquire();
|
//acquire();
|
||||||
|
@ -477,8 +504,9 @@ HoltWidget::update(const History& changed_history)
|
||||||
void
|
void
|
||||||
HoltWidget::acquire()
|
HoltWidget::acquire()
|
||||||
{
|
{
|
||||||
|
std::cout << "HoltWidget::acquire" << endl;
|
||||||
_holt_resources.clear();
|
_holt_resources.clear();
|
||||||
_holt_processes.clear();
|
_holt_schedulables.clear();
|
||||||
_holt_requests.clear();
|
_holt_requests.clear();
|
||||||
_n_res = _n_proc = 0;
|
_n_res = _n_proc = 0;
|
||||||
|
|
||||||
|
@ -517,9 +545,13 @@ HoltWidget::acquire()
|
||||||
|| proc_state==Schedulable::state_blocked )
|
|| proc_state==Schedulable::state_blocked )
|
||||||
{
|
{
|
||||||
_n_proc++;
|
_n_proc++;
|
||||||
HoltProcess *hp = new HoltProcess(*p, pos);
|
HoltSchedulable *hp;
|
||||||
_holt_processes.push_back(hp);
|
if(!_show_threads)
|
||||||
|
{
|
||||||
|
hp = new HoltSchedulable(*p, pos);
|
||||||
|
_holt_schedulables.push_back(hp);
|
||||||
pos += Vec2(4*_radius, 0);
|
pos += Vec2(4*_radius, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// iter trough threads, requests, subrequests
|
// iter trough threads, requests, subrequests
|
||||||
// FIXME
|
// FIXME
|
||||||
|
@ -543,6 +575,12 @@ HoltWidget::acquire()
|
||||||
|| thr_state==Schedulable::state_blocked )
|
|| thr_state==Schedulable::state_blocked )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(_show_threads)
|
||||||
|
{
|
||||||
|
hp = new HoltSchedulable(*t, pos);
|
||||||
|
_holt_schedulables.push_back(hp);
|
||||||
|
pos += Vec2(4*_radius, 0);
|
||||||
|
}
|
||||||
// iter trough requests
|
// iter trough requests
|
||||||
const std::vector<Request*>& rvect = t->get_requests();
|
const std::vector<Request*>& rvect = t->get_requests();
|
||||||
std::vector<Request*>::const_iterator req_iter = rvect.begin();
|
std::vector<Request*>::const_iterator req_iter = rvect.begin();
|
||||||
|
@ -570,6 +608,7 @@ HoltWidget::acquire()
|
||||||
HoltResources::const_iterator hpos = _holt_resources.find(sr->get_resource_key());
|
HoltResources::const_iterator hpos = _holt_resources.find(sr->get_resource_key());
|
||||||
if (pos != env.get_resources().end() && hpos!=_holt_resources.end())
|
if (pos != env.get_resources().end() && hpos!=_holt_resources.end())
|
||||||
{
|
{
|
||||||
|
// associates process (or thread) with resource)
|
||||||
HoltRequest *hreq = new HoltRequest(*hp, *(hpos->second), sr->get_state());
|
HoltRequest *hreq = new HoltRequest(*hp, *(hpos->second), sr->get_state());
|
||||||
_holt_requests.push_back(hreq);
|
_holt_requests.push_back(hreq);
|
||||||
// cout << "added HoltRequest\n"
|
// cout << "added HoltRequest\n"
|
||||||
|
@ -597,6 +636,7 @@ HoltWidget::acquire()
|
||||||
void
|
void
|
||||||
HoltWidget::draw_widget(cairo_t* ctx)
|
HoltWidget::draw_widget(cairo_t* ctx)
|
||||||
{
|
{
|
||||||
|
std::cout << "HoltWidget::draw_widget" << endl;
|
||||||
arrange();
|
arrange();
|
||||||
typedef HoltResources::const_iterator holt_res_iterator;
|
typedef HoltResources::const_iterator holt_res_iterator;
|
||||||
holt_res_iterator riter = _holt_resources.begin();
|
holt_res_iterator riter = _holt_resources.begin();
|
||||||
|
@ -608,10 +648,10 @@ HoltWidget::draw_widget(cairo_t* ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef HoltProcesses::const_iterator holt_proc_iterator;
|
typedef HoltProcesses::const_iterator holt_proc_iterator;
|
||||||
holt_proc_iterator piter = _holt_processes.begin();
|
holt_proc_iterator piter = _holt_schedulables.begin();
|
||||||
while(piter!=_holt_processes.end())
|
while(piter!=_holt_schedulables.end())
|
||||||
{
|
{
|
||||||
HoltProcess* hp = (*piter);
|
HoltSchedulable* hp = (*piter);
|
||||||
hp->draw(ctx);
|
hp->draw(ctx);
|
||||||
piter++;
|
piter++;
|
||||||
}
|
}
|
||||||
|
@ -633,6 +673,7 @@ HoltWidget::draw_widget(cairo_t* ctx)
|
||||||
void
|
void
|
||||||
HoltWidget::calc_drawing_size(cairo_t* ctx, size_t& width, size_t& height)
|
HoltWidget::calc_drawing_size(cairo_t* ctx, size_t& width, size_t& height)
|
||||||
{
|
{
|
||||||
|
cout << "Holt widget BEFORE calc_drawing_size width=" << width << " height=" << height << endl;
|
||||||
// int pos = _simulation->get_front();
|
// int pos = _simulation->get_front();
|
||||||
// const History& hist = _simulation->get_history();
|
// const History& hist = _simulation->get_history();
|
||||||
int max = _n_proc;
|
int max = _n_proc;
|
||||||
|
@ -673,11 +714,12 @@ HoltWidget::calc_drawing_size(cairo_t* ctx, size_t& width, size_t& height)
|
||||||
width = height = diam + 4 * _radius;
|
width = height = diam + 4 * _radius;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// cout << "Holt widget width=" << width << " height=" << height << endl;
|
cout << "Holt widget AFTER calc_drawing_size width=" << width << " height=" << height << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
HoltWidget::calc_widget_size(size_t& width, size_t& height)
|
HoltWidget::calc_widget_size(size_t& width, size_t& height)
|
||||||
{
|
{
|
||||||
|
cout << "Holt widget BEFORE calc_widget_size width=" << width << " height=" << height << endl;
|
||||||
width = height = 20; // default minimum size
|
width = height = 20; // default minimum size
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,15 +31,10 @@
|
||||||
#include <complex>
|
#include <complex>
|
||||||
|
|
||||||
|
|
||||||
// *********************************************************************************
|
|
||||||
// ---------------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// BEGIN - inserted from old version
|
|
||||||
//
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
{
|
{
|
||||||
class History;
|
class History;
|
||||||
class Process;
|
class Schedulable;
|
||||||
class Resource;
|
class Resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,110 +88,38 @@ namespace sgpem
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class HoltProcess : public HoltNode
|
class HoltSchedulable : public HoltNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//HoltProcess(const Process& process, double x=0.0, double y=0.0);
|
//HoltSchedulable(const Schedulable& schedulable, double x=0.0, double y=0.0);
|
||||||
HoltProcess(const Process& process, Vec2 pt = Vec2(0.0, 0.0));
|
HoltSchedulable(const Schedulable& schedulable, Vec2 pt = Vec2(0.0, 0.0));
|
||||||
virtual ~HoltProcess();
|
virtual ~HoltSchedulable();
|
||||||
|
|
||||||
virtual void draw(cairo_t *cr);
|
virtual void draw(cairo_t *cr);
|
||||||
virtual Vec2 get_intersection_to(Vec2 pt);
|
virtual Vec2 get_intersection_to(Vec2 pt);
|
||||||
protected:
|
protected:
|
||||||
private:
|
private:
|
||||||
const Process* _process;
|
const Schedulable* _schedulable;
|
||||||
};
|
};
|
||||||
|
|
||||||
class HoltRequest
|
class HoltRequest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HoltRequest(HoltProcess& hp, HoltResource& hr, Request::state state);
|
HoltRequest(HoltSchedulable& hp, HoltResource& hr, Request::state state);
|
||||||
virtual ~HoltRequest();
|
virtual ~HoltRequest();
|
||||||
|
|
||||||
virtual void draw(cairo_t *cr);
|
virtual void draw(cairo_t *cr);
|
||||||
virtual void arrow(cairo_t *cr, Vec2 first, Vec2 second);
|
virtual void arrow(cairo_t *cr, Vec2 first, Vec2 second);
|
||||||
protected:
|
protected:
|
||||||
private:
|
private:
|
||||||
HoltProcess* _hp;
|
HoltSchedulable* _hp;
|
||||||
HoltResource* _hr;
|
HoltResource* _hr;
|
||||||
Request::state _state;
|
Request::state _state;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
class HoltGraph : public Gtk::DrawingArea
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum arrange_mode
|
|
||||||
{
|
|
||||||
arrange_horizontal = 1 << 0,
|
|
||||||
arrange_vertical = 1 << 1,
|
|
||||||
arrange_circular = 1 << 2
|
|
||||||
};
|
|
||||||
enum resize_mode
|
|
||||||
{
|
|
||||||
resize_none = 0,
|
|
||||||
resize_radius = 1 << 0,
|
|
||||||
resize_distance = 1 << 1,
|
|
||||||
resize_both = resize_radius | resize_distance,
|
|
||||||
resize_asymetrical = 0,
|
|
||||||
resize_symetrical = 1 << 2
|
|
||||||
};
|
|
||||||
typedef std::map<resource_key_t, HoltResource*> HoltResources;
|
|
||||||
typedef std::vector<HoltProcess*> HoltProcesses;
|
|
||||||
typedef std::vector<HoltRequest*> HoltRequests;
|
|
||||||
|
|
||||||
HoltGraph();
|
|
||||||
virtual ~HoltGraph();
|
|
||||||
|
|
||||||
void set_history(const sgpem::History& hist);
|
|
||||||
arrange_mode get_arrange_mode();
|
|
||||||
arrange_mode set_arrange_mode(arrange_mode mode);
|
|
||||||
resize_mode get_resize_mode();
|
|
||||||
resize_mode set_resize_mode(resize_mode mode);
|
|
||||||
void arrange();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
//Overridden default signal handlers:
|
|
||||||
virtual void on_realize();
|
|
||||||
virtual bool on_expose_event(GdkEventExpose* e);
|
|
||||||
virtual void on_size_request(Gtk::Requisition* requisition);
|
|
||||||
virtual void on_size_allocate(Gtk::Allocation& allocation);
|
|
||||||
|
|
||||||
Glib::RefPtr<Gdk::GC> gc_;
|
|
||||||
Gdk::Color blue_, red_;
|
|
||||||
Gdk::Color filler_, back_;
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
const sgpem::History* _hist;
|
|
||||||
double _radius;
|
|
||||||
double _eff_radius;
|
|
||||||
double _x_dist;
|
|
||||||
double _y_dist;
|
|
||||||
double _x_req;
|
|
||||||
double _y_req;
|
|
||||||
|
|
||||||
HoltResources _holt_resources;
|
|
||||||
HoltProcesses _holt_processes;
|
|
||||||
HoltRequests _holt_requests;
|
|
||||||
|
|
||||||
arrange_mode _arrange_mode;
|
|
||||||
resize_mode _resize_mode;
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
} // end namespace sgpem
|
|
||||||
|
|
||||||
//
|
|
||||||
// END - inserted from old version
|
|
||||||
//
|
|
||||||
// ---------------------------------------------------------------------------------
|
|
||||||
// *********************************************************************************
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace sgpem
|
|
||||||
{
|
|
||||||
class HoltWidget
|
class HoltWidget
|
||||||
: public SimulationObserver,
|
: public SimulationObserver,
|
||||||
public HistoryObserver,
|
public HistoryObserver,
|
||||||
|
@ -211,7 +134,7 @@ namespace sgpem
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map<resource_key_t, HoltResource*> HoltResources;
|
typedef std::map<resource_key_t, HoltResource*> HoltResources;
|
||||||
typedef std::vector<HoltProcess*> HoltProcesses;
|
typedef std::vector<HoltSchedulable*> HoltProcesses;
|
||||||
typedef std::vector<HoltRequest*> HoltRequests;
|
typedef std::vector<HoltRequest*> HoltRequests;
|
||||||
|
|
||||||
HoltWidget(Simulation& simulation);
|
HoltWidget(Simulation& simulation);
|
||||||
|
@ -226,6 +149,8 @@ namespace sgpem
|
||||||
arrange_mode get_arrange_mode();
|
arrange_mode get_arrange_mode();
|
||||||
arrange_mode set_arrange_mode(arrange_mode mode);
|
arrange_mode set_arrange_mode(arrange_mode mode);
|
||||||
void arrange();
|
void arrange();
|
||||||
|
bool get_show_threads();
|
||||||
|
bool set_show_threads(bool show);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -242,12 +167,13 @@ namespace sgpem
|
||||||
double _radius;
|
double _radius;
|
||||||
|
|
||||||
HoltResources _holt_resources;
|
HoltResources _holt_resources;
|
||||||
HoltProcesses _holt_processes;
|
HoltProcesses _holt_schedulables;
|
||||||
HoltRequests _holt_requests;
|
HoltRequests _holt_requests;
|
||||||
int _n_proc;
|
int _n_proc;
|
||||||
int _n_res;
|
int _n_res;
|
||||||
|
|
||||||
arrange_mode _arrange_mode;
|
arrange_mode _arrange_mode;
|
||||||
|
bool _show_threads;
|
||||||
};
|
};
|
||||||
|
|
||||||
} //~ namespace sgpem
|
} //~ namespace sgpem
|
||||||
|
|
|
@ -243,6 +243,7 @@ protected:
|
||||||
virtual void on_button_stop_clicked();
|
virtual void on_button_stop_clicked();
|
||||||
virtual void on_button_pause_clicked();
|
virtual void on_button_pause_clicked();
|
||||||
virtual void on_button_runmode_clicked();
|
virtual void on_button_runmode_clicked();
|
||||||
|
virtual void on_button_showthreads_clicked();
|
||||||
virtual void on_buttons_radio_clicked();
|
virtual void on_buttons_radio_clicked();
|
||||||
virtual void on_buttons_radio_disp_clicked();
|
virtual void on_buttons_radio_disp_clicked();
|
||||||
virtual bool on_timer_timeout();
|
virtual bool on_timer_timeout();
|
||||||
|
@ -254,6 +255,7 @@ protected:
|
||||||
Gtk::Button _stop_button;
|
Gtk::Button _stop_button;
|
||||||
Gtk::Button _pause_button;
|
Gtk::Button _pause_button;
|
||||||
Gtk::CheckButton _runmode_button;
|
Gtk::CheckButton _runmode_button;
|
||||||
|
Gtk::CheckButton _showthreads_button;
|
||||||
Gtk::RadioButton _noscale_radio;
|
Gtk::RadioButton _noscale_radio;
|
||||||
Gtk::RadioButton _fit_radio;
|
Gtk::RadioButton _fit_radio;
|
||||||
Gtk::RadioButton _stretch_radio;
|
Gtk::RadioButton _stretch_radio;
|
||||||
|
@ -276,6 +278,7 @@ MainWindow::MainWindow(Simulation& simulation)
|
||||||
_stop_button("Stop"),
|
_stop_button("Stop"),
|
||||||
_pause_button("Pause"),
|
_pause_button("Pause"),
|
||||||
_runmode_button("Continue"),
|
_runmode_button("Continue"),
|
||||||
|
_showthreads_button("Show threads"),
|
||||||
_noscale_radio("no scale"),
|
_noscale_radio("no scale"),
|
||||||
_fit_radio("scale all"),
|
_fit_radio("scale all"),
|
||||||
_stretch_radio("stretch"),
|
_stretch_radio("stretch"),
|
||||||
|
@ -299,6 +302,10 @@ MainWindow::MainWindow(Simulation& simulation)
|
||||||
_runmode_button.set_active(false);
|
_runmode_button.set_active(false);
|
||||||
_runmode_button.show();
|
_runmode_button.show();
|
||||||
|
|
||||||
|
_buttons_box.pack_start(_showthreads_button);
|
||||||
|
_showthreads_button.set_active(false);
|
||||||
|
_showthreads_button.show();
|
||||||
|
|
||||||
// scale radio buttons
|
// scale radio buttons
|
||||||
Gtk::RadioButton::Group group = _noscale_radio.get_group();
|
Gtk::RadioButton::Group group = _noscale_radio.get_group();
|
||||||
_fit_radio.set_group(group);
|
_fit_radio.set_group(group);
|
||||||
|
@ -348,6 +355,7 @@ MainWindow::MainWindow(Simulation& simulation)
|
||||||
_stop_button.signal_clicked().connect( sigc::mem_fun(*this, &MainWindow::on_button_stop_clicked), true );
|
_stop_button.signal_clicked().connect( sigc::mem_fun(*this, &MainWindow::on_button_stop_clicked), true );
|
||||||
_pause_button.signal_clicked().connect( sigc::mem_fun(*this, &MainWindow::on_button_pause_clicked), true );
|
_pause_button.signal_clicked().connect( sigc::mem_fun(*this, &MainWindow::on_button_pause_clicked), true );
|
||||||
_runmode_button.signal_clicked().connect( sigc::mem_fun(*this, &MainWindow::on_button_runmode_clicked), true );
|
_runmode_button.signal_clicked().connect( sigc::mem_fun(*this, &MainWindow::on_button_runmode_clicked), true );
|
||||||
|
_showthreads_button.signal_clicked().connect( sigc::mem_fun(*this, &MainWindow::on_button_showthreads_clicked), true );
|
||||||
|
|
||||||
_noscale_radio.signal_clicked().connect( sigc::mem_fun(*this, &MainWindow::on_buttons_radio_clicked), true );
|
_noscale_radio.signal_clicked().connect( sigc::mem_fun(*this, &MainWindow::on_buttons_radio_clicked), true );
|
||||||
_fit_radio.signal_clicked().connect( sigc::mem_fun(*this, &MainWindow::on_buttons_radio_clicked), true );
|
_fit_radio.signal_clicked().connect( sigc::mem_fun(*this, &MainWindow::on_buttons_radio_clicked), true );
|
||||||
|
@ -359,6 +367,9 @@ MainWindow::MainWindow(Simulation& simulation)
|
||||||
|
|
||||||
Glib::signal_timeout().connect(sigc::mem_fun(*this, &MainWindow::on_timer_timeout), 1000);
|
Glib::signal_timeout().connect(sigc::mem_fun(*this, &MainWindow::on_timer_timeout), 1000);
|
||||||
|
|
||||||
|
on_button_runmode_clicked();
|
||||||
|
on_button_showthreads_clicked();
|
||||||
|
|
||||||
//is equivalent to:
|
//is equivalent to:
|
||||||
/*
|
/*
|
||||||
const Glib::RefPtr<Glib::TimeoutSource> timeout_source = Glib::TimeoutSource::create(1000);
|
const Glib::RefPtr<Glib::TimeoutSource> timeout_source = Glib::TimeoutSource::create(1000);
|
||||||
|
@ -373,6 +384,7 @@ MainWindow::~MainWindow()
|
||||||
|
|
||||||
void MainWindow::on_button_start_clicked()
|
void MainWindow::on_button_start_clicked()
|
||||||
{
|
{
|
||||||
|
std::cout << "on_button_start_clicked" << endl;
|
||||||
if(_sim_state == Simulation::state_stopped
|
if(_sim_state == Simulation::state_stopped
|
||||||
|| _sim_state == Simulation::state_paused)
|
|| _sim_state == Simulation::state_paused)
|
||||||
{
|
{
|
||||||
|
@ -392,6 +404,7 @@ void MainWindow::on_button_start_clicked()
|
||||||
}
|
}
|
||||||
void MainWindow::on_button_stop_clicked()
|
void MainWindow::on_button_stop_clicked()
|
||||||
{
|
{
|
||||||
|
std::cout << "on_button_stop_clicked" << endl;
|
||||||
if(_sim_state == Simulation::state_running
|
if(_sim_state == Simulation::state_running
|
||||||
|| _sim_state == Simulation::state_paused)
|
|| _sim_state == Simulation::state_paused)
|
||||||
{
|
{
|
||||||
|
@ -402,6 +415,7 @@ void MainWindow::on_button_stop_clicked()
|
||||||
}
|
}
|
||||||
void MainWindow::on_button_pause_clicked()
|
void MainWindow::on_button_pause_clicked()
|
||||||
{
|
{
|
||||||
|
std::cout << "on_button_pause_clicked" << endl;
|
||||||
if(_sim_state == Simulation::state_running)
|
if(_sim_state == Simulation::state_running)
|
||||||
{
|
{
|
||||||
_sim_state = Simulation::state_paused;
|
_sim_state = Simulation::state_paused;
|
||||||
|
@ -411,12 +425,23 @@ void MainWindow::on_button_pause_clicked()
|
||||||
_sim_state = Simulation::state_running;
|
_sim_state = Simulation::state_running;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_button_runmode_clicked()
|
void MainWindow::on_button_runmode_clicked()
|
||||||
{
|
{
|
||||||
|
std::cout << "on_button_runmode_clicked" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_button_showthreads_clicked()
|
||||||
|
{
|
||||||
|
std::cout << "on_button_showthreads_clicked" << endl;
|
||||||
|
_holt_widget.set_show_threads(_showthreads_button.get_active());
|
||||||
|
_holt_widget.resize_redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_buttons_radio_clicked()
|
void MainWindow::on_buttons_radio_clicked()
|
||||||
{
|
{
|
||||||
|
std::cout << "on_buttons_radio_clicked" << endl;
|
||||||
if(_noscale_radio.get_active())
|
if(_noscale_radio.get_active())
|
||||||
{
|
{
|
||||||
// std::cout << "scaling_none" << endl;
|
// std::cout << "scaling_none" << endl;
|
||||||
|
@ -443,6 +468,7 @@ void MainWindow::on_buttons_radio_clicked()
|
||||||
|
|
||||||
void MainWindow::on_buttons_radio_disp_clicked()
|
void MainWindow::on_buttons_radio_disp_clicked()
|
||||||
{
|
{
|
||||||
|
std::cout << "on_buttons_radio_disp_clicked" << endl;
|
||||||
if(_horizontal_radio.get_active())
|
if(_horizontal_radio.get_active())
|
||||||
{
|
{
|
||||||
// std::cout << "_horizontal_radio" << endl;
|
// std::cout << "_horizontal_radio" << endl;
|
||||||
|
@ -570,11 +596,11 @@ void fillHistory(History &hist)
|
||||||
History::ResourcePair respair = hist.add_resource(Glib::ustring("Resource 1"), false, 1, 2);
|
History::ResourcePair respair = hist.add_resource(Glib::ustring("Resource 1"), false, 1, 2);
|
||||||
|
|
||||||
// add a resource - name, preemptable, places, availability
|
// add a resource - name, preemptable, places, availability
|
||||||
History::ResourcePair respair2 = hist.add_resource(Glib::ustring("Invalid? Resource <n> 1"), false, 1, 2);
|
History::ResourcePair respair2 = hist.add_resource(Glib::ustring("Very Long Named Resource 2"), false, 1, 2);
|
||||||
|
|
||||||
// delete resources to kreate a key numbering hole
|
// delete resources to kreate a key numbering hole
|
||||||
hist.remove(respair0.first);
|
// hist.remove(respair0.first);
|
||||||
hist.remove(respair00.first);
|
// hist.remove(respair00.first);
|
||||||
|
|
||||||
// add a process - name, arrival time, priority
|
// add a process - name, arrival time, priority
|
||||||
Process& p1 = hist.add_process(Glib::ustring("Process 1"), 0, 2); // name, arrival time, priority
|
Process& p1 = hist.add_process(Glib::ustring("Process 1"), 0, 2); // name, arrival time, priority
|
||||||
|
@ -586,22 +612,31 @@ void fillHistory(History &hist)
|
||||||
Process& p3 = hist.add_process(Glib::ustring("Process 3"), 5, 5); // name, arrival time, priority
|
Process& p3 = hist.add_process(Glib::ustring("Process 3"), 5, 5); // name, arrival time, priority
|
||||||
|
|
||||||
// add a process - name, arrival time, priority
|
// add a process - name, arrival time, priority
|
||||||
Process& p4 = hist.add_process(Glib::ustring("Invalid? <process/> &3 or\\4"), 9, 1); // name, arrival time, priority
|
Process& p4 = hist.add_process(Glib::ustring("Very Long Named Process 4"), 9, 1); // name, arrival time, priority
|
||||||
|
|
||||||
// add a thread - name, parent, cpu time, arrival time, priority
|
// add a thread - name, parent, cpu time, arrival time, priority
|
||||||
Thread& p1_t1 = hist.add_thread(Glib::ustring("P1 - Thread 1"), p1, 14, 0, 2);
|
Thread& p1_t1 = hist.add_thread(Glib::ustring("P1 - Th 1"), p1, 14, 0, 2);
|
||||||
|
|
||||||
// add a thread - name, parent, cpu time, arrival time, priority
|
// add a thread - name, parent, cpu time, arrival time, priority
|
||||||
// Thread& p1_t2 = hist.add_thread(Glib::ustring("P1 - Thread 2"), p1, 3, 0, 5);
|
Thread& p1_t2 = hist.add_thread(Glib::ustring("P1 - Th 2"), p1, 3, 3, 5);
|
||||||
|
|
||||||
// add a thread - name, parent, cpu time, arrival time, priority
|
// add a thread - name, parent, cpu time, arrival time, priority
|
||||||
Thread& p2_t1 = hist.add_thread(Glib::ustring("P2 - Thread 1"), p2, 20, 0, 2);
|
Thread& p1_t3 = hist.add_thread(Glib::ustring("P1 - Th 3"), p1, 4, 3, 5);
|
||||||
|
|
||||||
// add a thread - name, parent, cpu time, arrival time, priority
|
// add a thread - name, parent, cpu time, arrival time, priority
|
||||||
Thread& p3_t1 = hist.add_thread(Glib::ustring("P3 - Thread 2"), p3, 12, 0, 2);
|
Thread& p1_t4 = hist.add_thread(Glib::ustring("P1 - Th 4"), p1, 5, 3, 4);
|
||||||
|
|
||||||
// add a thread - name, parent, cpu time, arrival time, priority
|
// add a thread - name, parent, cpu time, arrival time, priority
|
||||||
Thread& p4_t1 = hist.add_thread(Glib::ustring("P4 - Thread 1"), p4, 3, 0, 2);
|
Thread& p2_t1 = hist.add_thread(Glib::ustring("P2 - Th 1"), p2, 20, 0, 2);
|
||||||
|
|
||||||
|
// add a thread - name, parent, cpu time, arrival time, priority
|
||||||
|
Thread& p3_t1 = hist.add_thread(Glib::ustring("P3 - Th 2"), p3, 12, 0, 2);
|
||||||
|
|
||||||
|
// add a thread - name, parent, cpu time, arrival time, priority
|
||||||
|
Thread& p4_t1 = hist.add_thread(Glib::ustring("P4 - Th 1"), p4, 7, 0, 2);
|
||||||
|
|
||||||
|
// add a thread - name, parent, cpu time, arrival time, priority
|
||||||
|
Thread& p4_t2 = hist.add_thread(Glib::ustring("P4 - Th 2"), p4, 3, 6, 2);
|
||||||
|
|
||||||
// add a request - Thread, time
|
// add a request - Thread, time
|
||||||
Request& req1 = hist.add_request(p1_t1, 3);
|
Request& req1 = hist.add_request(p1_t1, 3);
|
||||||
|
|
Loading…
Reference in New Issue