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);
}
// }
}
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);
}
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);
}
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);
}
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);
}
Aggregations