public class FileCurrent extends AbstractDataCollector
SensorRepository to a file. If the KEY_MAPLIST
property is given, only sensors present in this list are writtn. The file
(KEY_CURRENT) is writtn
whenever data is available.
Depending on the KEY_APPEND property,
the file is either newly writtn at each call or appended to.
A typical file may look as
# Date nsolz solz 30.09.02 18:10:07* +35.08866* +35.27701*The values given are the physical averages, if available. Otherwise the raw values are given.
KEY_BADFLAG
string added to the value, while for good weather data this string is
replaced with an empty string of equal length.| Modifier and Type | Field and Description |
|---|---|
private DateFormat |
date
The date formatter to use for output.
|
private static boolean |
DEFAPPEND
The default appending behaviour.
|
private static String |
DEFBADFLAG
The default setting of the bad-weather indicator.
|
private static String |
DEFCURRENT
The default name of the output file.
|
private static DateFormat |
DEFDATE
The date/time formatter.
|
private static long |
DEFINTERVAL
The default notification period in ms.
|
private static boolean |
DEFSTRICT
The default adding to file behaviour on incomplete sets.
|
private static String |
DEFUNIT
The default unit string.
|
private static String |
DEFVALIDFLAG
The default setting of the non-valid-reading indicator.
|
private static String |
DEFWEATHER
The default binding name of the weather trigger.
|
static String |
KEY_APPEND
The key defining if appending should be enabled.
|
static String |
KEY_BADFLAG
The key to the bad-weather indicator.
|
static String |
KEY_CURRENT
The key to the file where the current data should be writtn to.
|
static String |
KEY_DATE
The key to the date-format string.
|
static String |
KEY_MAPLIST
The key to a list of sensor that should be mapped.
|
static String |
KEY_STRICT
If true, only data sets containing all sensors are writtn.
|
static String |
KEY_UNIT
The key to the default unit string.
|
static String |
KEY_VALIDFLAG
The key to the non-valid reading indicator.
|
static String |
KEY_WEATHER
The key to the bindname of the weather parameter.
|
private List<String> |
map
The list of all sensor names that should be mapped in the output file.
|
private Map<String,DataEvent> |
validread
A mapping of sensor names to last valid readings.
|
KEY_CLASS, KEY_INTERVAL, KEY_RMIDATACOLLECTKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORCONFIG| Constructor and Description |
|---|
FileCurrent(Map<String,String> prop)
Constructs a new file collector.
|
| Modifier and Type | Method and Description |
|---|---|
long |
getInterval()
Returns the notification interval.
|
private static boolean |
isValidReading(DataEvent de)
Defines if the handed-over data event consists of valid readings.
|
void |
processData(Map<String,DataEvent> sensor,
boolean weather)
The file collector writes out all the data it received in a single
file.
|
String |
toString()
A short description of the current data collector.
|
private void |
writeData(Writer out,
Map<String,DataEvent> data,
boolean weather)
Writes the sensor data to the given stream.
|
private void |
writeHeader(Writer out,
Map<String,DataEvent> data)
Writes a header to the specified stream.
|
createDataCollectoraugment, augment, augment, augment, augment, clone, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, initProperties, isNew, parseObject, parseObject, reload, reload, removeProperty, requires, rescanned, setObject, setProperties, setProperty, stringPropertiespublic static final String KEY_CURRENT
public static final String KEY_APPEND
public static final String KEY_WEATHER
public static final String KEY_BADFLAG
public static final String KEY_VALIDFLAG
public static final String KEY_MAPLIST
public static final String KEY_STRICT
public static final String KEY_UNIT
public static final String KEY_DATE
private static final long DEFINTERVAL
private static final String DEFCURRENT
private static final boolean DEFAPPEND
private static final String DEFWEATHER
private static final String DEFBADFLAG
private static final String DEFVALIDFLAG
private static final boolean DEFSTRICT
private static final String DEFUNIT
private static final DateFormat DEFDATE
private final Map<String,DataEvent> validread
private final DateFormat date
public FileCurrent(Map<String,String> prop)
KEY_CURRENT, the
KEY_APPEND, the KEY_STRICT, the KEY_WEATHER
and the two flags,
KEY_BADFLAG and KEY_VALIDFLAG obtain their default
values if not present. If
the KEY_MAPLIST property is set, the look-up list for
the sensors to output is initialized.public long getInterval()
public void processData(Map<String,DataEvent> sensor, boolean weather)
sensor - Mapping sensor names to data events.weather - True if current weather is good.private void writeHeader(Writer out, Map<String,DataEvent> data) throws IOException
map look-up
list is defined, only matching sensor names are considered.IOExceptionprivate void writeData(Writer out, Map<String,DataEvent> data, boolean weather) throws IOException
map exists, only sensors given in this list are writtn out.IOExceptionpublic String toString()
toString in class PropertyContainerprivate static boolean isValidReading(DataEvent de)