de.jaetzold.art.examples
Class RCXRotationSensorStateDecider

java.lang.Object
  |
  +--de.jaetzold.art.examples.RCXRotationSensorStateDecider
All Implemented Interfaces:
StateDecider

public class RCXRotationSensorStateDecider
extends Object
implements StateDecider

A simple class which maps raw sensor-values to one of the four positions the LEGO-Rotationsensor may have. The raw sensor values are around 359, 527, 1023 and 777 which are mapped by this decider to the states 1, 2, 3 and 4. All values not very close to the four named (about +-7) don't result in a state-change. It has such short borders because it seems that the original sensor measuring of the RCX also doesn't take any "wrong" values into account.


Field Summary
protected  StateDecider target
           
 
Constructor Summary
RCXRotationSensorStateDecider()
           
 
Method Summary
 boolean isCacheable()
          Tells whether this instance will in the future produce the same state for the same value argument, independent of the actualState.
 double nextStateValue(double actualState, double value)
          Return the next state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

target

protected StateDecider target
Constructor Detail

RCXRotationSensorStateDecider

public RCXRotationSensorStateDecider()
Method Detail

nextStateValue

public double nextStateValue(double actualState,
                             double value)
Description copied from interface: StateDecider
Return the next state. The result may depend on the given actualState and the current value but is allowed to depend on anything else. Be sure to have isCacheable() return a correct result then.
Specified by:
nextStateValue in interface StateDecider
Following copied from interface: de.jaetzold.util.StateDecider
See Also:
StateDecider.isCacheable()

isCacheable

public boolean isCacheable()
Description copied from interface: StateDecider
Tells whether this instance will in the future produce the same state for the same value argument, independent of the actualState. This can be false first and then true at a later time, but it is not legal to return false here after a return of true in the past, because the true answer before was wrong then.
Specified by:
isCacheable in interface StateDecider
Following copied from interface: de.jaetzold.util.StateDecider
Returns:
true if this instance guarantees, that any further call to nextStateValue() with the same value-argument returns the same state