use of org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecialDaysRequestDataDto in project open-smart-grid-platform by OSGP.
the class ConfigurationService method setSpecialDays.
public void setSpecialDays(final DlmsConnectionManager conn, final DlmsDevice device, final SpecialDaysRequestDto specialDaysRequest, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
// The Special days towards the Smart Meter
final SpecialDaysRequestDataDto specialDaysRequestData = specialDaysRequest.getSpecialDaysRequestData();
LOGGER.info(VISUAL_SEPARATOR);
LOGGER.info("********** Set Special Days: 0-0:11.0.0.255 **********");
LOGGER.info(VISUAL_SEPARATOR);
final List<SpecialDayDto> specialDays = specialDaysRequestData.getSpecialDays();
for (final SpecialDayDto specialDay : specialDays) {
LOGGER.info("Date :{}, dayId : {} ", specialDay.getSpecialDayDate(), specialDay.getDayId());
}
LOGGER.info(VISUAL_SEPARATOR);
final AccessResultCode accessResultCode = this.setSpecialDaysCommandExecutor.execute(conn, device, specialDays, messageMetadata);
if (!AccessResultCode.SUCCESS.equals(accessResultCode)) {
throw new ProtocolAdapterException("Set special days reported result is: " + accessResultCode);
}
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecialDaysRequestDataDto in project open-smart-grid-platform by OSGP.
the class SetSpecialDaysCommandExecutor method fromBundleRequestInput.
@Override
public List<SpecialDayDto> fromBundleRequestInput(final ActionRequestDto bundleInput) throws ProtocolAdapterException {
this.checkActionRequestType(bundleInput);
final SpecialDaysRequestDataDto specialDaysRequestDataDto = (SpecialDaysRequestDataDto) bundleInput;
return specialDaysRequestDataDto.getSpecialDays();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecialDaysRequestDataDto in project open-smart-grid-platform by OSGP.
the class SpecialDaysRequestMappingTest method testSpecialDaysRequestMappingNonEmptyListNoCosemDate.
// To check mapping of SpecialDaysRequest, when its SpecialDaysRequestData
// has a filled List (1 value), where CosemDate is not specified.
@Test
public void testSpecialDaysRequestMappingNonEmptyListNoCosemDate() {
final String deviceIdentification = "nr1";
final int dayId = 1;
final SpecialDay specialDay = new SpecialDay(new CosemDate(), dayId);
final SpecialDaysRequestData specialDaysRequestData = new SpecialDaysRequestDataBuilder().addSpecialDay(specialDay).build();
final SpecialDaysRequest specialDaysRequestValueObject = new SpecialDaysRequest(deviceIdentification, specialDaysRequestData);
final SpecialDaysRequestDto specialDaysRequestDto = this.configurationMapper.map(specialDaysRequestValueObject, SpecialDaysRequestDto.class);
assertThat(specialDaysRequestDto.getDeviceIdentification()).isEqualTo(deviceIdentification);
final SpecialDaysRequestDataDto requestDataDto = specialDaysRequestDto.getSpecialDaysRequestData();
assertThat(requestDataDto).isNotNull();
assertThat(requestDataDto.getSpecialDays()).isNotNull();
assertThat(requestDataDto.getSpecialDays().size()).isEqualTo(dayId);
final SpecialDayDto specialDayDto = requestDataDto.getSpecialDays().get(0);
assertThat(specialDayDto.getDayId()).isEqualTo(dayId);
final CosemDate specialDayDate = specialDay.getSpecialDayDate();
final CosemDateDto specialDayDateDto = specialDayDto.getSpecialDayDate();
assertThat(specialDayDateDto.getYear()).isEqualTo(specialDayDate.getYear());
assertThat(specialDayDateDto.getMonth()).isEqualTo(specialDayDate.getMonth());
assertThat(specialDayDateDto.getDayOfMonth()).isEqualTo(specialDayDate.getDayOfMonth());
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecialDaysRequestDataDto in project open-smart-grid-platform by OSGP.
the class SpecialDaysRequestMappingTest method testSpecialDaysRequestMappingNonEmptyList.
// To check mapping of SpecialDaysRequest, when its SpecialDaysRequestData
// has a filled List (1 value).
@Test
public void testSpecialDaysRequestMappingNonEmptyList() {
final String deviceIdentification = "nr1";
final int year = 2016;
final int month = 3;
final int dayOfMonth = 11;
final int dayId = 1;
final SpecialDay specialDay = new SpecialDay(new CosemDate(year, month, dayOfMonth), dayId);
final SpecialDaysRequestData specialDaysRequestData = new SpecialDaysRequestDataBuilder().addSpecialDay(specialDay).build();
final SpecialDaysRequest specialDaysRequestValueObject = new SpecialDaysRequest(deviceIdentification, specialDaysRequestData);
final SpecialDaysRequestDto specialDaysRequestDto = this.configurationMapper.map(specialDaysRequestValueObject, SpecialDaysRequestDto.class);
assertThat(specialDaysRequestDto.getDeviceIdentification()).isEqualTo(deviceIdentification);
final SpecialDaysRequestDataDto requestDataDto = specialDaysRequestDto.getSpecialDaysRequestData();
assertThat(requestDataDto).isNotNull();
assertThat(requestDataDto.getSpecialDays()).isNotNull();
assertThat(requestDataDto.getSpecialDays().size()).isEqualTo(dayId);
final SpecialDayDto specialDayDto = requestDataDto.getSpecialDays().get(0);
assertThat(specialDayDto.getDayId()).isEqualTo(dayId);
final CosemDateDto specialDayDateDto = specialDayDto.getSpecialDayDate();
assertThat(specialDayDateDto.getYear()).isEqualTo(year);
assertThat(specialDayDateDto.getMonth()).isEqualTo(month);
assertThat(specialDayDateDto.getDayOfMonth()).isEqualTo(dayOfMonth);
}
Aggregations