Search in sources :

Example 31 with DataObject

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

the class FindEventsCommandExecutorTest method generateDataObjectsExtendedPowerQuality.

private List<DataObject> generateDataObjectsExtendedPowerQuality() {
    final List<DataObject> dataObjects = new ArrayList<>();
    IntStream.rangeClosed(93, 98).forEach(code -> {
        final DataObject eventCode = DataObject.newInteger16Data((short) code);
        final DataObject eventTime = DataObject.newDateTimeData(new CosemDateTime(2018, 12, 31, 23, code - 60, 0, 0));
        final DataObject magnitude = DataObject.newInteger32Data(5);
        final DataObject duration = DataObject.newInteger32Data(6);
        final DataObject struct = DataObject.newStructureData(eventTime, eventCode, magnitude, duration);
        dataObjects.add(struct);
    });
    return dataObjects;
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) ArrayList(java.util.ArrayList) CosemDateTime(org.openmuc.jdlms.datatypes.CosemDateTime)

Example 32 with DataObject

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

the class FindEventsCommandExecutorTest method generateDataObjects.

private List<DataObject> generateDataObjects() {
    final List<DataObject> dataObjects = new ArrayList<>();
    IntStream.rangeClosed(77, 89).forEach(code -> {
        final DataObject eventCode = DataObject.newInteger16Data((short) code);
        final DataObject eventTime = DataObject.newDateTimeData(new CosemDateTime(2018, 12, 31, 23, code - 60, 0, 0));
        final DataObject struct = DataObject.newStructureData(eventTime, eventCode);
        dataObjects.add(struct);
    });
    return dataObjects;
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) ArrayList(java.util.ArrayList) CosemDateTime(org.openmuc.jdlms.datatypes.CosemDateTime)

Example 33 with DataObject

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

the class FindEventsCommandExecutorTest method before.

@BeforeEach
public void before() throws ProtocolAdapterException, IOException {
    final DataObject fromDate = mock(DataObject.class);
    final DataObject toDate = mock(DataObject.class);
    this.messageMetadata = MessageMetadata.newBuilder().withCorrelationUid("123456").build();
    this.findEventsRequestDto = new FindEventsRequestDto(EventLogCategoryDto.POWER_QUALITY_EVENT_LOG, DateTime.now().minusDays(70), DateTime.now());
    final DataObjectToEventListConverter dataObjectToEventListConverter = new DataObjectToEventListConverter(this.dlmsHelper);
    final DlmsObjectConfigService dlmsObjectConfigService = new DlmsObjectConfigService(this.dlmsHelper, new DlmsObjectConfigConfiguration().getDlmsObjectConfigs());
    this.executor = new FindEventsCommandExecutor(this.dlmsHelper, dataObjectToEventListConverter, dlmsObjectConfigService);
    when(this.dlmsHelper.asDataObject(this.findEventsRequestDto.getFrom())).thenReturn(fromDate);
    when(this.dlmsHelper.asDataObject(this.findEventsRequestDto.getUntil())).thenReturn(toDate);
    when(this.dlmsHelper.convertDataObjectToDateTime(any(DataObject.class))).thenReturn(new CosemDateTimeDto());
    when(this.conn.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
    when(this.conn.getConnection()).thenReturn(this.dlmsConnection);
    when(this.dlmsConnection.get(any(AttributeAddress.class))).thenReturn(this.getResult);
}
Also used : DlmsObjectConfigConfiguration(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigConfiguration) FindEventsRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.FindEventsRequestDto) DlmsObjectConfigService(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigService) DataObject(org.openmuc.jdlms.datatypes.DataObject) DataObjectToEventListConverter(org.opensmartgridplatform.adapter.protocol.dlms.application.mapping.DataObjectToEventListConverter) AttributeAddress(org.openmuc.jdlms.AttributeAddress) CosemDateTimeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateTimeDto) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 34 with DataObject

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

the class SetConfigurationObjectServiceDsmr4Test method buildSetParameterDataGprsModeOnDevice.

@Test
public void buildSetParameterDataGprsModeOnDevice() throws ProtocolAdapterException {
    // SETUP
    when(this.configurationToSet.getGprsOperationMode()).thenReturn(null);
    when(this.configurationOnDevice.getGprsOperationMode()).thenReturn(GPRS_OPERATION_MODE);
    // CALL
    final DataObject result = this.instance.buildSetParameterData(this.configurationToSet, this.configurationOnDevice);
    // VERIFY
    final List<DataObject> elements = result.getValue();
    final int value = elements.get(0).getValue();
    assertThat(value).isEqualTo(GPRS_OPERATION_MODE.getNumber());
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) Test(org.junit.jupiter.api.Test)

Example 35 with DataObject

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

the class SetActivityCalendarCommandExecutorTest method verifySetParameterWeekProfiles.

private void verifySetParameterWeekProfiles(final SetParameter setParameter, final List<String> weekNames, final List<Short> dayIds) {
    final AttributeAddress attributeAddress = setParameter.getAttributeAddress();
    assertThat(attributeAddress.getClassId()).isEqualTo(CLASS_ID);
    assertThat(attributeAddress.getInstanceId()).isEqualTo(OBIS_CODE);
    assertThat(attributeAddress.getId()).isEqualTo(ATTRIBUTE_ID_WEEK_PROFILE_TABLE_PASSIVE);
    final DataObject dataObject = setParameter.getData();
    assertThat(dataObject.getType()).isEqualTo(Type.ARRAY);
    final List<DataObject> weeks = dataObject.getValue();
    this.verifyWeeks(weeks, weekNames, dayIds);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) AttributeAddress(org.openmuc.jdlms.AttributeAddress)

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