use of org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeWriteException 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.exceptions.NodeWriteException in project Protocol-Adapter-IEC61850 by OSGP.
the class NodeContainer method writeFloatArray.
public void writeFloatArray(final SubDataAttribute child, final Float[] values) throws NodeWriteException {
final Array array = (Array) this.parent.getChild(child.getDescription());
if (array.size() != values.length) {
throw new NodeWriteException(String.format("Invalid array size %d. Size on device is %d", values.length, array.size()));
}
for (int i = 0; i < values.length; i++) {
final BdaFloat32 bdaFloat = (BdaFloat32) array.getChild(i);
bdaFloat.setFloat(values[i]);
this.writeNode(bdaFloat);
}
// Unfortunately writing an array using "this.writeNode(array);"
// doesn't seem to work...
// Therefore the items are written in individual calls...
}
use of org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeWriteException in project Protocol-Adapter-IEC61850 by OSGP.
the class NodeContainer method writeDateArray.
public void writeDateArray(final SubDataAttribute child, final Date[] values) throws NodeWriteException {
final Array array = (Array) this.parent.getChild(child.getDescription());
if (array.size() != values.length) {
throw new NodeWriteException(String.format("Invalid array size %d. Size on device is %d", values.length, array.size()));
}
for (int i = 0; i < values.length; i++) {
final BdaTimestamp bdaTimestamp = (BdaTimestamp) array.getChild(i);
bdaTimestamp.setDate(values[i]);
this.writeNode(bdaTimestamp);
}
// Unfortunately writing an array using "this.writeNode(array);"
// doesn't seem to work...
// Therefore the items are written in individual calls...
}
use of org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeWriteException in project Protocol-Adapter-IEC61850 by OSGP.
the class DeviceRegistrationService method setLocationInformation.
/**
* Set the location information for this device. If the osgp_core database
* contains longitude and latitude information for the given device, those
* values must be saved to the corresponding data-attributes.
*/
protected void setLocationInformation(final DeviceConnection deviceConnection) {
final Ssld ssld = DeviceRegistrationService.this.ssldDataRepository.findByDeviceIdentification(deviceConnection.getDeviceIdentification());
if (ssld != null) {
final Float longitude = ssld.getGpsLongitude();
final Float latitude = ssld.getGpsLatitude();
LOGGER.info("Ssld found for device: {} longitude: {}, latitude: {}", deviceConnection.getDeviceIdentification(), longitude, latitude);
if (longitude != null && latitude != null) {
try {
new Iec61850SetGpsCoordinatesCommand().setGpsCoordinates(deviceConnection, longitude, latitude);
} catch (final NodeWriteException e) {
LOGGER.error("Unable to set location information for device: " + deviceConnection.getDeviceIdentification(), e);
}
}
}
}
use of org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeWriteException in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850RtuDeviceReportingService method enableStatusReportingOnDevice.
private void enableStatusReportingOnDevice(final DeviceConnection deviceConnection, final String deviceIdentification, final LogicalDevice logicalDevice, final int logicalDeviceIndex, final DataAttribute reportName) {
LOGGER.info("Allowing device {} to send events", deviceIdentification);
try {
final NodeContainer reportingNode = deviceConnection.getFcModelNode(logicalDevice, logicalDeviceIndex, LogicalNode.LOGICAL_NODE_ZERO, reportName, Fc.BR);
reportingNode.writeBoolean(SubDataAttribute.ENABLE_REPORTING, true);
} catch (final NullPointerException e) {
LOGGER.debug("NullPointerException", e);
LOGGER.warn("Skip enable reporting for device {}{}, report {}.", logicalDevice, logicalDeviceIndex, reportName.getDescription());
} catch (final NodeWriteException e) {
LOGGER.debug("NodeWriteException", e);
LOGGER.error("Enable reporting for device {}{}, report {}, failed with exception: {}", logicalDevice, logicalDeviceIndex, reportName.getDescription(), e.getMessage());
}
}
Aggregations