Search in sources :

Example 1 with ASdu

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

the class SinglePointWithQualityAsduHandlerTest method createAsdu.

private ASdu createAsdu() {
    final InformationObject ioLmd1 = this.createInformationObject(LMD_1_IOA, LMD_1_ON);
    final InformationObject ioLmd2 = this.createInformationObject(LMD_2_IOA, LMD_2_ON);
    return AsduBuilder.ofType(ASduType.M_SP_NA_1).withCauseOfTransmission(CauseOfTransmission.INTERROGATED_BY_STATION).withInformationObjects(ioLmd1, ioLmd2).build();
}
Also used : InformationObject(org.openmuc.j60870.ie.InformationObject)

Example 2 with ASdu

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

the class MeasurementAsduHandlerTest method shouldSendMeasurementReportWhenHandlingAsdu.

@Test
void shouldSendMeasurementReportWhenHandlingAsdu() throws Exception {
    // Arrange
    final ASdu asdu = AsduFactory.ofType(ASduType.M_ME_TF_1);
    final MeasurementReportDto measurementReportDto = this.mapper.map(asdu, MeasurementReportDto.class);
    final ResponseMetadata responseMetadata = new ResponseMetadata.Builder().withCorrelationUid(CORRELATION_UID).withDeviceIdentification(DEVICE_IDENTIFICATION).withDeviceType(DEVICE_TYPE).withOrganisationIdentification(ORGANISATION_IDENTIFICATION).build();
    when(this.converter.convert(asdu)).thenReturn(measurementReportDto);
    when(this.deviceResponseServiceRegistry.forDeviceType(DEVICE_TYPE)).thenReturn(this.deviceResponseService);
    // Act
    this.asduHandler.handleAsdu(asdu, responseMetadata);
    // Assert
    verify(this.deviceResponseService).process(measurementReportDto, responseMetadata);
}
Also used : MeasurementReportDto(org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto) ASdu(org.openmuc.j60870.ASdu) ResponseMetadata(org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.ResponseMetadata) Test(org.junit.jupiter.api.Test)

Example 3 with ASdu

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

the class Iec60870AsduConverterTest method shouldConvertAsduToMeasurementReportDto.

@Test
public void shouldConvertAsduToMeasurementReportDto() {
    // Arrange
    final MeasurementReportDto expected = MEASUREMENT_REPORT_DTO;
    final ASdu source = ASDU;
    // Act
    final MeasurementReportDto actual = this.mapper.map(source, MeasurementReportDto.class);
    // Assert
    assertThat(actual).isEqualTo(expected);
}
Also used : MeasurementReportDto(org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto) ASdu(org.openmuc.j60870.ASdu) Test(org.junit.jupiter.api.Test)

Example 4 with ASdu

use of org.openmuc.j60870.ASdu 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 5 with ASdu

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

the class ControlledStationSteps method sendInterrogationResponse.

private Object sendInterrogationResponse(final int commonAddress, final IeQualifierOfInterrogation qualifier, final ProcessImage processImage) {
    final ConnectionEventListener listener = this.connectionSteps.getConnectionEventListener();
    listener.newASdu(this.interrogationActivationConfirmationAsdu(commonAddress, qualifier));
    for (final ASdu asdu : processImage.toInterrogationAsdus(commonAddress, qualifier)) {
        listener.newASdu(asdu);
    }
    listener.newASdu(this.interrogationActivationTerminationAsdu(commonAddress, qualifier));
    return null;
}
Also used : ASdu(org.openmuc.j60870.ASdu) ConnectionEventListener(org.openmuc.j60870.ConnectionEventListener)

Aggregations

ASdu (org.openmuc.j60870.ASdu)20 Test (org.junit.jupiter.api.Test)14 InformationObject (org.openmuc.j60870.ie.InformationObject)9 LogItem (org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.LogItem)3 MeasurementReportDto (org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 When (io.cucumber.java.en.When)2 ASduType (org.openmuc.j60870.ASduType)2 IeQualifierOfInterrogation (org.openmuc.j60870.ie.IeQualifierOfInterrogation)2 ResponseMetadata (org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.ResponseMetadata)2 Iec60870AsduHandlerNotFoundException (org.opensmartgridplatform.iec60870.exceptions.Iec60870AsduHandlerNotFoundException)2 Iec60870AsduBuilder (org.opensmartgridplatform.simulator.protocol.iec60870.domain.Iec60870AsduBuilder)2 EOFException (java.io.EOFException)1 IOException (java.io.IOException)1 ZonedDateTime (java.time.ZonedDateTime)1 Random (java.util.Random)1 InOrder (org.mockito.InOrder)1 CauseOfTransmission (org.openmuc.j60870.CauseOfTransmission)1 Connection (org.openmuc.j60870.Connection)1 ConnectionEventListener (org.openmuc.j60870.ConnectionEventListener)1