Search in sources :

Example 6 with ApplianceLogger

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);
}
Also used : Appliance(de.avanux.smartapplianceenabler.appliance.Appliance) Schedule(de.avanux.smartapplianceenabler.appliance.Schedule) ApplianceLogger(de.avanux.smartapplianceenabler.log.ApplianceLogger)

Example 7 with ApplianceLogger

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;
}
Also used : ArrayList(java.util.ArrayList) ApplianceLogger(de.avanux.smartapplianceenabler.log.ApplianceLogger)

Example 8 with ApplianceLogger

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");
    }
}
Also used : ApplianceLogger(de.avanux.smartapplianceenabler.log.ApplianceLogger)

Example 9 with ApplianceLogger

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());
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) ApplianceLogger(de.avanux.smartapplianceenabler.log.ApplianceLogger) Interval(org.joda.time.Interval) Test(org.junit.Test)

Aggregations

ApplianceLogger (de.avanux.smartapplianceenabler.log.ApplianceLogger)9 LocalDateTime (org.joda.time.LocalDateTime)4 ArrayList (java.util.ArrayList)3 Interval (org.joda.time.Interval)3 Test (org.junit.Test)3 Appliance (de.avanux.smartapplianceenabler.appliance.Appliance)1 Schedule (de.avanux.smartapplianceenabler.appliance.Schedule)1