use of org.opensmartgridplatform.adapter.ws.schema.tariffswitching.schedulemanagement.TariffValue in project open-smart-grid-platform by OSGP.
the class TariffScheduleToScheduleConverter method convert.
@Override
public ScheduleEntry convert(final TariffSchedule source, final Type<? extends ScheduleEntry> destinationType, final MappingContext context) {
final ScheduleEntry schedule = new ScheduleEntry();
// Copy values
schedule.setWeekDay(this.mapperFacade.map(source.getWeekDay(), WeekDayType.class));
schedule.setStartDay(this.mapperFacade.map(source.getStartDay(), DateTime.class));
schedule.setEndDay(this.mapperFacade.map(source.getEndDay(), DateTime.class));
schedule.setTime(source.getTime());
schedule.setIndex(source.getIndex());
schedule.setIsEnabled(source.isIsEnabled());
schedule.setMinimumLightsOn(source.getMinimumLightsOn());
// Set the lightvalue
// For now a High tariff means the Relay is switched off (Situation
// in Zaltbommel)
// schedule.setLightValue( Arrays.asList(new LightValue(null,
// !source.isHigh(), null)) )
final List<LightValue> lightValues = new ArrayList<>();
for (final TariffValue tariffValue : source.getTariffValue()) {
final LightValue lightValue = new LightValue(tariffValue.getIndex(), !tariffValue.isHigh(), null);
lightValues.add(lightValue);
}
schedule.setLightValue(lightValues);
// Set defaults for Tariff schedules
schedule.setActionTime(ActionTimeType.ABSOLUTETIME);
schedule.setTriggerType(null);
return schedule;
}
use of org.opensmartgridplatform.adapter.ws.schema.tariffswitching.schedulemanagement.TariffValue in project open-smart-grid-platform by OSGP.
the class AuthorizeDeviceFunctionsSteps method setTariffSchedule.
private void setTariffSchedule(final Map<String, String> requestParameters) throws WebServiceSecurityException, GeneralSecurityException, IOException {
final org.opensmartgridplatform.adapter.ws.schema.tariffswitching.schedulemanagement.SetScheduleRequest request = new org.opensmartgridplatform.adapter.ws.schema.tariffswitching.schedulemanagement.SetScheduleRequest();
request.setDeviceIdentification(getString(requestParameters, PlatformPubliclightingKeys.KEY_DEVICE_IDENTIFICATION, PlatformPubliclightingDefaults.DEFAULT_DEVICE_IDENTIFICATION));
final TariffSchedule schedule = new TariffSchedule();
final TariffValue tariffValue = new TariffValue();
tariffValue.setHigh(true);
tariffValue.setIndex(1);
schedule.getTariffValue().add(tariffValue);
schedule.setIndex(0);
schedule.setWeekDay(org.opensmartgridplatform.adapter.ws.schema.tariffswitching.schedulemanagement.WeekDayType.ALL);
schedule.setTime(DateTime.now().toString());
schedule.setIsEnabled(true);
schedule.setMinimumLightsOn(10);
request.getSchedules().add(schedule);
ScenarioContext.current().put(PlatformPubliclightingKeys.RESPONSE, this.tariffSwitchingScheduleManagementClient.setSchedule(request));
}
use of org.opensmartgridplatform.adapter.ws.schema.tariffswitching.schedulemanagement.TariffValue in project open-smart-grid-platform by OSGP.
the class SetTariffScheduleSteps method addScheduleForRequest.
private void addScheduleForRequest(final SetScheduleRequest request, final WeekDayType weekDay, final String startDay, final String endDay, final String time, final String scheduleTariffValue) throws DatatypeConfigurationException {
final TariffSchedule schedule = new TariffSchedule();
schedule.setWeekDay(weekDay);
if (!startDay.isEmpty()) {
schedule.setStartDay(DatatypeFactory.newInstance().newXMLGregorianCalendar(DateTime.parse(startDay).toDateTime(DateTimeZone.UTC).toGregorianCalendar()));
}
if (!endDay.isEmpty()) {
schedule.setEndDay(DatatypeFactory.newInstance().newXMLGregorianCalendar(DateTime.parse(endDay).toDateTime(DateTimeZone.UTC).toGregorianCalendar()));
}
schedule.setTime(time);
for (final String tariffValue : scheduleTariffValue.split(";")) {
final TariffValue lv = new TariffValue();
final String[] tariffValues = tariffValue.split(",");
lv.setIndex(Integer.parseInt(tariffValues[0]));
lv.setHigh(Boolean.parseBoolean(tariffValues[1]));
schedule.getTariffValue().add(lv);
}
request.getSchedules().add(schedule);
}
Aggregations