Weather (WeatherReport report) { temperature = report.getTemperature(); windSpeed = report.getWindSpeed(); windDirection = report.getWindDirection(); cloudCover = report.getCloudCover(); }
@Override public Object unmarshal (HierarchicalStreamReader reader, UnmarshallingContext context) { String temp = reader.getAttribute("temp"); String wind = reader.getAttribute("windspeed"); String dir = reader.getAttribute("winddir"); String cloudCvr = reader.getAttribute("cloudcover"); return new WeatherReport(timeIndex++, Double.parseDouble(temp), Double.parseDouble(wind), Double.parseDouble(dir), Double.parseDouble(cloudCvr)); } }
double[] computeWeatherCorrections () { WeatherReport weather = weatherReportRepo.currentWeatherReport(); WeatherForecastPrediction[] forecasts = getForecastArray(); // smooth the current heat and cool sequences double thisHeat = Math.min(0.0, (weather.getTemperature() - heatThreshold)); lastHeat = tempAlpha * thisHeat + (1.0 - tempAlpha) * lastHeat; double[] smoothedHeat = smoothForecasts(lastHeat, heatThreshold, -1.0, forecasts); double thisCool = Math.max(0.0,(weather.getTemperature() - coolThreshold)); lastCool = tempAlpha * thisCool + (1.0 - tempAlpha) * lastCool; double[] smoothedCool = smoothForecasts(lastCool, coolThreshold, 1.0, forecasts); double[] result = new double[forecasts.length]; Arrays.fill(result, 0.0); for (int i = 0; i < forecasts.length; i += 1) { result[i] += smoothedHeat[i] * heatCoef; result[i] += smoothedCool[i] * coolCoef; } return result; }
/** * This function is utilized in order to check the weather at each time tick * of the competition clock and reschedule the appliances that are weather * sensitive to work. */ void weatherCheck (int day, int hour, Instant now) { int dayTemp = day % (VillageConstants.DAYS_OF_BOOTSTRAP + VillageConstants.DAYS_OF_COMPETITION); WeatherReport wr = null; wr = service.getWeatherReportRepo().currentWeatherReport(); if (wr != null) { double temperature = wr.getTemperature(); // log.debug("Temperature: " + temperature); Vector<Household> houses = getHouses(); for (Household house: houses) { house.weatherCheck(dayTemp, hour, now, temperature); } for (String type: numberOfHouses.keySet()) { updateAggDailyWeatherSensitiveLoad(type, day); if (dayTemp + 1 < VillageConstants.DAYS_OF_COMPETITION) { updateAggDailyWeatherSensitiveLoad(type, dayTemp + 1); } } } }
/** * This function is utilized in order to check the weather at each time tick * of the competition clock and reschedule the appliances that are weather * sensitive to work. */ void weatherCheck (int day, int hour, Instant now) { int dayTemp = day % (OfficeComplexConstants.DAYS_OF_BOOTSTRAP + OfficeComplexConstants.DAYS_OF_COMPETITION); WeatherReport wr = service.getWeatherReportRepo().currentWeatherReport(); if (wr != null) { double temperature = wr.getTemperature(); // log.debug("Temperature: " + temperature); Vector<Office> offices = getOffices(); for (Office office: offices) { office.weatherCheck(dayTemp, hour, now, temperature); } for (String type: numberOfOffices.keySet()) { updateAggDailyWeatherSensitiveLoad(type, day); if (dayTemp + 1 < OfficeComplexConstants.DAYS_OF_COMPETITION) { updateAggDailyWeatherSensitiveLoad(type, dayTemp + 1); } } } }
new WeatherReport( timeIndex, Double.parseDouble(temp[4]), Double.parseDouble(temp[5]),
double outsideTemp = weather.getTemperature();
private void broadcastWeatherReports () { WeatherReport report = null; try { report = weatherReportRepo.currentWeatherReport(); } catch (PowerTacException e) { log.error("Weather Service reports Weather Report Repo empty"); } if (report == null) { // In the event of an error return a default log.error("null weather-report for : " + timeslotRepo.currentSerialNumber() +" " + timeslotRepo.currentTimeslot()); brokerProxyService.broadcastMessage(new WeatherReport(timeslotRepo.currentSerialNumber(), 0.0, 0.0, 0.0, 0.0)); } else { brokerProxyService.broadcastMessage(report); } }