de.jaetzold.art
Class CombinedSensor

java.lang.Object
  |
  +--de.jaetzold.art.RawSensor
        |
        +--de.jaetzold.art.CombinedSensor
All Implemented Interfaces:
EventListener, PropertyChangeListener, Sensor, SensorPeer

public class CombinedSensor
extends RawSensor


Inner classes inherited from class de.jaetzold.art.RawSensor
RawSensor.ValueSensorPort
 
Fields inherited from class de.jaetzold.art.RawSensor
changes, precision, precisionSet, propertyChangeEventDescriptor
 
Constructor Summary
CombinedSensor()
           
CombinedSensor(Sensor operand, BinaryOperator operator)
           
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener l)
          A PropertyChangeListener receives PropertyChangeEvents whenever this Sensor receives a SensorEvent.
protected  double convertToIncoming(double value)
          This is a Template-Method for subclasses.
 boolean getDeliversFloatingPoint()
          Tells whether this Sensor delivers discrete values or not.
 Sensor getOperand()
          Beware, the used operand can change over time.
 BinaryOperator getOperator()
           
 double getPrecision()
          Returns the maximum of the expectable error in the value.
 boolean isConnected()
          Tells wether this Sensor has a Peer and whether the Peer is also connected.
 boolean isIncomingConversionCacheable()
          This is not the same as isCacheable() from Conversion or StateDecider.
 void processEvent(SensorEvent se)
          This Method is called when the value this Sensor resembles has changed and events are enabled.
 void removePropertyChangeListener(PropertyChangeListener l)
          Remove the specified listener.
 void setOperand(Sensor operand)
          It's the second operand to operator, the first is this sensor's value itself.
 void setOperator(BinaryOperator operator)
           
 
Methods inherited from class de.jaetzold.art.RawSensor
addSensorListener, addSensorListener, connectWith, connectWith, convertToOutgoing, disableEvent, disconnect, enableEvent, getChangeEventsEnabled, getIncomingConversionDelegate, getIntValue, getOutgoingConversionDelegate, getPeer, getPeerCacheEnabled, getPort, getSensorPort, getValue, isOutgoingConversionCacheable, isReversed, propertyChange, removeSensorListener, removeSensorListener, setChangeEventsEnabled, setIncomingConversionDelegate, setOutgoingConversionDelegate, setPeerCacheEnabled, setPrecision, setReversed, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CombinedSensor

public CombinedSensor()

CombinedSensor

public CombinedSensor(Sensor operand,
                      BinaryOperator operator)
Method Detail

setOperand

public void setOperand(Sensor operand)
It's the second operand to operator, the first is this sensor's value itself. A CombinedSensor is best connected to the Port which genereates the most events and gets the Sensor as operator which generates less events.

getOperand

public Sensor getOperand()
Beware, the used operand can change over time.

setOperator

public void setOperator(BinaryOperator operator)

getOperator

public BinaryOperator getOperator()

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)
Description copied from interface: Sensor
A PropertyChangeListener receives PropertyChangeEvents whenever this Sensor receives a SensorEvent. The PropertyChangeEvent has the SensorEvent as it's new value and the last SensorEvent as the old value. The property name used for this is value. This mechanism in the Sensor is not really used for anything else right now but may be in future releases.
Overrides:
addPropertyChangeListener in class RawSensor
Following copied from interface: de.jaetzold.art.Sensor
See Also:
Sensor.addSensorListener(SensorListener), SensorListener.processEvent(SensorEvent)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)
Description copied from interface: Sensor
Remove the specified listener.
Overrides:
removePropertyChangeListener in class RawSensor
Following copied from interface: de.jaetzold.art.Sensor
See Also:
Sensor.addPropertyChangeListener(PropertyChangeListener)

convertToIncoming

protected double convertToIncoming(double value)
Description copied from class: RawSensor
This is a Template-Method for subclasses. It converts the value as it comes from the peer into the internal value of this sensor. It is called whenever a new value comes from the peer. Because this Method also calls the incomingConversionDelegate (if one exists) it should not be overridden without calling super.
Overrides:
convertToIncoming in class RawSensor
Following copied from class: de.jaetzold.art.RawSensor
See Also:
RawSensor.convertToOutgoing(double), RawSensor.isIncomingConversionCacheable()

processEvent

public void processEvent(SensorEvent se)
Description copied from interface: Sensor
This Method is called when the value this Sensor resembles has changed and events are enabled. The given SensorEvent is then passed to any registered listeners, the SensorListeners as well as the PropertyChangeListeners. Unlike propertyChange(PropertyChangeEvent) this method is not interested in the new value but in the SensorEvent which resembles the change.
Overrides:
processEvent in class RawSensor
Following copied from interface: de.jaetzold.art.Sensor
See Also:
Sensor.propertyChange(java.beans.PropertyChangeEvent)

getPrecision

public double getPrecision()
Description copied from interface: Sensor
Returns the maximum of the expectable error in the value. This is just a guess, what means that nothing really important should depend on it. It is meant to give an algorithm using this Sensor an idea of how precise the value is so that it either can refuse to use it or try to compensate if necessary.
Overrides:
getPrecision in class RawSensor

isIncomingConversionCacheable

public boolean isIncomingConversionCacheable()
Description copied from class: RawSensor
This is not the same as isCacheable() from Conversion or StateDecider. The Conversion may depend on a delegate and that delegate can be set more than once. Therefore it would be impossible to assure that the Conversion remains cacheable. But the contract is, that as long as the delegate doesn't change you can assume that the incoming conversion remains cacheable once it has become so.
Overrides:
isIncomingConversionCacheable in class RawSensor
Following copied from class: de.jaetzold.art.RawSensor
See Also:
RawSensor.isOutgoingConversionCacheable(), RawSensor.setIncomingConversionDelegate(Conversion), Conversion.isCacheable()

isConnected

public boolean isConnected()
Description copied from interface: Sensor
Tells wether this Sensor has a Peer and whether the Peer is also connected. For example a Peer can be not connected if it is a Peer that only forwards calls to another Peer and that one is not connected or if the RobotInterface this Peer belongs to is not connected.
Overrides:
isConnected in class RawSensor
Following copied from interface: de.jaetzold.art.Sensor
See Also:
SensorPeer.isConnected(), RobotInterface.isConnected(), Sensor.connectWith(Port)

getDeliversFloatingPoint

public boolean getDeliversFloatingPoint()
Description copied from class: RawSensor
Tells whether this Sensor delivers discrete values or not. A result of false means that the result of a getValue() can be cast to int without a loss of precision. The result of this method is only valid as long as no one of the conversion delegates changes.
Overrides:
getDeliversFloatingPoint in class RawSensor
Following copied from class: de.jaetzold.art.RawSensor
See Also:
RawSensor.convertToIncoming(double), RawSensor.setIncomingConversionDelegate(Conversion), RawSensor.setOutgoingConversionDelegate(Conversion)