Search in sources :

Example 1 with Record

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

the class LogFileReaderTestSingleFile method setup.

@BeforeAll
public static void setup() {
    System.out.println("### Setup() LogFileReaderTestSingleFile");
    TestUtils.createTestFolder();
    // File file = new File(TestUtils.TESTFOLDERPATH + fileDate0 + "_" + loggingInterval + ext);
    // if (file.exists()) {
    // Do nothing, file exists.
    // }
    // else {
    // eine Datei
    channelIds = new String[] { "power" };
    // Logs 1 channel in second interval from 1 to 3 o'clock
    HashMap<String, LogChannel> logChannelList = new HashMap<>();
    LogChannelTestImpl ch1 = new LogChannelTestImpl(Channel0Name, "", "dummy description", "kW", ValueType.DOUBLE, 0.0, 0.0, false, 1000, 0, "", loggingInterval, loggingTimeOffset, false, false);
    logChannelList.put(Channel0Name, ch1);
    Calendar calendar = TestUtils.stringToDate(dateFormat, fileDate0 + " 01:00:00");
    for (int i = 0; i < ((60 * 60 * 2) * (1000d / loggingInterval)); i++) {
        LoggingRecord container1 = new LoggingRecord(Channel0Name, new Record(new DoubleValue(i), calendar.getTimeInMillis()));
        LogIntervalContainerGroup group = new LogIntervalContainerGroup();
        group.add(container1);
        LogFileWriter lfw = new LogFileWriter(TestUtils.TESTFOLDERPATH, false);
        lfw.log(group, loggingInterval, 0, calendar, logChannelList);
        AsciiLogger.setLastLoggedLineTimeStamp(loggingInterval, 0, calendar.getTimeInMillis());
        calendar.add(Calendar.MILLISECOND, loggingInterval);
    }
// }
}
Also used : HashMap(java.util.HashMap) DoubleValue(org.openmuc.framework.data.DoubleValue) Calendar(java.util.Calendar) LogChannel(org.openmuc.framework.datalogger.spi.LogChannel) LogIntervalContainerGroup(org.openmuc.framework.datalogger.ascii.LogIntervalContainerGroup) Record(org.openmuc.framework.data.Record) LoggingRecord(org.openmuc.framework.datalogger.spi.LoggingRecord) LogFileWriter(org.openmuc.framework.datalogger.ascii.LogFileWriter) LoggingRecord(org.openmuc.framework.datalogger.spi.LoggingRecord) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with Record

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

the class LogFileReaderTestSingleFile method tc004_t1_t2_after_available_data.

@Test
public void tc004_t1_t2_after_available_data() {
    System.out.println("### Begin test tc004_t1_t2_after_available_data");
    // test 5 - startTimestampRequest & endTimestampRequest after available logged data
    long t1 = TestUtils.stringToDate(dateFormat, fileDate0 + " 03:00:01").getTimeInMillis();
    long t2 = TestUtils.stringToDate(dateFormat, fileDate0 + " 03:59:59").getTimeInMillis();
    LogFileReader fr = new LogFileReader(TestUtils.TESTFOLDERPATH, channelTestImpl);
    List<Record> records = fr.getValues(t1, t2).get(channelTestImpl.getId());
    long expectedRecords = 0;
    boolean result;
    if (records.size() == expectedRecords) {
        result = true;
    } else {
        result = false;
    }
    System.out.print(Thread.currentThread().getStackTrace()[1].getMethodName());
    System.out.println(" records = " + records.size() + " (" + expectedRecords + " expected)");
    assertTrue(result);
}
Also used : LogFileReader(org.openmuc.framework.datalogger.ascii.LogFileReader) Record(org.openmuc.framework.data.Record) LoggingRecord(org.openmuc.framework.datalogger.spi.LoggingRecord) Test(org.junit.jupiter.api.Test)

Example 3 with Record

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

the class LogFileReaderTestSingleFile method tc002_t2_after_available_data.

