Search in sources :

Example 1 with ClockStatusDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ClockStatusDto 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());
}
Also used : ClockStatus(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus) CosemTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime) ClockStatusDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ClockStatusDto) CosemDateDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateDto) CosemDate(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate) CosemTimeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemTimeDto)

Example 2 with ClockStatusDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ClockStatusDto 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);
}
Also used : ClockStatus(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus) CosemTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime) ClockStatusDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ClockStatusDto) CosemDateDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateDto) CosemDate(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate) CosemTimeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemTimeDto)

Example 3 with ClockStatusDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ClockStatusDto in project open-smart-grid-platform by OSGP.

the class PushSetupAlarmMappingTest 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);
}
Also used : ClockStatus(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus) CosemTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime) ClockStatusDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ClockStatusDto) CosemDateDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateDto) CosemDate(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate) CosemTimeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemTimeDto)

Example 4 with ClockStatusDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ClockStatusDto in project open-smart-grid-platform by OSGP.

the class DlmsHelper method fromDateTimeValue.

public CosemDateTimeDto fromDateTimeValue(final byte[] dateTimeValue) {
    final ByteBuffer bb = ByteBuffer.wrap(dateTimeValue);
    final int year = bb.getShort() & 0xFFFF;
    final int monthOfYear = bb.get() & 0xFF;
    final int dayOfMonth = bb.get() & 0xFF;
    final int dayOfWeek = bb.get() & 0xFF;
    final int hourOfDay = bb.get() & 0xFF;
    final int minuteOfHour = bb.get() & 0xFF;
    final int secondOfMinute = bb.get() & 0xFF;
    final int hundredthsOfSecond = bb.get() & 0xFF;
    final int deviation = bb.getShort();
    final byte clockStatusValue = bb.get();
    final CosemDateDto date = new CosemDateDto(year, monthOfYear, dayOfMonth, dayOfWeek);
    final CosemTimeDto time = new CosemTimeDto(hourOfDay, minuteOfHour, secondOfMinute, hundredthsOfSecond);
    final ClockStatusDto clockStatus = new ClockStatusDto(clockStatusValue);
    return new CosemDateTimeDto(date, time, deviation, clockStatus);
}
Also used : CosemDateDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateDto) ClockStatusDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ClockStatusDto) ByteBuffer(java.nio.ByteBuffer) CosemTimeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemTimeDto) CosemDateTimeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateTimeDto)

Aggregations

ClockStatusDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ClockStatusDto)4 CosemDateDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateDto)4 CosemTimeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemTimeDto)4 ClockStatus (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus)3 CosemDate (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate)3 CosemTime (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime)3 ByteBuffer (java.nio.ByteBuffer)1 CosemDateTimeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateTimeDto)1