public class States extends EventGenerator
Event.STATE events
and allows to retrieve for each state its current value. Each instance can manage at most 256 states and
each state can have a value between 0 and 255.0 and getNumberOfStates()-1| Constructor and Description |
|---|
States(int[] nbValues,
int[] initialValues)
Creates a states generator.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getCurrentValue(int stateID)
Gets the current value of the given state.
|
int |
getEventType()
Gets the event type associated with the event generator.
|
int |
getNumberOfStates()
Gets the number of states managed by this instance.
|
int |
getNumberOfValues(int stateID)
Gets the total number of values for the given state.
|
static int |
getStateID(int event)
Gets the state's ID held by the state event.
|
static int |
getStateValue(int event)
Gets the state's value held by the state event.
|
void |
send(int stateID,
int value)
Stores the given state value and sends a MicroUI
Event.STATE to the States's listener. |
addToSystemPool, get, get, get, getEventHandler, getID, getList, removeFromSystemPool, sendEvent, setEventHandlerpublic States(int[] nbValues,
int[] initialValues)
nbValues - number of values for each state.initialValues - initial value for each state.java.lang.NullPointerException - if one of the parameters is null.java.lang.IllegalArgumentException - if both arrays don't have the same length.java.lang.IndexOutOfBoundsException - if arrays length is greater than 255.java.lang.IndexOutOfBoundsException - if nbValues[i] < 0 or nbValues[i] > 255.java.lang.IndexOutOfBoundsException - if initialValues[i] < 0 or initialValues[i] >= nbValues[i].public static int getStateID(int event)
event - the state event to decode.0 and 255.public static int getStateValue(int event)
event - the state event to decode.0 and 255.public int getEventType()
getEventType in class EventGeneratorpublic int getNumberOfValues(int stateID)
stateID - the state identifier value.java.lang.IndexOutOfBoundsException - when stateID is out of [0,getNumberOfStates()-1].public int getCurrentValue(int stateID)
stateID - the state identifier value.0 and getNumberOfValues(int)-1.java.lang.IndexOutOfBoundsException - when stateID is out of [0,getNumberOfStates()-1].public int getNumberOfStates()
public void send(int stateID,
int value)
Event.STATE to the States's listener.stateID - the state identifier value.value - the new state valuejava.lang.IndexOutOfBoundsException - when stateID is out of [0,getNumberOfStates()-1].java.lang.IndexOutOfBoundsException - when value is out of [0,getNumberOfValues(int)-1].