Search in sources :

Example 1 with TimestampMeasurementElementDto

use of org.opensmartgridplatform.dto.da.measurements.elements.TimestampMeasurementElementDto 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 TimestampMeasurementElementDto

use of org.opensmartgridplatform.dto.da.measurements.elements.TimestampMeasurementElementDto in project open-smart-grid-platform by OSGP.

the class DomainDistributionAutomationMapperTest method testTimestampMeasurementElementMapping.

@Test
public void testTimestampMeasurementElementMapping() {
    // Arrange
    final long value = 1556808340428l;
    final TimestampMeasurementElement expected = new TimestampMeasurementElement(value);
    final TimestampMeasurementElementDto dtoMeasurementElement = new TimestampMeasurementElementDto(value);
    // Act
    final TimestampMeasurementElement actual = this.mapper.map(dtoMeasurementElement, TimestampMeasurementElement.class);
    // Assert
    assertThat(actual).isEqualTo(expected);
}
Also used : TimestampMeasurementElementDto(org.opensmartgridplatform.dto.da.measurements.elements.TimestampMeasurementElementDto) TimestampMeasurementElement(org.opensmartgridplatform.domain.da.measurements.elements.TimestampMeasurementElement) Test(org.junit.jupiter.api.Test)

Example 3 with TimestampMeasurementElementDto

use of org.opensmartgridplatform.dto.da.measurements.elements.TimestampMeasurementElementDto in project open-smart-grid-platform by OSGP.

the class DtoMeasurementsFactory method gasFlowMeasurement.

public static MeasurementDto gasFlowMeasurement(final float gasFlow) {
    final BitmaskMeasurementElementDto flags = new BitmaskMeasurementElementDto((byte) 96);
    final TimestampMeasurementElementDto from = new TimestampMeasurementElementDto(1546800000501L);
    final TimestampMeasurementElementDto until = new TimestampMeasurementElementDto(1546700000444L);
    final FloatMeasurementElementDto cubicMeters = new FloatMeasurementElementDto(gasFlow);
    final List<MeasurementElementDto> measurementElements = new ArrayList<>();
    measurementElements.add(flags);
    measurementElements.add(from);
    measurementElements.add(until);
    measurementElements.add(cubicMeters);
    return DtoMeasurementsFactory.measurementFrom(measurementElements);
}
Also used : TimestampMeasurementElementDto(org.opensmartgridplatform.dto.da.measurements.elements.TimestampMeasurementElementDto) FloatMeasurementElementDto(org.opensmartgridplatform.dto.da.measurements.elements.FloatMeasurementElementDto) BitmaskMeasurementElementDto(org.opensmartgridplatform.dto.da.measurements.elements.BitmaskMeasurementElementDto) TimestampMeasurementElementDto(org.opensmartgridplatform.dto.da.measurements.elements.TimestampMeasurementElementDto) FloatMeasurementElementDto(org.opensmartgridplatform.dto.da.measurements.elements.FloatMeasurementElementDto) MeasurementElementDto(org.opensmartgridplatform.dto.da.measurements.MeasurementElementDto) ArrayList(java.util.ArrayList) BitmaskMeasurementElementDto(org.opensmartgridplatform.dto.da.measurements.elements.BitmaskMeasurementElementDto)

Aggregations

TimestampMeasurementElementDto (org.opensmartgridplatform.dto.da.measurements.elements.TimestampMeasurementElementDto)3 Test (org.junit.jupiter.api.Test)2 ArrayList (java.util.ArrayList)1 IeTime56 (org.openmuc.j60870.ie.IeTime56)1 TimestampMeasurementElement (org.opensmartgridplatform.domain.da.measurements.elements.TimestampMeasurementElement)1 MeasurementElementDto (org.opensmartgridplatform.dto.da.measurements.MeasurementElementDto)1 BitmaskMeasurementElementDto (org.opensmartgridplatform.dto.da.measurements.elements.BitmaskMeasurementElementDto)1 FloatMeasurementElementDto (org.opensmartgridplatform.dto.da.measurements.elements.FloatMeasurementElementDto)1