Search in sources :

Example 1 with Iec60870AsduHandler

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

the class Iec60870AsduHandlerRegistryTest method registryShouldReturnSingleCommandHandlerForSingleCommandAsduType.

@Test
public void registryShouldReturnSingleCommandHandlerForSingleCommandAsduType() throws Exception {
    // arrange
    final ASduType asduType = ASduType.C_SC_NA_1;
    final Iec60870SingleCommandAsduHandler expected = this.iec60870SingleCommandAsduHandler;
    // act
    final Iec60870AsduHandler actual = this.iec60870AsduHandlerRegistry.getHandler(asduType);
    // assert
    assertThat(actual).isEqualTo(expected);
}
Also used : ASduType(org.openmuc.j60870.ASduType) Iec60870AsduHandler(org.opensmartgridplatform.iec60870.Iec60870AsduHandler) Iec60870SingleCommandAsduHandler(org.opensmartgridplatform.simulator.protocol.iec60870.server.handlers.Iec60870SingleCommandAsduHandler) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with Iec60870AsduHandler

use of org.opensmartgridplatform.iec60870.Iec60870AsduHandler 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 Iec60870AsduHandler

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

the class Iec60870AsduHandlerRegistryTest method registryShouldReturnInterrogationCommandHandlerForInterrogationCommandAsduType.

@Test
public void registryShouldReturnInterrogationCommandHandlerForInterrogationCommandAsduType() throws Exception {
    // arrange
    final ASduType asduType = ASduType.C_IC_NA_1;
    final Iec60870InterrogationCommandAsduHandler expected = this.iec60870InterrogationCommandAsduHandler;
    // act
    final Iec60870AsduHandler actual = this.iec60870AsduHandlerRegistry.getHandler(asduType);
    // assert
    assertThat(actual).isEqualTo(expected);
}
Also used : ASduType(org.openmuc.j60870.ASduType) Iec60870AsduHandler(org.opensmartgridplatform.iec60870.Iec60870AsduHandler) Iec60870InterrogationCommandAsduHandler(org.opensmartgridplatform.simulator.protocol.iec60870.server.handlers.Iec60870InterrogationCommandAsduHandler) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

ASduType (org.openmuc.j60870.ASduType)3 Test (org.junit.jupiter.api.Test)2 Iec60870AsduHandler (org.opensmartgridplatform.iec60870.Iec60870AsduHandler)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 EOFException (java.io.EOFException)1 IOException (java.io.IOException)1 Iec60870AsduHandlerNotFoundException (org.opensmartgridplatform.iec60870.exceptions.Iec60870AsduHandlerNotFoundException)1 Iec60870InterrogationCommandAsduHandler (org.opensmartgridplatform.simulator.protocol.iec60870.server.handlers.Iec60870InterrogationCommandAsduHandler)1 Iec60870SingleCommandAsduHandler (org.opensmartgridplatform.simulator.protocol.iec60870.server.handlers.Iec60870SingleCommandAsduHandler)1