DlmsHelper { public DataObject asDataObject(final DateTime dateTime) { final CosemDate cosemDate = new CosemDate(dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth()); final CosemTime cosemTime = new CosemTime(dateTime.getHourOfDay(), dateTime.getMinuteOfHour(), dateTime.getSecondOfMinute(), dateTime.getMillisOfSecond() / 10); final int deviation = -(dateTime.getZone().getOffset(dateTime.getMillis()) / MILLISECONDS_PER_MINUTE); final ClockStatus[] clockStatusBits; if (dateTime.getZone().isStandardOffset(dateTime.getMillis())) { clockStatusBits = new ClockStatus[0]; } else { clockStatusBits = new ClockStatus[1]; clockStatusBits[0] = ClockStatus.DAYLIGHT_SAVING_ACTIVE; } final CosemDateTime cosemDateTime = new CosemDateTime(cosemDate, cosemTime, deviation, clockStatusBits); return DataObject.newDateTimeData(cosemDateTime); }  DataObject getAttributeValue(final DlmsConnectionManager conn, final AttributeAddress attributeAddress); List<GetResult> getAndCheck(final DlmsConnectionManager conn, final DlmsDevice device,
            final String description, final AttributeAddress... params); void checkResultList(final List<GetResult> getResultList, final int expectedResults,
            final String description); List<GetResult> getWithList(final DlmsConnectionManager conn, final DlmsDevice device,
            final AttributeAddress... params); DataObject getClockDefinition(); DataObject getAccessSelectionTimeRangeParameter(final DateTime from, final DateTime to,
            final DataObject selectedValues); DlmsMeterValueDto getScaledMeterValue(final GetResult value, final GetResult scalerUnit,
            final String description); DlmsMeterValueDto getScaledMeterValue(final DataObject value, final DataObject scalerUnitObject,
            final String description); DataObject getAMRProfileDefinition(); Long readLong(final GetResult getResult, final String description); Long readLong(final DataObject resultData, final String description); Long readLongNotNull(final GetResult getResult, final String description); Long readLongNotNull(final DataObject resultData, final String description); Integer readInteger(final GetResult getResult, final String description); Short readShort(final GetResult getResult, final String description); DataObject readDataObject(final GetResult getResult, final String description); String readString(final DataObject resultData, final String description); CosemDateTimeDto readDateTime(final GetResult getResult, final String description); CosemDateTimeDto readDateTime(final DataObject resultData, final String description); CosemDateTimeDto convertDataObjectToDateTime(final DataObject object); CosemDateTimeDto fromDateTimeValue(final byte[] dateTimeValue); DataObject asDataObject(final DateTime dateTime); DataObject asDataObject(final DateTime dateTime, final int deviation, final boolean dst); DataObject asDataObject(final CosemDateDto date); List<CosemObjectDefinitionDto> readListOfObjectDefinition(final GetResult getResult,
            final String description); List<CosemObjectDefinitionDto> readListOfObjectDefinition(final DataObject resultData,
            final String description); CosemObjectDefinitionDto readObjectDefinition(final DataObject resultData, final String description); CosemObisCodeDto readLogicalName(final DataObject resultData, final String description); SendDestinationAndMethodDto readSendDestinationAndMethod(final GetResult getResult, final String description); SendDestinationAndMethodDto readSendDestinationAndMethod(final DataObject resultData,
            final String description); TransportServiceTypeDto readTransportServiceType(final DataObject resultData, final String description); MessageTypeDto readMessageType(final DataObject resultData, final String description); List<WindowElementDto> readListOfWindowElement(final GetResult getResult, final String description); List<WindowElementDto> readListOfWindowElement(final DataObject resultData, final String description); WindowElementDto readWindowElement(final DataObject resultData, final String description); String getDebugInfo(final DataObject dataObject); String getDebugInfoByteArray(final byte[] bytes); String getDebugInfoLogicalName(final byte[] logicalNameValue); String getDebugInfoDateTimeBytes(final byte[] dateTimeValue); String getDebugInfoBitStringBytes(final byte[] bitStringValue); void validateBufferedDateTime(final DateTime bufferedDateTime, final DateTime beginDateTime,
            final DateTime endDateTime); static final int MILLISECONDS_PER_MINUTE; }
@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()); }
@Test public void testDateTimeSummerTimeWithDeviationAndDst() { final DataObject dateInSummerTimeDataObject = this.dlmsHelper.asDataObject(this.dateTimeSummerTime(), -120, true); assertThat(dateInSummerTimeDataObject.isCosemDateFormat()).isTrue(); assertThat(dateInSummerTimeDataObject.getValue() instanceof CosemDateTime).isTrue(); final CosemDateTime cosemDateTime = dateInSummerTimeDataObject.getValue(); assertThat(cosemDateTime.encode()).isEqualTo(this.byteArraySummerTime()); }
@Test public void testDateTimeSummerTimeWithDeviationAndDstFromOtherTimeZone() { 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()); }
@Test public void testDateTimeWinterTime() { final DataObject dateInWinterTimeDataObject = this.dlmsHelper.asDataObject(this.dateTimeWinterTime()); assertThat(dateInWinterTimeDataObject.isCosemDateFormat()).isTrue(); assertThat(dateInWinterTimeDataObject.getValue() instanceof CosemDateTime).isTrue(); final CosemDateTime cosemDateTime = dateInWinterTimeDataObject.getValue(); assertThat(cosemDateTime.encode()).isEqualTo(this.byteArrayWinterTime()); }
@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()); }
@Test public void testDateTimeWinterTimeWithDeviationAndDstFromOtherTimeZone() { 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()); }