Search in sources :

Example 1 with Schedule

use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.Schedule in project open-smart-grid-platform by OSGP.

the class AuthorizeDeviceFunctionsSteps method setLightSchedule.

private void setLightSchedule(final Map<String, String> requestParameters) throws WebServiceSecurityException, GeneralSecurityException, IOException {
    final org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.SetScheduleRequest request = new org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.SetScheduleRequest();
    request.setDeviceIdentification(getString(requestParameters, PlatformPubliclightingKeys.KEY_DEVICE_IDENTIFICATION, PlatformPubliclightingDefaults.DEFAULT_DEVICE_IDENTIFICATION));
    final Schedule schedule = new Schedule();
    schedule.setActionTime(ActionTimeType.SUNRISE);
    schedule.setIndex(0);
    schedule.setWeekDay(WeekDayType.ALL);
    schedule.setTime(DateTime.now().toString());
    schedule.setIsEnabled(true);
    schedule.setMinimumLightsOn(10);
    final org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.LightValue lightValue = new org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.LightValue();
    lightValue.setDimValue(100);
    lightValue.setIndex(1);
    lightValue.setOn(true);
    schedule.getLightValue().add(lightValue);
    schedule.setTriggerType(TriggerType.LIGHT_TRIGGER);
    final WindowType windowType = new WindowType();
    windowType.setMinutesAfter(0);
    windowType.setMinutesBefore(0);
    schedule.setTriggerWindow(windowType);
    request.getSchedules().add(schedule);
    ScenarioContext.current().put(PlatformPubliclightingKeys.RESPONSE, this.publicLightingScheduleManagementClient.setSchedule(request));
}
Also used : LightValue(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightValue) TariffSchedule(org.opensmartgridplatform.adapter.ws.schema.tariffswitching.schedulemanagement.TariffSchedule) Schedule(org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.Schedule) WindowType(org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.WindowType)

Example 2 with Schedule

use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.Schedule in project open-smart-grid-platform by OSGP.

the class SetLightScheduleSteps method addScheduleForRequest.

private void addScheduleForRequest(final SetScheduleRequest request, final WeekDayType weekDay, final String startDay, final String endDay, final ActionTimeType actionTime, final String time, final String scheduleLightValue, final String triggerType, final String triggerWindow) throws DatatypeConfigurationException {
    final Schedule schedule = new Schedule();
    schedule.setWeekDay(weekDay);
    if (StringUtils.isNotBlank(startDay)) {
        schedule.setStartDay(DatatypeFactory.newInstance().newXMLGregorianCalendar(DateTime.parse(startDay).toDateTime(DateTimeZone.UTC).toGregorianCalendar()));
    }
    if (StringUtils.isNotBlank(endDay)) {
        schedule.setEndDay(DatatypeFactory.newInstance().newXMLGregorianCalendar(DateTime.parse(endDay).toDateTime(DateTimeZone.UTC).toGregorianCalendar()));
    }
    schedule.setActionTime(actionTime);
    schedule.setTime(time);
    for (final String lightValue : scheduleLightValue.split(";")) {
        final LightValue lv = new LightValue();
        final String[] lightValues = lightValue.split(",");
        lv.setIndex(Integer.parseInt(lightValues[0]));
        lv.setOn(Boolean.parseBoolean(lightValues[1]));
        if (lightValues.length > 2) {
            lv.setDimValue(Integer.parseInt(lightValues[2]));
        }
        schedule.getLightValue().add(lv);
    }
    if (!triggerType.isEmpty()) {
        schedule.setTriggerType(TriggerType.valueOf(triggerType));
    }
    if (StringUtils.isNotBlank(triggerWindow)) {
        final String[] windowTypeValues = triggerWindow.split(",");
        if (windowTypeValues.length == 2) {
            final WindowType windowType = new WindowType();
            windowType.setMinutesBefore(Integer.parseInt(windowTypeValues[0]));
            windowType.setMinutesAfter(Integer.parseInt(windowTypeValues[1]));
            schedule.setTriggerWindow(windowType);
        }
    }
    request.getSchedules().add(schedule);
}
Also used : Schedule(org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.Schedule) LightValue(org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.LightValue) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) WindowType(org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.WindowType)

Aggregations

Schedule (org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.Schedule)2 WindowType (org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.WindowType)2 LightValue (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightValue)1 LightValue (org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.LightValue)1 TariffSchedule (org.opensmartgridplatform.adapter.ws.schema.tariffswitching.schedulemanagement.TariffSchedule)1 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)1