stella.sensor
Class RawDataEvent

java.lang.Object
  extended by java.util.EventObject
      extended by util.rmi.RmiEvent
          extended by stella.DataEvent
              extended by stella.sensor.RawDataEvent
All Implemented Interfaces:
Serializable, PostingEvent
Direct Known Subclasses:
CumulativeDataEvent

public class RawDataEvent
extends DataEvent

The generic data event for sensors that produce raw data. The measurement of the data event is set to the raw value, no other side information is available.
Sensors produce single numbers as a measurement, therefore the measurement is of Double type. Note that as a 'dirty trick' we leave the original measurement of the DataEvent untouched and use it as an escape pod to stuff bad/good weather information into it.

See Also:
Serialized Form

Field Summary
private  Double raw
          The raw measurement.
private  ConvertToPhysical rawconvert
          An instance to convert raw readings into physically meaningful values.
private  NumberFormat rawformat
          A formatter for the raw measurements.
private  NumberFormat sigformat
          A formatter for the raw deviation.
private  Double sigma
          The sigma of the individual measurement.
 
Fields inherited from class stella.DataEvent
FORMAT
 
Fields inherited from class util.rmi.RmiEvent
localHost, sourceName
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
RawDataEvent(DataEvent source)
          Constructs the raw data event from a single data event.
RawDataEvent(Object src)
          Constructs a raw data event specifiying only the source.
 
Method Summary
protected  String formatPhysical(Double meas)
          Formats a physical reading according to the rawconvert rule.
protected  String formatRaw(Double meas)
          Formats a raw reading according to the rawformat rule.
protected  String getDateString()
          Returns the date of the measurement and, if set, the measurement value converted to clear/bad, depending on its Boolean value.
 String getFormattedPhysical()
          Returns the physical quantity formatted to its converter's format.
 String getFormattedPhysicalDeviation()
          Returns the physical quantity formatted to its converter's format.
 String getFormattedRaw()
          Returns the raw reading as a string, formatted according to the raw formatter.
 String getFormattedRawDeviation()
          Returns the raw reading sigma as a string, formatted according to the raw formatter.
 double getPhysical()
          Returns the measurement as a physical meaningful quantity.
 double getPhysicalDeviation()
          Returns the error of the measurement in physical quantities.
 double getRaw()
          Returns the measurement as a primitive double.
 ConvertToPhysical getRawConvert()
          Retrieves the conversion class to transform raw measurements into physically meaningful quantities.
 double getRawDeviation()
          Returns the error of the measurement.
 NumberFormat getRawFormat()
          gets the raw-data formatter.
protected  String getRawString()
          Returns the raw measures, if possible with the error and both in their representation as physical quantities.
 NumberFormat getSigmaFormat()
          gets the raw-data formatter.
 void setRaw(double rw)
          Sets the measurement of this data event as a primitive double.
 void setRawConvert(ConvertToPhysical conv)
          Sets the conversion class to transform raw measurements into physically meaningful quantities.
 void setRawDeviation(double sig)
          Sets the error of the measurement.
 void setRawFormat(NumberFormat forraw)
          Sets the raw-data formatter.
 void setSigmaFormat(NumberFormat forraw)
          Sets the raw-data formatter.
 String toString()
          Returns a string representation of this raw data event.
 
Methods inherited from class stella.DataEvent
getMeasurement, getTimeOfMeasure, isValid, setMeasurement, setTimeOfMeasure, setValid
 
Methods inherited from class util.rmi.RmiEvent
getHost, getSourceName, setSourceName
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

raw

private Double raw
The raw measurement.


sigma

private Double sigma
The sigma of the individual measurement.


rawconvert

private ConvertToPhysical rawconvert
An instance to convert raw readings into physically meaningful values.


rawformat

private NumberFormat rawformat
A formatter for the raw measurements.


sigformat

private NumberFormat sigformat
A formatter for the raw deviation.

Constructor Detail

RawDataEvent

public RawDataEvent(Object src)
Constructs a raw data event specifiying only the source.


RawDataEvent

public RawDataEvent(DataEvent source)
Constructs the raw data event from a single data event. Note that the conversion instance rawconvert and the decimal formatters rawformat and sigformat are only pointer-copied and not cloned.

Method Detail

setRawFormat

public void setRawFormat(NumberFormat forraw)
Sets the raw-data formatter.


getRawFormat

public NumberFormat getRawFormat()
gets the raw-data formatter.


setSigmaFormat

public void setSigmaFormat(NumberFormat forraw)
Sets the raw-data formatter.


getSigmaFormat

public NumberFormat getSigmaFormat()
gets the raw-data formatter.


setRawConvert

public void setRawConvert(ConvertToPhysical conv)
Sets the conversion class to transform raw measurements into physically meaningful quantities.


getRawConvert

public ConvertToPhysical getRawConvert()
Retrieves the conversion class to transform raw measurements into physically meaningful quantities.


setRaw

public void setRaw(double rw)
Sets the measurement of this data event as a primitive double.


getRaw

public double getRaw()
Returns the measurement as a primitive double. If no measurement was set or the measurement is not of type Double, nan is returned.


getFormattedRaw

public String getFormattedRaw()
Returns the raw reading as a string, formatted according to the raw formatter. If the raw-formatter is null, Double.toString is used.


getPhysical

public double getPhysical()
Returns the measurement as a physical meaningful quantity. Only possible if the rawconvert conversion object has been set. If conversion fails for some reason, nan is returned.

Returns:
The measurment in physical quantities or Double.NaN

getFormattedPhysical

public String getFormattedPhysical()
Returns the physical quantity formatted to its converter's format.


setRawDeviation

public void setRawDeviation(double sig)
Sets the error of the measurement. Normally this will be some sort of standard deviation of a bunch of measurements.


getRawDeviation

public double getRawDeviation()
Returns the error of the measurement. If the error is not specified, Double.NaN is returned.


getFormattedRawDeviation

public String getFormattedRawDeviation()
Returns the raw reading sigma as a string, formatted according to the raw formatter. If the raw-formatter is null, Double.toString is used.


getPhysicalDeviation

public double getPhysicalDeviation()
Returns the error of the measurement in physical quantities. Only possible if the rawconvert conversion object has been set. If conversion fails for some reason, nan is returned.

Returns:
The measurment error in physical quantities or Double.NaN.

getFormattedPhysicalDeviation

public String getFormattedPhysicalDeviation()
Returns the physical quantity formatted to its converter's format.


toString

public String toString()
Returns a string representation of this raw data event.

Overrides:
toString in class DataEvent

getDateString

protected String getDateString()
Returns the date of the measurement and, if set, the measurement value converted to clear/bad, depending on its Boolean value.


getRawString

protected String getRawString()
Returns the raw measures, if possible with the error and both in their representation as physical quantities.


formatRaw

protected String formatRaw(Double meas)
Formats a raw reading according to the rawformat rule. If the measurement is NaN or null, nan is included in the string.

See Also:
formatPhysical(java.lang.Double)

formatPhysical

protected String formatPhysical(Double meas)
Formats a physical reading according to the rawconvert rule. If the measurement is NaN or null, the empty string is returned.

Parameters:
meas - The raw measurement value.
See Also:
formatRaw(java.lang.Double)