Search in sources :

Example 31 with DoubleValue

use of org.openmuc.framework.data.DoubleValue in project OpenMUC by isc-konstanz.

the class OpenmucParserServiceImplTest method serializeMultipleRecords.

@Test
void serializeMultipleRecords() throws SerializationException {
    StringBuilder sb = new StringBuilder();
    sb.append("{\"timestamp\":1582722316,\"flag\":\"VALID\",\"value\":3.0}");
    sb.append("\n");
    sb.append("{\"timestamp\":1582722316,\"flag\":\"VALID\",\"value\":5.0}");
    sb.append("\n");
    String controlString = sb.toString();
    Value doubleValue1 = new DoubleValue(3.0);
    long timestamp1 = 1582722316;
    Flag flag1 = Flag.VALID;
    Record record1 = new Record(doubleValue1, timestamp1, flag1);
    Value doubleValue2 = new DoubleValue(5.0);
    long timestamp2 = 1582722316;
    Flag flag2 = Flag.VALID;
    Record record2 = new Record(doubleValue2, timestamp2, flag2);
    List<LoggingRecord> openMucRecords = new ArrayList<>();
    openMucRecords.add(new LoggingRecord("channel1", record1));
    openMucRecords.add(new LoggingRecord("channel2", record2));
    byte[] serializedRecord = parserService.serialize(openMucRecords);
    String serializedJson = new String(serializedRecord);
    assertEquals(controlString, serializedJson);
}
Also used : DoubleValue(org.openmuc.framework.data.DoubleValue) ByteArrayValue(org.openmuc.framework.data.ByteArrayValue) DoubleValue(org.openmuc.framework.data.DoubleValue) StringValue(org.openmuc.framework.data.StringValue) Value(org.openmuc.framework.data.Value) ArrayList(java.util.ArrayList) Record(org.openmuc.framework.data.Record) LoggingRecord(org.openmuc.framework.datalogger.spi.LoggingRecord) Flag(org.openmuc.framework.data.Flag) LoggingRecord(org.openmuc.framework.datalogger.spi.LoggingRecord) Test(org.junit.jupiter.api.Test)

Aggregations

DoubleValue (org.openmuc.framework.data.DoubleValue)31 Record (org.openmuc.framework.data.Record)26 StringValue (org.openmuc.framework.data.StringValue)14 IntValue (org.openmuc.framework.data.IntValue)12 Value (org.openmuc.framework.data.Value)12 ByteArrayValue (org.openmuc.framework.data.ByteArrayValue)11 FloatValue (org.openmuc.framework.data.FloatValue)11 LongValue (org.openmuc.framework.data.LongValue)11 ShortValue (org.openmuc.framework.data.ShortValue)11 BooleanValue (org.openmuc.framework.data.BooleanValue)10 LoggingRecord (org.openmuc.framework.datalogger.spi.LoggingRecord)10 ByteValue (org.openmuc.framework.data.ByteValue)8 ArrayList (java.util.ArrayList)5 Flag (org.openmuc.framework.data.Flag)4 HashMap (java.util.HashMap)3 Test (org.junit.jupiter.api.Test)3 LogIntervalContainerGroup (org.openmuc.framework.datalogger.ascii.LogIntervalContainerGroup)3 Read (org.openmuc.framework.driver.annotation.Read)3 Calendar (java.util.Calendar)2 LinkedList (java.util.LinkedList)2