feat(cpn): Radio types can reference any libsim and/or firmware download id (#3432)
* Radio profiles reference any libsim and/or firmware download id * Revert files filter for now
This commit is contained in:
@@ -286,17 +286,19 @@ class Firmware
|
|||||||
typedef QList<OptionsGroup> OptionsList;
|
typedef QList<OptionsGroup> OptionsList;
|
||||||
|
|
||||||
|
|
||||||
explicit Firmware(const QString & id, const QString & name, Board::Type board) :
|
explicit Firmware(const QString & id, const QString & name, Board::Type board, const QString & downloadId = QString(), const QString & simulatorId = QString()) :
|
||||||
Firmware(nullptr, id, name, board)
|
Firmware(nullptr, id, name, board, downloadId, simulatorId)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
explicit Firmware(Firmware * base, const QString & id, const QString & name, Board::Type board) :
|
explicit Firmware(Firmware * base, const QString & id, const QString & name, Board::Type board, const QString & downloadId = QString(), const QString & simulatorId = QString()) :
|
||||||
id(id),
|
id(id),
|
||||||
name(name),
|
name(name),
|
||||||
board(board),
|
board(board),
|
||||||
variantBase(0),
|
variantBase(0),
|
||||||
base(base),
|
base(base),
|
||||||
eepromInterface(nullptr),
|
eepromInterface(nullptr),
|
||||||
|
downloadId(downloadId),
|
||||||
|
simulatorId(simulatorId),
|
||||||
analogInputNamesLookupTable(Boards::getAnalogNamesLookupTable(board)),
|
analogInputNamesLookupTable(Boards::getAnalogNamesLookupTable(board)),
|
||||||
switchesLookupTable(Boards::getSwitchesLookupTable(board)),
|
switchesLookupTable(Boards::getSwitchesLookupTable(board)),
|
||||||
trimSwitchesLookupTable(Boards::getTrimSwitchesLookupTable(board)),
|
trimSwitchesLookupTable(Boards::getTrimSwitchesLookupTable(board)),
|
||||||
@@ -432,6 +434,9 @@ class Firmware
|
|||||||
STRINGTAGMAPPINGFUNCS(rawSourceSpecialTypesLookupTable, RawSourceSpecialTypes);
|
STRINGTAGMAPPINGFUNCS(rawSourceSpecialTypesLookupTable, RawSourceSpecialTypes);
|
||||||
STRINGTAGMAPPINGFUNCS(rawSourceCyclicLookupTable, RawSourceCyclic);
|
STRINGTAGMAPPINGFUNCS(rawSourceCyclicLookupTable, RawSourceCyclic);
|
||||||
|
|
||||||
|
const QString getDownloadId() { return getFirmwareBase()->downloadId.isEmpty() ? getFlavour() : getFirmwareBase()->downloadId; }
|
||||||
|
const QString getSimulatorId() { return getFirmwareBase()->simulatorId.isEmpty() ? getId() : getFirmwareBase()->simulatorId; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString id;
|
QString id;
|
||||||
QString name;
|
QString name;
|
||||||
@@ -439,6 +444,8 @@ class Firmware
|
|||||||
unsigned int variantBase;
|
unsigned int variantBase;
|
||||||
Firmware * base;
|
Firmware * base;
|
||||||
EEPROMInterface * eepromInterface;
|
EEPROMInterface * eepromInterface;
|
||||||
|
QString downloadId;
|
||||||
|
QString simulatorId;
|
||||||
|
|
||||||
// used by YAML encode and decode
|
// used by YAML encode and decode
|
||||||
const StringTagMappingTable analogInputNamesLookupTable;
|
const StringTagMappingTable analogInputNamesLookupTable;
|
||||||
|
|||||||
@@ -1199,14 +1199,14 @@ void registerOpenTxFirmwares()
|
|||||||
OpenTxFirmware * firmware;
|
OpenTxFirmware * firmware;
|
||||||
|
|
||||||
/* FrSky Taranis X9D+ board */
|
/* FrSky Taranis X9D+ board */
|
||||||
firmware = new OpenTxFirmware(FIRMWAREID("x9d+"), Firmware::tr("FrSky Taranis X9D+"), BOARD_TARANIS_X9DP);
|
firmware = new OpenTxFirmware(FIRMWAREID("x9d+"), Firmware::tr("FrSky Taranis X9D+"), BOARD_TARANIS_X9DP, "x9dp");
|
||||||
firmware->addOption("noras", Firmware::tr("Disable RAS (SWR)"));
|
firmware->addOption("noras", Firmware::tr("Disable RAS (SWR)"));
|
||||||
addOpenTxTaranisOptions(firmware);
|
addOpenTxTaranisOptions(firmware);
|
||||||
registerOpenTxFirmware(firmware);
|
registerOpenTxFirmware(firmware);
|
||||||
addOpenTxRfOptions(firmware, EU + FLEX + AFHDS3);
|
addOpenTxRfOptions(firmware, EU + FLEX + AFHDS3);
|
||||||
|
|
||||||
/* FrSky Taranis X9D+ 2019 board */
|
/* FrSky Taranis X9D+ 2019 board */
|
||||||
firmware = new OpenTxFirmware(FIRMWAREID("x9d+2019"), Firmware::tr("FrSky Taranis X9D+ 2019"), BOARD_TARANIS_X9DP_2019);
|
firmware = new OpenTxFirmware(FIRMWAREID("x9d+2019"), Firmware::tr("FrSky Taranis X9D+ 2019"), BOARD_TARANIS_X9DP_2019, "x9dp2019");
|
||||||
addOpenTxTaranisOptions(firmware);
|
addOpenTxTaranisOptions(firmware);
|
||||||
registerOpenTxFirmware(firmware);
|
registerOpenTxFirmware(firmware);
|
||||||
addOpenTxRfOptions(firmware, FLEX);
|
addOpenTxRfOptions(firmware, FLEX);
|
||||||
@@ -1246,7 +1246,7 @@ void registerOpenTxFirmwares()
|
|||||||
addOpenTxRfOptions(firmware, EU + FLEX);
|
addOpenTxRfOptions(firmware, EU + FLEX);
|
||||||
|
|
||||||
/* FrSky X7 Access board */
|
/* FrSky X7 Access board */
|
||||||
firmware = new OpenTxFirmware(FIRMWAREID("x7access"), Firmware::tr("FrSky Taranis X7 / X7S Access"), BOARD_TARANIS_X7_ACCESS);
|
firmware = new OpenTxFirmware(FIRMWAREID("x7access"), Firmware::tr("FrSky Taranis X7 / X7S Access"), BOARD_TARANIS_X7_ACCESS, "x7-access");
|
||||||
addOpenTxTaranisOptions(firmware);
|
addOpenTxTaranisOptions(firmware);
|
||||||
registerOpenTxFirmware(firmware);
|
registerOpenTxFirmware(firmware);
|
||||||
addOpenTxRfOptions(firmware, FLEX);
|
addOpenTxRfOptions(firmware, FLEX);
|
||||||
@@ -1272,7 +1272,7 @@ void registerOpenTxFirmwares()
|
|||||||
addOpenTxRfOptions(firmware, EU + FLEX);
|
addOpenTxRfOptions(firmware, EU + FLEX);
|
||||||
|
|
||||||
/* FrSky X10 Express board */
|
/* FrSky X10 Express board */
|
||||||
firmware = new OpenTxFirmware(FIRMWAREID("x10express"), Firmware::tr("FrSky Horus X10 Express / X10S Express"), BOARD_X10_EXPRESS);
|
firmware = new OpenTxFirmware(FIRMWAREID("x10express"), Firmware::tr("FrSky Horus X10 Express / X10S Express"), BOARD_X10_EXPRESS, "x10-access");
|
||||||
addOpenTxFrskyOptions(firmware);
|
addOpenTxFrskyOptions(firmware);
|
||||||
registerOpenTxFirmware(firmware);
|
registerOpenTxFirmware(firmware);
|
||||||
addOpenTxRfOptions(firmware, FLEX);
|
addOpenTxRfOptions(firmware, FLEX);
|
||||||
|
|||||||
@@ -88,13 +88,13 @@ class OpenTxFirmware: public Firmware
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
OpenTxFirmware(const QString & id, OpenTxFirmware * parent):
|
OpenTxFirmware(const QString & id, OpenTxFirmware * parent):
|
||||||
Firmware(parent, id, parent->getName(), parent->getBoard())
|
Firmware(parent, id, parent->getName(), parent->getBoard(), parent->getDownloadId(), parent->getSimulatorId())
|
||||||
{
|
{
|
||||||
setEEpromInterface(parent->getEEpromInterface());
|
setEEpromInterface(parent->getEEpromInterface());
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenTxFirmware(const QString & id, const QString & name, const Board::Type board):
|
OpenTxFirmware(const QString & id, const QString & name, const Board::Type board, const QString & downloadId = QString(), const QString & simulatorId = QString()):
|
||||||
Firmware(id, name, board)
|
Firmware(id, name, board, downloadId, simulatorId)
|
||||||
{
|
{
|
||||||
// Note: these align with the radio NOT computer locales - TODO harmonise with ISO and one list!!!
|
// Note: these align with the radio NOT computer locales - TODO harmonise with ISO and one list!!!
|
||||||
addLanguage("en");
|
addLanguage("en");
|
||||||
|
|||||||
@@ -332,8 +332,8 @@ bool isSimulatorRunning() { return simulatorRunning; }
|
|||||||
|
|
||||||
void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
|
void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
|
||||||
{
|
{
|
||||||
QString fwId = SimulatorLoader::findSimulatorByFirmwareName(getCurrentFirmware()->getId());
|
QString simulatorId = SimulatorLoader::findSimulatorByName(getCurrentFirmware()->getSimulatorId());
|
||||||
if (fwId.isEmpty()) {
|
if (simulatorId.isEmpty()) {
|
||||||
QMessageBox::warning(NULL,
|
QMessageBox::warning(NULL,
|
||||||
CPN_STR_TTL_WARNING,
|
CPN_STR_TTL_WARNING,
|
||||||
QCoreApplication::translate("Companion", "Simulator for this firmware is not yet available"));
|
QCoreApplication::translate("Companion", "Simulator for this firmware is not yet available"));
|
||||||
@@ -348,7 +348,7 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
|
|||||||
simuData->setCurrentModel(modelIdx);
|
simuData->setCurrentModel(modelIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
SimulatorMainWindow * dialog = new SimulatorMainWindow(parent, fwId, flags);
|
SimulatorMainWindow * dialog = new SimulatorMainWindow(parent, simulatorId, flags);
|
||||||
dialog->setWindowModality(Qt::ApplicationModal);
|
dialog->setWindowModality(Qt::ApplicationModal);
|
||||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
#define SIMULATOR_FLAGS_NOTX 0x01 // simulating a single model from Companion
|
#define SIMULATOR_FLAGS_NOTX 0x01 // simulating a single model from Companion
|
||||||
#define SIMULATOR_FLAGS_STANDALONE 0x02 // started from stanalone simulator
|
#define SIMULATOR_FLAGS_STANDALONE 0x02 // started from stanalone simulator
|
||||||
|
|
||||||
#define SIMULATOR_OPTIONS_VERSION 2
|
#define SIMULATOR_OPTIONS_VERSION 3
|
||||||
|
|
||||||
namespace Simulator
|
namespace Simulator
|
||||||
{
|
{
|
||||||
@@ -129,13 +129,16 @@ struct SimulatorOptions
|
|||||||
QByteArray windowState; // SimulatorMainWindow dock/toolbar/options UI state
|
QByteArray windowState; // SimulatorMainWindow dock/toolbar/options UI state
|
||||||
QByteArray dbgConsoleState; // DebugOutput UI state
|
QByteArray dbgConsoleState; // DebugOutput UI state
|
||||||
QByteArray radioOutputsState; // RadioOutputsWidget UI state
|
QByteArray radioOutputsState; // RadioOutputsWidget UI state
|
||||||
|
// added in v3
|
||||||
|
QString simulatorId;
|
||||||
|
|
||||||
quint16 loadedVersion() const { return m_version; } //! loaded structure definition version (0 if none/error)
|
quint16 loadedVersion() const { return m_version; } //! loaded structure definition version (0 if none/error)
|
||||||
|
|
||||||
friend QDataStream & operator << (QDataStream &out, const SimulatorOptions & o)
|
friend QDataStream & operator << (QDataStream &out, const SimulatorOptions & o)
|
||||||
{
|
{
|
||||||
out << quint16(SIMULATOR_OPTIONS_VERSION) << o.startupDataType << o.firmwareId << o.dataFile << o.dataFolder
|
out << quint16(SIMULATOR_OPTIONS_VERSION) << o.startupDataType << o.firmwareId << o.dataFile << o.dataFolder
|
||||||
<< o.sdPath << o.windowGeometry << o.controlsState << o.lcdColor << o.windowState << o.dbgConsoleState << o.radioOutputsState;
|
<< o.sdPath << o.windowGeometry << o.controlsState << o.lcdColor << o.windowState << o.dbgConsoleState << o.radioOutputsState
|
||||||
|
<< o.simulatorId;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,6 +150,8 @@ struct SimulatorOptions
|
|||||||
>> o.sdPath >> o.windowGeometry >> o.controlsState >> o.lcdColor;
|
>> o.sdPath >> o.windowGeometry >> o.controlsState >> o.lcdColor;
|
||||||
if (o.m_version >= 2)
|
if (o.m_version >= 2)
|
||||||
in >> o.windowState >> o.dbgConsoleState >> o.radioOutputsState;
|
in >> o.windowState >> o.dbgConsoleState >> o.radioOutputsState;
|
||||||
|
if (o.m_version >= 3)
|
||||||
|
in >> o.simulatorId;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qWarning() << "Error loading SimulatorOptions, saved version not valid:" << o.m_version << "Expected <=" << SIMULATOR_OPTIONS_VERSION;
|
qWarning() << "Error loading SimulatorOptions, saved version not valid:" << o.m_version << "Expected <=" << SIMULATOR_OPTIONS_VERSION;
|
||||||
@@ -176,7 +181,7 @@ struct SimulatorOptions
|
|||||||
friend QDebug operator << (QDebug d, const SimulatorOptions & o)
|
friend QDebug operator << (QDebug d, const SimulatorOptions & o)
|
||||||
{
|
{
|
||||||
QDebugStateSaver saver(d);
|
QDebugStateSaver saver(d);
|
||||||
d.nospace() << "SimulatorOptions: firmwareId=" << o.firmwareId << "; dataFile=" << o.dataFile << "; dataFolder=" << o.dataFolder
|
d.nospace() << "SimulatorOptions: firmwareId=" << o.firmwareId << "; simulatorId=" << o.simulatorId << "; dataFile=" << o.dataFile << "; dataFolder=" << o.dataFolder
|
||||||
<< "; sdPath=" << o.sdPath << "; startupDataType=" << o.startupDataType;
|
<< "; sdPath=" << o.sdPath << "; startupDataType=" << o.startupDataType;
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ void SimulatorLoader::unregisterSimulators()
|
|||||||
delete lib;
|
delete lib;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SimulatorLoader::findSimulatorByFirmwareName(const QString & name)
|
QString SimulatorLoader::findSimulatorByName(const QString & name)
|
||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
QString ret;
|
QString ret;
|
||||||
@@ -133,7 +133,7 @@ QString SimulatorLoader::findSimulatorByFirmwareName(const QString & name)
|
|||||||
SimulatorInterface * SimulatorLoader::loadSimulator(const QString & name)
|
SimulatorInterface * SimulatorLoader::loadSimulator(const QString & name)
|
||||||
{
|
{
|
||||||
SimulatorInterface * si = NULL;
|
SimulatorInterface * si = NULL;
|
||||||
QString libname = findSimulatorByFirmwareName(name);
|
QString libname = findSimulatorByName(name);
|
||||||
|
|
||||||
if (libname.isEmpty()) {
|
if (libname.isEmpty()) {
|
||||||
qWarning() << "Simulator" << name << "not found.";
|
qWarning() << "Simulator" << name << "not found.";
|
||||||
@@ -166,7 +166,7 @@ bool SimulatorLoader::unloadSimulator(const QString & name)
|
|||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
#if SIMULATOR_INTERFACE_LOADER_DYNAMIC
|
#if SIMULATOR_INTERFACE_LOADER_DYNAMIC
|
||||||
QString simuName = findSimulatorByFirmwareName(name);
|
QString simuName = findSimulatorByName(name);
|
||||||
if (simuName.isEmpty())
|
if (simuName.isEmpty())
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ class SimulatorLoader
|
|||||||
static void registerSimulators();
|
static void registerSimulators();
|
||||||
static void unregisterSimulators();
|
static void unregisterSimulators();
|
||||||
static QStringList getAvailableSimulators();
|
static QStringList getAvailableSimulators();
|
||||||
static QString findSimulatorByFirmwareName(const QString & name);
|
static QString findSimulatorByName(const QString & name);
|
||||||
static SimulatorInterface * loadSimulator(const QString & name);
|
static SimulatorInterface * loadSimulator(const QString & name);
|
||||||
static bool unloadSimulator(const QString & name);
|
static bool unloadSimulator(const QString & name);
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ extern AppData g; // ensure what "g" means
|
|||||||
|
|
||||||
const quint16 SimulatorMainWindow::m_savedUiStateVersion = 2;
|
const quint16 SimulatorMainWindow::m_savedUiStateVersion = 2;
|
||||||
|
|
||||||
SimulatorMainWindow::SimulatorMainWindow(QWidget *parent, const QString & firmwareId, quint8 flags, Qt::WindowFlags wflags) :
|
SimulatorMainWindow::SimulatorMainWindow(QWidget *parent, const QString & simulatorId, quint8 flags, Qt::WindowFlags wflags) :
|
||||||
QMainWindow(parent, wflags),
|
QMainWindow(parent, wflags),
|
||||||
ui(new Ui::SimulatorMainWindow),
|
ui(new Ui::SimulatorMainWindow),
|
||||||
m_simulatorWidget(NULL),
|
m_simulatorWidget(NULL),
|
||||||
@@ -52,7 +52,7 @@ SimulatorMainWindow::SimulatorMainWindow(QWidget *parent, const QString & firmwa
|
|||||||
m_telemetryDockWidget(NULL),
|
m_telemetryDockWidget(NULL),
|
||||||
m_trainerDockWidget(NULL),
|
m_trainerDockWidget(NULL),
|
||||||
m_outputsDockWidget(NULL),
|
m_outputsDockWidget(NULL),
|
||||||
m_simulatorId(firmwareId),
|
m_simulatorId(simulatorId),
|
||||||
m_exitStatusCode(0),
|
m_exitStatusCode(0),
|
||||||
m_radioProfileId(g.sessionId()),
|
m_radioProfileId(g.sessionId()),
|
||||||
m_radioSizeConstraint(Qt::Horizontal | Qt::Vertical),
|
m_radioSizeConstraint(Qt::Horizontal | Qt::Vertical),
|
||||||
@@ -61,7 +61,7 @@ SimulatorMainWindow::SimulatorMainWindow(QWidget *parent, const QString & firmwa
|
|||||||
m_showMenubar(true)
|
m_showMenubar(true)
|
||||||
{
|
{
|
||||||
if (m_simulatorId.isEmpty()) {
|
if (m_simulatorId.isEmpty()) {
|
||||||
m_simulatorId = SimulatorLoader::findSimulatorByFirmwareName(getCurrentFirmware()->getId());
|
m_simulatorId = SimulatorLoader::findSimulatorByName(getCurrentFirmware()->getSimulatorId());
|
||||||
}
|
}
|
||||||
m_simulator = SimulatorLoader::loadSimulator(m_simulatorId);
|
m_simulator = SimulatorLoader::loadSimulator(m_simulatorId);
|
||||||
if (!m_simulator) {
|
if (!m_simulator) {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class SimulatorMainWindow : public QMainWindow
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SimulatorMainWindow(QWidget * parent, const QString & firmwareId = "", quint8 flags=0, Qt::WindowFlags wflags = Qt::WindowFlags());
|
explicit SimulatorMainWindow(QWidget * parent, const QString & simulatorId = "", quint8 flags=0, Qt::WindowFlags wflags = Qt::WindowFlags());
|
||||||
~SimulatorMainWindow();
|
~SimulatorMainWindow();
|
||||||
|
|
||||||
int getExitStatus(QString * msg = Q_NULLPTR);
|
int getExitStatus(QString * msg = Q_NULLPTR);
|
||||||
|
|||||||
@@ -24,8 +24,11 @@
|
|||||||
#include "appdata.h"
|
#include "appdata.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "simulatorinterface.h"
|
#include "simulatorinterface.h"
|
||||||
|
#include "eeprominterface.h"
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QStandardItemModel>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
using namespace Simulator;
|
using namespace Simulator;
|
||||||
|
|
||||||
@@ -35,9 +38,12 @@ SimulatorStartupDialog::SimulatorStartupDialog(SimulatorOptions * options, int *
|
|||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::SimulatorStartupDialog),
|
ui(new Ui::SimulatorStartupDialog),
|
||||||
m_options(options),
|
m_options(options),
|
||||||
m_profileId(profId)
|
m_profileId(profId),
|
||||||
|
m_simProxy(nullptr)
|
||||||
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
this->setWindowIcon(QIcon(":/icon.png"));
|
||||||
|
|
||||||
QMapIterator<int, QString> pi(g.getActiveProfiles());
|
QMapIterator<int, QString> pi(g.getActiveProfiles());
|
||||||
while (pi.hasNext()) {
|
while (pi.hasNext()) {
|
||||||
@@ -45,7 +51,34 @@ SimulatorStartupDialog::SimulatorStartupDialog(SimulatorOptions * options, int *
|
|||||||
ui->radioProfile->addItem(pi.value(), pi.key());
|
ui->radioProfile->addItem(pi.value(), pi.key());
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->radioType->addItems(SimulatorLoader::getAvailableSimulators());
|
QStandardItemModel * fwModel = new QStandardItemModel(this);
|
||||||
|
foreach(Firmware * firmware, Firmware::getRegisteredFirmwares()) {
|
||||||
|
QStandardItem * item = new QStandardItem();
|
||||||
|
//qDebug() << "name:" << firmware->getName() << "firmware:" << firmware->getId() << "simulator:" << firmware->getSimulatorId();
|
||||||
|
item->setText(firmware->getName());
|
||||||
|
item->setData(firmware->getId(), IMDR_Id);
|
||||||
|
item->setData(firmware->getSimulatorId(), IMDR_SimulatorId);
|
||||||
|
fwModel->appendRow(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
QSortFilterProxyModel * fwProxy = new QSortFilterProxyModel(this);
|
||||||
|
fwProxy->setSourceModel(fwModel);
|
||||||
|
fwProxy->sort(1);
|
||||||
|
|
||||||
|
ui->cbRadioType->setModel(fwProxy);
|
||||||
|
|
||||||
|
QStandardItemModel * simModel = new QStandardItemModel(this);
|
||||||
|
foreach(QString sim, SimulatorLoader::getAvailableSimulators()) {
|
||||||
|
QStandardItem * item = new QStandardItem();
|
||||||
|
item->setText(sim);
|
||||||
|
simModel->appendRow(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_simProxy = new QSortFilterProxyModel(this);
|
||||||
|
m_simProxy->setSourceModel(simModel);
|
||||||
|
m_simProxy->sort(1);
|
||||||
|
|
||||||
|
ui->cbSimulator->setModel(m_simProxy);
|
||||||
|
|
||||||
ui->optGrp_dataSource->setId(ui->optFile, SimulatorOptions::START_WITH_FILE);
|
ui->optGrp_dataSource->setId(ui->optFile, SimulatorOptions::START_WITH_FILE);
|
||||||
ui->optGrp_dataSource->setId(ui->optFolder, SimulatorOptions::START_WITH_FOLDER);
|
ui->optGrp_dataSource->setId(ui->optFolder, SimulatorOptions::START_WITH_FOLDER);
|
||||||
@@ -58,8 +91,8 @@ SimulatorStartupDialog::SimulatorStartupDialog(SimulatorOptions * options, int *
|
|||||||
|
|
||||||
loadRadioProfile(*m_profileId);
|
loadRadioProfile(*m_profileId);
|
||||||
|
|
||||||
QObject::connect(ui->radioProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(onRadioProfileChanged(int)));
|
QObject::connect(ui->radioProfile, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &SimulatorStartupDialog::onRadioProfileChanged);
|
||||||
QObject::connect(ui->radioType, SIGNAL(currentIndexChanged(int)), this, SLOT(onRadioTypeChanged(int)));
|
QObject::connect(ui->cbRadioType, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &SimulatorStartupDialog::onRadioTypeChanged);
|
||||||
QObject::connect(ui->btnSelectDataFile, &QToolButton::clicked, this, &SimulatorStartupDialog::onDataFileSelect);
|
QObject::connect(ui->btnSelectDataFile, &QToolButton::clicked, this, &SimulatorStartupDialog::onDataFileSelect);
|
||||||
QObject::connect(ui->btnSelectDataFolder, &QToolButton::clicked, this, &SimulatorStartupDialog::onDataFolderSelect);
|
QObject::connect(ui->btnSelectDataFolder, &QToolButton::clicked, this, &SimulatorStartupDialog::onDataFolderSelect);
|
||||||
QObject::connect(ui->btnSelectSdPath, &QToolButton::clicked, this, &SimulatorStartupDialog::onSdPathSelect);
|
QObject::connect(ui->btnSelectSdPath, &QToolButton::clicked, this, &SimulatorStartupDialog::onSdPathSelect);
|
||||||
@@ -69,6 +102,7 @@ SimulatorStartupDialog::SimulatorStartupDialog(SimulatorOptions * options, int *
|
|||||||
SimulatorStartupDialog::~SimulatorStartupDialog()
|
SimulatorStartupDialog::~SimulatorStartupDialog()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
|
delete m_simProxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulatorStartupDialog::changeEvent(QEvent *e)
|
void SimulatorStartupDialog::changeEvent(QEvent *e)
|
||||||
@@ -86,12 +120,12 @@ void SimulatorStartupDialog::changeEvent(QEvent *e)
|
|||||||
// FIXME : need a better way to check for this
|
// FIXME : need a better way to check for this
|
||||||
bool SimulatorStartupDialog::usesCategorizedStorage(const QString & name)
|
bool SimulatorStartupDialog::usesCategorizedStorage(const QString & name)
|
||||||
{
|
{
|
||||||
return name.contains(QRegExp("(x12|x10|horus|16|18|nv14)", Qt::CaseInsensitive));
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SimulatorStartupDialog::usesCategorizedStorage()
|
bool SimulatorStartupDialog::usesCategorizedStorage()
|
||||||
{
|
{
|
||||||
return usesCategorizedStorage(ui->radioType->currentText());
|
return usesCategorizedStorage(ui->cbRadioType->currentText());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SimulatorStartupDialog::findRadioId(const QString & str)
|
QString SimulatorStartupDialog::findRadioId(const QString & str)
|
||||||
@@ -108,21 +142,21 @@ QString SimulatorStartupDialog::findRadioId(const QString & str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO : this could be smarter and actually look for a matching file in the folder
|
// TODO : this could be smarter and actually look for a matching file in the folder
|
||||||
QString SimulatorStartupDialog::radioEepromFileName(const QString & firmwareId, QString folder)
|
QString SimulatorStartupDialog::radioEepromFileName(const QString & simulatorId, QString folder)
|
||||||
{
|
{
|
||||||
QString eepromFileName = "", ext = "bin";
|
QString eepromFileName = "", ext = "bin";
|
||||||
|
|
||||||
if (folder.isEmpty())
|
if (folder.isEmpty())
|
||||||
folder = g.eepromDir();
|
folder = g.eepromDir();
|
||||||
|
|
||||||
QString radioId = findRadioId(firmwareId);
|
QString radioId = findRadioId(simulatorId);
|
||||||
int pos = radioId.indexOf("-");
|
int pos = radioId.indexOf("-");
|
||||||
if (pos > 0)
|
if (pos > 0)
|
||||||
radioId = radioId.mid(pos+1);
|
radioId = radioId.mid(pos+1);
|
||||||
if (usesCategorizedStorage(radioId))
|
if (usesCategorizedStorage(radioId))
|
||||||
ext = "etx";
|
ext = "etx";
|
||||||
|
|
||||||
eepromFileName = QString("eeprom-%1.%2").arg(radioId, ext);
|
eepromFileName = QString("%1.%2").arg(radioId, ext);
|
||||||
eepromFileName = QDir(folder).filePath(eepromFileName.toLatin1());
|
eepromFileName = QDir(folder).filePath(eepromFileName.toLatin1());
|
||||||
// qDebug() << "radioId" << radioId << "eepromFileName" << eepromFileName;
|
// qDebug() << "radioId" << radioId << "eepromFileName" << eepromFileName;
|
||||||
|
|
||||||
@@ -163,18 +197,31 @@ void SimulatorStartupDialog::loadRadioProfile(int id)
|
|||||||
|
|
||||||
*m_options = g.profile[id].simulatorOptions();
|
*m_options = g.profile[id].simulatorOptions();
|
||||||
|
|
||||||
tmpstr = m_options->firmwareId;
|
if (m_options->firmwareId.isEmpty() && !g.profile[id].fwType().isEmpty())
|
||||||
if (tmpstr.isEmpty() && !g.profile[id].fwType().isEmpty())
|
m_options->firmwareId = g.profile[id].fwType();
|
||||||
tmpstr = g.profile[id].fwType();
|
|
||||||
else if (!(tmpstr2 = SimulatorLoader::findSimulatorByFirmwareName(m_options->firmwareId)).isEmpty())
|
m_options->firmwareId = findRadioId(m_options->firmwareId);
|
||||||
tmpstr = tmpstr2;
|
|
||||||
i = ui->radioType->findText(findRadioId(tmpstr), Qt::MatchContains);
|
i = ui->cbRadioType->findData(m_options->firmwareId, IMDR_Id, Qt::MatchContains);
|
||||||
if (i > -1)
|
if (i > -1)
|
||||||
ui->radioType->setCurrentIndex(i);
|
ui->cbRadioType->setCurrentIndex(i);
|
||||||
|
|
||||||
|
setGlobalFirmware(m_options->firmwareId);
|
||||||
|
|
||||||
|
// always refresh as linked simulatorId as could change over time
|
||||||
|
m_options->simulatorId = getCurrentFirmware()->getSimulatorId();
|
||||||
|
|
||||||
|
m_simProxy->setFilterFixedString(m_options->simulatorId);
|
||||||
|
|
||||||
|
i = ui->cbSimulator->findText(findRadioId(m_options->simulatorId), Qt::MatchContains);
|
||||||
|
if (i > -1)
|
||||||
|
ui->cbSimulator->setCurrentIndex(i);
|
||||||
|
|
||||||
|
//qDebug() << "firmware:" << m_options->firmwareId << "simulator:" << m_options->simulatorId;
|
||||||
|
|
||||||
tmpstr = m_options->dataFile;
|
tmpstr = m_options->dataFile;
|
||||||
if (tmpstr.isEmpty())
|
if (tmpstr.isEmpty())
|
||||||
tmpstr = radioEepromFileName(ui->radioType->currentText());
|
tmpstr = radioEepromFileName(ui->cbRadioType->currentData().toString());
|
||||||
ui->dataFile->setText(tmpstr);
|
ui->dataFile->setText(tmpstr);
|
||||||
|
|
||||||
tmpstr = m_options->dataFolder;
|
tmpstr = m_options->dataFolder;
|
||||||
@@ -199,8 +246,12 @@ void SimulatorStartupDialog::loadRadioProfile(int id)
|
|||||||
|
|
||||||
void SimulatorStartupDialog::accept()
|
void SimulatorStartupDialog::accept()
|
||||||
{
|
{
|
||||||
|
if (ui->cbSimulator->currentText() == "")
|
||||||
|
return;
|
||||||
|
|
||||||
*m_profileId = ui->radioProfile->currentData().toInt();
|
*m_profileId = ui->radioProfile->currentData().toInt();
|
||||||
m_options->firmwareId = ui->radioType->currentText();
|
m_options->firmwareId = ui->cbRadioType->currentData().toString();
|
||||||
|
m_options->simulatorId = ui->cbSimulator->currentText();
|
||||||
m_options->dataFile = ui->dataFile->text();
|
m_options->dataFile = ui->dataFile->text();
|
||||||
m_options->dataFolder = ui->dataFolder->text();
|
m_options->dataFolder = ui->dataFolder->text();
|
||||||
m_options->sdPath = ui->sdPath->text();
|
m_options->sdPath = ui->sdPath->text();
|
||||||
@@ -221,8 +272,21 @@ void SimulatorStartupDialog::onRadioTypeChanged(int index)
|
|||||||
{
|
{
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
return;
|
return;
|
||||||
ui->dataFile->setText(radioEepromFileName(ui->radioType->currentText()));
|
|
||||||
|
QString id = ui->cbRadioType->currentData(IMDR_Id).toString();
|
||||||
|
ui->dataFile->setText(radioEepromFileName(id));
|
||||||
updateContainerTypes();
|
updateContainerTypes();
|
||||||
|
|
||||||
|
setGlobalFirmware(id);
|
||||||
|
|
||||||
|
// always refresh as linked simulatorId as could change over time
|
||||||
|
id = getCurrentFirmware()->getSimulatorId();
|
||||||
|
|
||||||
|
m_simProxy->setFilterFixedString(id);
|
||||||
|
|
||||||
|
const int i = ui->cbSimulator->findText(findRadioId(id), Qt::MatchContains);
|
||||||
|
if (i > -1)
|
||||||
|
ui->cbSimulator->setCurrentIndex(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulatorStartupDialog::onDataFileSelect(bool)
|
void SimulatorStartupDialog::onDataFileSelect(bool)
|
||||||
@@ -257,3 +321,9 @@ void SimulatorStartupDialog::onSdPathSelect(bool)
|
|||||||
ui->optSdPath->setChecked(true);
|
ui->optSdPath->setChecked(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimulatorStartupDialog::setGlobalFirmware(const QString & id)
|
||||||
|
{
|
||||||
|
Firmware::setCurrentVariant(Firmware::getFirmwareForId(id));
|
||||||
|
//qDebug() << "current firmware:" << getCurrentFirmware()->getId();
|
||||||
|
}
|
||||||
|
|||||||
@@ -28,18 +28,26 @@ namespace Ui {
|
|||||||
class SimulatorStartupDialog;
|
class SimulatorStartupDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class QSortFilterProxyModel;
|
||||||
|
|
||||||
class SimulatorStartupDialog : public QDialog
|
class SimulatorStartupDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
enum ItemModelDataRoles {
|
||||||
|
IMDR_Id = Qt::UserRole,
|
||||||
|
IMDR_SimulatorId
|
||||||
|
};
|
||||||
|
Q_ENUM(ItemModelDataRoles)
|
||||||
|
|
||||||
explicit SimulatorStartupDialog(SimulatorOptions * options, int * profId, QWidget *parent = 0);
|
explicit SimulatorStartupDialog(SimulatorOptions * options, int * profId, QWidget *parent = 0);
|
||||||
~SimulatorStartupDialog();
|
~SimulatorStartupDialog();
|
||||||
|
|
||||||
static bool usesCategorizedStorage(const QString & name);
|
static bool usesCategorizedStorage(const QString & name);
|
||||||
static QString findRadioId(const QString & str);
|
static QString findRadioId(const QString & str);
|
||||||
static QString radioEepromFileName(const QString & firmwareId, QString folder = "");
|
static QString radioEepromFileName(const QString & simulatorId, QString folder = "");
|
||||||
|
|
||||||
void updateContainerTypes();
|
void updateContainerTypes();
|
||||||
|
|
||||||
@@ -62,6 +70,9 @@ class SimulatorStartupDialog : public QDialog
|
|||||||
Ui::SimulatorStartupDialog *ui;
|
Ui::SimulatorStartupDialog *ui;
|
||||||
SimulatorOptions * m_options;
|
SimulatorOptions * m_options;
|
||||||
int * m_profileId;
|
int * m_profileId;
|
||||||
|
QSortFilterProxyModel * m_simProxy;
|
||||||
|
|
||||||
|
void setGlobalFirmware(const QString & id);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SIMULATORSTARTUPDIALOG_H
|
#endif // SIMULATORSTARTUPDIALOG_H
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>550</width>
|
<width>550</width>
|
||||||
<height>217</height>
|
<height>284</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
@@ -97,7 +97,7 @@ Create or edit profiles using the Companion application.</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QComboBox" name="radioType">
|
<widget class="QComboBox" name="cbRadioType">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@@ -110,35 +110,35 @@ The radio type specified in the selected profile is used by default.</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="label_6">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Data Source:</string>
|
<string>Data Source:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Data File:</string>
|
<string>Data File:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="QLabel" name="label_5">
|
<widget class="QLabel" name="label_5">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Data Folder:</string>
|
<string>Data Folder:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="6" column="0">
|
||||||
<widget class="QLabel" name="label_7">
|
<widget class="QLabel" name="label_7">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>SD Image Path:</string>
|
<string>SD Image Path:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QWidget" name="wdgt_dataFile" native="true">
|
<widget class="QWidget" name="wdgt_dataFile" native="true">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
@@ -165,8 +165,8 @@ The radio type specified in the selected profile is used by default.</string>
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="dataFile">
|
<widget class="QLineEdit" name="dataFile">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Radio data (.bin/.eeprom/.otx) image file to use. A new file with a default image will be created if necessary.<br />
|
<string>Radio data (.etx) settings file to use. A new file with default settings will be created if necessary.<br />
|
||||||
<b>NOTE</b>: any existing EEPROM data incompatible with the selected radio type may be overwritten!</string>
|
<b>NOTE</b>: any existing data incompatible with the selected radio type may be overwritten!</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -190,7 +190,7 @@ The radio type specified in the selected profile is used by default.</string>
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="5" column="1">
|
||||||
<widget class="QWidget" name="wdgt_dataFolder" native="true">
|
<widget class="QWidget" name="wdgt_dataFolder" native="true">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
@@ -242,7 +242,7 @@ New folder(s) with default radio/model will be created here if necessary.</strin
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1">
|
<item row="6" column="1">
|
||||||
<widget class="QWidget" name="wdgt_sdPath" native="true">
|
<widget class="QWidget" name="wdgt_sdPath" native="true">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
@@ -294,7 +294,7 @@ The default is configured in the chosen Radio Profile.</string>
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QWidget" name="wdgt_dataSource" native="true">
|
<widget class="QWidget" name="wdgt_dataSource" native="true">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
@@ -354,6 +354,16 @@ The default is configured in the chosen Radio Profile.</string>
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Simulator:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QComboBox" name="cbSimulator"/>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -391,7 +391,7 @@ bool SimulatorWidget::useTempDataPath(bool deleteOnClose)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will save radio data from temporary folder structure back into an .etx file, eg. for Horus.
|
// This will save radio data from temporary folder structure back into an .etx file
|
||||||
bool SimulatorWidget::saveTempData()
|
bool SimulatorWidget::saveTempData()
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|||||||
+19
-16
@@ -60,7 +60,7 @@ void showMessage(const QString & message, enum QMessageBox::Icon icon = QMessage
|
|||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
msgBox.setText("<html><body><pre>" + message.toHtmlEscaped() + "</pre></body></html>");
|
msgBox.setText("<html><body><pre>" + message.toHtmlEscaped() + "</pre></body></html>");
|
||||||
msgBox.setIcon(icon);
|
msgBox.setIcon(icon);
|
||||||
msgBox.setWindowTitle(QApplication::translate("SimulatorMain", "OpenTx Simulator"));
|
msgBox.setWindowTitle(QApplication::translate("SimulatorMain", "EdgeTx Simulator"));
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ CommandLineParseResult cliOptions(SimulatorOptions * simOptions, int * profileId
|
|||||||
QApplication::translate("SimulatorMain", "path"));
|
QApplication::translate("SimulatorMain", "path"));
|
||||||
|
|
||||||
const QCommandLineOption optStart(QStringList() << "start-with" << "w",
|
const QCommandLineOption optStart(QStringList() << "start-with" << "w",
|
||||||
QApplication::translate("SimulatorMain", "Data source type to use (applicable to Horus only). One of:") + " (file|folder|sd)",
|
QApplication::translate("SimulatorMain", "Data source type to use. One of:") + " (file|folder|sd)",
|
||||||
QApplication::translate("SimulatorMain", "type"));
|
QApplication::translate("SimulatorMain", "type"));
|
||||||
|
|
||||||
cliOptions.addPositionalArgument(QApplication::translate("SimulatorMain", "data-source"),
|
cliOptions.addPositionalArgument(QApplication::translate("SimulatorMain", "data-source"),
|
||||||
@@ -180,9 +180,9 @@ CommandLineParseResult cliOptions(SimulatorOptions * simOptions, int * profileId
|
|||||||
cliOptsFound = true;
|
cliOptsFound = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cliOptsFound || (simOptions->dataFile.isEmpty() && !simOptions->firmwareId.isEmpty())) {
|
if (cliOptsFound || (simOptions->dataFile.isEmpty() && !simOptions->simulatorId.isEmpty())) {
|
||||||
// this constructs a new default radio data file name in the user-configured eeprom directory
|
// this constructs a new default radio data file name in the user-configured eeprom directory
|
||||||
simOptions->dataFile = SimulatorStartupDialog::radioEepromFileName(simOptions->firmwareId, g.eepromDir());
|
simOptions->dataFile = SimulatorStartupDialog::radioEepromFileName(simOptions->simulatorId, g.eepromDir());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cliOptions.isSet(optSdDir)) {
|
if (cliOptions.isSet(optSdDir)) {
|
||||||
@@ -231,11 +231,8 @@ CommandLineParseResult cliOptions(SimulatorOptions * simOptions, int * profileId
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
|
||||||
/* From doc: This attribute must be set before Q(Gui)Application is constructed. */
|
/* From doc: This attribute must be set before Q(Gui)Application is constructed. */
|
||||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
#endif
|
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
app.setApplicationName(APP_SIMULATOR);
|
app.setApplicationName(APP_SIMULATOR);
|
||||||
@@ -291,8 +288,13 @@ int main(int argc, char *argv[])
|
|||||||
SimulatorOptions simOptions = g.profile[profileId].simulatorOptions();
|
SimulatorOptions simOptions = g.profile[profileId].simulatorOptions();
|
||||||
|
|
||||||
// TODO : defaults should be set in Profile::init()
|
// TODO : defaults should be set in Profile::init()
|
||||||
if (simOptions.firmwareId.isEmpty())
|
if (simOptions.firmwareId.isEmpty()) {
|
||||||
simOptions.firmwareId = SimulatorLoader::findSimulatorByFirmwareName(g.profile[profileId].fwType());
|
simOptions.firmwareId = g.profile[profileId].fwType();
|
||||||
|
}
|
||||||
|
|
||||||
|
// do not used saved simulatorId always refresh
|
||||||
|
simOptions.simulatorId = SimulatorLoader::findSimulatorByName(Firmware::getFirmwareForId(simOptions.firmwareId)->getSimulatorId());
|
||||||
|
|
||||||
if (simOptions.dataFolder.isEmpty())
|
if (simOptions.dataFolder.isEmpty())
|
||||||
simOptions.dataFolder = g.eepromDir();
|
simOptions.dataFolder = g.eepromDir();
|
||||||
if (simOptions.sdPath.isEmpty())
|
if (simOptions.sdPath.isEmpty())
|
||||||
@@ -309,7 +311,7 @@ int main(int argc, char *argv[])
|
|||||||
return finish(1);
|
return finish(1);
|
||||||
|
|
||||||
// Present GUI startup options dialog if necessary
|
// Present GUI startup options dialog if necessary
|
||||||
if (cliResult == CommandLineNone || profileId == -1 || simOptions.firmwareId.isEmpty() || (simOptions.dataFile.isEmpty() && simOptions.dataFolder.isEmpty())) {
|
if (cliResult == CommandLineNone || profileId == -1 || simOptions.simulatorId.isEmpty() || (simOptions.dataFile.isEmpty() && simOptions.dataFolder.isEmpty())) {
|
||||||
SimulatorStartupDialog * dlg = new SimulatorStartupDialog(&simOptions, &profileId);
|
SimulatorStartupDialog * dlg = new SimulatorStartupDialog(&simOptions, &profileId);
|
||||||
int ret = dlg->exec();
|
int ret = dlg->exec();
|
||||||
delete dlg;
|
delete dlg;
|
||||||
@@ -322,14 +324,14 @@ int main(int argc, char *argv[])
|
|||||||
// Validate startup options
|
// Validate startup options
|
||||||
|
|
||||||
QString resultMsg;
|
QString resultMsg;
|
||||||
if (profileId < 0 || simOptions.firmwareId.isEmpty() || (simOptions.dataFile.isEmpty() && simOptions.dataFolder.isEmpty() && simOptions.sdPath.isEmpty())) {
|
if (profileId < 0 || simOptions.simulatorId.isEmpty() || (simOptions.dataFile.isEmpty() && simOptions.dataFolder.isEmpty() && simOptions.sdPath.isEmpty())) {
|
||||||
resultMsg = QApplication::translate("SimulatorMain", "ERROR: Couldn't start simulator, missing radio/profile/data file/folder.\n Profile ID: [%1]; Radio ID: [%2];\nData File: [%3]");
|
resultMsg = QApplication::translate("SimulatorMain", "ERROR: Couldn't start simulator, missing radio/profile/data file/folder.\n Profile ID: [%1]; Radio ID: [%2];\nData File: [%3]");
|
||||||
showMessage(resultMsg.arg(profileId).arg(simOptions.firmwareId, simOptions.dataFile), QMessageBox::Critical);
|
showMessage(resultMsg.arg(profileId).arg(simOptions.simulatorId, simOptions.dataFile), QMessageBox::Critical);
|
||||||
return finish(1);
|
return finish(1);
|
||||||
}
|
}
|
||||||
if (!g.getActiveProfiles().contains(profileId) || !SimulatorLoader::getAvailableSimulators().contains(simOptions.firmwareId)) {
|
if (!g.getActiveProfiles().contains(profileId) || !SimulatorLoader::getAvailableSimulators().contains(simOptions.simulatorId)) {
|
||||||
QTextStream stream(&resultMsg);
|
QTextStream stream(&resultMsg);
|
||||||
stream << QApplication::translate("SimulatorMain", "ERROR: Radio profile or simulator firmware not found.\nProfile ID: [%1]; Radio ID: [%2]").arg(profileId).arg(simOptions.firmwareId);
|
stream << QApplication::translate("SimulatorMain", "ERROR: Radio profile or simulator firmware not found.\nProfile ID: [%1]; Radio ID: [%2]").arg(profileId).arg(simOptions.simulatorId);
|
||||||
stream << sharedHelpText();
|
stream << sharedHelpText();
|
||||||
showMessage(resultMsg, QMessageBox::Critical);
|
showMessage(resultMsg, QMessageBox::Critical);
|
||||||
return finish(1);
|
return finish(1);
|
||||||
@@ -342,12 +344,13 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Set global firmware environment
|
// Set global firmware environment
|
||||||
Firmware::setCurrentVariant(Firmware::getFirmwareForId(simOptions.firmwareId));
|
Firmware::setCurrentVariant(Firmware::getFirmwareForId(simOptions.firmwareId));
|
||||||
|
//qDebug() << "current firmware:" << getCurrentFirmware()->getId();
|
||||||
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
SimulatorMainWindow * mainWindow = new SimulatorMainWindow(NULL, simOptions.firmwareId, SIMULATOR_FLAGS_STANDALONE);
|
SimulatorMainWindow * mainWindow = new SimulatorMainWindow(NULL, simOptions.simulatorId, SIMULATOR_FLAGS_STANDALONE);
|
||||||
if ((result = mainWindow->getExitStatus(&resultMsg))) {
|
if ((result = mainWindow->getExitStatus(&resultMsg))) {
|
||||||
if (resultMsg.isEmpty())
|
if (resultMsg.isEmpty())
|
||||||
resultMsg = QApplication::translate("SimulatorMain", "Uknown error during Simulator startup.");
|
resultMsg = QApplication::translate("SimulatorMain", "Unknown error during Simulator startup.");
|
||||||
showMessage(resultMsg, QMessageBox::Critical);
|
showMessage(resultMsg, QMessageBox::Critical);
|
||||||
}
|
}
|
||||||
else if (mainWindow->setOptions(simOptions, true)) {
|
else if (mainWindow->setOptions(simOptions, true)) {
|
||||||
|
|||||||
@@ -780,24 +780,7 @@ bool UpdateInterface::setFilteredAssets(const UpdateParameters::AssetParams & ap
|
|||||||
|
|
||||||
void UpdateInterface::setFirmwareFlavour()
|
void UpdateInterface::setFirmwareFlavour()
|
||||||
{
|
{
|
||||||
const QStringList currVariant = getCurrentFirmware()->getId().split('-');
|
m_params->fwFlavour = getCurrentFirmware()->getDownloadId();
|
||||||
|
|
||||||
m_params->fwFlavour = "";
|
|
||||||
|
|
||||||
if (currVariant.size() > 1) {
|
|
||||||
m_params->fwFlavour = currVariant.at(1);
|
|
||||||
// Companion registered firmware identities (refer opentxinterface.cpp) do not always match the EdgeTX repo fw.json file
|
|
||||||
const QMap<QString, QString> map = {
|
|
||||||
{ "x7access", "x7-access" },
|
|
||||||
{ "x9d+", "x9dp" },
|
|
||||||
{ "x9d+2019", "x9dp2019" },
|
|
||||||
{ "x9ehall", "x9e-hall" },
|
|
||||||
{ "x10express", "x10-access" }
|
|
||||||
};
|
|
||||||
QString repofw = map[m_params->fwFlavour];
|
|
||||||
if (!repofw.isEmpty())
|
|
||||||
m_params->fwFlavour = repofw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateInterface::setLanguage()
|
void UpdateInterface::setLanguage()
|
||||||
|
|||||||
@@ -187,7 +187,8 @@ void OpenTxSimulator::readRadioData(QByteArray & dest)
|
|||||||
{
|
{
|
||||||
#if defined(EEPROM_SIZE)
|
#if defined(EEPROM_SIZE)
|
||||||
QMutexLocker lckr(&m_mtxRadioData);
|
QMutexLocker lckr(&m_mtxRadioData);
|
||||||
memcpy(dest.data(), eeprom, std::min<int>(EEPROM_SIZE, dest.size()));
|
if (eeprom)
|
||||||
|
memcpy(dest.data(), eeprom, qMin<int>(EEPROM_SIZE, dest.size()));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user