|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--de.jaetzold.art.RawSensor
This class represents a basic input-device of a hardware-interface. Each device, such as a Sensor needs to be connected to a Port first. Through connecting with a Port this Object gets its peer which is required for proper use.
connectWith(Port)
Inner Class Summary | |
class |
RawSensor.ValueSensorPort
A SensorPort for the value of this Sensor. |
Field Summary | |
protected PropertyChangeSupport |
changes
Now comes the stuff for the events and their listeners |
protected double |
precision
The local value for precision. |
protected boolean |
precisionSet
This is false by default. |
protected SensorEventDescriptor |
propertyChangeEventDescriptor
An instance of AllSensorEventDescriptor . |
Constructor Summary | |
RawSensor()
Contructs a new RawSensor. |
Method Summary | |
void |
addPropertyChangeListener(PropertyChangeListener l)
A PropertyChangeListener receives PropertyChangeEvents whenever this Sensor receives a SensorEvent. |
void |
addSensorListener(SensorListener listener)
Adds the specified SensorListener to this Sensor so that it receives SensorEvents from it. |
void |
addSensorListener(SensorListener listener,
SensorEventDescriptor eventDescriptor)
Adds the specified SensorListener to this Sensor so that it receives the SensorEvents which are described by the specified SensorEventDescriptor. |
void |
connectWith(Port port)
Connects the Sensor with the given Port. |
void |
connectWith(SensorPort port)
Connects this Sensor with the given Port. |
protected double |
convertToIncoming(double peerValue)
This is a Template-Method for subclasses. |
protected double |
convertToOutgoing(double internalValue)
This is a Template-Method for subclasses. |
void |
disableEvent(SensorEventDescriptor eventDescriptor)
Disables the type of Event described by the given SensorEventDescriptor. |
void |
disconnect()
Disconnects this Sensor from it's Peer and it's Port. |
void |
enableEvent(SensorEventDescriptor eventDescriptor)
Enables the type of Event described by the given SensorEventDescriptor. |
protected boolean |
getChangeEventsEnabled()
Tells whether this Sensor is configured to receive Events from its Peer whenever something changes. |
boolean |
getDeliversFloatingPoint()
Tells whether this Sensor delivers discrete values or not. |
Conversion |
getIncomingConversionDelegate()
Returns the delegate for converting peer-side values to the internal representation of this Sensor. |
int |
getIntValue()
The value-retrieving methods |
Conversion |
getOutgoingConversionDelegate()
Returns the delegate for converting the internal value-representation of this Sensor to the one that is presented to the outside. |
protected SensorPeer |
getPeer()
Returns the Peer this Sensor actually uses. |
boolean |
getPeerCacheEnabled()
Tells whether this Sensor tries to minimize traffic to and from the Peer. |
Port |
getPort()
Returns the Port to which this Sensor is connected. |
double |
getPrecision()
Returns the maximum of the expectable error in the value. |
SensorPort |
getSensorPort()
Returns a Port through which other Sensors can be connected to this Sensor. |
double |
getValue()
Returns the value this Sensor represents as a double. |
boolean |
isConnected()
Tells wether this Sensor has a Peer and whether the Peer is also connected. |
protected boolean |
isIncomingConversionCacheable()
This is not the same as isCacheable() from Conversion or StateDecider. |
protected boolean |
isOutgoingConversionCacheable()
Same meaning as isIncomingConversionCacheable() but for the outgoingConversion. |
boolean |
isReversed()
Tells whether this Sensor treats negative values as positive and the other way round. |
void |
processEvent(SensorEvent event)
This Method is called when the value this Sensor resembles has changed and events are enabled. |
void |
propertyChange(PropertyChangeEvent event)
This is the method through which a Sensor gets informed about changes in the hardware-value it resembles. |
void |
removePropertyChangeListener(PropertyChangeListener l)
Remove the specified listener. |
void |
removeSensorListener(SensorListener listener)
Removes the specified SensorListener so that it no longer receives SensorEvents from this Sensor. |
void |
removeSensorListener(SensorListener listener,
SensorEventDescriptor eventDescriptor)
Removes the specified SensorListener so that it no longer receives from this Sensor the SensorEvents which are described by the specified SensorEventDescriptor. |
protected void |
setChangeEventsEnabled(boolean enabled)
Configures whether this Sensor wants to receive Events from its Peer whenever something changes. |
void |
setIncomingConversionDelegate(Conversion delegate)
This is the delegate for converting peer-side values to the internal representation of this Sensor. |
void |
setOutgoingConversionDelegate(Conversion delegate)
This is the delegate for converting the internal value-representation of this Sensor to the one that is presented to the outside. |
void |
setPeerCacheEnabled(boolean enabled)
Should this Sensor try to minimize traffic to and from the Peer? This is enabled by default. |
void |
setPrecision(double precision)
Sets the local value for precision. |
void |
setReversed(boolean reversed)
Controls whether this Sensor should treat negative values as positive and the other way round. |
void |
update()
Causes a new SensorEvent for this Sensor to be generated and delivered. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected boolean precisionSet
setPrecision(double)
protected double precision
precisionSet
,
setPrecision(double)
protected PropertyChangeSupport changes
protected SensorEventDescriptor propertyChangeEventDescriptor
AllSensorEventDescriptor
. It is used as a descriptor for PropertyChangeEvents.SensorEventDescriptor
,
AllSensorEventDescriptor
Constructor Detail |
public RawSensor()
connectWith(Port)
Method Detail |
protected double convertToIncoming(double peerValue)
super
.convertToOutgoing(double)
,
isIncomingConversionCacheable()
protected double convertToOutgoing(double internalValue)
super
.convertToIncoming(double)
,
isOutgoingConversionCacheable()
public boolean isReversed()
setReversed(boolean)
public void setReversed(boolean reversed)
public double getPrecision()
Sensor
getPrecision
in interface Sensor
public void setPrecision(double precision)
precisionSet
,
setPrecision(double)
protected boolean isIncomingConversionCacheable()
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.isOutgoingConversionCacheable()
,
setIncomingConversionDelegate(Conversion)
,
Conversion.isCacheable()
protected boolean isOutgoingConversionCacheable()
isIncomingConversionCacheable()
but for the outgoingConversion.isIncomingConversionCacheable()
public void setIncomingConversionDelegate(Conversion delegate)
getSensorPort()
.convertToIncoming(double)
,
setOutgoingConversionDelegate(Conversion)
,
getSensorPort()
public Conversion getIncomingConversionDelegate()
convertToIncoming(double)
,
setIncomingConversionDelegate(Conversion)
public void setOutgoingConversionDelegate(Conversion delegate)
getSensorPort()
.convertToOutgoing(double)
,
setIncomingConversionDelegate(Conversion)
,
getSensorPort()
public Conversion getOutgoingConversionDelegate()
convertToOutgoing(double)
,
setOutgoingConversionDelegate(Conversion)
protected SensorPeer getPeer()
public Port getPort()
Sensor
getSensorPort()
and getPort()
.getPort
in interface Sensor
de.jaetzold.art.Sensor
Sensor.getPort()
public boolean getDeliversFloatingPoint()
getDeliversFloatingPoint
in interface SensorPeer
convertToIncoming(double)
,
setIncomingConversionDelegate(Conversion)
,
setOutgoingConversionDelegate(Conversion)
public void setPeerCacheEnabled(boolean enabled)
getPeerCacheEnabled()
,
setChangeEventsEnabled(boolean)
public boolean getPeerCacheEnabled()
setPeerCacheEnabled(boolean)
protected boolean getChangeEventsEnabled()
setPeerCacheEnabled(boolean)
,
setChangeEventsEnabled(boolean)
protected void setChangeEventsEnabled(boolean enabled)
setPeerCacheEnabled(boolean)
,
getChangeEventsEnabled()
public int getIntValue()
getIntValue
in interface Sensor
de.jaetzold.art.Sensor
Sensor.getValue()
public double getValue()
Sensor
getValue
in interface Sensor
public void disconnect()
Sensor
disconnect
in interface Sensor
de.jaetzold.art.Sensor
Sensor.connectWith(Port)
public boolean isConnected()
Sensor
RobotInterface
this Peer belongs to is not connected.isConnected
in interface Sensor
de.jaetzold.art.Sensor
SensorPeer.isConnected()
,
RobotInterface.isConnected()
,
Sensor.connectWith(Port)
public void connectWith(Port port)
Sensor
connectWith
in interface Sensor
de.jaetzold.art.Sensor
SensorPort
public void connectWith(SensorPort port)
RawSensor.ValueSensorPort
,
connectWith(Port)
public void addPropertyChangeListener(PropertyChangeListener l)
Sensor
value
.
This mechanism in the Sensor is not really used for anything else right now but may be in future releases.addPropertyChangeListener
in interface Sensor
de.jaetzold.art.Sensor
Sensor.addSensorListener(SensorListener)
,
SensorListener.processEvent(SensorEvent)
public void removePropertyChangeListener(PropertyChangeListener l)
Sensor
removePropertyChangeListener
in interface Sensor
de.jaetzold.art.Sensor
Sensor.addPropertyChangeListener(PropertyChangeListener)
public void addSensorListener(SensorListener listener, SensorEventDescriptor eventDescriptor)
addSensorListener(SensorListener)
.
Note: By now using special SensorEventDescriptors only has the effect that the Events not described are discarded before delivering them to listener but they are still generated.addSensorListener(SensorListener)
,
removeSensorListener(SensorListener,SensorEventDescriptor)
,
SensorListener
,
SensorEventDescriptor
public void removeSensorListener(SensorListener listener, SensorEventDescriptor eventDescriptor)
addSensorListener(SensorListener,SensorEventDescriptor)
,
SensorListener
,
SensorEventDescriptor
public void addSensorListener(SensorListener listener)
Sensor
addSensorListener
in interface Sensor
de.jaetzold.art.Sensor
Sensor.removeSensorListener(SensorListener)
,
SensorListener.processEvent(SensorEvent)
public void removeSensorListener(SensorListener listener)
Sensor
removeSensorListener
in interface Sensor
de.jaetzold.art.Sensor
Sensor.addSensorListener(SensorListener)
,
SensorListener.processEvent(SensorEvent)
public void propertyChange(PropertyChangeEvent event)
Sensor
processEvent(SensorEvent)
.propertyChange
in interface Sensor
de.jaetzold.art.Sensor
Sensor.processEvent(SensorEvent)
public void processEvent(SensorEvent event)
Sensor
propertyChange(PropertyChangeEvent)
this method is not interested in the new value but in the SensorEvent which resembles the change.processEvent
in interface Sensor
de.jaetzold.art.Sensor
Sensor.propertyChange(java.beans.PropertyChangeEvent)
public void enableEvent(SensorEventDescriptor eventDescriptor)
AllSensorEventDescriptor
has been used. It can however be used to enable the caching of the peer-side values without registering a listener for this Sensor.enableEvent
in interface SensorPeer
setPeerCacheEnabled(boolean)
,
setChangeEventsEnabled(boolean)
,
AllSensorEventDescriptor
public void disableEvent(SensorEventDescriptor eventDescriptor)
disableEvent
in interface SensorPeer
enableEvent(SensorEventDescriptor)
public void update()
Sensor
update
in interface Sensor
de.jaetzold.art.Sensor
Sensor.processEvent(SensorEvent)
,
SensorPeer.update()
,
SensorEvent
public SensorPort getSensorPort()
Sensor
getSensorPort()
and getPort()
.getSensorPort
in interface Sensor
de.jaetzold.art.Sensor
Sensor.getPort()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |