- Completed the ADD command, or better, what was implementable of the ADD commmand... Beware this is UNTESTED code!
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@760 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
751ecf6415
commit
d31c31d8a3
|
@ -45,7 +45,7 @@ using Glib::ustring;
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
{
|
{
|
||||||
//TODO move this class to another file...
|
//TODO move this class to another file... (?)
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class CommandParameter
|
class CommandParameter
|
||||||
{
|
{
|
||||||
|
@ -767,6 +767,7 @@ TextSimulation::on_show_threads(const Tokens& arguments)
|
||||||
catch(out_of_range e)
|
catch(out_of_range e)
|
||||||
{
|
{
|
||||||
p_stderr(_("ERROR: this process identifier does not belong to an existing process\n"));
|
p_stderr(_("ERROR: this process identifier does not belong to an existing process\n"));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
show(threads);
|
show(threads);
|
||||||
|
@ -803,6 +804,7 @@ TextSimulation::on_show_requests(const Tokens& arguments)
|
||||||
catch(out_of_range e)
|
catch(out_of_range e)
|
||||||
{
|
{
|
||||||
p_stderr(_("ERROR: the identifier(s) do not belong to an existing entity\n"));
|
p_stderr(_("ERROR: the identifier(s) do not belong to an existing entity\n"));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
show(requests);
|
show(requests);
|
||||||
|
@ -841,6 +843,7 @@ TextSimulation::on_show_subrequests(const Tokens& arguments)
|
||||||
catch(out_of_range e)
|
catch(out_of_range e)
|
||||||
{
|
{
|
||||||
p_stderr(_("ERROR: the identifier(s) do not belong to an existing entity\n"));
|
p_stderr(_("ERROR: the identifier(s) do not belong to an existing entity\n"));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
show(subrequests);
|
show(subrequests);
|
||||||
|
@ -932,13 +935,6 @@ TextSimulation::on_add_process(const Tokens& arguments)
|
||||||
h.add_process(name.value, arrival_time.value, base_priority.value);
|
h.add_process(name.value, arrival_time.value, base_priority.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommandParameter(const ustring& _description,
|
|
||||||
// const T& _low_bound,
|
|
||||||
// const T& _up_bound,
|
|
||||||
// bool _required,
|
|
||||||
// const T& _preset);
|
|
||||||
//
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextSimulation::on_add_resource(const Tokens& arguments)
|
TextSimulation::on_add_resource(const Tokens& arguments)
|
||||||
{
|
{
|
||||||
|
@ -964,19 +960,136 @@ TextSimulation::on_add_resource(const Tokens& arguments)
|
||||||
void
|
void
|
||||||
TextSimulation::on_add_thread(const Tokens& arguments)
|
TextSimulation::on_add_thread(const Tokens& arguments)
|
||||||
{
|
{
|
||||||
p_stderr(_("\nFIXME: Not implemented\n"));
|
if(!check_arguments_num(arguments, 1))
|
||||||
}
|
return;
|
||||||
|
|
||||||
|
ustring process = arguments[0];
|
||||||
|
|
||||||
|
vector<DynamicProcess*> processes;
|
||||||
|
|
||||||
|
DynamicProcess* p;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
p = processes.at(string_to<int>(process) - 1);
|
||||||
|
}
|
||||||
|
catch(domain_error e)
|
||||||
|
{
|
||||||
|
p_stderr(_("ERROR: provided identifier(s) not a valid integer\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch(out_of_range e)
|
||||||
|
{
|
||||||
|
p_stderr(_("ERROR: the identifier(s) do not belong to an existing entity\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandParameter<ustring> name(_("name"), "", "", false, "");
|
||||||
|
CommandParameter<int> cpu_time(_("cpu time"), 0, INT_MAX, true, 0);
|
||||||
|
CommandParameter<int> arrival_time(_("arrival time"), 0, INT_MAX, false, 0);
|
||||||
|
CommandParameter<int> base_priority(_("base priority"), 0, INT_MAX, false, 0);
|
||||||
|
|
||||||
|
get_parameter(name);
|
||||||
|
get_parameter(cpu_time);
|
||||||
|
get_parameter(arrival_time);
|
||||||
|
get_parameter(base_priority);
|
||||||
|
|
||||||
|
// FIXME: need to use the true history, not this stub
|
||||||
|
ConcreteHistory h;
|
||||||
|
|
||||||
|
h.add_thread(name.value, *p, cpu_time.value, arrival_time.value,
|
||||||
|
base_priority.value);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TextSimulation::on_add_request(const Tokens& arguments)
|
TextSimulation::on_add_request(const Tokens& arguments)
|
||||||
{
|
{
|
||||||
p_stderr(_("\nFIXME: Not implemented\n"));
|
if(!check_arguments_num(arguments, 2))
|
||||||
|
return;
|
||||||
|
|
||||||
|
ustring process = arguments[0];
|
||||||
|
ustring thread = arguments[1];
|
||||||
|
|
||||||
|
// FIXME need to get the true arrays. i think it's
|
||||||
|
// still not possible at the actual stage of development
|
||||||
|
vector<DynamicProcess*> processes;
|
||||||
|
DynamicThread* t;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int pid = string_to<int>(process) - 1;
|
||||||
|
int tid = string_to<int>(thread) - 1;
|
||||||
|
|
||||||
|
vector<DynamicThread*> threads = processes.at(pid)->get_dynamic_threads();
|
||||||
|
t = threads.at(tid);
|
||||||
|
}
|
||||||
|
catch(domain_error e)
|
||||||
|
{
|
||||||
|
p_stderr(_("ERROR: provided identifier(s) not a valid integer\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch(out_of_range e)
|
||||||
|
{
|
||||||
|
p_stderr(_("ERROR: the identifier(s) do not belong to an existing entity\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandParameter<int> instant(_("instant"), 0, INT_MAX, true, 0);
|
||||||
|
|
||||||
|
get_parameter(instant);
|
||||||
|
|
||||||
|
// FIXME: need to use the true history, not this stub
|
||||||
|
ConcreteHistory h;
|
||||||
|
|
||||||
|
h.add_request(*t, instant.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TextSimulation::on_add_subrequest(const Tokens& arguments)
|
TextSimulation::on_add_subrequest(const Tokens& arguments)
|
||||||
{
|
{
|
||||||
p_stderr(_("\nFIXME: Not implemented\n"));
|
if(!check_arguments_num(arguments, 3))
|
||||||
|
return;
|
||||||
|
|
||||||
|
ustring process = arguments[0];
|
||||||
|
ustring thread = arguments[1];
|
||||||
|
ustring request = arguments[2];
|
||||||
|
|
||||||
|
// FIXME need to get the true arrays. i think it's
|
||||||
|
// still not possible at the actual stage of development
|
||||||
|
vector<DynamicProcess*> processes;
|
||||||
|
DynamicRequest* r;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int pid = string_to<int>(process) - 1;
|
||||||
|
int tid = string_to<int>(thread) - 1;
|
||||||
|
int rid = string_to<int>(request) - 1;
|
||||||
|
|
||||||
|
vector<DynamicThread*> threads = processes.at(pid)->get_dynamic_threads();
|
||||||
|
vector<DynamicRequest*> requests = threads.at(tid)->get_dynamic_requests();
|
||||||
|
r = requests.at(rid);
|
||||||
|
}
|
||||||
|
catch(domain_error e)
|
||||||
|
{
|
||||||
|
p_stderr(_("ERROR: provided identifier(s) not a valid integer\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch(out_of_range e)
|
||||||
|
{
|
||||||
|
p_stderr(_("ERROR: the identifier(s) do not belong to an existing entity\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME here we are in troubles, we ask the resource key, but the user can't know it.
|
||||||
|
// How we may obtain it? I think it'll be better making it a member of DynamicResource
|
||||||
|
CommandParameter<int> resource_key(_("resource key"), 0, INT_MAX, true, 0);
|
||||||
|
CommandParameter<int> duration(_("duration"), 0, INT_MAX, true, 0);
|
||||||
|
CommandParameter<int> places(_("places"), 0, INT_MAX, false, 1);
|
||||||
|
|
||||||
|
// FIXME: need to use the true history, not this stub
|
||||||
|
ConcreteHistory h;
|
||||||
|
|
||||||
|
h.add_subrequest(*r, resource_key.value /*resource key*/, duration.value, places.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue