de.jaetzold.art
Class LightSensor

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

public class LightSensor
extends RawSensor

This class represents values which are associated with some kind of light-level. It is a sensor for a particular unit of measure.


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
LightSensor()
           
 
Method Summary
 void connectWith(SensorPort port)
          Connects this Sensor with the given Port.
protected  double convertToIncoming(double value)
          This is a Template-Method for subclasses.
 void disconnect()
          Disconnects this Sensor from it's Peer and it's Port.
 boolean getDeliversFloatingPoint()
          Tells whether this Sensor delivers discrete values or not.
 double getMeasurableMax()
          This is the value above which the sensor isn't accurate enough anymore.
 double getMeasurableMin()
          This is the value below which the sensor isn't accurate enough anymore.
 Conversion getScalingConversion()
          Returns the delegate used for scale-conversion.
 boolean isIncomingConversionCacheable()
          This is not the same as isCacheable() from Conversion or StateDecider.
 void setMeasurableMax(double max)
          This sets the value above which the sensor isn't accurate enough anymore.
 void setMeasurableMin(double min)
          This sets the value below which the sensor isn't accurate enough anymore.
 void setScalingConversion(Conversion scalingConversion)
          This is a delegate used for scale-conversion.
 
Methods inherited from class de.jaetzold.art.RawSensor
addPropertyChangeListener, addSensorListener, addSensorListener, connectWith, convertToOutgoing, disableEvent, enableEvent, getChangeEventsEnabled, getIncomingConversionDelegate, getIntValue, getOutgoingConversionDelegate, getPeer, getPeerCacheEnabled, getPort, getPrecision, getSensorPort, getValue, isConnected, isOutgoingConversionCacheable, isReversed, processEvent, propertyChange, removePropertyChangeListener, 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

LightSensor

public LightSensor()
Method Detail

setScalingConversion

public void setScalingConversion(Conversion scalingConversion)
This is a delegate used for scale-conversion.

getScalingConversion

public Conversion getScalingConversion()
Returns the delegate used for scale-conversion.

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()

getMeasurableMin

public double getMeasurableMin()
This is the value below which the sensor isn't accurate enough anymore. If the peer is a LightSensorPeer the value is taken from it until it is set explicitly.
See Also:
setMeasurableMin(double), RawSensor.getPrecision()

setMeasurableMin

public void setMeasurableMin(double min)
This sets the value below which the sensor isn't accurate enough anymore.
See Also:
RawSensor.getPrecision()

getMeasurableMax

public double getMeasurableMax()
This is the value above which the sensor isn't accurate enough anymore. If the peer is a LightSensorPeer the value is taken from it otherwise it must be set explicitly.
See Also:
setMeasurableMax(double), RawSensor.getPrecision()

setMeasurableMax

public void setMeasurableMax(double max)
This sets the value above which the sensor isn't accurate enough anymore.
See Also:
RawSensor.getPrecision()

connectWith

public void connectWith(SensorPort port)
Description copied from class: RawSensor
Connects this Sensor with the given Port. The Sensor gets its peer from the Port so it is therefore required before the Sensor can be properly used.
Overrides:
connectWith in class RawSensor
Following copied from class: de.jaetzold.art.RawSensor
See Also:
RawSensor.ValueSensorPort, RawSensor.connectWith(Port)

disconnect

public void disconnect()
Description copied from interface: Sensor
Disconnects this Sensor from it's Peer and it's Port. This is implicitly called when the Sensor is already connected and asked to connect with another Port.
Overrides:
disconnect in class RawSensor
Following copied from interface: de.jaetzold.art.Sensor
See Also:
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)

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()