2 * Author - Bertrand Songis <bsongis@gmail.com>
4 * Based on th9x -> http://code.google.com/p/th9x/
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
17 #ifndef _OPENTX_SIMULATOR_H_
18 #define _OPENTX_SIMULATOR_H_
20 #include "simulatorinterface.h"
29 #define DLLEXPORT __declspec(dllexport)
32 class DLLEXPORT OpenTxSimulator
: public SimulatorInterface
39 virtual ~OpenTxSimulator();
41 virtual QString
name();
42 virtual bool isRunning();
43 virtual void readRadioData(QByteArray
& dest
);
44 virtual uint8_t * getLcd();
45 virtual uint8_t getSensorInstance(uint16_t id
, uint8_t defaultValue
= 0);
46 virtual uint16_t getSensorRatio(uint16_t id
);
47 virtual const int getCapability(Capability cap
);
49 static QVector
<QIODevice
*> tracebackDevices
;
54 virtual void start(const char * filename
= NULL
, bool tests
= true);
56 virtual void setSdPath(const QString
& sdPath
= "", const QString
& settingsPath
= "");
57 virtual void setVolumeGain(const int value
);
58 virtual void setRadioData(const QByteArray
& data
);
59 virtual void setAnalogValue(uint8_t index
, int16_t value
);
60 virtual void setKey(uint8_t key
, bool state
);
61 virtual void setSwitch(uint8_t swtch
, int8_t state
);
62 virtual void setTrim(unsigned int idx
, int value
);
63 virtual void setTrimSwitch(uint8_t trim
, bool state
);
64 virtual void setTrainerInput(unsigned int inputNumber
, int16_t value
);
65 virtual void setInputValue(int type
, uint8_t index
, int16_t value
);
66 virtual void rotaryEncoderEvent(int steps
);
67 virtual void setTrainerTimeout(uint16_t ms
);
68 virtual void sendTelemetry(uint8_t * data
, unsigned int len
);
69 virtual void setLuaStateReloadPermanentScripts();
70 virtual void addTracebackDevice(QIODevice
* device
);
71 virtual void removeTracebackDevice(QIODevice
* device
);
78 bool isStopRequested();
79 void setStopRequested(bool stop
);
80 bool checkLcdChanged();
81 void checkOutputsChanged();
82 uint8_t getStickMode();
83 const char * getPhaseName(unsigned int phase
);
84 const QString
getCurrentPhaseName();
85 const char * getError();
86 const int voltageToAdc(const int volts
);
88 QString simuSdDirectory
;
89 QString simuSettingsDirectory
;
93 QMutex m_mtxRadioData
;
95 QMutex m_mtxTbDevices
;
97 bool m_resetOutputsData
;
102 #endif // _OPENTX_SIMULATOR_H_