use of org.openmuc.j60870.ie.InformationObject in project open-smart-grid-platform by OSGP.
the class AsduSteps method aLightMeasurementOccursForAddress.
@When("a light measurement event occurs for address {int} with value {string}")
public void aLightMeasurementOccursForAddress(final int informationObjectAddress, final String informationElementValue) {
final boolean on = "ON".equalsIgnoreCase(informationElementValue);
final InformationObject[] informationObjects = { new InformationObject(informationObjectAddress, new IeSinglePointWithQuality(on, false, false, false, false), new IeTime56(System.currentTimeMillis(), TimeZone.getDefault(), false)) };
final ASdu asdu = new ASdu(ASduType.M_SP_TB_1, false, CauseOfTransmission.SPONTANEOUS, false, false, 0, 1, informationObjects);
this.connectionSteps.getConnectionEventListener().newASdu(asdu);
}
use of org.openmuc.j60870.ie.InformationObject 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.ie.InformationObject 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.ie.InformationObject 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);
}
use of org.openmuc.j60870.ie.InformationObject in project open-smart-grid-platform by OSGP.
the class DefaultControlledStationAsduFactoryTest method testCreateSingleCommand.
@Test
void testCreateSingleCommand() {
// Arrange
final DefaultControlledStationAsduFactory defaultControlledAsduFactory = new DefaultControlledStationAsduFactory();
final ASdu expected = new ASdu(ASduType.C_SC_NA_1, false, CauseOfTransmission.SPONTANEOUS, false, false, 0, 1, new InformationObject[] { new InformationObject(0, this.informationElementFactory.createInformationElements(Iec60870InformationObjectType.QUALIFIER_OF_INTERROGATION, 20)) });
// Act
final ASdu actual = defaultControlledAsduFactory.createSingleCommandAsdu();
// Assert
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
}
Aggregations