Search in sources :

Example 56 with DataObject

use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.

the class SetConfigurationObjectCommandExecutorDsmr4IT method captureSetParameterStructureData.

private List<DataObject> captureSetParameterStructureData() throws IOException {
    verify(this.dlmsConnection).set(this.setParameterArgumentCaptor.capture());
    final SetParameter setParameter = this.setParameterArgumentCaptor.getValue();
    final DataObject setParameterData = setParameter.getData();
    return setParameterData.getValue();
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) SetParameter(org.openmuc.jdlms.SetParameter)

Example 57 with DataObject

use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.

the class DataObjectToEventListConverterTest method testEventsWithCodeTimeStampAndCounter.

@Test
void testEventsWithCodeTimeStampAndCounter() throws ProtocolAdapterException {
    // GIVEN
    final DateTime dateTime1 = new DateTime(2021, 9, 16, 10, 35, 10, DateTimeZone.UTC);
    final DateTime dateTime2 = new DateTime(2021, 9, 17, 11, 22, 45, DateTimeZone.UTC);
    final DataObject eventDataObject1 = this.createEventDataObject(dateTime1, 1, 11);
    final DataObject eventDataObject2 = this.createEventDataObject(dateTime2, 2, 12);
    final DataObject source = DataObject.newArrayData(Arrays.asList(eventDataObject1, eventDataObject2));
    final EventDto expectedEvent1 = new EventDto(dateTime1, 1, 11, EventLogCategoryDto.COMMUNICATION_SESSION_LOG.name());
    final EventDto expectedEvent2 = new EventDto(dateTime2, 2, 12, EventLogCategoryDto.COMMUNICATION_SESSION_LOG.name());
    // WHEN
    final List<EventDto> events = this.converter.convert(source, EventLogCategoryDto.COMMUNICATION_SESSION_LOG);
    // THEN
    assertThat(events).usingRecursiveFieldByFieldElementComparator().containsExactly(expectedEvent1, expectedEvent2);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) EventDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.EventDto) DateTime(org.joda.time.DateTime) Test(org.junit.jupiter.api.Test)

Example 58 with DataObject

use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.

the class DataObjectToEventListConverterTest method testEventsWithCodeAndTimeStamp.

@Test
void testEventsWithCodeAndTimeStamp() throws ProtocolAdapterException {
    // GIVEN
    final DateTime dateTime1 = new DateTime(2021, 9, 16, 10, 35, 10, DateTimeZone.UTC);
    final DateTime dateTime2 = new DateTime(2021, 9, 17, 11, 22, 45, DateTimeZone.UTC);
    final DataObject eventDataObject1 = this.createEventDataObject(dateTime1, 1);
    final DataObject eventDataObject2 = this.createEventDataObject(dateTime2, 2);
    final DataObject source = DataObject.newArrayData(Arrays.asList(eventDataObject1, eventDataObject2));
    final EventDto expectedEvent1 = new EventDto(dateTime1, 1, null, EventLogCategoryDto.STANDARD_EVENT_LOG.name());
    final EventDto expectedEvent2 = new EventDto(dateTime2, 2, null, EventLogCategoryDto.STANDARD_EVENT_LOG.name());
    // WHEN
    final List<EventDto> events = this.converter.convert(source, EventLogCategoryDto.STANDARD_EVENT_LOG);
    // THEN
    assertThat(events).usingRecursiveFieldByFieldElementComparator().containsExactly(expectedEvent1, expectedEvent2);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) EventDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.EventDto) DateTime(org.joda.time.DateTime) Test(org.junit.jupiter.api.Test)

Example 59 with DataObject

use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.

the class DataObjectToEventListConverterTest method testWrongEventElementListSize.

@Test
void testWrongEventElementListSize() {
    final DataObject source = DataObject.newArrayData(Collections.singletonList(DataObject.newArrayData(Collections.singletonList(this.getDataObject(1)))));
    final Throwable thrown = catchThrowable(() -> this.converter.convert(source, EventLogCategoryDto.STANDARD_EVENT_LOG));
    assertThat(thrown).isInstanceOf(ProtocolAdapterException.class).hasMessage("eventData size should be 2");
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) AssertionsForClassTypes.catchThrowable(org.assertj.core.api.AssertionsForClassTypes.catchThrowable) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) Test(org.junit.jupiter.api.Test)

Example 60 with DataObject

use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.

the class DlmsHelper method readSendDestinationAndMethod.

public SendDestinationAndMethodDto readSendDestinationAndMethod(final DataObject resultData, final String description) throws ProtocolAdapterException {
    final List<DataObject> sendDestinationAndMethodElements = this.readList(resultData, description);
    if (sendDestinationAndMethodElements == null) {
        return null;
    }
    final TransportServiceTypeDto transportService = this.readTransportServiceType(sendDestinationAndMethodElements.get(0), "Transport Service from " + description);
    final String destination = this.readString(sendDestinationAndMethodElements.get(1), "Destination from " + description);
    final MessageTypeDto message = this.readMessageType(sendDestinationAndMethodElements.get(2), "Message from " + description);
    return new SendDestinationAndMethodDto(transportService, destination, message);
}
Also used : SendDestinationAndMethodDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SendDestinationAndMethodDto) DataObject(org.openmuc.jdlms.datatypes.DataObject) TransportServiceTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.TransportServiceTypeDto) BitString(org.openmuc.jdlms.datatypes.BitString) MessageTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.MessageTypeDto)

Aggregations

DataObject (org.openmuc.jdlms.datatypes.DataObject)176 ArrayList (java.util.ArrayList)46 AttributeAddress (org.openmuc.jdlms.AttributeAddress)36 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)34 Test (org.junit.jupiter.api.Test)31 GetResult (org.openmuc.jdlms.GetResult)23 SelectiveAccessDescription (org.openmuc.jdlms.SelectiveAccessDescription)16 DateTime (org.joda.time.DateTime)15 CosemDateTime (org.openmuc.jdlms.datatypes.CosemDateTime)14 SetParameter (org.openmuc.jdlms.SetParameter)12 DlmsObject (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject)11 BitString (org.openmuc.jdlms.datatypes.BitString)10 ObisCode (org.openmuc.jdlms.ObisCode)9 IOException (java.io.IOException)8 ConnectionException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ConnectionException)7 GetResultImpl (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl)6 List (java.util.List)5 MethodResultCode (org.openmuc.jdlms.MethodResultCode)5 AttributeAddressForProfile (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.AttributeAddressForProfile)5 DlmsProfile (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsProfile)5