use of com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850DisableRegistrationCommand method disableRegistration.
public void disableRegistration(final DeviceConnection deviceConnection) throws NodeWriteException {
final NodeContainer deviceRegistration = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.STREET_LIGHT_CONFIGURATION, DataAttribute.REGISTRATION, Fc.CF);
deviceRegistration.writeBoolean(SubDataAttribute.DEVICE_REGISTRATION_ENABLED, false);
LOGGER.info("Registration disabled for device: {}", deviceConnection.getDeviceIdentification());
}
use of com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850EnableReportingCommand method enableReportingOnDeviceWithoutUsingSequenceNumber.
/**
* Enable reporting so the device can send reports. This version of the
* function does not use the 'sequence number' to filter incoming reports.
* When using the {@link Iec61850ClearReportCommand} the 'sequence number'
* will always be reset to 0.
*
* @throws NodeWriteException
* In case writing of data-attributes fails.
*/
public void enableReportingOnDeviceWithoutUsingSequenceNumber(final Iec61850Client iec61850Client, final DeviceConnection deviceConnection) throws NodeWriteException {
final NodeContainer reporting = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.LOGICAL_NODE_ZERO, DataAttribute.REPORTING, Fc.BR);
final Iec61850ClientBaseEventListener reportListener = deviceConnection.getConnection().getIec61850ClientAssociation().getReportListener();
reportListener.setSqNum(0);
reporting.writeBoolean(SubDataAttribute.ENABLE_REPORTING, true);
LOGGER.info("Allowing device {} to send reports containing events", deviceConnection.getDeviceIdentification());
}
use of com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850ClearReportCommand method clearReportOnDevice.
public void clearReportOnDevice(final DeviceConnection deviceConnection) throws NodeWriteException {
final NodeContainer reporting = deviceConnection.getFcModelNode(LogicalDevice.LIGHTING, LogicalNode.LOGICAL_NODE_ZERO, DataAttribute.REPORTING, Fc.BR);
reporting.writeBoolean(SubDataAttribute.ENABLE_REPORTING, false);
reporting.writeBoolean(SubDataAttribute.PURGE_BUF, true);
LOGGER.info("Cleared event buffer for device: {}", deviceConnection.getDeviceIdentification());
}
use of com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850Client method sendCommandWithRetry.
/**
* Executes the apply method of the given {@link Function} with retries and
* message logging.
*
* @return The given T.
*/
public <T> T sendCommandWithRetry(final Function<T> function, final String functionName, final String deviceIdentification) throws ProtocolAdapterException {
T output = null;
final DeviceMessageLog deviceMessageLog = new DeviceMessageLog(IED.FLEX_OVL, LogicalDevice.LIGHTING, functionName);
try {
output = function.apply(deviceMessageLog);
} catch (final NodeWriteException | NodeReadException e) {
if (ConnectionState.OK.equals(e.getConnectionState())) {
// ServiceError means we have to retry.
LOGGER.error("Caught ServiceError, retrying", e);
this.sendCommandWithRetry(function, deviceIdentification, 1, deviceMessageLog);
} else {
LOGGER.error("Caught IOException, connection with device is broken.", e);
}
} catch (final ConnectionFailureException e) {
throw e;
} catch (final Exception e) {
throw new ProtocolAdapterException(e == null ? "Could not execute command" : e.getMessage(), e);
}
return output;
}
use of com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850RtuDeviceReportingService method enableMeasurementReportingOnDevice.
private void enableMeasurementReportingOnDevice(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