[Simulator] Further Simulator improvements. (#4282)

* Refactor CompStoreObj to use templates. Clean up some formatting.

* [Simulator] Add SimulatorOptions type to replace individual simulator options; Fix storage handler for custom types; Cleanup some redundant code.

* [Simulator][Joystick] Rework the joystick options/calibration dialog.  Can now enable/disable/select the Joystick from there. Delay start of calibration until Start is pressed (otherwise looks like last calibration didn't work). And generally refactor a lot of it to be smarter.

* Cosmetics.

* [Simulator] Add state handling for RadioWidget class. Split code to cpp file.

* [Simulator] Add SimulatorStartupDialog as its own UI class.

* [Simulator] Multiple changes and new features:
    All Horus data source options are now fully supported with data properly saved after use (SD path, .otx file, or custom data path);
    Loading .otx files now works for all radio types (but not saving data back to .otx);
    Switch and knob/slider states are now saved to per radio profile;
    Joystick configuration/calibration is now available directly from inside Simulator;
    Due to refactoring, all previously saved per-profile simulator settings are now invalid;
    Further consolidated simulator dialog startup/shutdown, now handles temp. paths internally, etc;
    With WIN_USE_CONSOLE defined, Simulator and Companion when started from Windows command line will now use that console for all messages (instead of opening a new one). This allows full debug output to be seen at all stages of execution and after exit.

* [Simulator] Fix build w/out SDL Joystick support.

* [Simulator] Fix bogus throttle warning on simulator start; Add forgotten RadioWidgetState flags to stream handlers; Add debug state saver in SimulatorOptions.
This commit is contained in:
Max Paperno
2017-01-25 16:20:45 +01:00
committed by Bertrand Songis
parent b53ec7392c
commit 6e2474081f
22 changed files with 2869 additions and 1785 deletions
+21 -5
View File
@@ -24,6 +24,7 @@
#include "constants.h"
#include "helpers.h"
#include "radiodata.h"
#include "simulator.h"
#include <QDialog>
#include <QVector>
@@ -39,8 +40,6 @@
#define CBEEP_ON "QLabel { background-color: #FF364E }"
#define CBEEP_OFF "QLabel { }"
typedef QPair<QString, QString> keymapHelp_t;
void traceCb(const char * text);
class Firmware;
@@ -66,6 +65,8 @@ namespace Ui {
class SimulatorDialog;
}
using namespace Simulator;
class SimulatorDialog : public QDialog
{
Q_OBJECT
@@ -75,22 +76,34 @@ class SimulatorDialog : public QDialog
virtual ~SimulatorDialog();
void setRadioProfileId(int value);
void setSdPath(const QString & sdPath);
void setDataPath(const QString & dataPath);
void setPaths(const QString & sdPath, const QString & dataPath);
void setRadioSettings(const GeneralSettings settings);
void setEepromData(const QByteArray & eeprom = NULL, bool fromFile = false);
void setStartupData(const QByteArray & dataSource = NULL, bool fromFile = false);
void setRadioData(RadioData * radioData);
void setOptions(SimulatorOptions & options, bool withSave = true);
bool saveRadioData(RadioData * radioData, const QString & path = "", QString * error = NULL);
bool useTempDataPath(bool deleteOnClose = true, bool saveOnClose = false);
bool saveTempData();
void deleteTempData();
void setUiAreaStyle(const QString & style);
void traceCallback(const char * text);
void start();
QString getSdPath() const { return sdCardPath; }
QString getDataPath() const { return radioDataPath; }
private:
void setupUi();
void setupRadioWidgets();
void setupOutputsDisplay();
void setupGVarsDisplay();
void setupJoysticks();
QFrame * createLogicalSwitch(QWidget * parent, int switchNo, QVector<QLabel *> & labels);
void setupTimer();
void restoreRadioWidgetsState();
QList<QByteArray> saveRadioWidgetsState();
void setValues();
void getValues();
@@ -125,14 +138,16 @@ class SimulatorDialog : public QDialog
QString sdCardPath;
QString radioDataPath;
QByteArray eepromData;
QByteArray startupData;
Board::Type m_board;
quint8 flags;
int radioProfileId;
int lastPhase;
int buttonPressed;
int trimPressed;
bool eepromDataFromFile;
bool startupFromFile;
bool deleteTempRadioData;
bool saveTempRadioData;
bool middleButtonPressed;
#ifdef JOYSTICKS
@@ -155,6 +170,7 @@ class SimulatorDialog : public QDialog
void centerSticks();
void openTelemetrySimulator();
void openTrainerSimulator();
void openJoystickDialog();
void openDebugOutput();
void updateDebugOutput();
void luaReload();