CupCarbon
CupCarbon copied to clipboard
Weather: Parsing Excpetion
For the Weather sensor, there is a parsing error being thrown every time a Natural Evt. file is attached.
The issue is that the Weather code parses the time as an integer but by default (as far as I can tell) the Natural Event Generator saves the time as a double.
I compared the Weather parsing code to the Gas parsing code (function, loadValuesFromFIle) and it looks like the Gas code correctly parses the time as a Double instead of an integer. See code snippets bellow comparing Weather to Gas.
Weather.java -> loadValuesFromFile
while ((s = b.readLine()) != null) {
ts = s.split(" ");
valueTime.add(Integer.parseInt(ts[0]));
values.add(Double.parseDouble(ts[1]));
}
Gas.java -> loadValuesFromFile
while ((s = b.readLine()) != null) {
ts = s.split(" ");
valueTime.add(Double.parseDouble(ts[0]));
values.add(Double.parseDouble(ts[1]));
}
Changing the Weather code to parse Integers instead of Doubles fixes this issue.