Search in sources :

Example 26 with DataObject

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

the class GetPeriodicMeterReadsGasCommandExecutorIntegrationTest method setResponsesForScalerUnit.

private void setResponsesForScalerUnit(final List<AttributeAddress> attributeAddressesForScalerUnit) {
    final int DLMS_ENUM_VALUE_M3 = 14;
    final DataObject responseDataObject = DataObject.newStructureData(DataObject.newInteger8Data((byte) 0), DataObject.newEnumerateData(DLMS_ENUM_VALUE_M3));
    for (final AttributeAddress attributeAddress : attributeAddressesForScalerUnit) {
        this.connectionStub.addReturnValue(attributeAddress, responseDataObject);
    }
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) AttributeAddress(org.openmuc.jdlms.AttributeAddress)

Example 27 with DataObject

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

the class GetPeriodicMeterReadsGasCommandExecutorIntegrationTest method setResponseForProfile.

private void setResponseForProfile(final AttributeAddress attributeAddressForProfile, final Protocol protocol, final PeriodTypeDto type, final boolean useNullData) {
    // PERIOD 1
    final DataObject period1Clock = this.PERIOD_1_CLOCK;
    final DataObject period1Status = DataObject.newUInteger8Data(this.PERIOD1_AMR_STATUS_VALUE);
    final DataObject period1Value = DataObject.newUInteger32Data(this.PERIOD_1_LONG_VALUE);
    final DataObject period1CaptureTime = DataObject.newDateTimeData(this.PERIOD_1_CAPTURE_TIME);
    final DataObject periodItem1;
    if (type == PeriodTypeDto.MONTHLY && protocol == Protocol.DSMR_4_2_2) {
        periodItem1 = DataObject.newStructureData(Arrays.asList(period1Clock, period1Value, period1CaptureTime));
    } else {
        periodItem1 = DataObject.newStructureData(Arrays.asList(period1Clock, period1Status, period1Value, period1CaptureTime));
    }
    // PERIOD 2
    final DataObject period2Clock;
    final DataObject period2CaptureTime;
    if (useNullData) {
        period2Clock = DataObject.newNullData();
        period2CaptureTime = DataObject.newNullData();
    } else {
        period2Clock = this.PERIOD_2_CLOCK;
        period2CaptureTime = DataObject.newDateTimeData(this.PERIOD_2_CAPTURE_TIME);
    }
    final DataObject period2Status = DataObject.newUInteger8Data(this.PERIOD2_AMR_STATUS_VALUE);
    final DataObject period2Value = DataObject.newUInteger32Data(this.PERIOD_2_LONG_VALUE);
    final DataObject periodItem2;
    if (type == PeriodTypeDto.MONTHLY && protocol == Protocol.DSMR_4_2_2) {
        // No status for Monthly values in DSMR4.2.2
        periodItem2 = DataObject.newStructureData(Arrays.asList(period2Clock, period2Value, period2CaptureTime));
    } else {
        periodItem2 = DataObject.newStructureData(Arrays.asList(period2Clock, period2Status, period2Value, period2CaptureTime));
    }
    // Create returnvalue and set in stub
    final DataObject responseDataObject = DataObject.newArrayData(Arrays.asList(periodItem1, periodItem2));
    this.connectionStub.addReturnValue(attributeAddressForProfile, responseDataObject);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject)

Example 28 with DataObject

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

the class GetPeriodicMeterReadsGasCommandExecutorIntegrationTest method createSelectiveAccessDescriptionSmr5.

private SelectiveAccessDescription createSelectiveAccessDescriptionSmr5(final DataObject from, final DataObject to) {
    final DataObject selectedValues = DataObject.newArrayData(Collections.emptyList());
    final DataObject expectedAccessParam = DataObject.newStructureData(Arrays.asList(this.CLOCK, from, to, selectedValues));
    return new SelectiveAccessDescription(1, expectedAccessParam);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) SelectiveAccessDescription(org.openmuc.jdlms.SelectiveAccessDescription)

Example 29 with DataObject

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

the class DlmsObjectConfigServiceTest method testProfileWithOneMedium.

@Test
void testProfileWithOneMedium() {
    // SETUP
    final Integer channel = null;
    final Medium filterMedium = Medium.ELECTRICITY;
    final DataObject selectedValues = DataObject.newArrayData(Collections.emptyList());
    final DataObject accessParams = this.getAccessParams(selectedValues);
    final SelectiveAccessDescription access = new SelectiveAccessDescription(1, accessParams);
    final AttributeAddress expectedAddress = new AttributeAddress(this.profileE.getClassId(), this.profileE.getObisCodeAsString(), this.profileE.getDefaultAttributeId(), access);
    // CALL
    final Optional<AttributeAddressForProfile> attributeAddressForProfile = this.service.findAttributeAddressForProfile(this.device422, DlmsObjectType.INTERVAL_VALUES, channel, this.from, this.to, filterMedium);
    // VERIFY
    assertThat(attributeAddressForProfile).isPresent();
    AttributeAddressAssert.is(attributeAddressForProfile.get().getAttributeAddress(), expectedAddress);
    assertThat(attributeAddressForProfile.get().getSelectedObjects()).isEqualTo(this.captureObjectsE);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) SelectiveAccessDescription(org.openmuc.jdlms.SelectiveAccessDescription) Medium(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.Medium) AttributeAddress(org.openmuc.jdlms.AttributeAddress) Test(org.junit.jupiter.api.Test)

Example 30 with DataObject

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

the class DlmsObjectConfigServiceTest method testProfileWithMediumCombinedAndNoFilterMedium.

@Test
void testProfileWithMediumCombinedAndNoFilterMedium() {
    // SETUP
    final Integer channel = 1;
    final Medium filterMedium = null;
    final DataObject selectedValues = DataObject.newArrayData(Collections.emptyList());
    final DataObject accessParams = this.getAccessParams(selectedValues);
    final SelectiveAccessDescription access = new SelectiveAccessDescription(1, accessParams);
    final AttributeAddress expectedAddress = new AttributeAddress(this.profileCombined.getClassId(), this.profileCombined.getObisCodeAsString(), this.profileCombined.getDefaultAttributeId(), access);
    // CALL
    final Optional<AttributeAddressForProfile> attributeAddressForProfile = this.service.findAttributeAddressForProfile(this.device422, DlmsObjectType.DAILY_LOAD_PROFILE, channel, this.from, this.to, filterMedium);
    // VERIFY
    assertThat(attributeAddressForProfile).isPresent();
    AttributeAddressAssert.is(attributeAddressForProfile.get().getAttributeAddress(), expectedAddress);
    assertThat(attributeAddressForProfile.get().getSelectedObjects()).isEqualTo(this.captureObjectsCombined);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) SelectiveAccessDescription(org.openmuc.jdlms.SelectiveAccessDescription) Medium(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.Medium) AttributeAddress(org.openmuc.jdlms.AttributeAddress) Test(org.junit.jupiter.api.Test)

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