Search in sources :

Example 46 with DataObject

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

the class DlmsHelperTest method testDateTimeSummerTimeWithDeviationAndDstFromOtherTimeZone.

@Test
public void testDateTimeSummerTimeWithDeviationAndDstFromOtherTimeZone() {
    /*
     * 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 UTC time zone would
     * be synchronizing time on a device in the Amsterdam time zone.
     */
    final DataObject dateInSummerTimeDataObject = this.dlmsHelper.asDataObject(this.dateTimeSummerTimeUtc(), -120, true);
    assertThat(dateInSummerTimeDataObject.isCosemDateFormat()).isTrue();
    assertThat(dateInSummerTimeDataObject.getValue() instanceof CosemDateTime).isTrue();
    final CosemDateTime cosemDateTime = dateInSummerTimeDataObject.getValue();
    assertThat(cosemDateTime.encode()).isEqualTo(this.byteArraySummerTime());
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) CosemDateTime(org.openmuc.jdlms.datatypes.CosemDateTime) Test(org.junit.jupiter.api.Test)

Example 47 with DataObject

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

the class DlmsHelperTest method testByteArrayToHexString.

@Test
public void testByteArrayToHexString() throws ProtocolAdapterException {
    final byte[] bytes = new byte[] { 25, 24, 7, 118 };
    final DataObject dataObject = DataObject.newOctetStringData(bytes);
    final String hexString = this.dlmsHelper.readHexString(dataObject, "reading a Hexadecimal String");
    assertThat(hexString).isEqualTo("19180776");
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) Test(org.junit.jupiter.api.Test)

Example 48 with DataObject

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

the class DlmsHelperTest method testDateTimeSummerTime.

@Test
public void testDateTimeSummerTime() {
    final DataObject dateInSummerTimeDataObject = this.dlmsHelper.asDataObject(this.dateTimeSummerTime());
    assertThat(dateInSummerTimeDataObject.isCosemDateFormat()).isTrue();
    assertThat(dateInSummerTimeDataObject.getValue() instanceof CosemDateTime).isTrue();
    final CosemDateTime cosemDateTime = dateInSummerTimeDataObject.getValue();
    assertThat(cosemDateTime.encode()).isEqualTo(this.byteArraySummerTime());
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) CosemDateTime(org.openmuc.jdlms.datatypes.CosemDateTime) Test(org.junit.jupiter.api.Test)

Example 49 with DataObject

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

the class DlmsHelperTest method testDateTimeWinterTimeWithDeviationAndDst.

@Test
public void testDateTimeWinterTimeWithDeviationAndDst() {
    final DataObject dateInWinterTimeDataObject = this.dlmsHelper.asDataObject(this.dateTimeWinterTime(), -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)

Example 50 with DataObject

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

the class DataObjectToOutageListConverter method convert.

public List<OutageDto> convert(final DataObject source) throws ProtocolAdapterException {
    final List<OutageDto> eventList = new ArrayList<>();
    if (source == null) {
        throw new ProtocolAdapterException("DataObject should not be null");
    }
    final List<DataObject> dataObjects = source.getValue();
    for (final DataObject dataObject : dataObjects) {
        eventList.add(this.getOutageDto(dataObject));
    }
    return eventList;
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) OutageDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.OutageDto) ArrayList(java.util.ArrayList) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)

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