use of org.openmuc.jdlms.datatypes.CosemDateTime in project open-smart-grid-platform by OSGP.
the class Smr51Profile method gsmGprsDiagnostic.
@Bean
public GsmDiagnostic gsmGprsDiagnostic() {
final CellInfo cellInfo = new CellInfo(this.gsmDiagnosticCellInfoCellId, this.gsmDiagnosticCellInfoLocationId, this.gsmDiagnosticCellInfoSignalQuality, this.gsmDiagnosticCellInfoBer, this.gsmDiagnosticCellInfoMcc, this.gsmDiagnosticCellInfoMnc, this.gsmDiagnosticCellInfoChannelNumber);
final List<AdjacentCellInfo> adjacentCellInfos = IntStream.range(0, this.gsmDiagnosticAdjacentCellsCellIds.size()).mapToObj(i -> new AdjacentCellInfo(this.gsmDiagnosticAdjacentCellsCellIds.get(i), this.gsmDiagnosticAdjacentCellsSignalQualities.get(i))).collect(Collectors.toList());
final CosemDateTime captureTime = new CosemDateTime(this.gsmDiagnosticYear, this.gsmDiagnosticMonth, this.gsmDiagnosticDayOfMonth, this.gsmDiagnosticDayOfWeek, this.gsmDiagnosticHour, this.gsmDiagnosticMinute, this.gsmDiagnosticSecond, this.gsmDiagnosticHundredths, this.gsmDiagnosticDeviation, ClockStatus.clockStatusFrom(this.gsmDiagnosticClockStatus).toArray(new ClockStatus[0]));
return new GsmDiagnostic("0.0.25.6.0.255", this.gsmDiagnosticOperator, this.gsmDiagnosticStatus, this.gsmDiagnosticCsAttachment, this.gsmDiagnosticPsStatus, cellInfo, adjacentCellInfos, captureTime);
}
use of org.openmuc.jdlms.datatypes.CosemDateTime in project open-smart-grid-platform by OSGP.
the class CosemDateTimeFilterTest method asDataObject.
/**
* Creates a COSEM date-time object based on the given {@code dateTime}. This COSEM date-time will
* be for the same instant in time as the given {@code dateTime} but may be for another time zone.
*
* <p>Because the time zone with the {@code deviation} may be different than the one with the
* {@code dateTime}, and the {@code deviation} alone does not provide sufficient information on
* whether daylight savings is active for the given instant in time, {@code dst} has to be
* provided to indicate whether daylight savings are active.
*
* @param dateTime a DateTime indicating an instant in time to be used for the COSEM date-time.
* @param deviation the deviation in minutes of local time to GMT to be included in the COSEM
* date-time.
* @param dst {@code true} if daylight savings are active for the instant of the COSEM date-time,
* otherwise {@code false}.
* @return a DataObject having a CosemDateTime for the instant of the given DateTime, with the
* given deviation and DST status information, as value.
*/
public DataObject asDataObject(final DateTime dateTime, final int deviation, final boolean dst) {
/*
* Create a date time that may not point to the right instant in time,
* but that will give proper values getting the different fields for the
* COSEM date and time objects.
*/
final DateTime dateTimeWithOffset = dateTime.toDateTime(DateTimeZone.UTC).minusMinutes(deviation);
final CosemDate cosemDate = new CosemDate(dateTimeWithOffset.getYear(), dateTimeWithOffset.getMonthOfYear(), dateTimeWithOffset.getDayOfMonth());
final CosemTime cosemTime = new CosemTime(dateTimeWithOffset.getHourOfDay(), dateTimeWithOffset.getMinuteOfHour(), dateTimeWithOffset.getSecondOfMinute(), dateTimeWithOffset.getMillisOfSecond() / 10);
final ClockStatus[] clockStatusBits;
if (dst) {
clockStatusBits = new ClockStatus[1];
clockStatusBits[0] = ClockStatus.DAYLIGHT_SAVING_ACTIVE;
} else {
clockStatusBits = new ClockStatus[0];
}
final CosemDateTime cosemDateTime = new CosemDateTime(cosemDate, cosemTime, deviation, clockStatusBits);
return DataObject.newOctetStringData(cosemDateTime.encode());
}
use of org.openmuc.jdlms.datatypes.CosemDateTime in project open-smart-grid-platform by OSGP.
the class ClockTest method transistionFromDst.
private void transistionFromDst(final Clock clock, final String hexDateTime) throws InterruptedException {
Thread.sleep(CLOCK_TRANSITION_TIME);
final CosemDateTime dateTime = this.getCosemDateTime(hexDateTime);
final CosemDateTime returned = clock.getTime().getValue();
/*
* Transition from 02:59:59 to 3 o'clock is a transition from DST, so
* the clock is set back to 2 o'clock. The hour therefore stays the
* same.
*/
this.doDstTansitionAssertions(dateTime, returned, 0, false);
}
use of org.openmuc.jdlms.datatypes.CosemDateTime in project open-smart-grid-platform by OSGP.
the class CosemDateTimeProcessor method create.
@Override
public DataObject create(final Object data) {
if (!(data instanceof Calendar)) {
throw new IllegalArgumentException(this.getClass().getSimpleName() + " can not create expected DataObject from type " + data.getClass().getSimpleName());
}
final Calendar cal = (Calendar) data;
final CosemDateTime dateTime = new CosemDateTime(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH), 0xff, cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND), 0, 0);
return DataObject.newDateTimeData(dateTime);
}
use of org.openmuc.jdlms.datatypes.CosemDateTime in project open-smart-grid-platform by OSGP.
the class FindEventsCommandExecutorTest method generateDataObjectsExtendedPowerQuality.
private List<DataObject> generateDataObjectsExtendedPowerQuality() {
final List<DataObject> dataObjects = new ArrayList<>();
IntStream.rangeClosed(93, 98).forEach(code -> {
final DataObject eventCode = DataObject.newInteger16Data((short) code);
final DataObject eventTime = DataObject.newDateTimeData(new CosemDateTime(2018, 12, 31, 23, code - 60, 0, 0));
final DataObject magnitude = DataObject.newInteger32Data(5);
final DataObject duration = DataObject.newInteger32Data(6);
final DataObject struct = DataObject.newStructureData(eventTime, eventCode, magnitude, duration);
dataObjects.add(struct);
});
return dataObjects;
}
Aggregations