@Test
public void tc002_t2_after_available_data() {
    System.out.println("### Begin test tc002_t2_after_available_data");
    long t1 = TestUtils.stringToDate(dateFormat, fileDate0 + " 01:00:00").getTimeInMillis();
    long t2 = TestUtils.stringToDate(dateFormat, fileDate0 + " 02:00:00").getTimeInMillis();
    LogFileReader fr = new LogFileReader(TestUtils.TESTFOLDERPATH, channelTestImpl);
    List<Record> records = fr.getValues(t1, t2).get(channelTestImpl.getId());
    // 
    long expectedRecords = 361;
    boolean result;
    if (records.size() == expectedRecords) {
        result = true;
    } else {
        result = false;
    }
    System.out.print(Thread.currentThread().getStackTrace()[1].getMethodName());
    System.out.println(" records = " + records.size() + " (" + expectedRecords + " expected)");
    assertTrue(result);
}
Also used : LogFileReader(org.openmuc.framework.datalogger.ascii.LogFileReader) Record(org.openmuc.framework.data.Record) LoggingRecord(org.openmuc.framework.datalogger.spi.LoggingRecord) Test(org.junit.jupiter.api.Test)

Example 4 with Record

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

the class LogFileReaderTestSingleFile method tc001_t1_before_available_data_t2_within.

@Test
public void tc001_t1_before_available_data_t2_within() {
    System.out.println("### Begin test tc001_t1_before_available_data_t2_within");
    long t1 = TestUtils.stringToDate(dateFormat, fileDate0 + " 00:00:00").getTimeInMillis();
    long t2 = TestUtils.stringToDate(dateFormat, fileDate0 + " 00:00:10").getTimeInMillis();
    LogFileReader fr = new LogFileReader(TestUtils.TESTFOLDERPATH, channelTestImpl);
    List<Record> records = fr.getValues(t1, t2).get(channelTestImpl.getId());
    long expectedRecords = 0;
    boolean result;
    if (records.size() == expectedRecords) {
        result = true;
    } else {
        result = false;
    }
    System.out.print(Thread.currentThread().getStackTrace()[1].getMethodName());
    System.out.println(" records = " + records.size() + " (" + expectedRecords + " expected)");
    assertTrue(result);
}
Also used : LogFileReader(org.openmuc.framework.datalogger.ascii.LogFileReader) Record(org.openmuc.framework.data.Record) LoggingRecord(org.openmuc.framework.datalogger.spi.LoggingRecord) Test(org.junit.jupiter.api.Test)

Example 5 with Record

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

the class LogFileReaderTestSingleFile method tc000_t1_t2_within_available_data.

@Test
public void tc000_t1_t2_within_available_data() {
    System.out.println("### Begin test tc000_t1_t2_within_available_data");
    long t1 = TestUtils.stringToDate(dateFormat, fileDate0 + " 01:50:00").getTimeInMillis();
    long t2 = TestUtils.stringToDate(dateFormat, fileDate0 + " 01:51:00").getTimeInMillis();
    LogFileReader fr = new LogFileReader(TestUtils.TESTFOLDERPATH, channelTestImpl);
    List<Record> records = fr.getValues(t1, t2).get(channelTestImpl.getId());
    long expectedRecords = 7;
    boolean result;
    if (records.size() == expectedRecords) {
        result = true;
    } else {
        result = false;
    }
    System.out.print(Thread.currentThread().getStackTrace()[1].getMethodName());
    System.out.println(" records = " + records.size() + " (" + expectedRecords + " expected)");
    assertTrue(result);
}
Also used : LogFileReader(org.openmuc.framework.datalogger.ascii.LogFileReader) Record(org.openmuc.framework.data.Record) LoggingRecord(org.openmuc.framework.datalogger.spi.LoggingRecord) Test(org.junit.jupiter.api.Test)

Aggregations

Record (org.openmuc.framework.data.Record)115 DoubleValue (org.openmuc.framework.data.DoubleValue)34 LoggingRecord (org.openmuc.framework.datalogger.spi.LoggingRecord)34 Value (org.openmuc.framework.data.Value)26 ChannelRecordContainer (org.openmuc.framework.driver.spi.ChannelRecordContainer)24 Test (org.junit.jupiter.api.Test)21 StringValue (org.openmuc.framework.data.StringValue)20 BooleanValue (org.openmuc.framework.data.BooleanValue)18 ByteArrayValue (org.openmuc.framework.data.ByteArrayValue)14 ArrayList (java.util.ArrayList)13 IntValue (org.openmuc.framework.data.IntValue)13 FloatValue (org.openmuc.framework.data.FloatValue)12 LongValue (org.openmuc.framework.data.LongValue)12 ShortValue (org.openmuc.framework.data.ShortValue)12 LogFileReader (org.openmuc.framework.datalogger.ascii.LogFileReader)12 ConnectionException (org.openmuc.framework.driver.spi.ConnectionException)12 ByteValue (org.openmuc.framework.data.ByteValue)10 Flag (org.openmuc.framework.data.Flag)10 IOException (java.io.IOException)9 HashMap (java.util.HashMap)7