use of org.opensmartgridplatform.adapter.protocol.iec61850.domain.entities.Iec61850ReportEntry in project open-smart-grid-platform by OSGP.
the class Iec61850RtuDeviceReportingService method resyncBufferedReport.
private void resyncBufferedReport(final DeviceConnection connection, final String deviceIdentification, final Brcb brcb) {
final NodeContainer node = new NodeContainer(connection, brcb);
try {
this.client.readNodeDataValues(connection.getConnection().getClientAssociation(), node.getFcmodelNode());
} catch (final NodeReadException e) {
LOGGER.debug("NodeReadException", e);
LOGGER.error("Resync reporting failed, could not read report id from device {}, exception: {}", deviceIdentification, e.getMessage());
return;
}
final String reportId = node.getString(SubDataAttribute.REPORT_ID);
LOGGER.debug("Resync reporting for report {} on device {}", reportId, deviceIdentification);
final Iec61850ReportEntry reportEntry = this.iec61850ReportEntryRepository.findByDeviceIdentificationAndReportId(deviceIdentification, reportId);
if (reportEntry == null) {
LOGGER.info("Resync reporting for report {} on device {} not possible, no last report entry found", reportId, deviceIdentification);
} else {
LOGGER.info("Resync reporting for report {} on device {} with last report entry: {}", reportId, deviceIdentification, reportEntry);
try {
node.writeOctetString(SubDataAttribute.ENTRY_ID, reportEntry.getEntryId());
} catch (final NodeWriteException e) {
LOGGER.debug("NodeWriteException", e);
LOGGER.error("Resync reporting for report {} on device {} failed with exception: {}", reportId, deviceIdentification, e.getMessage());
}
}
}
use of org.opensmartgridplatform.adapter.protocol.iec61850.domain.entities.Iec61850ReportEntry in project open-smart-grid-platform by OSGP.
the class ReportingService method storeLastReportEntry.
@Transactional(value = "transactionManager")
public void storeLastReportEntry(final Report report, final String deviceIdentification) {
if (Objects.isNull(report.getEntryId()) || Objects.isNull(report.getTimeOfEntry())) {
LOGGER.warn("Not all report entry data availabe for report id {} and device identification {}, skip storing last report entry", report.getRptId(), deviceIdentification);
return;
}
Iec61850ReportEntry reportEntry = this.iec61850ReportEntryRepository.findByDeviceIdentificationAndReportId(deviceIdentification, report.getRptId());
if (reportEntry == null) {
reportEntry = new Iec61850ReportEntry(deviceIdentification, report.getRptId(), report.getEntryId().getValue(), new Date(report.getTimeOfEntry().getTimestampValue()));
LOGGER.info("Store new last report entry: {}", reportEntry);
} else {
reportEntry.updateLastReportEntry(report.getEntryId().getValue(), new Date(report.getTimeOfEntry().getTimestampValue()));
LOGGER.info("Store updated last report entry: {}", reportEntry);
}
try {
this.iec61850ReportEntryRepository.saveAndFlush(reportEntry);
} catch (final JpaOptimisticLockingFailureException e) {
LOGGER.debug("JpaOptimisticLockingFailureException", e);
LOGGER.warn("JPA optimistic locking failure exception while saving last report entry: {} with id {} and version {}", reportEntry, reportEntry.getId(), reportEntry.getVersion());
}
}
Aggregations