Search in sources :

Example 11 with CosemTime

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime in project open-smart-grid-platform by OSGP.

the class CosemDateTimeConverterTest method testToCosemDateTimeMapping.

/**
 * Tests if mapping a byte[] to a CosemDateTime object succeeds.
 */
@Test
public void testToCosemDateTimeMapping() {
    // actual mapping
    final CosemDateTime cosemDateTime = this.mapperFactory.getMapperFacade().map(COSEMDATETIME_BYTE_ARRAY_NORMAL, CosemDateTime.class);
    // check mapping
    assertThat(cosemDateTime).isNotNull();
    final CosemDate cosemDate = cosemDateTime.getDate();
    assertThat(((byte) (cosemDate.getYear() >> 8))).isEqualTo(FIRST_BYTE_FOR_YEAR);
    assertThat(((byte) (cosemDate.getYear() & 0xFF))).isEqualTo(SECOND_BYTE_FOR_YEAR);
    assertThat(cosemDate.getMonth()).isEqualTo(BYTE_FOR_MONTH);
    assertThat(cosemDate.getDayOfMonth()).isEqualTo(BYTE_FOR_DAY_OF_MONTH);
    assertThat((byte) cosemDate.getDayOfWeek()).isEqualTo(BYTE_FOR_DAY_OF_WEEK);
    final CosemTime cosemTime = cosemDateTime.getTime();
    assertThat(cosemTime.getHour()).isEqualTo(BYTE_FOR_HOUR_OF_DAY);
    assertThat(cosemTime.getMinute()).isEqualTo(BYTE_FOR_MINUTE_OF_HOUR);
    assertThat(cosemTime.getSecond()).isEqualTo(BYTE_FOR_SECOND_OF_MINUTE);
    assertThat(cosemTime.getHundredths()).isEqualTo(BYTE_FOR_HUNDREDS_0F_SECONDS);
    final int deviation = cosemDateTime.getDeviation();
    assertThat(((byte) (deviation >> 8))).isEqualTo(FIRST_BYTE_FOR_DEVIATION);
    assertThat(((byte) (deviation & 0xFF))).isEqualTo(SECOND_BYTE_FOR_DEVIATION);
    assertThat(((byte) ClockStatus.STATUS_NOT_SPECIFIED)).isEqualTo(BYTE_FOR_CLOCKSTATUS);
}
Also used : CosemTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime) CosemDateTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime) CosemDate(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate) Test(org.junit.jupiter.api.Test)

Aggregations

CosemTime (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime)11 CosemDate (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate)8 ClockStatus (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus)7 CosemDateTime (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime)5 Test (org.junit.jupiter.api.Test)4 CosemTimeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemTimeDto)4 DayProfileAction (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.DayProfileAction)3 ClockStatusDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ClockStatusDto)3 CosemDateDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateDto)3 CosemObisCode (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObisCode)2 CosemObjectDefinition (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition)2 DayProfile (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.DayProfile)2 SeasonProfile (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SeasonProfile)2 WeekProfile (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WeekProfile)2 WindowElement (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement)2 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 PushSetupAlarm (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm)1 PushSetupSms (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupSms)1 DayProfileActionDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.DayProfileActionDto)1