- Added the "set cpu-policy" command. It`s still not useful until we initialize the pyloader plugin...
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@789 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
ddb0d99aca
commit
0dd711657f
|
@ -37,7 +37,7 @@ ConcreteSimulation::ConcreteSimulation() :
|
|||
{}
|
||||
|
||||
void
|
||||
ConcreteSimulation::set_timer(const int& t)
|
||||
ConcreteSimulation::set_timer(unsigned int t)
|
||||
{
|
||||
_timer_interval = t;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace sgpem
|
|||
|
||||
void stop();
|
||||
|
||||
void set_timer(const int&);
|
||||
void set_timer(const unsigned int);
|
||||
|
||||
int get_timer() const;
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace sgpem
|
|||
interpreted when the simulation advancement mode is continue.
|
||||
The input value is in milliseconds, and it must be in range [0, 10000].
|
||||
*/
|
||||
virtual void set_timer(const int&) = 0;
|
||||
virtual void set_timer(unsigned int) = 0;
|
||||
|
||||
/**
|
||||
\see set_timer()
|
||||
|
|
|
@ -677,20 +677,63 @@ TextSimulation::on_set(const Tokens& arguments)
|
|||
else
|
||||
value = arguments[1];
|
||||
|
||||
if(attr == "SIMULATION_TICK")
|
||||
if(attr == "SIMULATION-TICK")
|
||||
{
|
||||
try
|
||||
{
|
||||
Simulation::get_instance().set_timer(string_to<int>(value));
|
||||
int timer = string_to<int>(value);
|
||||
|
||||
if(timer < 0)
|
||||
throw domain_error("");
|
||||
|
||||
Simulation::get_instance().set_timer(timer);
|
||||
}
|
||||
catch(domain_error e)
|
||||
{
|
||||
p_stderr(_("\nERROR: you must provide a valid integer value\n"));
|
||||
p_stderr(_("\nERROR: you must provide a valid unsigned integer value\n"));
|
||||
}
|
||||
|
||||
}
|
||||
else if(attr == "CPU-POLICY")
|
||||
{
|
||||
int policy;
|
||||
|
||||
try
|
||||
{
|
||||
policy = string_to<int>(value) - 1;
|
||||
|
||||
if(policy < 0)
|
||||
throw domain_error("");
|
||||
|
||||
typedef vector<PolicyManager*> ManagerVec;
|
||||
typedef vector<Policy*>::iterator PolicyIt;
|
||||
|
||||
PoliciesGatekeeper& gatekeeper = PoliciesGatekeeper::get_instance();
|
||||
|
||||
ManagerVec managers = gatekeeper.get_registered();
|
||||
|
||||
for(ManagerVec::iterator it = managers.begin(); it != managers.end(); ++it)
|
||||
{
|
||||
vector<Policy*> policies = (*it)->get_avail_policies();
|
||||
for(PolicyIt it = policies.begin(); it != policies.end(); ++it)
|
||||
{
|
||||
if(policy == 0)
|
||||
Simulation::get_instance().set_policy(*it);
|
||||
|
||||
--policy;
|
||||
}
|
||||
}
|
||||
|
||||
if(policy >= 0)
|
||||
throw domain_error("");
|
||||
}
|
||||
catch(domain_error e)
|
||||
{
|
||||
p_stderr(_("\nERROR: invalid unsigned integer or not a valid policy index\n"));
|
||||
}
|
||||
}
|
||||
else
|
||||
p_stderr(_("\nERROR: invalid attribute. Accepted are: simulation_tick\n"));
|
||||
p_stderr(_("\nERROR: invalid attribute. Accepted are: simulation-tick, cpu-policy\n"));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue