Search in sources :

Example 1 with Iec60870AsduHandlerNotFoundException

use of org.opensmartgridplatform.iec60870.exceptions.Iec60870AsduHandlerNotFoundException in project open-smart-grid-platform by OSGP.

the class ClientAsduHandlerRegistry method getHandler.

public ClientAsduHandler getHandler(final ASdu asdu) throws Iec60870AsduHandlerNotFoundException {
    final ASduType asduType = asdu.getTypeIdentification();
    final ClientAsduHandler handler = this.handlers.get(asduType);
    if (handler == null) {
        LOGGER.error("Unable to process ASDU {}, no ASDU handler found for ASDU type {}", asdu, asduType);
        throw new Iec60870AsduHandlerNotFoundException(asduType);
    }
    return handler;
}
Also used : ASduType(org.openmuc.j60870.ASduType) Iec60870AsduHandlerNotFoundException(org.opensmartgridplatform.iec60870.exceptions.Iec60870AsduHandlerNotFoundException)

Example 2 with Iec60870AsduHandlerNotFoundException

use of org.opensmartgridplatform.iec60870.exceptions.Iec60870AsduHandlerNotFoundException in project open-smart-grid-platform by OSGP.

the class Iec60870ConnectionEventListener method newASdu.

@Override
public void newASdu(final ASdu asdu) {
    try {
        final ASduType asduType = asdu.getTypeIdentification();
        final Iec60870AsduHandler asduHandler = this.iec60870AsduHandlerRegistry.getHandler(asduType);
        asduHandler.handleAsdu(this.connection, asdu);
    } catch (final Iec60870AsduHandlerNotFoundException e) {
        LOGGER.error("Unknown request received, no handler available for ASDU: {}", asdu, e);
    } catch (final EOFException e) {
        LOGGER.error("Connection closed on connection ({}).", this.connection, e);
    } catch (final Exception e) {
        LOGGER.error("Exception occurred on connection ({}).", this.connection, e);
    }
}
Also used : ASduType(org.openmuc.j60870.ASduType) EOFException(java.io.EOFException) Iec60870AsduHandlerNotFoundException(org.opensmartgridplatform.iec60870.exceptions.Iec60870AsduHandlerNotFoundException) IOException(java.io.IOException) EOFException(java.io.EOFException) Iec60870AsduHandlerNotFoundException(org.opensmartgridplatform.iec60870.exceptions.Iec60870AsduHandlerNotFoundException)

Example 3 with Iec60870AsduHandlerNotFoundException

use of org.opensmartgridplatform.iec60870.exceptions.Iec60870AsduHandlerNotFoundException in project open-smart-grid-platform by OSGP.

the class ClientConnectionEventListener method newASdu.

@Override
public void newASdu(final ASdu asdu) {
    LOGGER.info("Received incoming ASDU from device {}:\n{}", this.deviceIdentification, asdu);
    try {
        final ResponseMetadata newResponseMetadata = this.responseMetadataFactory.createWithNewCorrelationUid(this.responseMetadata);
        final LogItem logItem = this.logItemFactory.create(asdu, this.deviceIdentification, newResponseMetadata.getOrganisationIdentification(), true);
        this.loggingService.log(logItem);
        final ClientAsduHandler asduHandler = this.asduHandlerRegistry.getHandler(asdu);
        asduHandler.handleAsdu(asdu, newResponseMetadata);
    } catch (final Iec60870AsduHandlerNotFoundException e) {
        LOGGER.error("Unknown request received, no handler available for ASDU: {}", asdu, e);
    } catch (final Exception e) {
        LOGGER.error("Exception occurred while handling an incoming ASDU from device {}.", this.deviceIdentification, e);
    }
}
Also used : LogItem(org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.LogItem) Iec60870AsduHandlerNotFoundException(org.opensmartgridplatform.iec60870.exceptions.Iec60870AsduHandlerNotFoundException) IOException(java.io.IOException) ResponseMetadata(org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.ResponseMetadata) Iec60870AsduHandlerNotFoundException(org.opensmartgridplatform.iec60870.exceptions.Iec60870AsduHandlerNotFoundException)

Aggregations

Iec60870AsduHandlerNotFoundException (org.opensmartgridplatform.iec60870.exceptions.Iec60870AsduHandlerNotFoundException)3 IOException (java.io.IOException)2 ASduType (org.openmuc.j60870.ASduType)2 EOFException (java.io.EOFException)1 LogItem (org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.LogItem)1 ResponseMetadata (org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.ResponseMetadata)1