Search in sources :

Example 6 with ASduType

use of org.openmuc.j60870.ASduType in project open-smart-grid-platform by OSGP.

the class AsduSteps method whenIReceiveAsduOfType.

@When("I receive an ASDU of type {string} from the IEC60870 device")
public void whenIReceiveAsduOfType(final String asduType) {
    LOGGER.debug("When I receive an ASDU of type {}", asduType);
    final ASdu asdu = AsduFactory.ofType(ASduType.valueOf(asduType));
    this.connectionSteps.getConnectionEventListener().newASdu(asdu);
}
Also used : ASdu(org.openmuc.j60870.ASdu) When(io.cucumber.java.en.When)

Example 7 with ASduType

use of org.openmuc.j60870.ASduType 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 8 with ASduType

use of org.openmuc.j60870.ASduType 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)7 Test (org.junit.jupiter.api.Test)5 Iec60870AsduHandlerNotFoundException (org.opensmartgridplatform.iec60870.exceptions.Iec60870AsduHandlerNotFoundException)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)2 Iec60870AsduHandler (org.opensmartgridplatform.iec60870.Iec60870AsduHandler)2 When (io.cucumber.java.en.When)1 EOFException (java.io.EOFException)1 IOException (java.io.IOException)1 ASdu (org.openmuc.j60870.ASdu)1 Iec60870InterrogationCommandAsduHandler (org.opensmartgridplatform.simulator.protocol.iec60870.server.handlers.Iec60870InterrogationCommandAsduHandler)1 Iec60870SingleCommandAsduHandler (org.opensmartgridplatform.simulator.protocol.iec60870.server.handlers.Iec60870SingleCommandAsduHandler)1