Search in sources :

Example 6 with SelectiveAccessDescription

use of org.openmuc.jdlms.SelectiveAccessDescription 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 7 with SelectiveAccessDescription

use of org.openmuc.jdlms.SelectiveAccessDescription 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)

Example 8 with SelectiveAccessDescription

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

the class GetPeriodicMeterReadsGasCommandExecutorIntegrationTest method createSelectiveAccessDescriptionDsmr4Interval.

private SelectiveAccessDescription createSelectiveAccessDescriptionDsmr4Interval(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 9 with SelectiveAccessDescription

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

the class FindEventsCommandExecutor method getSelectiveAccessDescription.

private SelectiveAccessDescription getSelectiveAccessDescription(final DlmsDevice device, final DateTime beginDateTime, final DateTime endDateTime) throws ProtocolAdapterException {
    /*
     * Define the clock object {8,0-0:1.0.0.255,2,0} to be used as
     * restricting object in a range descriptor with a from value and to
     * value to determine which elements from the buffered array should be
     * retrieved.
     */
    final DlmsObject clockObject = this.dlmsObjectConfigService.getDlmsObject(device, DlmsObjectType.CLOCK);
    final DataObject clockDefinition = DataObject.newStructureData(Arrays.asList(DataObject.newUInteger16Data(clockObject.getClassId()), DataObject.newOctetStringData(clockObject.getObisCode().bytes()), DataObject.newInteger8Data((byte) clockObject.getDefaultAttributeId()), DataObject.newUInteger16Data(0)));
    final DataObject fromValue = this.dlmsHelper.asDataObject(beginDateTime);
    final DataObject toValue = this.dlmsHelper.asDataObject(endDateTime);
    /*
     * Retrieve all captured objects by setting selectedValues to an empty
     * array.
     */
    final DataObject selectedValues = DataObject.newArrayData(Collections.emptyList());
    final DataObject accessParameter = DataObject.newStructureData(Arrays.asList(clockDefinition, fromValue, toValue, selectedValues));
    return new SelectiveAccessDescription(ACCESS_SELECTOR_RANGE_DESCRIPTOR, accessParameter);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) SelectiveAccessDescription(org.openmuc.jdlms.SelectiveAccessDescription) DlmsObject(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject)

Example 10 with SelectiveAccessDescription

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

the class AbstractGetPowerQualityProfileHandler method getSelectiveAccessDescription.

private SelectiveAccessDescription getSelectiveAccessDescription(final DateTime beginDateTime, final DateTime endDateTime, final DataObject selectableCaptureObjects) {
    /*
     * Define the clock object {8,0-0:1.0.0.255,2,0} to be used as
     * restricting object in a range descriptor with a from value and to
     * value to determine which elements from the buffered array should be
     * retrieved.
     */
    final DataObject clockDefinition = this.dlmsHelper.getClockDefinition();
    final DataObject fromValue = this.dlmsHelper.asDataObject(beginDateTime);
    final DataObject toValue = this.dlmsHelper.asDataObject(endDateTime);
    final DataObject accessParameter = DataObject.newStructureData(Arrays.asList(clockDefinition, fromValue, toValue, selectableCaptureObjects));
    return new SelectiveAccessDescription(ACCESS_SELECTOR_RANGE_DESCRIPTOR, accessParameter);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) SelectiveAccessDescription(org.openmuc.jdlms.SelectiveAccessDescription)

Aggregations

SelectiveAccessDescription (org.openmuc.jdlms.SelectiveAccessDescription)17 DataObject (org.openmuc.jdlms.datatypes.DataObject)16 AttributeAddress (org.openmuc.jdlms.AttributeAddress)6 DlmsObject (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject)5 Test (org.junit.jupiter.api.Test)3 Medium (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.Medium)3 DateTime (org.joda.time.DateTime)2 ObisCode (org.openmuc.jdlms.ObisCode)2 DlmsProfile (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsProfile)2 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertThatExceptionOfType (org.assertj.core.api.Assertions.assertThatExceptionOfType)1 Fail.fail (org.assertj.core.api.Fail.fail)1