lejos.realtime
Class PeriodicParameters

java.lang.Object
  extended by lejos.realtime.SchedulingParameters
      extended by lejos.realtime.ReleaseParameters
          extended by lejos.realtime.PeriodicParameters
All Implemented Interfaces:
Cloneable

public class PeriodicParameters
extends ReleaseParameters

Author:
Team iRboT

Constructor Summary
PeriodicParameters(HighResolutionTime start, RelativeTime period)
          Create a PeriodicParameters object.
PeriodicParameters(HighResolutionTime start, RelativeTime period, RelativeTime cost, RelativeTime deadline, AsyncEventHandler overrunHandler, AsyncEventHandler missHandler)
          Create a PeriodicParameters object.
PeriodicParameters(RelativeTime period)
          Create a PeriodicParameters object.
 
Method Summary
 RelativeTime getPeriod()
          Gets the period.
 HighResolutionTime getStart()
          Gets the start time.
 void setDeadline(RelativeTime deadline)
          Sets the deadline value.
 boolean setIfFeasible(RelativeTime period, RelativeTime cost, RelativeTime deadline)
          This method first performs a feasibility analysis using the new period, cost and deadline attributes as replacements for the matching attributes of this.
 void setPeriod(RelativeTime period)
          Sets the period.
 void setStart(HighResolutionTime start)
          Sets the start time.
 
Methods inherited from class lejos.realtime.ReleaseParameters
clone, getCost, getCostOverrunHandler, getDeadline, getDeadlineMissHandler, setCost, setCostOverrunHandler, setDeadlineMissHandler, setIfFeasible
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PeriodicParameters

public PeriodicParameters(RelativeTime period)
Create a PeriodicParameters object. This constructor has the same effect as invoking PeriodicParameters(null, period, null, null, null, null)

Parameters:
period - The period is the interval between successive unblocks of the RealtimeThread.waitForNextPeriod() and RealtimeThread.waitForNextPeriodInterruptible() methods. There is no default value. If period is null an exception is thrown.
Throws:
IllegalArgumentException - Thrown if the period is null or its time value is not greater than zero.
IllegalAssignmentError - Thrown if period cannot be stored in this.

PeriodicParameters

public PeriodicParameters(HighResolutionTime start,
                          RelativeTime period)
Create a PeriodicParameters object. This constructor has the same effect as invoking PeriodicParameters(start, period, null, null, null, null)

Parameters:
start - Time at which the first release begins (i.e. the real-time thread becomes eligible for execution.) If a RelativeTime, this time is relative to the first time the thread becomes activated (that is, when start() is called). If an AbsoluteTime, then the first release is the maximum of the start parameter and the time of the call to the associated RealtimeThread.start() method. If null, the default value is a new instance of RelativeTime(0,0).
period - The period is the interval between successive unblocks of the RealtimeThread.waitForNextPeriod() and RealtimeThread.waitForNextPeriodInterruptible() methods. There is no default value. If period is null an exception is thrown.
Throws:
IllegalArgumentException - Thrown if the period is null or its time value is not greater than zero.
IllegalAssignmentError - Thrown if start or period cannot be stored in this.

PeriodicParameters

public PeriodicParameters(HighResolutionTime start,
                          RelativeTime period,
                          RelativeTime cost,
                          RelativeTime deadline,
                          AsyncEventHandler overrunHandler,
                          AsyncEventHandler missHandler)
Create a PeriodicParameters object.

