Search in sources :

Example 1 with LoggingRecord

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

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;
}
Also used : ByteValue(org.openmuc.framework.data.ByteValue) ShortValue(org.openmuc.framework.data.ShortValue) DoubleValue(org.openmuc.framework.data.DoubleValue) BooleanValue(org.openmuc.framework.data.BooleanValue) LongValue(org.openmuc.framework.data.LongValue) LogIntervalContainerGroup(org.openmuc.framework.datalogger.ascii.LogIntervalContainerGroup) Record(org.openmuc.framework.data.Record) LoggingRecord(org.openmuc.framework.datalogger.spi.LoggingRecord) FloatValue(org.openmuc.framework.data.FloatValue) ByteArrayValue(org.openmuc.framework.data.ByteArrayValue) StringValue(org.openmuc.framework.data.StringValue) LoggingRecord(org.openmuc.framework.datalogger.spi.LoggingRecord) IntValue(org.openmuc.framework.data.IntValue)

Example 3 with LoggingRecord

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();
}
Also used : PrintStream(java.io.PrintStream) LoggingRecord(org.openmuc.framework.datalogger.spi.LoggingRecord)

Example 4 with LoggingRecord

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);
    }
}
Also used : DataLoggerService(org.openmuc.framework.datalogger.spi.DataLoggerService) LoggingRecord(org.openmuc.framework.datalogger.spi.LoggingRecord)

Example 5 with LoggingRecord

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());
        }
    }
}
Also used : Record(org.openmuc.framework.data.Record) LoggingRecord(org.openmuc.framework.datalogger.spi.LoggingRecord) LoggingRecord(org.openmuc.framework.datalogger.spi.LoggingRecord)

Aggregations

LoggingRecord (org.openmuc.framework.datalogger.spi.LoggingRecord)27 Record (org.openmuc.framework.data.Record)11 HashMap (java.util.HashMap)9 ArrayList (java.util.ArrayList)8 Test (org.junit.jupiter.api.Test)7 MqttLogMsg (org.openmuc.framework.datalogger.mqtt.dto.MqttLogMsg)7 DoubleValue (org.openmuc.framework.data.DoubleValue)6 MqttLogChannel (org.openmuc.framework.datalogger.mqtt.dto.MqttLogChannel)6 MqttLogMsgBuilder (org.openmuc.framework.datalogger.mqtt.util.MqttLogMsgBuilder)6 LogChannel (org.openmuc.framework.datalogger.spi.LogChannel)6 LogIntervalContainerGroup (org.openmuc.framework.datalogger.ascii.LogIntervalContainerGroup)4 Calendar (java.util.Calendar)3 Value (org.openmuc.framework.data.Value)3 DataLoggerService (org.openmuc.framework.datalogger.spi.DataLoggerService)3 IOException (java.io.IOException)2 Timestamp (java.sql.Timestamp)2 List (java.util.List)2 BeforeAll (org.junit.jupiter.api.BeforeAll)2 ByteArrayValue (org.openmuc.framework.data.ByteArrayValue)2 StringValue (org.openmuc.framework.data.StringValue)2