Search in sources :

Example 41 with DataObject

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

the class GetPeriodicMeterReadsGasCommandExecutorIntegrationTest method createAttributeAddress.

private AttributeAddress createAttributeAddress(final Protocol protocol, final PeriodTypeDto type, final Date timeFrom, final Date timeTo) throws Exception {
    final DataObject from = this.dlmsHelper.asDataObject(new DateTime(timeFrom));
    final DataObject to = this.dlmsHelper.asDataObject(new DateTime(timeTo));
    if (protocol == Protocol.DSMR_4_2_2) {
        if (type == PeriodTypeDto.DAILY) {
            return this.createAttributeAddressDsmr4Daily(from, to);
        } else if (type == PeriodTypeDto.MONTHLY) {
            return this.createAttributeAddressDsmr4Monthly(from, to);
        } else if (type == PeriodTypeDto.INTERVAL) {
            return this.createAttributeAddressDsmr4Interval(from, to);
        }
    } else if (protocol == Protocol.SMR_5_0_0 || protocol == Protocol.SMR_5_1) {
        if (type == PeriodTypeDto.DAILY) {
            return this.createAttributeAddressSmr5Daily(from, to);
        } else if (type == PeriodTypeDto.MONTHLY) {
            return this.createAttributeAddressSmr5Monthly(from, to);
        } else if (type == PeriodTypeDto.INTERVAL) {
            return this.createAttributeAddressSmr5Interval(from, to);
        }
    }
    throw new Exception("Invalid combination of protocol " + protocol.getName() + " and version " + protocol.getVersion());
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) DateTime(org.joda.time.DateTime) CosemDateTime(org.openmuc.jdlms.datatypes.CosemDateTime)

Example 42 with DataObject

use of org.openmuc.jdlms.datatypes.DataObject 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 43 with DataObject

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

the class SetPushSetupAlarmCommandExecutorTest method verifyPushObjectListParameter.

private void verifyPushObjectListParameter(final SetParameter setParameter) {
    final AttributeAddress attributeAddress = setParameter.getAttributeAddress();
    assertThat(attributeAddress.getClassId()).isEqualTo(CLASS_ID);
    assertThat(attributeAddress.getInstanceId()).isEqualTo(OBIS_CODE);
    assertThat(attributeAddress.getId()).isEqualTo(ATTRIBUTE_ID_PUSH_OBJECT_LIST);
    final DataObject dataObject = setParameter.getData();
    assertThat(dataObject.getType()).isEqualTo(Type.ARRAY);
    final List<DataObject> values = dataObject.getValue();
    assertThat(values).hasSize(PUSH_OBJECT_LIST.size());
    this.verifyPushObject(values.get(0), PUSH_OBJECT_1_CLASS_ID, PUSH_OBJECT_1_OBIS_CODE.toByteArray(), (byte) PUSH_OBJECT_1_ATTRIBUTE_ID, PUSH_OBJECT_1_DATA_INDEX);
    this.verifyPushObject(values.get(1), PUSH_OBJECT_2_CLASS_ID, PUSH_OBJECT_2_OBIS_CODE.toByteArray(), (byte) PUSH_OBJECT_2_ATTRIBUTE_ID, PUSH_OBJECT_2_DATA_INDEX);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) AttributeAddress(org.openmuc.jdlms.AttributeAddress)

Example 44 with DataObject

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

the class AttributeAddressAssert method assertThatArrayIs.

private static void assertThatArrayIs(final DataObject actual, final DataObject expected) {
    final List<DataObject> actualList = actual.getValue();
    final List<DataObject> expectedList = expected.getValue();
    assertThat(actualList.size()).isEqualTo(expectedList.size());
    int index = 0;
    for (final DataObject actualObject : actualList) {
        assertThatDataObjectIs(actualObject, expectedList.get(index));
        index++;
    }
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject)

Example 45 with DataObject

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

the class DlmsHelperTest method testDateTimeWinterTimeWithDeviationAndDstFromOtherTimeZone.

@Test
public void testDateTimeWinterTimeWithDeviationAndDstFromOtherTimeZone() {
    /*
     * The date and time on the device should be set according to the
     * deviation and daylight savings information provided as parameters.
     * The time of the server can be given in another time zone than the
     * device is in, but the instant in time should remain the same.
     *
     * This test has a time input as if a server in the New York time zone
     * would be synchronizing time on a device in the Amsterdam time zone.
     */
    final DataObject dateInWinterTimeDataObject = this.dlmsHelper.asDataObject(this.dateTimeWinterTimeNewYork(), -60, false);
    assertThat(dateInWinterTimeDataObject.isCosemDateFormat()).isTrue();
    assertThat(dateInWinterTimeDataObject.getValue() instanceof CosemDateTime).isTrue();
    final CosemDateTime cosemDateTime = dateInWinterTimeDataObject.getValue();
    assertThat(cosemDateTime.encode()).isEqualTo(this.byteArrayWinterTime());
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) CosemDateTime(org.openmuc.jdlms.datatypes.CosemDateTime) 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