nz.ac.waikato.modeljunit.timing
Class TimedModel

java.lang.Object
  extended by nz.ac.waikato.modeljunit.Model
      extended by nz.ac.waikato.modeljunit.timing.TimedModel

public class TimedModel
extends Model

An extension of the model class which supports timed models.

Author:
ScottT

Field Summary
 
Fields inherited from class nz.ac.waikato.modeljunit.Model
fsmActions_, fsmModel_, fsmSequence_, fsmState_, output_, VOID_ARGS
 
Constructor Summary
TimedModel(TimedFsmModel model)
           
 
Method Summary
 boolean doAction(int index)
          Try to take the given Action from the current state.
 void doReset(java.lang.String reason)
          Reset the FSM to its initial state.
 int enabled(int index)
          Partitioning actions to make sure that only tick actions can happen when in a tick state
 java.lang.reflect.Field getLowestTimeout()
          Gets the timeout that will expire next in the model.
 int getLowestTimeoutValue()
          Gets the value of the lowest enabled timeout.
 int getTime()
          Gets the current Time of the model.
 java.lang.String getTimeoutName(int index)
           
 double getTimeoutProbability()
           
 boolean incrementTime()
          Increment the current time by a random value between the minimum and maximum delays.
 void loadModelClass(java.lang.Class fsm)
          Loads the given class and finds its @Action methods.
 void setTime(int value)
          Sets the current time in the FSM object.
 void setTimeoutProbability(double value)
           
 
Methods inherited from class nz.ac.waikato.modeljunit.Model
addListener, addListener, doReset, enabledGuards, getActionName, getActionNumber, getCurrentState, getGraphListener, getListener, getListenerNames, getModel, getModelClass, getModelName, getNumActions, getOutput, getTesting, getVersion, isEnabled, isInitialState, isTerminal, notifyDoneGuard, notifyDoneReset, notifyDoneTransition, notifyFailure, notifyStartAction, printMessage, printWarning, removeAllListeners, removeListener, setOutput, setTesting
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimedModel

public TimedModel(TimedFsmModel model)
Method Detail

loadModelClass

public void loadModelClass(java.lang.Class fsm)
Loads the given class and finds its @Action methods. This method must be called before any fsm traversals are done.

Overrides:
loadModelClass in class Model

enabled

public int enabled(int index)
Partitioning actions to make sure that only tick actions can happen when in a tick state

Overrides:
enabled in class Model
Parameters:
index - Index into the fsmActions_ array.
Returns:
The `enabledness' of this Action.

doReset

public void doReset(java.lang.String reason)
Description copied from class: Model
Reset the FSM to its initial state. This also calls the doneReset(reason, testing) method of all the listeners. TODO: enhance it so that it gives no-guards-enabled and guards-not-deterministic warnings in the initial state.

Overrides:
doReset in class Model
Parameters:
reason - Why the reset was performed (an adjective).

doAction

public boolean doAction(int index)
Description copied from class: Model
Try to take the given Action from the current state. Returns true if the Action was taken, false if it was disabled.

Overrides:
doAction in class Model
Parameters:
index - Index into the fsmTransitions array.
Returns:
True if taken, false if it is disabled.

getTime

public int getTime()
Gets the current Time of the model. Uses reflection to retrieve the Time value in the FSM object.

Returns:
time or -1 if there is no Time field in the model.

setTime

public void setTime(int value)
Sets the current time in the FSM object.

Parameters:
value -

incrementTime

public boolean incrementTime()
Increment the current time by a random value between the minimum and maximum delays. If the time can be incremented by at least the minimum delay without going past any timeouts then the time will be incremented between either minDelay and max Delay or minDelay and lowestTimeout

Returns:
true if the time was changed, otherwise false

getLowestTimeout

public java.lang.reflect.Field getLowestTimeout()
Gets the timeout that will expire next in the model. If no timeouts are set then null is returned

Returns:
first timeout field, or null

getLowestTimeoutValue

public int getLowestTimeoutValue()
Gets the value of the lowest enabled timeout. Returns Integer.MIN_VALUE if no timeouts are set.

Returns:
next timeout value.

getTimeoutName

public java.lang.String getTimeoutName(int index)

getTimeoutProbability

public double getTimeoutProbability()

setTimeoutProbability

public void setTimeoutProbability(double value)


Copyright © 2009 ModelJUnit Project. All Rights Reserved.