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);
}
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);
}
}
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);
}
Aggregations