1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
|
/**
* @licence app begin@
* Copyright (C) 2011-2012 BMW AG
*
* This file is part of COVESA Project Dlt Viewer.
*
* Contributions are licensed to the COVESA Alliance under one or more
* Contribution License Agreements.
*
* \copyright
* This Source Code Form is subject to the terms of the
* Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
* this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* \author Alexander Wenzel <alexander.aw.wenzel@bmw.de> 2011-2012
*
* \file qdlt.h
* For further information see http://www.covesa.global/.
* @licence end@
*/
#ifndef QDLT_FILE_H
#define QDLT_FILE_H
#include "export_rules.h"
#include <QObject>
#include <QString>
#include <QFile>
#include <QDateTime>
#ifdef USECOLOR
#include <QColor>
#endif
#include <QMutex>
#include <time.h>
class QDLT_EXPORT QDltFileItem
{
public:
//! DLT log file.
QFile infile;
//! Index of all DLT messages.
/*!
Index contains positions of beginning of DLT messages in DLT log file.
*/
QVector<qint64> indexAll;
};
//! Access to a DLT log file.
/*!
This class provide access to DLT log file.
This class is currently not thread safe.
*/
class QDLT_EXPORT QDltFile : public QDlt
{
public:
//! The constructor.
/*!
*/
QDltFile();
//! The destructor.
/*!
\return The name of the plugin
*/
~QDltFile();
void clear();
int getNumberOfFiles() const;
//! Get the number of DLT message in the DLT log file.
/*!
\return the number of all DLT messages in the currently opened DLT file.
*/
int size() const;
//! Get the file size of the DLT log file.
/*!
\return the size of the DLT file.
*/
qint64 fileSize() const;
//! Get the number of filtered DLT message in the DLT log file.
/*!
\return the number of filtered DLT messages in the currently opened DLT file.
*/
int sizeFilter() const;
//! Open a DLT log file.
/*!
The DLT log file is parsed and a index of all DLT log messages is created.
\param filename The DLT filename.
\return true if the file is successfully opened with no error, false if an error occured.
*/
bool open(QString _filename,bool append = false);
//! Close teh currently opened DLT log file.
/*!
*/
void close();
//! Sets the internal index of all DLT messages.
/*!
\param New index list of all DLT messages
*/
void setDltIndex(QVector<qint64> &_indexAll, int num = 0);
//! Clears the internal index of all DLT messages.
/*!
*/
void clearIndex();
//! Create an internal index of all DLT messages of the currently opened DLT log file.
/*!
\return true if the operation was successful, false if an error occurred.
*/
bool createIndex();
//! Update the index of the currently opened DLT log file by checking if new DLT messages were added to the file.
/*!
\return true if the operation was successful, false if an error occurred.
*/
bool updateIndex();
//! Create an internal index of all filtered DLT messages of the currently opened DLT log file.
/*!
\return true if the operation was successful, false if an error occurred.
*/
bool createIndexFilter();
//! Update the filtered index of the currently opened DLT log file by checking if new DLT messages were added to the file.
/*!
\return true if the operation was successful, false if an error occurred.
*/
bool updateIndexFilter();
//! Get one message of the DLT log file.
/*!
This function retrieves on DLT message of the log file
\param index The number of the DLT message in the DLT file starting from zero.
\param msg The message which contains the DLT message after the function returns.
\return true if the message is valid, false if an error occurred.
*/
bool getMsg(int index,QDltMsg &msg) const;
//! Get one DLT message of the DLT log file selected by index
/*!
\param index position of the DLT message in the log file up to the number DLT messages in the file
\return Byte array containing the complete DLT message.
*/
QByteArray getMsg(int index) const;
//! Get one DLT message of the filtered DLT log file selected by index
/*!
\param index position of the DLT message in the log file up to the number of DLT messages in the file
\return Byte array containing the complete DLT message.
*/
QByteArray getMsgFilter(int index) const;
//! Get the position in the log file of the filtered DLT log file selected by index
/*!
\param index position of the DLT message in the log file up to the number of DLT messages in the file
\return real position in log file, -1 if invalid.
*/
int getMsgFilterPos(int index) const;
//! Delete all filters and markers.
/*!
This includes all positive and negative filters and markers.
*/
void clearFilter();
//! Get current filter list
/*!
\return filter list.
*/
QDltFilterList getFilterList() const;
//! Set current filter list
/*!
\param filter list.
*/
void setFilterList(QDltFilterList &_filterList);
//! Add a filter to the filter list.
/*!
\param filter the filter configuration
*/
void addFilter(QDltFilter *filter);
//! Update presorted filter list.
/*!
*/
void updateSortedFilter();
//! Get the status of the filter.
/*!
\return true if filtering is enabled, false if filtering is disabled
*/
bool isFilter() const;
//! Enable or disable filtering.
/*!
\return state true if filtering is enabled, false if filtering is disabled
*/
void enableFilter(bool state);
//! Enable or disable sort by time.
/*!
\return state true if sort by time, false if sort by time is disabled
*/
void enableSortByTime(bool state);
//! Enable or disable sort by time.
/*!
\return state true if sort by time, false if sort by time is disabled
*/
void enableSortByTimestamp(bool state);
//! Check if message matches the filter.
/*!
\param msg The message to be checked
\return true if message wil be displayed, false if message will be filtered out
*/
bool checkFilter(QDltMsg &msg);
//! Clear the filter index.
/*!
*/
void clearFilterIndex();
//! Add filter to the filter index.
/*!
\param index The position of the message in the allIndex to be added
*/
void addFilterIndex (int index);
//! Check if message will be marked.
/*!
Colours used are:
1 = green
2 = red
3 = yellow
4 = blue
5 = light grey
6 = dark grey
\param msg The messages to be marked
\return 0 if message will not be marked, colour if message will be marked
*/
#ifdef USECOLOR
QColor checkMarker(QDltMsg &msg);
#else
QString checkMarker(QDltMsg &msg);
#endif
//! Get file name of the underlying file object
/*!
* \return File name
**/
QString getFileName(int num = 0);
//! Get number of messages of the underlying file object
/*!
* \return File size or -1 in case of "wrong "out of range" input index
**/
int getFileMsgNumber(int num = 0) const;
//! Get Index of all DLT messages matching filter
/*!
* \return List of file positions
**/
QVector<qint64> getIndexFilter() const;
//! Set Index of all DLT messages matching filter
/*!
* \param _indexFilter List of file positions
**/
void setIndexFilter(QVector<qint64> _indexFilter);
protected:
private:
//! Mutex to lock critical path for infile
mutable QMutex mutexQDlt;
//!all files including indexes
QList<QDltFileItem*> files;
//! Index of all DLT messages matching filter.
/*!
Index contains positions of DLT messages in indexAll.
*/
QVector<qint64> indexFilter;
//! This contains the list of filters.
QDltFilterList filterList;
//! Enabling filter.
/*!
true filtering is enabled.
false filtering is disabled.
*/
bool filterFlag;
//! Enabling sortByTime.
/*!
true sorting is enabled.
false sorting is disabled.
*/
bool sortByTimeFlag;
//! Enabling sortByTimestamp.
/*!
true sorting is enabled.
false sorting is disabled.
*/
bool sortByTimestampFlag;
};
#endif // QDLT_FILE_H
|