use of org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateTimeDto in project open-smart-grid-platform by OSGP.
the class DlmsHelper method buildWindowElementFromDataObjects.
private WindowElementDto buildWindowElementFromDataObjects(final List<DataObject> elements, final String description) throws ProtocolAdapterException {
if (elements.size() != 2) {
LOGGER.error("Unexpected number of ResultData elements for WindowElement value: {}", elements.size());
throw new ProtocolAdapterException("Expected list for WindowElement to contain 2 elements, got: " + elements.size());
}
final CosemDateTimeDto startTime = this.readDateTime(elements.get(0), "Start Time from " + description);
final CosemDateTimeDto endTime = this.readDateTime(elements.get(1), "End Time from " + description);
return new WindowElementDto(startTime, endTime);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateTimeDto in project open-smart-grid-platform by OSGP.
the class DlmsHelper method fromDateTimeValue.
public CosemDateTimeDto fromDateTimeValue(final byte[] dateTimeValue) {
final ByteBuffer bb = ByteBuffer.wrap(dateTimeValue);
final int year = bb.getShort() & 0xFFFF;
final int monthOfYear = bb.get() & 0xFF;
final int dayOfMonth = bb.get() & 0xFF;
final int dayOfWeek = bb.get() & 0xFF;
final int hourOfDay = bb.get() & 0xFF;
final int minuteOfHour = bb.get() & 0xFF;
final int secondOfMinute = bb.get() & 0xFF;
final int hundredthsOfSecond = bb.get() & 0xFF;
final int deviation = bb.getShort();
final byte clockStatusValue = bb.get();
final CosemDateDto date = new CosemDateDto(year, monthOfYear, dayOfMonth, dayOfWeek);
final CosemTimeDto time = new CosemTimeDto(hourOfDay, minuteOfHour, secondOfMinute, hundredthsOfSecond);
final ClockStatusDto clockStatus = new ClockStatusDto(clockStatusValue);
return new CosemDateTimeDto(date, time, deviation, clockStatus);
}
Aggregations