[Simulator] Asynchronous SimulatorInterface & a few new features. (#4738)
[opentx.git] / companion / src / simulation / radiooutputswidget.h
blob1f699e99d367870bc416beb3c0a96b722d2c7e07
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 RADIOOUTPUTSWIDGET_H
22 #define RADIOOUTPUTSWIDGET_H
24 #include "simulator.h"
25 #include "simulatorinterface.h"
27 #include <QTimer>
28 #include <QWidget>
30 namespace Ui {
31 class RadioOutputsWidget;
34 class Firmware;
35 //class SimulatorInterface;
37 class QFrame;
38 class QLabel;
39 class QSlider;
41 using namespace Simulator;
43 class RadioOutputsWidget : public QWidget
45 Q_OBJECT
47 public:
48 explicit RadioOutputsWidget(SimulatorInterface * simulator, Firmware * firmware, QWidget * parent = 0);
49 ~RadioOutputsWidget();
51 public slots:
52 void start();
53 //void stop();
54 void restart();
56 protected slots:
57 void saveState();
58 void restoreState();
59 void onChannelOutValueChange(quint8 index, qint32 value);
60 void onVirtSwValueChange(quint8 index, qint32 value);
61 void onGVarValueChange(quint8 index, qint32 value);
62 void onPhaseChanged(qint32 phase, const QString &);
64 protected:
65 void changeEvent(QEvent *e);
66 void setupChannelsDisplay();
67 void setupLsDisplay();
68 void setupGVarsDisplay();
69 QWidget * createLogicalSwitch(QWidget * parent, int switchNo);
71 SimulatorInterface * m_simulator;
72 Firmware * m_firmware;
74 QHash<int, QPair<QLabel *, QSlider *> > m_channelsMap; // m_channelsMap[chanIndex] = {QLabel*, QSlider*}
75 QHash<int, QLabel *> m_logicSwitchMap; // m_logicSwitchMap[lsIndex] = QLabel*
76 QHash<int, QHash<int, QLabel *> > m_globalVarsMap; // m_globalVarsMap[gvarIndex][fmodeIndex] = QLabel*
78 int m_radioProfileId;
79 int m_dataUpdateFreq;
81 const static quint16 m_savedViewStateVersion;
83 private:
84 Ui::RadioOutputsWidget * ui;
87 #endif // RADIOOUTPUTSWIDGET_H