Search in sources :

Example 1 with IeTime56

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

the class IeTime56ConverterTest method shouldConvertIeTime56ToTimestamp.

@Test
public void shouldConvertIeTime56ToTimestamp() {
    // Arrange
    final long timestamp = ZonedDateTime.now(ZoneOffset.UTC).toInstant().toEpochMilli();
    final TimestampMeasurementElementDto expected = new TimestampMeasurementElementDto(timestamp);
    final IeTime56 source = new IeTime56(timestamp, this.timeZone, false);
    // Act
    final TimestampMeasurementElementDto actual = this.converter.convert(source, null, null);
    // Assert
    assertThat(actual).isEqualTo(expected);
}
Also used : TimestampMeasurementElementDto(org.opensmartgridplatform.dto.da.measurements.elements.TimestampMeasurementElementDto) IeTime56(org.openmuc.j60870.ie.IeTime56) Test(org.junit.jupiter.api.Test)

Example 2 with IeTime56

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

the class LightMeasurementDeviceAsduFactory method createInformationElementWithTimetag.

private InformationElement[][] createInformationElementWithTimetag(final boolean value, final long timestamp) {
    final TimeZone timeZone = TimeZone.getTimeZone(this.timeZoneString);
    final boolean invalid = false;
    return new InformationElement[][] { { new IeSinglePointWithQuality(value, false, false, false, false), new IeTime56(timestamp, timeZone, invalid) } };
}
Also used : IeSinglePointWithQuality(org.openmuc.j60870.ie.IeSinglePointWithQuality) TimeZone(java.util.TimeZone) IeTime56(org.openmuc.j60870.ie.IeTime56) InformationElement(org.openmuc.j60870.ie.InformationElement)

Example 3 with IeTime56

use of org.openmuc.j60870.ie.IeTime56 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 4 with IeTime56

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

the class Iec60870Server method addTimestamp.

private static InformationElement[][] addTimestamp(final InformationElement[][] informationElements) {
    final InformationElement[][] result = Arrays.copyOf(informationElements, 2);
    result[1] = new InformationElement[] { new IeTime56(System.currentTimeMillis()) };
    return result;
}
Also used : IeTime56(org.openmuc.j60870.ie.IeTime56)

Aggregations

IeTime56 (org.openmuc.j60870.ie.IeTime56)4 IeSinglePointWithQuality (org.openmuc.j60870.ie.IeSinglePointWithQuality)2 When (io.cucumber.java.en.When)1 TimeZone (java.util.TimeZone)1 Test (org.junit.jupiter.api.Test)1 ASdu (org.openmuc.j60870.ASdu)1 InformationElement (org.openmuc.j60870.ie.InformationElement)1 InformationObject (org.openmuc.j60870.ie.InformationObject)1 TimestampMeasurementElementDto (org.opensmartgridplatform.dto.da.measurements.elements.TimestampMeasurementElementDto)1