Search in sources :

Example 6 with CosemDateDto

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

the class SetActivityCalendarCommandExecutorTest method testSetActivityCalendarWithMultipleSeasonsWeeksDaysAndActions.

@Test
void testSetActivityCalendarWithMultipleSeasonsWeeksDaysAndActions() throws ProtocolAdapterException, IOException, FunctionalException {
    // SETUP
    when(this.conn.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
    when(this.conn.getConnection()).thenReturn(this.dlmsConnection);
    when(this.dlmsConnection.set(any(SetParameter.class))).thenReturn(AccessResultCode.SUCCESS);
    when(this.activationExecutor.execute(this.conn, this.DLMS_DEVICE, null, this.messageMetadata)).thenReturn(MethodResultCode.SUCCESS);
    final List<Short> dayIds = Arrays.asList((short) 1, (short) 2, (short) 3);
    final List<CosemTimeDto> actionStartTimes = Arrays.asList(new CosemTimeDto(0, 0, 0, 0), new CosemTimeDto(10, 15, 0, 0));
    final List<String> weekNames = Arrays.asList("1", "2");
    final List<String> seasonNames = Arrays.asList("1", "2", "3");
    final List<CosemDateDto> seasonStarts = Arrays.asList(new CosemDateDto(0xFFFF, 1, 1), new CosemDateDto(0xFFFF, 6, 15), new CosemDateDto(0xFFFF, 12, 25));
    final ActivityCalendarDto activityCalendar = this.createActivityCalendar(seasonNames, seasonStarts, weekNames, dayIds, actionStartTimes);
    // CALL
    final AccessResultCode resultCode = this.executor.execute(this.conn, this.DLMS_DEVICE, activityCalendar, this.messageMetadata);
    // VERIFY
    assertThat(resultCode).isEqualTo(AccessResultCode.SUCCESS);
    verify(this.dlmsConnection, times(4)).set(this.setParameterArgumentCaptor.capture());
    this.activityCalendarValidator.verify(() -> ActivityCalendarValidator.validate(activityCalendar), times(1));
    final List<SetParameter> setParameters = this.setParameterArgumentCaptor.getAllValues();
    this.verifySetParameters(setParameters, dayIds, actionStartTimes, weekNames, seasonNames, seasonStarts);
}
Also used : CosemDateDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateDto) AccessResultCode(org.openmuc.jdlms.AccessResultCode) SetParameter(org.openmuc.jdlms.SetParameter) ActivityCalendarDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActivityCalendarDto) CosemTimeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemTimeDto) Test(org.junit.jupiter.api.Test)

Example 7 with CosemDateDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateDto 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 8 with CosemDateDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateDto 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 9 with CosemDateDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateDto 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 10 with CosemDateDto

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

the class CosemDateTimeConverter method convertTo.

@Override
public org.openmuc.jdlms.datatypes.CosemDateTime convertTo(final CosemDateTimeDto source, final Type<org.openmuc.jdlms.datatypes.CosemDateTime> destinationType, final MappingContext context) {
    final CosemTimeDto time = source.getTime();
    final CosemDateDto date = source.getDate();
    final Set<ClockStatus> clockStatus = ClockStatus.clockStatusFrom((byte) source.getClockStatus().getStatus());
    return new org.openmuc.jdlms.datatypes.CosemDateTime(date.getYear(), date.getMonth(), date.getDayOfMonth(), date.getDayOfWeek(), time.getHour(), time.getMinute(), time.getSecond(), time.getHundredths(), source.getDeviation(), clockStatus.toArray(new ClockStatus[clockStatus.size()]));
}
Also used : ClockStatus(org.openmuc.jdlms.datatypes.CosemDateTime.ClockStatus) CosemDateDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateDto) CosemTimeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemTimeDto)

Aggregations

CosemDateDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateDto)12 CosemTimeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemTimeDto)10 Test (org.junit.jupiter.api.Test)5 CosemDate (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate)5 ClockStatusDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ClockStatusDto)4 AccessResultCode (org.openmuc.jdlms.AccessResultCode)3 SetParameter (org.openmuc.jdlms.SetParameter)3 ClockStatus (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus)3 CosemTime (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime)3 ActivityCalendarDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ActivityCalendarDto)3 SpecialDay (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDay)2 SpecialDaysRequest (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequest)2 SpecialDaysRequestData (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequestData)2 SpecialDayDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecialDayDto)2 SpecialDaysRequestDataDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecialDaysRequestDataDto)2 SpecialDaysRequestDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecialDaysRequestDto)2 ByteBuffer (java.nio.ByteBuffer)1 DateTime (org.joda.time.DateTime)1 ClockStatus (org.openmuc.jdlms.datatypes.CosemDateTime.ClockStatus)1 CosemDateTimeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateTimeDto)1