use of org.openmuc.framework.datalogger.spi.LoggingRecord 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.datalogger.spi.LoggingRecord in project OpenMUC by isc-konstanz.
the class LogFileWriterTest method getGroup.
private static LogIntervalContainerGroup getGroup(long timeStamp, int i, boolean boolValue, byte byteValue, String testString) {
LogIntervalContainerGroup group = new LogIntervalContainerGroup();
LoggingRecord container1 = new LoggingRecord(ch01, new Record(new FloatValue(i * -7 - 0.555F), timeStamp));
LoggingRecord container2 = new LoggingRecord(ch02, new Record(new DoubleValue(i * +7 - 0.555), timeStamp));
LoggingRecord container3 = new LoggingRecord(ch03, new Record(new BooleanValue(boolValue), timeStamp));
LoggingRecord container4 = new LoggingRecord(ch04, new Record(new ShortValue((short) i), timeStamp));
LoggingRecord container5 = new LoggingRecord(ch05, new Record(new IntValue(i), timeStamp));
LoggingRecord container6 = new LoggingRecord(ch06, new Record(new LongValue(i * 1000000), timeStamp));
LoggingRecord container7 = new LoggingRecord(ch07, new Record(new ByteValue(byteValue), timeStamp));
LoggingRecord container8 = new LoggingRecord(ch08, new Record(new StringValue(testString), timeStamp));
LoggingRecord container9 = new LoggingRecord(ch09, new Record(new ByteArrayValue(testByteArray), timeStamp));
group.add(container1);
group.add(container2);
group.add(container3);
group.add(container4);
group.add(container5);
group.add(container6);
group.add(container7);
group.add(container8);
group.add(container9);
return group;
}
use of org.openmuc.framework.datalogger.spi.LoggingRecord in project OpenMUC by isc-konstanz.
the class LogFileWriter method log.
/**
* Main logger writing controller.
*
* @param group
* log interval container group
* @param loggingInterval
* logging interval
* @param logTimeOffset
* logging time offset
* @param calendar
* calendar of current time
* @param logChannelList
* logging channel list
*/
public void log(LogIntervalContainerGroup group, int loggingInterval, int logTimeOffset, Calendar calendar, Map<String, LogChannel> logChannelList) {
PrintStream out = getStream(group, loggingInterval, logTimeOffset, calendar, logChannelList);
if (out == null) {
return;
}
List<LoggingRecord> logRecordContainer = group.getList();
if (isFillUpFiles) {
fillUpFile(loggingInterval, logTimeOffset, calendar, logChannelList, logRecordContainer, out);
}
String logLine = getLoggingLine(logRecordContainer, logChannelList, calendar, false);
// print because of println makes different newline char on different systems
out.print(logLine);
out.flush();
out.close();
}
use of org.openmuc.framework.datalogger.spi.LoggingRecord in project OpenMUC by isc-konstanz.
the class LoggingController method deliverLogsToLogServices.
private void deliverLogsToLogServices(long startTime) {
for (DataLoggerService dataLogger : activeDataLoggers) {
List<LoggingRecord> logContainers = logContainerMap.get(dataLogger.getId());
dataLogger.log(logContainers, startTime);
}
}
use of org.openmuc.framework.datalogger.spi.LoggingRecord in project OpenMUC by isc-konstanz.
the class LoggingController method extendMapForDefinedLoggerFromSettings.
private void extendMapForDefinedLoggerFromSettings(ChannelImpl channel, String logSettings) {
List<String> definedLoggerInChannel = parseDefinedLogger(logSettings);
for (String definedLogger : definedLoggerInChannel) {
if (logContainerMap.get(definedLogger) != null) {
Record latestRecord = channel.getLatestRecord();
logContainerMap.get(definedLogger).add(new LoggingRecord(channel.getId(), channel.getAddress(), channel.getSettings(), channel.getValueType(), channel.getValueTypeLength(), latestRecord));
} else if (activeDataLoggers.size() > 0) {
logger.warn("DataLoggerService with ID \"{}\" not found for channel: {}", definedLogger, channel.config.getId());
}
}
}
Aggregations