use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus in project open-smart-grid-platform by OSGP.
the class PushSetupSmsMappingTest method testPushSetupSmsMappingWithLists.
// To test Mapping if lists contain values
@Test
public void testPushSetupSmsMappingWithLists() {
// build test data
final CosemObisCode logicalName = new CosemObisCode(new int[] { 1, 2, 3, 4, 5, 6 });
final CosemObjectDefinition cosemObjectDefinition = new CosemObjectDefinition(1, logicalName, 2);
final CosemDateTime startTime = new CosemDateTime(new CosemDate(2016, 3, 17), new CosemTime(11, 52, 45), 0, new ClockStatus(ClockStatus.STATUS_NOT_SPECIFIED));
final CosemDateTime endTime = new CosemDateTime(new CosemDate(2016, 3, 17), new CosemTime(11, 52, 45), 0, new ClockStatus(ClockStatus.STATUS_NOT_SPECIFIED));
final WindowElement windowElement = new WindowElement(startTime, endTime);
final PushSetupSms pushSetupSms = new PushSetupSmsBuilder().withFilledLists(cosemObjectDefinition, windowElement).build();
// actual mapping
final PushSetupSmsDto pushSetupSmsDto = this.configurationMapper.map(pushSetupSms, PushSetupSmsDto.class);
// check values
this.checkCosemObisCodeMapping(pushSetupSms.getLogicalName(), pushSetupSmsDto.getLogicalName());
this.checkSendDestinationAndMethodMapping(pushSetupSms, pushSetupSmsDto);
this.checkIntegerMapping(pushSetupSms, pushSetupSmsDto);
this.checkNonEmptyListMapping(pushSetupSms, pushSetupSmsDto);
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus in project open-smart-grid-platform by OSGP.
the class CosemDateTimeConverter method convert.
@Override
public CosemDateTime convert(final byte[] source, final Type<? extends CosemDateTime> destinationType, final MappingContext context) {
final ByteBuffer bb = ByteBuffer.wrap(source);
final int year = bb.getShort() & 0xFFFF;
final int month = bb.get() & 0xFF;
final int dayOfMonth = bb.get() & 0xFF;
final int dayOfWeek = bb.get() & 0xFF;
final int hour = bb.get() & 0xFF;
final int minute = bb.get() & 0xFF;
final int second = bb.get() & 0xFF;
final int hundredths = bb.get() & 0xFF;
final int deviation = bb.getShort();
final ClockStatus clockStatus = new ClockStatus(bb.get());
final CosemTime time = new CosemTime(hour, minute, second, hundredths);
final CosemDate date = new CosemDate(year, month, dayOfMonth, dayOfWeek);
return new CosemDateTime(date, time, deviation, clockStatus);
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus in project open-smart-grid-platform by OSGP.
the class ActivityCalendarMappingTest method checkCosemDateTimeMapping.
// method to test mapping of CosemDateTime objects
private void checkCosemDateTimeMapping(final CosemDateTime cosemDateTime, final CosemDateTimeDto cosemDateTimeDto) {
// make sure neither is null
assertThat(cosemDateTime).isNotNull();
assertThat(cosemDateTimeDto).isNotNull();
// check variables
assertThat(cosemDateTimeDto.getDeviation()).isEqualTo(cosemDateTime.getDeviation());
final ClockStatus clockStatus = cosemDateTime.getClockStatus();
final ClockStatusDto clockStatusDto = cosemDateTimeDto.getClockStatus();
assertThat(clockStatusDto.getStatus()).isEqualTo(clockStatus.getStatus());
assertThat(clockStatusDto.isSpecified()).isEqualTo(clockStatus.isSpecified());
final CosemDate cosemDate = cosemDateTime.getDate();
final CosemDateDto cosemDateDto = cosemDateTimeDto.getDate();
assertThat(cosemDateDto.getYear()).isEqualTo(cosemDate.getYear());
assertThat(cosemDateDto.getMonth()).isEqualTo(cosemDate.getMonth());
assertThat(cosemDateDto.getDayOfMonth()).isEqualTo(cosemDate.getDayOfMonth());
assertThat(cosemDateDto.getDayOfWeek()).isEqualTo(cosemDate.getDayOfWeek());
final CosemTime cosemTime = cosemDateTime.getTime();
final CosemTimeDto cosemTimeDto = cosemDateTimeDto.getTime();
assertThat(cosemTimeDto.getHour()).isEqualTo(cosemTime.getHour());
assertThat(cosemTimeDto.getMinute()).isEqualTo(cosemTime.getMinute());
assertThat(cosemTimeDto.getSecond()).isEqualTo(cosemTime.getSecond());
assertThat(cosemTimeDto.getHundredths()).isEqualTo(cosemTime.getHundredths());
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus in project open-smart-grid-platform by OSGP.
the class ActivityCalendarBuilder method withFilledList.
public ActivityCalendarBuilder withFilledList() {
final CosemDate date = new CosemDate(2016, 3, 16);
final CosemTime time = new CosemTime(11, 45, 33);
final int deviation = 1;
final ClockStatus clockStatus = new ClockStatus(ClockStatus.STATUS_NOT_SPECIFIED);
final CosemDateTime seasonStart = new CosemDateTime(date, time, deviation, clockStatus);
final CosemTime startTime = time;
final DayProfileAction dayProfileAction = new DayProfileAction(new Integer(10), startTime);
final List<DayProfileAction> dayProfileActionList = new ArrayList<>();
dayProfileActionList.add(dayProfileAction);
final DayProfile dayProfile = new DayProfile(new Integer(10), dayProfileActionList);
final WeekProfile weekProfile = WeekProfile.newBuilder().withWeekProfileName("weekProfile1").withMonday(dayProfile).withTuesday(dayProfile).withWednesday(dayProfile).withThursday(dayProfile).withFriday(dayProfile).withSaturday(dayProfile).withSunday(dayProfile).build();
final SeasonProfile seasonProfile = new SeasonProfile("profile1", seasonStart, weekProfile);
this.seasonProfileList.add(seasonProfile);
return this;
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus in project open-smart-grid-platform by OSGP.
the class PushSetupSmsMappingTest method checkCosemDateTimeMapping.
// method to test mapping of CosemDateTime objects
private void checkCosemDateTimeMapping(final CosemDateTime cosemDateTime, final CosemDateTimeDto cosemDateTimeDto) {
// make sure neither is null
assertThat(cosemDateTime).isNotNull();
assertThat(cosemDateTimeDto).isNotNull();
// check variables
assertThat(cosemDateTimeDto.getDeviation()).isEqualTo(cosemDateTime.getDeviation());
final ClockStatus clockStatus = cosemDateTime.getClockStatus();
final ClockStatusDto clockStatusDto = cosemDateTimeDto.getClockStatus();
assertThat(clockStatusDto.getStatus()).isEqualTo(clockStatus.getStatus());
assertThat(clockStatusDto.isSpecified()).isEqualTo(clockStatus.isSpecified());
final CosemDate cosemDate = cosemDateTime.getDate();
final CosemDateDto cosemDateDto = cosemDateTimeDto.getDate();
assertThat(cosemDateDto).isEqualToComparingFieldByField(cosemDate);
final CosemTime cosemTime = cosemDateTime.getTime();
final CosemTimeDto cosemTimeDto = cosemDateTimeDto.getTime();
assertThat(cosemTimeDto).isEqualToComparingFieldByField(cosemTime);
}
Aggregations