Parameters:
start - Time at which the first release begins (i.e. the real-time thread becomes eligible for execution.) If a RelativeTime, this time is relative to the first time the thread becomes activated (that is, when start() is called). If an AbsoluteTime, then the first release is the maximum of the start parameter and the time of the call to the associated RealtimeThread.start() method. If null, the default value is a new instance of RelativeTime(0,0).
period - The period is the interval between successive unblocks of the RealtimeThread.waitForNextPeriod() and RealtimeThread.waitForNextPeriodInterruptible() methods. There is no default value. If period is null an exception is thrown.
cost - Processing time per release. On implementations which can measure the amount of time a schedulable object is executed, this value is the maximum amount of time a schedulable object receives per release. On implementations which cannot measure execution time, this value is used as a hint to the feasibility algorithm. On such systems it is not possible to determine when any particular object exceeds or will exceed cost time units in a release. If null, the default value is a new instance of RelativeTime(0,0).
deadline - The latest permissible completion time measured from the release time of the associated invocation of the schedulable object. If null, the default value is new instance of RelativeTime(period).
overrunHandler - This handler is invoked if an invocation of the schedulable object exceeds cost in the given release. Implementations may ignore this parameter. If null, the default value no overrun handler.
missHandler - This handler is invoked if the run() method of the schedulable object is still executing after the deadline has passed. Although minimum implementations do not consider deadlines in feasibility calculations, they must recognize variable deadlines and invoke the miss handler as appropriate. If null, the default value no deadline miss handler.
Throws:
IllegalArgumentException - Thrown if the period is null or its time value is not greater than zero, or if the time value of cost is less than zero, or if the time value of deadline is not greater than zero.
IllegalAssignmentError - Thrown if start, period, cost, deadline, overrunHandler or missHandler cannot be stored in this.
Method Detail

getPeriod

public RelativeTime getPeriod()
Gets the period.

Returns:
The current value in period.

getStart

public HighResolutionTime getStart()
Gets the start time.

Returns:
The current value in start. This is the value that was specified in the constructor or by setStart(), not the actual absolute time corresponding to the start of one of the schedulable objects associated with this PeriodicParameters object.

setDeadline

public void setDeadline(RelativeTime deadline)
Sets the deadline value. If this parameter object is associated with any schedulable object (by being passed through the schedulable object's constructor or set with a method such as RealtimeThread.setReleaseParameters(ReleaseParameters)) the deadline of those schedulable objects is altered as specified by each schedulable object's respective scheduler. Overrides: setDeadline in class ReleaseParameters

Overrides:
setDeadline in class ReleaseParameters
Parameters:
deadline - The latest permissible completion time measured from the release time of the associated invocation of the schedulable object. If deadline is null, the deadline is set to a new instance of RelativeTime equal to period.
Throws:
IllegalArgumentException - Thrown if the time value of deadline is less than or equal to zero, or if the new value of this deadline is incompatible with the scheduler for any associated schedulable object.
IllegalAssignmentError - Thrown if deadline cannot be stored in this.

setIfFeasible

public boolean setIfFeasible(RelativeTime period,
                             RelativeTime cost,
                             RelativeTime deadline)
This method first performs a feasibility analysis using the new period, cost and deadline attributes as replacements for the matching attributes of this. If the resulting system is feasible the method replaces the current attributes of this. If this parameter object is associated with any schedulable object (by being passed through the schedulable object's constructor or set with a method such as RealtimeThread.setReleaseParameters(ReleaseParameters)) the parameters of those schedulable objects are altered as specified by each schedulable object's respective scheduler.

Parameters:
period - The proposed period. There is no default value. If period is null an exception is thrown.
cost - The proposed cost. If null, the default value is a new instance of RelativeTime(0,0).
deadline - The proposed deadline. If null, the default value is new instance of RelativeTime(period).
Throws:
IllegalArgumentException - Thrown if the period is null or its time value is not greater than zero, or if the time value of cost is less than zero, or if the time value of deadline is not greater than zero. Also thrown if the values are incompatible with the scheduler for any of the schedulable objects which are presently using this parameter object.
IllegalAssignmentError - Thrown if period, cost or deadline cannot be stored in this.

setPeriod

public void setPeriod(RelativeTime period)
Sets the period.

Parameters:
period - The value to which period is set.
Throws:
IllegalArgumentException - Thrown if the given period is null or its time value is not greater than zero. Also thrown if period is incompatible with the scheduler for any associated schedulable object.
IllegalAssignmentError - Thrown if period cannot be stored in this.

setStart

public void setStart(HighResolutionTime start)
Sets the start time. The effect of changing the start time for any schedulable objects associated with this parameter object is determined by the scheduler associated with each schedulable object. Note: An instance of PeriodicParameters may be shared by several schedulable objects. A change to the start time may take effect on a subset of these schedulable objects. That leaves the start time returned by getStart unreliable as a way to determine the start time of a schedulable object.

Parameters:
start - The new start time. If null, the default value is a new instance of RelativeTime(0,0).
Throws:
IllegalArgumentException - Thrown if the given start time is incompatible with the scheduler for any of the schedulable objects which are presently using this parameter object.
IllegalAssignmentError - Thrown if start cannot be stored in this.