use of org.openmuc.framework.datalogger.spi.LogChannel 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.LogChannel in project OpenMUC by isc-konstanz.
the class AsciiLogger method setChannelsToLog.
/**
* Will called if OpenMUC starts the logger
*/
@Override
public void setChannelsToLog(List<LogChannel> logChannels) {
Calendar calendar = new GregorianCalendar(Locale.getDefault());
logChannelList.clear();
logger.trace("channels to log:");
for (LogChannel logChannel : logChannels) {
if (logger.isTraceEnabled()) {
logger.trace("channel.getId() " + logChannel.getId());
logger.trace("channel.getLoggingInterval() " + logChannel.getLoggingInterval());
}
logChannelList.put(logChannel.getId(), logChannel);
}
if (isFillUpFiles) {
Map<String, Boolean> areHeaderIdentical = LoggerUtils.areHeadersIdentical(loggerDirectory, logChannels, calendar);
for (Entry<String, Boolean> entry : areHeaderIdentical.entrySet()) {
String key = entry.getKey();
boolean isHeaderIdentical = entry.getValue();
if (isHeaderIdentical) {
// Fill file up with error flag 32 (DATA_LOGGING_NOT_ACTIVE)
if (logger.isTraceEnabled()) {
logger.trace("Fill file " + LoggerUtils.buildFilename(key, calendar) + " up with error flag 32.");
}
fillUpFileWithErrorCode(loggerDirectory, key, calendar);
} else {
// rename file in old file (if file is existing), because of configuration has
// changed
LoggerUtils.renameFileToOld(loggerDirectory, key, calendar);
}
}
} else {
LoggerUtils.renameAllFilesToOld(loggerDirectory, calendar);
}
}
use of org.openmuc.framework.datalogger.spi.LogChannel in project OpenMUC by isc-konstanz.
the class LogFileHeader method getIESDataFormatHeaderString.
/**
* Generate the standard IES Data Format Header
*
* @param filename
* the name of the file to add the header
* @param logChannelList
* a list of all channels for this file
* @return the header as a string
*/
public static String getIESDataFormatHeaderString(String filename, List<LogChannel> logChannelList) {
StringBuilder sb0 = new StringBuilder();
StringBuilder sb1 = new StringBuilder();
setHeaderTop(sb0, logChannelList.get(0).getLoggingInterval(), filename);
// write channel specific header informations
int colNumber = 4;
Iterator<LogChannel> iterator = logChannelList.listIterator();
while (iterator.hasNext()) {
LogChannel logChannel = iterator.next();
appendChannelSpecificComment(sb0, logChannel, colNumber);
sb1.append(logChannel.getId());
if (iterator.hasNext()) {
sb1.append(Const.SEPARATOR);
}
++colNumber;
}
appendColumnHeaderTimestamp(sb0);
sb0.append(sb1);
sb0.append(Const.LINESEPARATOR);
return sb0.toString();
}
use of org.openmuc.framework.datalogger.spi.LogChannel in project OpenMUC by isc-konstanz.
the class AmqpLogger method setChannelsToLog.
@Override
public void setChannelsToLog(List<LogChannel> logChannels) {
channelsToLog.clear();
for (LogChannel logChannel : logChannels) {
String channelId = logChannel.getId();
channelsToLog.put(channelId, logChannel);
}
}
use of org.openmuc.framework.datalogger.spi.LogChannel in project OpenMUC by isc-konstanz.
the class AmqpLogger method getQueueName.
private String getQueueName(String channelId) {
LogChannel logChannelMeta = channelsToLog.get(channelId);
String logSettings = logChannelMeta.getLoggingSettings();
if (logSettings == null || logSettings.isEmpty()) {
return propertyHandler.getString(Settings.FRAMEWORK) + channelId;
} else {
return parseDefinedQueue(logSettings);
}
}
Aggregations