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());
}
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");
}
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());
}
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());
}
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;
}
Aggregations