use of com.alliander.osgp.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 com.alliander.osgp.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());
}
}
use of com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850SsldDeviceService method enableReporting.
private void enableReporting(final DeviceConnection deviceConnection, final DeviceRequest deviceRequest) throws NodeWriteException {
// Enabling device reporting.
new Iec61850EnableReportingCommand().enableReportingOnDeviceWithoutUsingSequenceNumber(this.iec61850Client, deviceConnection);
// Don't disconnect now! The device should be able to send reports.
new Timer().schedule(new TimerTask() {
@Override
public void run() {
try {
new Iec61850ClearReportCommand().clearReportOnDevice(deviceConnection);
} catch (final ProtocolAdapterException e) {
LOGGER.error("Unable to clear report for device: " + deviceRequest.getDeviceIdentification(), e);
}
Iec61850SsldDeviceService.this.iec61850DeviceConnectionService.disconnect(deviceConnection, deviceRequest);
}
}, this.disconnectDelay);
}
use of com.alliander.osgp.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 com.alliander.osgp.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...
}
Aggregations