public class LoggerUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static void |
addSpaces(int length,
int size,
java.lang.StringBuilder sb)
This method adds a blank spaces to a StringBuilder object.
|
static void |
appendSpaces(java.lang.StringBuilder sb,
int number)
This method adds a string value up with blank spaces from left to right.
|
static java.util.Map<java.lang.String,java.lang.Boolean> |
areHeadersIdentical(java.lang.String loggerDirectory,
java.util.List<org.openmuc.framework.datalogger.spi.LogChannel> channels,
java.util.Calendar calendar) |
static void |
buildError(java.lang.StringBuilder sbValue,
org.openmuc.framework.data.Flag flag)
Construct a error value with standard error prefix and the flag as number.
|
static java.lang.String |
buildFilename(int loggingInterval,
int logTimeOffset,
java.util.Calendar calendar)
Builds the Logfile name from logging interval, logging time offset and the date of the calendar
|
static java.lang.String |
buildFilename(java.lang.String intervalTimeOffset,
java.util.Calendar calendar)
Builds the Logfile name from string interval_timeOffset and the date of the calendar
|
static void |
byteArrayToHexString(java.lang.StringBuilder sb,
byte[] byteArray)
Converts a byte array to an hexadecimal string
|
static long |
fillUp(java.io.PrintWriter out,
long unixTimeStamp,
long loggingInterval,
long numberOfFillUpLines,
java.lang.StringBuilder errorValues)
* fills a AsciiLogg file up.
|
static java.util.Calendar |
getCalendarTodayZero(java.util.Calendar today)
Returns the calendar from today with the first hour, minute, second and millisecond.
|
static int |
getColumnNumberByName(java.lang.String line,
java.lang.String name)
Get the column number by name.
|
static java.util.Map<java.lang.String,java.lang.Integer> |
getColumnNumbersByNames(java.lang.String line,
java.lang.String[] names)
Get the columns number by names.
|
static int |
getCommentColumnNumberByName(java.lang.String name,
java.io.BufferedReader br)
Get the column number by name, in comments.
|
static java.lang.String |
getCommentValue(int colNumber,
int column,
java.io.BufferedReader br)
Get the value which is coded in the comment
|
static java.lang.StringBuilder |
getErrorValues(java.lang.String[] lineArray)
Returns the error value as a StringBuilder.
|
static java.lang.String |
getFilename(int loggingInterval,
int logTimeOffset,
long timestamp)
Returns the filename, with the help of the timestamp and the interval.
|
static java.util.List<java.lang.String> |
getFilenames(int loggingInterval,
int logTimeOffset,
long startTimestamp,
long endTimestamp)
Returns all filenames of the given time span defined by the two dates
|
static java.lang.String |
getHeaderFromFile(java.lang.String filePath) |
static int |
getLengthOfValueType(org.openmuc.framework.data.ValueType valueType)
Returns the predefined size of a ValueType.
|
static long |
getNumberOfFillUpLines(long lastUnixTimeStamp,
long loggingInterval) |
static java.io.PrintWriter |
getPrintWriter(java.io.File file,
boolean append) |
static java.io.RandomAccessFile |
getRandomAccessFile(java.io.File file,
java.lang.String accesMode)
Returns a RandomAccessFile of the specified file.
|
static int |
getValueTypeLengthFromFile(int columnNumber,
java.io.File dataFile) |
static boolean |
hasNext(java.util.List<org.openmuc.framework.datalogger.spi.LoggingRecord> containers,
int i)
Checks if it has a next container entry.
|
static org.openmuc.framework.data.ValueType |
identifyValueType(int columnNumber,
java.io.File dataFile)
Identifies the ValueType of a logger value on a specific col_no
|
static void |
renameAllFilesToOld(java.lang.String directoryPath,
java.util.Calendar calendar)
This method rename all *.dat files with the date from today in directoryPath into a *.old0, *.old1, ...
|
static void |
renameFileToOld(java.lang.String directoryPath,
java.lang.String loggerIntervalLoggerTimeOffset,
java.util.Calendar calendar)
This method renames a singel <date>_<loggerInterval>_<loggerTimeOffset>.dat file into a *.old0,
*.old1, ...
|
static void |
setLoggerTimestamps(java.lang.StringBuilder sb,
java.util.Calendar calendar)
Constructs the timestamp for every log value into a StringBuilder.
|
static void |
setLoggerTimestamps(java.lang.StringBuilder sb,
long unixTimeStamp)
Constructs the timestamp for every log value into a StringBuilder.
|
public static java.util.List<java.lang.String> getFilenames(int loggingInterval,
int logTimeOffset,
long startTimestamp,
long endTimestamp)
loggingInterval - logging intervallogTimeOffset - logging time offsetstartTimestamp - start time stampendTimestamp - end time stamppublic static java.lang.String getFilename(int loggingInterval,
int logTimeOffset,
long timestamp)
loggingInterval - logging intervallogTimeOffset - logging time offsettimestamp - timestamppublic static java.lang.String buildFilename(int loggingInterval,
int logTimeOffset,
java.util.Calendar calendar)
loggingInterval - logging intervallogTimeOffset - logging time offsetcalendar - Calendar for the time of the file namepublic static java.lang.String buildFilename(java.lang.String intervalTimeOffset,
java.util.Calendar calendar)
intervalTimeOffset - the IntervallTimeOffsetcalendar - Calendar for the time of the file namepublic static boolean hasNext(java.util.List<org.openmuc.framework.datalogger.spi.LoggingRecord> containers,
int i)
containers - a list with LogRecordContaineri - the current possition of the listpublic static void renameAllFilesToOld(java.lang.String directoryPath,
java.util.Calendar calendar)
directoryPath - directory pathcalendar - Calendar for the time of the file namepublic static void renameFileToOld(java.lang.String directoryPath,
java.lang.String loggerIntervalLoggerTimeOffset,
java.util.Calendar calendar)
directoryPath - directory pathloggerIntervalLoggerTimeOffset - logger interval with logger time offset as String separated with underlinecalendar - calendar of the daypublic static java.util.Calendar getCalendarTodayZero(java.util.Calendar today)
today - the current calendarpublic static void addSpaces(int length,
int size,
java.lang.StringBuilder sb)
length - length of the value to add the spacessize - maximal allowed sizesb - StringBuilder object to add the spacespublic static void appendSpaces(java.lang.StringBuilder sb,
int number)
sb - StringBuilder in wich the spaces will appendednumber - the number of spacespublic static void buildError(java.lang.StringBuilder sbValue,
org.openmuc.framework.data.Flag flag)
flag - the wished error flagsbValue - string buffer to add the error flagpublic static int getColumnNumberByName(java.lang.String line,
java.lang.String name)
line - the line to searchname - the name to search in linepublic static java.util.Map<java.lang.String,java.lang.Integer> getColumnNumbersByNames(java.lang.String line,
java.lang.String[] names)
line - the line to searchnames - the name to search in linepublic static int getCommentColumnNumberByName(java.lang.String name,
java.io.BufferedReader br)
throws java.io.IOException
name - the name to searchbr - the BufferedReaderjava.io.IOException - throws IOException If an I/O error occurspublic static java.lang.String getCommentValue(int colNumber,
int column,
java.io.BufferedReader br)
throws java.io.IOException
colNumber - the number of the channelcolumn - the columnbr - a BufferedReaderjava.io.IOException - If an I/O error occurspublic static org.openmuc.framework.data.ValueType identifyValueType(int columnNumber,
java.io.File dataFile)
columnNumber - column numberdataFile - the logger data filepublic static int getValueTypeLengthFromFile(int columnNumber,
java.io.File dataFile)
public static int getLengthOfValueType(org.openmuc.framework.data.ValueType valueType)
valueType - the type to get the predefined sizepublic static void byteArrayToHexString(java.lang.StringBuilder sb,
byte[] byteArray)
sb - to add hex stringbyteArray - the byte array to convertpublic static void setLoggerTimestamps(java.lang.StringBuilder sb,
java.util.Calendar calendar)
sb - the StringBuilder to add the logger timestampcalendar - Calendar with the wished timepublic static void setLoggerTimestamps(java.lang.StringBuilder sb,
long unixTimeStamp)
sb - the StringBuilder to add the logger timestampunixTimeStamp - unix time stamp in mspublic static java.lang.String getHeaderFromFile(java.lang.String filePath)
public static java.io.RandomAccessFile getRandomAccessFile(java.io.File file,
java.lang.String accesMode)
file - file get the RandomAccessFileaccesMode - access modenull if an error occured.public static java.io.PrintWriter getPrintWriter(java.io.File file,
boolean append)
throws java.io.IOException
java.io.IOExceptionpublic static java.util.Map<java.lang.String,java.lang.Boolean> areHeadersIdentical(java.lang.String loggerDirectory,
java.util.List<org.openmuc.framework.datalogger.spi.LogChannel> channels,
java.util.Calendar calendar)
public static long fillUp(java.io.PrintWriter out,
long unixTimeStamp,
long loggingInterval,
long numberOfFillUpLines,
java.lang.StringBuilder errorValues)
out - the output stream to write onunixTimeStamp - unix time stamploggingInterval - logging intervalnumberOfFillUpLines - the number to fill up lineserrorValues - the error value set in the linepublic static long getNumberOfFillUpLines(long lastUnixTimeStamp,
long loggingInterval)
public static java.lang.StringBuilder getErrorValues(java.lang.String[] lineArray)
lineArray - a ascii line as a array with error code