use of org.openmuc.openiec61850.ServiceError in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850Client method readAllDataValues.
/**
* Read the values of all data attributes of all data objects of all Logical
* Nodes.
*
* @param clientAssociation
* An {@link ClientAssociation} instance.
*
* @throws NodeReadException
* In case the read action fails.
*/
public void readAllDataValues(final ClientAssociation clientAssociation) throws NodeReadException {
try {
LOGGER.debug("Start getAllDataValues from device");
clientAssociation.getAllDataValues();
LOGGER.debug("Completed getAllDataValues from device");
} catch (final ServiceError e) {
LOGGER.error("ServiceError during readAllDataValues", e);
throw new NodeReadException(e.getMessage(), e, ConnectionState.OK);
} catch (final IOException e) {
LOGGER.error("IOException during readAllDataValues", e);
throw new NodeReadException(e.getMessage(), e, ConnectionState.BROKEN);
}
}
use of org.openmuc.openiec61850.ServiceError 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 org.openmuc.openiec61850.ServiceError in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850Client method readServerModelFromDevice.
/**
* Read the device model from the device.
*
* @param clientAssociation
* The {@link ClientAssociation} instance.
*
* @return A {@link ServerModel} instance.
* @throws ProtocolAdapterException
*/
public ServerModel readServerModelFromDevice(final ClientAssociation clientAssociation) throws ProtocolAdapterException {
try {
LOGGER.debug("Start reading server model from device");
// RetrieveModel() will call all GetDirectory and GetDefinition ACSI
// services needed to get the complete server model.
final ServerModel serverModel = clientAssociation.retrieveModel();
LOGGER.debug("Completed reading server model from device");
return serverModel;
} catch (final ServiceError e) {
clientAssociation.close();
throw new ProtocolAdapterException("Service Error requesting model.", e);
} catch (final IOException e) {
throw new ProtocolAdapterException("Fatal IOException requesting model.", e);
}
}
Aggregations