Search in sources :

Example 6 with InformationObject

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);
}
Also used : IeSinglePointWithQuality(org.openmuc.j60870.ie.IeSinglePointWithQuality) IeTime56(org.openmuc.j60870.ie.IeTime56) InformationObject(org.openmuc.j60870.ie.InformationObject) ASdu(org.openmuc.j60870.ASdu) When(io.cucumber.java.en.When)

Example 7 with InformationObject

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));
}
Also used : ASdu(org.openmuc.j60870.ASdu) InformationObject(org.openmuc.j60870.ie.InformationObject)

Example 8 with InformationObject

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);
}
Also used : LogItem(org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.LogItem) IeQualifierOfInterrogation(org.openmuc.j60870.ie.IeQualifierOfInterrogation) ASdu(org.openmuc.j60870.ASdu) InformationObject(org.openmuc.j60870.ie.InformationObject)

Example 9 with InformationObject

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);
}
Also used : InformationObject(org.openmuc.j60870.ie.InformationObject) ASdu(org.openmuc.j60870.ASdu) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 10 with InformationObject

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);
}
Also used : DefaultControlledStationAsduFactory(org.opensmartgridplatform.simulator.protocol.iec60870.domain.defaultcontrolledstation.DefaultControlledStationAsduFactory) ASdu(org.openmuc.j60870.ASdu) InformationObject(org.openmuc.j60870.ie.InformationObject) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

InformationObject (org.openmuc.j60870.ie.InformationObject)10 ASdu (org.openmuc.j60870.ASdu)6 Test (org.junit.jupiter.api.Test)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 Iec60870AsduBuilder (org.opensmartgridplatform.simulator.protocol.iec60870.domain.Iec60870AsduBuilder)2 When (io.cucumber.java.en.When)1 ZonedDateTime (java.time.ZonedDateTime)1 Random (java.util.Random)1 IeQualifierOfInterrogation (org.openmuc.j60870.ie.IeQualifierOfInterrogation)1 IeSinglePointWithQuality (org.openmuc.j60870.ie.IeSinglePointWithQuality)1 IeTime56 (org.openmuc.j60870.ie.IeTime56)1 LogItem (org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.LogItem)1 MeasurementGroupDto (org.opensmartgridplatform.dto.da.measurements.MeasurementGroupDto)1 DefaultControlledStationAsduFactory (org.opensmartgridplatform.simulator.protocol.iec60870.domain.defaultcontrolledstation.DefaultControlledStationAsduFactory)1