Skip to content
Snippets Groups Projects
Commit 180867d7 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Added decision for warning status

parent 1c3d750d
No related branches found
No related tags found
No related merge requests found
......@@ -52,6 +52,10 @@ public class AppleScabModel extends I18nImpl implements Model{
private final static Double LEAF_WETNESS_THRESHOLD = 20d;
private final static Integer APPLE_SCAB_STADIUM_ASCOSPORE = 1;
private final static Integer APPLE_SCAB_STADIUM_CONIDIA = 2;
// Thresholds for warning status
private final static Double MILLS_THRESHOLD_RED_WARNING = 100d;
private final static Double MILLS_THRESHOLD_YELLOW_WARNING = 90d;
// The data store for all calculations and data
private AppleScabCalculations calculations;
......@@ -88,6 +92,8 @@ public class AppleScabModel extends I18nImpl implements Model{
} catch (WeatherObservationListException ex) {
Logger.getLogger(AppleScabModel.class.getName()).log(Level.SEVERE, null, ex);
}
// Looping through background data, adding as much as possible
List<Result> results = new ArrayList<>();
for(Date timeStamp:this.calculations.getSortedDateKeys())
{
......@@ -106,10 +112,47 @@ public class AppleScabModel extends I18nImpl implements Model{
result.setValue(AppleScabCalculations.AGGREGATED_TEMPERATURE, aggregatedTemperature != null ? String.valueOf(aggregatedTemperature) : "");
Double aggregatedPrecipitation = this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.AGGREGATED_PRECIPITATION);
result.setValue(AppleScabCalculations.AGGREGATED_PRECIPITATION, aggregatedPrecipitation != null ? String.valueOf(aggregatedPrecipitation) : "");
// Deciding warning status
result.setWarningStatus(this.getWarningStatus(timeStamp));
results.add(result);
}
return results;
}
/**
*
* @param timeStamp
* @return
*/
private Integer getWarningStatus(Date timeStamp)
{
Double accumulatedMills = this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.ACCUMULATED_MILLS);
if(accumulatedMills == null)
{
return Result.WARNING_STATUS_NO_WARNING;
}
else if(this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.ASCOSPORE_MATURITY) == 100d)
{
return Result.WARNING_STATUS_NO_WARNING;
}
else
{
if(accumulatedMills >= MILLS_THRESHOLD_RED_WARNING)
{
return Result.WARNING_STATUS_HIGH_RISK;
}
else if(accumulatedMills >= MILLS_THRESHOLD_YELLOW_WARNING)
{
return Result.WARNING_STATUS_MINOR_RISK;
}
else
{
return Result.WARNING_STATUS_NO_RISK;
}
}
}
@Override
public ModelId getModelId() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment