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