Search in sources :

Example 1 with InformationObject

use of org.openmuc.j60870.ie.InformationObject 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 InformationObject

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

the class Iec60870InformationObjectConverterTest method testConvertInformationObjectToMeasurementGroupDto.

@Test
public void testConvertInformationObjectToMeasurementGroupDto() {
    // Arrange
    final MeasurementGroupDto expected = MEASUREMENT_GROUP_DTO;
    final InformationObject source = INFORMATION_OBJECT;
    // Act
    final MeasurementGroupDto actual = this.mapper.map(source, MeasurementGroupDto.class);
    // Assert
    assertThat(actual).isEqualTo(expected);
}
Also used : MeasurementGroupDto(org.opensmartgridplatform.dto.da.measurements.MeasurementGroupDto) InformationObject(org.openmuc.j60870.ie.InformationObject) Test(org.junit.jupiter.api.Test)

Example 3 with InformationObject

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

the class LightMeasurementDeviceAsduFactory method createLightMeasurementEvent.

public ASdu createLightMeasurementEvent() {
    final long timestamp = System.currentTimeMillis();
    final InformationObject[] informationObjects = new InformationObject[1];
    final int index = new Random().nextInt(this.ioa.length);
    this.switchValue(index);
    final String eventValue = this.iev[index] ? "DARK" : "LIGHT";
    LOGGER.info("Creating Light Measurement event for IOA {} with value {} ({})", this.ioa[index], this.iev[index], eventValue);
    informationObjects[0] = new InformationObject(this.ioa[index], this.createInformationElementWithTimetag(this.iev[index], timestamp));
    return new Iec60870AsduBuilder().withAsduType(ASduType.M_SP_TB_1).withSequenceOfElements(false).withCauseOfTransmission(CauseOfTransmission.SPONTANEOUS).withInformationObjects(informationObjects).build();
}
Also used : Random(java.util.Random) InformationObject(org.openmuc.j60870.ie.InformationObject) Iec60870AsduBuilder(org.opensmartgridplatform.simulator.protocol.iec60870.domain.Iec60870AsduBuilder)

Example 4 with InformationObject

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

the class LightMeasurementDeviceAsduFactoryTest method shouldCreateInterrogationCommandResponse.

@Test
void shouldCreateInterrogationCommandResponse() {
    // Arrange
    this.iec60870AsduFactory.initialize();
    final InformationObject[] expectedInformationObjects = new InformationObject[4];
    expectedInformationObjects[0] = new InformationObject(42, this.createInformationElement(false));
    expectedInformationObjects[1] = new InformationObject(78, this.createInformationElement(false));
    expectedInformationObjects[2] = new InformationObject(127, this.createInformationElement(true));
    expectedInformationObjects[3] = new InformationObject(95, this.createInformationElement(false));
    final ASdu expected = new ASdu(ASduType.M_SP_NA_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 5 with InformationObject

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

the class DefaultControlledStationAsduFactory method createShortFloatingPointMeasurementAsdu.

public ASdu createShortFloatingPointMeasurementAsdu() {
    final ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
    final long timestamp = now.toInstant().toEpochMilli();
    final float hour = now.getHour();
    final float minute = now.getMinute();
    final InformationObject[] informationObjects = new InformationObject[this.ioa.length];
    for (int index = 0; index < this.ioa.length; index++) {
        final float value = (index == 0 ? hour : minute);
        informationObjects[index] = new InformationObject(this.ioa[index], this.createInformationElementWithTimetag(value, timestamp));
    }
    return new Iec60870AsduBuilder().withAsduType(ASduType.M_ME_TF_1).withSequenceOfElements(false).withCauseOfTransmission(CauseOfTransmission.SPONTANEOUS).withInformationObjects(informationObjects).build();
}
Also used : ZonedDateTime(java.time.ZonedDateTime) InformationObject(org.openmuc.j60870.ie.InformationObject) Iec60870AsduBuilder(org.opensmartgridplatform.simulator.protocol.iec60870.domain.Iec60870AsduBuilder)

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