|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnz.ac.waikato.modeljunit.examples.TrafficLight
public class TrafficLight
Nested Class Summary | |
---|---|
static class |
TrafficLight.STATE
|
Field Summary | |
---|---|
int |
allowCarsTimer
Timer to control the safety period where both lights are red because the lights are changing from allowing pedestrians to cross to allowing cars through |
int |
allowPedestriansTimer
Timer to control the saftey period where both lights are red because the lights are changing from allowing cars through to allowing predestrians to cross |
int |
crossingTimer
This timer controls the period in which the light is green for pedestrians to cross. |
int |
now
The current time of the model |
int |
trafficFlowTimer
This timer controls the minimum 20 second period in which the light must be green for cars.When the timer expires the minimumWaitElapsed action will be called |
Constructor Summary | |
---|---|
TrafficLight()
|
Method Summary | |
---|---|
void |
allowCars()
|
boolean |
allowCarsGuard()
|
void |
allowPedestrians()
|
boolean |
allowPedestriansGuard()
Guard for the safetyPeriodEnd action. |
void |
finishPedestrianPeriod()
|
boolean |
finishPedestrianPeriodGuard()
|
int |
getNextTimeIncrement()
Take random steps of between 1 and 10 time units (inclusive) |
java.lang.Object |
getState()
Return the current state of the FSM model. |
static void |
main(java.lang.String[] args)
|
void |
minimumWaitElapsed()
|
boolean |
minimumWaitElapsedGuard()
|
void |
pedestrianArrive()
Action for pedestrians arriving at the crossing. |
void |
reset(boolean testing)
Reset the model to its initial state. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public int trafficFlowTimer
public int crossingTimer
public int allowPedestriansTimer
public int allowCarsTimer
public int now
Constructor Detail |
---|
public TrafficLight()
Method Detail |
---|
public java.lang.Object getState()
FsmModel
Advanced Feature: This method can be used to define
equivalence classes over the states, if you want to reduce
the number of states to keep the FSM small.
For example, if you have a integer state variable I that can
have a huge number of possible values, you could define your
getState() method to return new Integer(I % 10)
.
This would reduce the FSM to just 10 states, where FSM state 0
represents all the states where I=0 or I=10 or I=20 etc., and
FSM state 1 represents all the states where I=1 or I=11 or I=21 etc.
getState
in interface FsmModel
public void reset(boolean testing)
FsmModel
reset
in interface FsmModel
testing
- true means the SUT should be reset too.public void pedestrianArrive()
public boolean allowPedestriansGuard()
public void allowPedestrians()
public boolean allowCarsGuard()
public void allowCars()
public boolean minimumWaitElapsedGuard()
public void minimumWaitElapsed()
public boolean finishPedestrianPeriodGuard()
public void finishPedestrianPeriod()
public static void main(java.lang.String[] args)
public int getNextTimeIncrement()
getNextTimeIncrement
in interface TimedFsmModel
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |