use of org.openmuc.j60870.ASdu 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.ASdu in project open-smart-grid-platform by OSGP.
the class Iec60870ServerEventListener method sendInformationUpdateEvent.
public void sendInformationUpdateEvent(final int informationObjectAddress, final InformationElement[][] informationElements) {
final ASdu event = new ASdu(ASduType.M_SP_TB_1, false, CauseOfTransmission.SPONTANEOUS, false, false, 0, 0, new InformationObject(informationObjectAddress, informationElements));
this.iec60870ConnectionRegistry.getAllConnections().forEach(connection -> this.sendEvent(connection, event));
}
use of org.openmuc.j60870.ASdu in project open-smart-grid-platform by OSGP.
the class GeneralInterrogationService method sendGeneralInterrogation.
public void sendGeneralInterrogation(final ClientConnection deviceConnection, final RequestMetadata requestMetadata) throws IOException {
final String connectedDevice = deviceConnection.getConnectionParameters().getDeviceIdentification();
final int commonAddress = deviceConnection.getConnectionParameters().getCommonAddress();
deviceConnection.getConnection().interrogation(commonAddress, CauseOfTransmission.ACTIVATION, new IeQualifierOfInterrogation(QUALIFIER_OF_INTERROGATION_ID));
// interrogation command creates this asdu internally, however we
// need it here as well for logging...
final ASdu asdu = new ASdu(ASduType.C_IC_NA_1, false, CauseOfTransmission.ACTIVATION, false, false, ORIGINATOR_ADDRESS, commonAddress, new InformationObject(0, new IeQualifierOfInterrogation(QUALIFIER_OF_INTERROGATION_ID)));
final LogItem logItem = new LogItem(connectedDevice, requestMetadata.getOrganisationIdentification(), false, asdu.toString());
this.loggingService.log(logItem);
}
use of org.openmuc.j60870.ASdu in project open-smart-grid-platform by OSGP.
the class Iec60870InterrogationCommandAsduHandler method handleAsdu.
@Override
public void handleAsdu(final Connection connection, final ASdu asdu) throws IOException {
LOGGER.info("Received interrogation command. Sending confirmation for ASDU: {}", asdu);
connection.sendConfirmation(asdu);
final ASdu responseAsdu = this.iec60870AsduFactory.createInterrogationCommandResponseAsdu();
LOGGER.info("Processing interrogation command. Sending response ASDU: {}.", responseAsdu);
connection.send(responseAsdu);
final ASdu terminationAsdu = this.iec60870AsduFactory.createActivationTerminationResponseAsdu();
LOGGER.info("Finished processing interrogation command. Sending termination ASDU: {}", terminationAsdu);
connection.send(terminationAsdu);
}
use of org.openmuc.j60870.ASdu in project open-smart-grid-platform by OSGP.
the class DefaultControlledStationAsduFactoryTest method testCreateInterrogationCommandResponse.
@Test
void testCreateInterrogationCommandResponse() {
// Arrange
this.iec60870AsduFactory.initialize();
final InformationObject[] expectedInformationObjects = new InformationObject[2];
expectedInformationObjects[0] = new InformationObject(9127, this.createInformationElement(10.0f));
expectedInformationObjects[1] = new InformationObject(9128, this.createInformationElement(20.5f));
final ASdu expected = new ASdu(ASduType.M_ME_NC_1, false, CauseOfTransmission.INTERROGATED_BY_STATION, false, false, 0, 1, expectedInformationObjects);
// Act
final ASdu actual = this.iec60870AsduFactory.createInterrogationCommandResponseAsdu();
// Assert
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
}
Aggregations