Event-based model, to be periodically activated by the scheduler. More...
#include <OSDLModel.h>
Public Member Functions | |
PeriodicalModel (Events::Period period=1, bool autoRegister=true, Engine::ObjectSchedulingPolicy policy=Engine::relaxed, Engine::Weight weight=1) | |
Constructor of an OSDL MVC model which is to be periodically scheduled. | |
virtual | ~PeriodicalModel () throw () |
Virtual destructor. | |
virtual const std::string | toString (Ceylan::VerbosityLevels level=Ceylan::high) const |
Returns an user-friendly description of the state of this object. | |
virtual void | registerToScheduler () |
Registers this active object to the supposedly already existing scheduler. | |
virtual void | unregisterFromScheduler () |
Unregisters this active object from the existing scheduler to whom it was supposedly registered. | |
virtual Events::Period | getPeriod () const |
Returns the period for this active object. | |
virtual void | setPeriod (Events::Period newPeriod) |
Sets a period for this object, which will be periodically scheduled accordingly. | |
virtual Ceylan::Maths::Hertz | setFrequency (Ceylan::Maths::Hertz newFrequency) |
Sets the period of this object so that it gets activated on specified frequency, making this object periodically activated if it was not, or changing its already defined period otherwise. | |
virtual Events::Period | getSubslotNumber () const |
Returns the number of the sub-slot this active object is referenced in. | |
virtual void | onRegistering (Events::Period subslot) |
Automatically called by the scheduler at registration time. | |
virtual void | setBirthTick (Events::SimulationTick currentSimulationTick) |
Sets the birth time, expressed in simulation ticks, of this active object. | |
virtual Events::SimulationTick | convertDurationToActivationCount (Ceylan::System::Millisecond duration) const |
Returns the number of activations of this periodical object which corresponds to the specified duration. | |
virtual ObjectSchedulingPolicy | getPolicy () const |
Returns the scheduling policy for this active object. | |
virtual Weight | getWeight () const |
Returns the average processing need for each activation of this object. | |
virtual Events::SimulationTick | getBirthTick () const |
Returns the birth time, expressed in simulation ticks, of this active object. | |
virtual void | onActivation (Events::SimulationTick newTick)=0 |
Pure virtual method, which is called when this active object gets activated on behalf of the scheduler. | |
virtual void | onSkip (Events::SimulationTick skippedTick) |
Called whenever the scheduler had to skip a period of activation for this object. | |
virtual void | onImpossibleActivation (Events::SimulationTick missedTick) |
Called whenever the scheduler was unable to activate this object. | |
Protected Member Functions | |
Events::SimulationTick | getLocalTime () const |
Returns this object local time, as if the origin of time was this object creation. | |
Protected Attributes | |
Events::Period | _period |
Tells what is the requested scheduling period for this object. | |
Events::Period | _subslot |
Records in which sub-slot this object is stored. | |
ObjectSchedulingPolicy | _policy |
Determines the scheduling policy of this object. | |
Weight | _weight |
Describe the average processing need for each activation of this object. | |
bool | _registered |
Tells whether this active object has already been registered to a scheduler. | |
Events::SimulationTick | _birthTick |
The date of birth of this object, expressed in simulation time. |
Event-based model, to be periodically activated by the scheduler.
Definition at line 74 of file OSDLModel.h.
OSDL::MVC::PeriodicalModel::PeriodicalModel | ( | Events::Period | period = 1 , |
|
bool | autoRegister = true , |
|||
Engine::ObjectSchedulingPolicy | policy = Engine::relaxed , |
|||
Engine::Weight | weight = 1 | |||
) | [explicit] |
Constructor of an OSDL MVC model which is to be periodically scheduled.
period | tells how many simulation ticks are to be waited by the scheduler until this model is activated again. The period must not be null. | |
autoRegister | tells whether this new Model is to automatically register itself to the scheduler. It requires the scheduler to exist already. | |
policy | allows to choose a scheduling policy, according to the quality of service this model requires. | |
weight | evaluates how much processing power an activation of this model is to cost on average. This helps the scheduler doing its job balance. |
Engine::SchedulingException | if the construction failed. |
PeriodicalModel::~PeriodicalModel | ( | ) | throw () [virtual] |
Virtual destructor.
Definition at line 66 of file OSDLModel.cc.
OSDL::Events::SimulationTick PeriodicalActiveObject::convertDurationToActivationCount | ( | Ceylan::System::Millisecond | duration | ) | const [virtual, inherited] |
Returns the number of activations of this periodical object which corresponds to the specified duration.
For example a duration of 400 ms, for a periodical object whose period is 50 ms, corresponds to 8 of its simulation ticks.
duration |
SchedulingException | if the operation failed, notably if this object is not stored in a sub-slot already. |
Definition at line 340 of file OSDLPeriodicalActiveObject.cc.
References OSDL::Engine::PeriodicalActiveObject::_period, OSDL::Engine::Scheduler::GetExistingScheduler(), OSDL::Engine::Scheduler::getSimulationTickCount(), and OSDL::Engine::Scheduler::getTimeSliceDuration().
SimulationTick ActiveObject::getBirthTick | ( | ) | const [virtual, inherited] |
Returns the birth time, expressed in simulation ticks, of this active object.
Definition at line 107 of file OSDLActiveObject.cc.
References OSDL::Engine::ActiveObject::_birthTick.
Referenced by OSDL::Engine::Scheduler::unregisterProgrammedObject().
Events::SimulationTick OSDL::Engine::ActiveObject::getLocalTime | ( | ) | const [protected, inherited] |
Returns this object local time, as if the origin of time was this object creation.
Period PeriodicalActiveObject::getPeriod | ( | ) | const [virtual, inherited] |
Returns the period for this active object.
Definition at line 194 of file OSDLPeriodicalActiveObject.cc.
References OSDL::Engine::PeriodicalActiveObject::_period.
Referenced by OSDL::Engine::Scheduler::registerPeriodicalObject(), and OSDL::Engine::Scheduler::unregisterPeriodicalObject().
ObjectSchedulingPolicy ActiveObject::getPolicy | ( | ) | const [virtual, inherited] |
Returns the scheduling policy for this active object.
Definition at line 80 of file OSDLActiveObject.cc.
References OSDL::Engine::ActiveObject::_policy.
Referenced by OSDL::Engine::PeriodicSlot::add().
Period PeriodicalActiveObject::getSubslotNumber | ( | ) | const [virtual, inherited] |
Returns the number of the sub-slot this active object is referenced in.
This sub-slot is set on registration: the scheduler calls the onRegistering method of this object.
SchedulingException | if the operation failed, notably if this object is not stored in a sub-slot already. |
Definition at line 271 of file OSDLPeriodicalActiveObject.cc.
References OSDL::Engine::PeriodicalActiveObject::_period, and OSDL::Engine::PeriodicalActiveObject::_subslot.
Weight ActiveObject::getWeight | ( | ) | const [virtual, inherited] |
Returns the average processing need for each activation of this object.
Definition at line 89 of file OSDLActiveObject.cc.
References OSDL::Engine::ActiveObject::_weight.
virtual void OSDL::Engine::ActiveObject::onActivation | ( | Events::SimulationTick | newTick | ) | [pure virtual, inherited] |
Pure virtual method, which is called when this active object gets activated on behalf of the scheduler.
virtual void OSDL::Engine::ActiveObject::onImpossibleActivation | ( | Events::SimulationTick | missedTick | ) | [virtual, inherited] |
Called whenever the scheduler was unable to activate this object.
This can happen for example when an absolute simulation tick is specified whereas the current time is already in its future.
Default behaviour for this method is: throw a SchedulingException.
missedTick | tells which tick is out of range. |
SchedulingException | if this active object should not stand activation failures. |
void PeriodicalActiveObject::onRegistering | ( | Events::Period | subslot | ) | [virtual, inherited] |
Automatically called by the scheduler at registration time.
Sets the sub-slot, to ease deallocation.
SchedulingException | if the operation failed. |
Definition at line 284 of file OSDLPeriodicalActiveObject.cc.
References OSDL::Engine::ActiveObject::_registered, and OSDL::Engine::PeriodicalActiveObject::_subslot.
Referenced by OSDL::Engine::Scheduler::registerPeriodicalObject().
virtual void OSDL::Engine::ActiveObject::onSkip | ( | Events::SimulationTick | skippedTick | ) | [virtual, inherited] |
Called whenever the scheduler had to skip a period of activation for this object.
Default behaviour for this method is: do nothing except complain in the warning channel.
skippedTick | tells which tick was skipped. |
SchedulingException | if this active object cannot stand skipped stimulation ticks. |
void PeriodicalActiveObject::registerToScheduler | ( | ) | [virtual, inherited] |
Registers this active object to the supposedly already existing scheduler.
SchedulingException | if the operation failed. |
Implements OSDL::Engine::ActiveObject.
Definition at line 152 of file OSDLPeriodicalActiveObject.cc.
References OSDL::Engine::ActiveObject::_registered, OSDL::Engine::Scheduler::GetExistingScheduler(), and OSDL::Engine::Scheduler::registerPeriodicalObject().
Referenced by OSDL::Engine::PeriodicalActiveObject::PeriodicalActiveObject().
void PeriodicalActiveObject::setBirthTick | ( | Events::SimulationTick | currentSimulationTick | ) | [virtual, inherited] |
Sets the birth time, expressed in simulation ticks, of this active object.
SchedulingException | if the operation failed. |
Reimplemented from OSDL::Engine::ActiveObject.
Definition at line 301 of file OSDLPeriodicalActiveObject.cc.
References OSDL::Engine::ActiveObject::_birthTick, OSDL::Engine::PeriodicalActiveObject::_period, and OSDL::Engine::PeriodicalActiveObject::_subslot.
Referenced by OSDL::Engine::Scheduler::registerPeriodicalObject().
virtual Ceylan::Maths::Hertz OSDL::Engine::PeriodicalActiveObject::setFrequency | ( | Ceylan::Maths::Hertz | newFrequency | ) | [virtual, inherited] |
Sets the period of this object so that it gets activated on specified frequency, making this object periodically activated if it was not, or changing its already defined period otherwise.
newFrequency | the desired frequency, expressed in Hertz. |
SchedulingException | if there was no existing scheduler available. |
virtual void OSDL::Engine::PeriodicalActiveObject::setPeriod | ( | Events::Period | newPeriod | ) | [virtual, inherited] |
Sets a period for this object, which will be periodically scheduled accordingly.
newPeriod | the new period of activation for this object, expressed in simulation ticks. Must be strictly positive. |
SchedulingException | if the operation failed. |
const string PeriodicalModel::toString | ( | Ceylan::VerbosityLevels | level = Ceylan::high |
) | const [virtual] |
Returns an user-friendly description of the state of this object.
level | the requested verbosity level. |
Reimplemented from OSDL::Engine::PeriodicalActiveObject.
Definition at line 73 of file OSDLModel.cc.
void PeriodicalActiveObject::unregisterFromScheduler | ( | ) | [virtual, inherited] |
Unregisters this active object from the existing scheduler to whom it was supposedly registered.
SchedulingException | if the operation failed. |
Implements OSDL::Engine::ActiveObject.
Definition at line 169 of file OSDLPeriodicalActiveObject.cc.
References OSDL::Engine::ActiveObject::_registered, OSDL::Engine::Scheduler::GetExistingScheduler(), and OSDL::Engine::Scheduler::unregisterPeriodicalObject().
Referenced by OSDL::Engine::PeriodicalActiveObject::~PeriodicalActiveObject().
Events::SimulationTick OSDL::Engine::ActiveObject::_birthTick [protected, inherited] |
The date of birth of this object, expressed in simulation time.
Definition at line 373 of file OSDLActiveObject.h.
Referenced by OSDL::Engine::ActiveObject::getBirthTick(), OSDL::Engine::PeriodicalActiveObject::setBirthTick(), and OSDL::Engine::ActiveObject::toString().
Events::Period OSDL::Engine::PeriodicalActiveObject::_period [protected, inherited] |
Tells what is the requested scheduling period for this object.
Definition at line 355 of file OSDLPeriodicalActiveObject.h.
Referenced by OSDL::Engine::PeriodicalActiveObject::convertDurationToActivationCount(), OSDL::Engine::PeriodicalActiveObject::getPeriod(), OSDL::Engine::PeriodicalActiveObject::getSubslotNumber(), OSDL::Engine::PeriodicalActiveObject::PeriodicalActiveObject(), OSDL::Engine::PeriodicalActiveObject::setBirthTick(), and OSDL::Engine::PeriodicalActiveObject::toString().
ObjectSchedulingPolicy OSDL::Engine::ActiveObject::_policy [protected, inherited] |
Determines the scheduling policy of this object.
Definition at line 338 of file OSDLActiveObject.h.
Referenced by OSDL::Engine::ActiveObject::getPolicy(), and OSDL::Engine::ActiveObject::toString().
bool OSDL::Engine::ActiveObject::_registered [protected, inherited] |
Tells whether this active object has already been registered to a scheduler.
Definition at line 358 of file OSDLActiveObject.h.
Referenced by OSDL::Engine::ProgrammedActiveObject::absoluteProgrammedActivationsWanted(), OSDL::Engine::ProgrammedActiveObject::addProgrammedActivations(), OSDL::Engine::ProgrammedActiveObject::onRegistering(), OSDL::Engine::PeriodicalActiveObject::onRegistering(), OSDL::Engine::ProgrammedActiveObject::registerToScheduler(), OSDL::Engine::PeriodicalActiveObject::registerToScheduler(), OSDL::Engine::ProgrammedActiveObject::setProgrammedActivations(), OSDL::Engine::ActiveObject::toString(), OSDL::Engine::ProgrammedActiveObject::unregisterFromScheduler(), OSDL::Engine::PeriodicalActiveObject::unregisterFromScheduler(), OSDL::Engine::ActiveObject::~ActiveObject(), OSDL::Engine::PeriodicalActiveObject::~PeriodicalActiveObject(), and OSDL::Engine::ProgrammedActiveObject::~ProgrammedActiveObject().
Events::Period OSDL::Engine::PeriodicalActiveObject::_subslot [protected, inherited] |
Records in which sub-slot this object is stored.
Definition at line 365 of file OSDLPeriodicalActiveObject.h.
Referenced by OSDL::Engine::PeriodicalActiveObject::getSubslotNumber(), OSDL::Engine::PeriodicalActiveObject::onRegistering(), OSDL::Engine::PeriodicalActiveObject::setBirthTick(), and OSDL::Engine::PeriodicalActiveObject::toString().
Weight OSDL::Engine::ActiveObject::_weight [protected, inherited] |
Describe the average processing need for each activation of this object.
The greater the weight is, the heavier processing should be.
Definition at line 349 of file OSDLActiveObject.h.
Referenced by OSDL::Engine::ActiveObject::getWeight(), and OSDL::Engine::ActiveObject::toString().