use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate 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.CosemDate 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.CosemDate 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.CosemDate in project open-smart-grid-platform by OSGP.
the class CosemDateConverter method convert.
@Override
public CosemDate convert(final byte[] source, final Type<? extends CosemDate> destinationType, final MappingContext context) {
final ByteBuffer bb = ByteBuffer.wrap(source);
final int year = bb.getShort() & 0xFFFF;
final int month = bb.get() & 0xFF;
final int day = bb.get() & 0xFF;
final int weekDay = bb.get() & 0xFF;
return new CosemDate(year, month, day, weekDay);
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate 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