Search in sources :

Example 1 with ServiceError

use of com.beanit.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);
    }
}
Also used : ServiceError(org.openmuc.openiec61850.ServiceError) NodeReadException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException) IOException(java.io.IOException)

Example 2 with ServiceError

use of com.beanit.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);
    }
}
Also used : ServiceError(org.openmuc.openiec61850.ServiceError) ServerModel(org.openmuc.openiec61850.ServerModel) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) IOException(java.io.IOException)

Example 3 with ServiceError

use of com.beanit.openiec61850.ServiceError in project open-smart-grid-platform 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);
    }
}
Also used : ServiceError(com.beanit.openiec61850.ServiceError) NodeReadException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeReadException) IOException(java.io.IOException)

Example 4 with ServiceError

use of com.beanit.openiec61850.ServiceError in project open-smart-grid-platform by OSGP.

the class RtuSimulator method write.

@Override
public List<ServiceError> write(final List<BasicDataAttribute> bdas) {
    for (final BasicDataAttribute bda : bdas) {
        LOGGER.info("got a write request: {}", bda);
        this.writeValueAndUpdateRelatedAttributes(bda);
    }
    return new ArrayList<>();
}
Also used : ArrayList(java.util.ArrayList) BasicDataAttribute(com.beanit.openiec61850.BasicDataAttribute)

Example 5 with ServiceError

use of com.beanit.openiec61850.ServiceError in project open-smart-grid-platform 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 ProtocolAdapterException e) {
        throw e;
    } catch (final Exception e) {
        throw new ProtocolAdapterException(e.getMessage() == null ? COULD_NOT_EXECUTE_COMMAND : e.getMessage(), e);
    }
    return output;
}
Also used : DeviceMessageLog(org.opensmartgridplatform.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog) NodeWriteException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeWriteException) NodeReadException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeReadException) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) NodeReadException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeReadException) ConnectionFailureException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) IOException(java.io.IOException) SclParseException(com.beanit.openiec61850.SclParseException) NodeWriteException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeWriteException)

Aggregations

IOException (java.io.IOException)5 ServiceError (com.beanit.openiec61850.ServiceError)2 ServiceError (org.openmuc.openiec61850.ServiceError)2 NodeReadException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeReadException)2 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)2 NodeReadException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException)1 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)1 BasicDataAttribute (com.beanit.openiec61850.BasicDataAttribute)1 SclParseException (com.beanit.openiec61850.SclParseException)1 ServerModel (com.beanit.openiec61850.ServerModel)1 ArrayList (java.util.ArrayList)1 ServerModel (org.openmuc.openiec61850.ServerModel)1 DeviceMessageLog (org.opensmartgridplatform.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog)1 ConnectionFailureException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException)1 NodeWriteException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeWriteException)1