Update CREDITS.txt
[opentx.git] / companion / src / simulation / debugoutput.h
blob0e08e6c5b5d9ff7dfb839615a5fabbfcfaae2c8e
1 /*
2 * Copyright (C) OpenTX
4 * Based on code named
5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #ifndef _DEBUGOUTPUT_H_
22 #define _DEBUGOUTPUT_H_
24 #include "simulator.h"
25 #include "simulatorinterface.h"
27 #include <QMutex>
28 #include <QTimer>
29 #include <QValidator>
30 #include <QWidget>
32 // NOTE : The buffer sizes need to be large enough to handle the flood of data when X12/X10 simulator starts up with TRACE_SIMPGMSPACE=1 (> 40K!).
33 // These are maximum sizes, not necessarily allocated sizes.
34 #ifndef DEBUG_OUTPUT_WIDGET_OUT_BUFF_SIZE
35 // This buffer holds received and processed data until it can be printed to our console.
36 #define DEBUG_OUTPUT_WIDGET_OUT_BUFF_SIZE (50 * 1024) // [bytes]
37 #endif
38 #ifndef DEBUG_OUTPUT_WIDGET_INP_BUFF_SIZE
39 // This buffer is active if line filter is enabled and holds received data until it can be filtered and placed in output buffer.
40 #define DEBUG_OUTPUT_WIDGET_INP_BUFF_SIZE (50 * 1024) // [bytes]
41 #endif
43 namespace Ui {
44 class DebugOutput;
47 class QAbstractButton;
48 class QMessageLogContext;
49 class FilteredTextBuffer;
51 using namespace Simulator;
53 class DebugOutput : public QWidget
55 Q_OBJECT
57 public:
58 explicit DebugOutput(QWidget * parent, SimulatorInterface * simulator);
59 virtual ~DebugOutput();
61 static QRegularExpression makeRegEx(const QString & input, bool * isExlusive = NULL);
63 signals:
64 void filterExprChanged(const QRegularExpression & expr);
65 void filterEnabledChanged(const bool enabled);
66 void filterExclusiveChanged(const bool exlusive);
67 void filterChanged(bool enable, bool exclusive, const QRegularExpression & expr);
68 void tracebackDeviceChange(QIODevice * device);
70 protected slots:
71 void saveState();
72 void restoreState();
73 void processBytesReceived();
74 void onDataBufferOverflow(const qint64 len);
75 void onFilterStateChanged();
76 void onFilterTextChanged(const QString &);
77 void onFilterToggled(bool enable);
78 void on_bufferSize_editingFinished();
79 void on_actionWordWrap_toggled(bool checked);
80 void on_actionClearScr_triggered();
81 void on_actionShowFilterHelp_triggered();
83 protected:
84 Ui::DebugOutput * ui;
85 SimulatorInterface * m_simulator;
86 FilteredTextBuffer * m_dataBufferDevice;
87 int m_radioProfileId;
88 bool m_filterEnable;
89 bool m_filterExclude;
91 const static quint16 m_savedViewStateVersion;
94 class DebugOutputFilterValidator : public QValidator
96 public:
97 DebugOutputFilterValidator(QObject *parent = Q_NULLPTR) : QValidator(parent) { }
98 virtual State validate(QString & input, int &) const;
101 class DeleteComboBoxItemEventFilter : public QObject
103 Q_OBJECT
104 public:
105 DeleteComboBoxItemEventFilter(QObject *parent = Q_NULLPTR) : QObject(parent) { }
106 protected:
107 bool eventFilter(QObject *obj, QEvent *event);
110 #endif // _DEBUGOUTPUT_H_