use of de.avanux.smartapplianceenabler.log.ApplianceLogger in project SmartApplianceEnabler by camueller.
the class SaeController method setSchedules.
@RequestMapping(value = SCHEDULES_URL, method = RequestMethod.POST, consumes = "application/xml")
@ResponseBody
public void setSchedules(@RequestParam(value = "ApplianceId") String applianceId, @RequestBody Schedules schedules) {
ApplianceLogger applianceLogger = ApplianceLogger.createForAppliance(logger, applianceId);
List<Schedule> schedulesToSet = schedules.getSchedules();
applianceLogger.debug("Received request to set " + (schedulesToSet != null ? schedulesToSet.size() : "0") + " schedule(s)");
Appliance appliance = ApplianceManager.getInstance().findAppliance(applianceId);
appliance.getRunningTimeMonitor().setSchedules(schedulesToSet);
}
use of de.avanux.smartapplianceenabler.log.ApplianceLogger in project SmartApplianceEnabler by camueller.
the class SempController method createDevice2EM.
protected Device2EM createDevice2EM(LocalDateTime now) {
List<DeviceStatus> deviceStatuses = new ArrayList<DeviceStatus>();
List<PlanningRequest> planningRequests = new ArrayList<PlanningRequest>();
List<Appliance> appliances = ApplianceManager.getInstance().getAppliances();
for (Appliance appliance : appliances) {
ApplianceLogger applianceLogger = ApplianceLogger.createForAppliance(logger, appliance.getId());
if (!timeFrameChangedListenerRegistered && appliance.getRunningTimeMonitor() != null) {
appliance.getRunningTimeMonitor().addTimeFrameChangedListener(this);
timeFrameChangedListenerRegistered = true;
}
DeviceStatus deviceStatus = createDeviceStatus(applianceLogger, appliance);
deviceStatuses.add(deviceStatus);
PlanningRequest planningRequest = createPlanningRequest(applianceLogger, now, appliance);
if (planningRequest != null) {
planningRequests.add(planningRequest);
}
}
device2EM.setDeviceStatus(deviceStatuses);
device2EM.setPlanningRequest(planningRequests);
return device2EM;
}
use of de.avanux.smartapplianceenabler.log.ApplianceLogger in project SmartApplianceEnabler by camueller.
the class SempController method activeIntervalChanged.
@Override
public void activeIntervalChanged(String applianceId, TimeframeInterval deactivatedInterval, TimeframeInterval activatedInterval) {
if (activatedInterval == null) {
Appliance appliance = ApplianceManager.getInstance().findAppliance(applianceId);
ApplianceLogger applianceLogger = ApplianceLogger.createForAppliance(logger, applianceId);
setApplianceState(applianceLogger, appliance, false, "Switching off due to end of time frame");
}
}
use of de.avanux.smartapplianceenabler.log.ApplianceLogger in project SmartApplianceEnabler by camueller.
the class SempControllerTest method createSempTimeFrame_TimeFrameOverMidnight_AfterMidnight.
@Test
public void createSempTimeFrame_TimeFrameOverMidnight_AfterMidnight() {
ApplianceLogger logger = new ApplianceLogger(LoggerFactory.getLogger(Appliance.class));
logger.setApplianceId(DEVICE_ID);
LocalDateTime now = toToday(0, 30, 0);
Schedule schedule = new Schedule(7200, 7200, new TimeOfDay(20, 0, 0), new TimeOfDay(4, 0, 0));
Interval interval = schedule.getTimeframe().getIntervals(now).get(0).getInterval();
de.avanux.smartapplianceenabler.semp.webservice.Timeframe sempTimeFrame = sempController.createSempTimeFrame(logger, DEVICE_ID, schedule, interval, 0, 0, now);
Assert.assertEquals(0, (long) sempTimeFrame.getEarliestStart());
Assert.assertEquals(12600, (long) sempTimeFrame.getLatestEnd());
}
Aggregations