Search in sources :

Example 41 with Value

use of org.openmuc.framework.data.Value 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

Value (org.openmuc.framework.data.Value)41 Record (org.openmuc.framework.data.Record)26 DoubleValue (org.openmuc.framework.data.DoubleValue)25 StringValue (org.openmuc.framework.data.StringValue)20 BooleanValue (org.openmuc.framework.data.BooleanValue)15 ByteArrayValue (org.openmuc.framework.data.ByteArrayValue)15 IntValue (org.openmuc.framework.data.IntValue)15 FloatValue (org.openmuc.framework.data.FloatValue)12 LongValue (org.openmuc.framework.data.LongValue)12 ShortValue (org.openmuc.framework.data.ShortValue)12 Flag (org.openmuc.framework.data.Flag)11 ByteValue (org.openmuc.framework.data.ByteValue)10 LoggingRecord (org.openmuc.framework.datalogger.spi.LoggingRecord)7 ChannelRecordContainer (org.openmuc.framework.driver.spi.ChannelRecordContainer)7 ArgumentSyntaxException (org.openmuc.framework.config.ArgumentSyntaxException)4 ConnectionException (org.openmuc.framework.driver.spi.ConnectionException)4 ModbusException (com.ghgande.j2mod.modbus.ModbusException)3 ModbusIOException (com.ghgande.j2mod.modbus.ModbusIOException)3 LinkedHashMap (java.util.LinkedHashMap)3 Test (org.junit.jupiter.api.Test)3