mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
Update sim base and the sims
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
#include "sim-can_debugger.h"
|
#include "sim-can_debugger.h"
|
||||||
#include "ui_sim-can_debugger.h"
|
#include "ui_sim-can_debugger.h"
|
||||||
|
|
||||||
Can_Debugger::Can_Debugger(OpenAPI::OAICANApiApi* api, QWidget *parent) :
|
Can_Debugger::Can_Debugger(Web_socket_wrapper* web_socket, QWidget *parent) :
|
||||||
SimulatorBase(api, parent),
|
SimulatorBase(web_socket, parent),
|
||||||
ui(new Ui::Can_Debugger) {
|
ui(new Ui::Can_Debugger) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->setWindowTitle("CAN Debugger");
|
this->setWindowTitle("CAN Debugger");
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class Can_Debugger : public SimulatorBase {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Can_Debugger(OpenAPI::OAICANApiApi* api, QWidget *parent = nullptr);
|
explicit Can_Debugger(Web_socket_wrapper* web_socket, QWidget *parent = nullptr);
|
||||||
~Can_Debugger();
|
~Can_Debugger();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
+82
-138
@@ -1,24 +1,16 @@
|
|||||||
#include "simulatorbase.h"
|
#include "simulatorbase.h"
|
||||||
|
|
||||||
SimulatorBase::SimulatorBase(OpenAPI::OAICANApiApi* api, QWidget* parent) :
|
SimulatorBase::SimulatorBase(Web_socket_wrapper* web_socket, QWidget* parent) :
|
||||||
QMainWindow{parent},
|
QMainWindow{parent},
|
||||||
error_dialog(new NetworkError(this))
|
m_error_dialog(new NetworkError(this))
|
||||||
{
|
{
|
||||||
this->api = api;
|
this->m_web_socket = web_socket;
|
||||||
timer_update = new QTimer(this);
|
|
||||||
timer_update->connect(timer_update, &QTimer::timeout, this, [=]{sim_update();});
|
|
||||||
refresh_rate = 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimulatorBase::sim_update(void)
|
|
||||||
{
|
|
||||||
api->apiCanapiCurrentsimGet();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulatorBase::showEvent( QShowEvent* event )
|
void SimulatorBase::showEvent( QShowEvent* event )
|
||||||
{
|
{
|
||||||
QWidget::showEvent( event );
|
QWidget::showEvent( event );
|
||||||
QD << "Starting refresh timer";
|
QD << "Connecting callbacks";
|
||||||
setup_cb();
|
setup_cb();
|
||||||
this->timer_update->start(refresh_rate);
|
this->timer_update->start(refresh_rate);
|
||||||
closed = false;
|
closed = false;
|
||||||
@@ -39,95 +31,71 @@ void SimulatorBase::closeEvent(QCloseEvent* event)
|
|||||||
|
|
||||||
void SimulatorBase::setup_cb(void)
|
void SimulatorBase::setup_cb(void)
|
||||||
{
|
{
|
||||||
connect(api, &OpenAPI::OAICANApiApi::apiCanapiUielementsPushbuttonPostSignal, this, [this](bool output){apiCanapiUielements_bool_cb(output);});
|
connect(m_web_socket, &Web_socket_wrapper::on_command_cb, this, [=](json& j){on_cmd_cb(j);});
|
||||||
connect(api, &OpenAPI::OAICANApiApi::apiCanapiUielementsPushbuttonPostSignalError, this, [this](bool output, QNetworkReply::NetworkError error_type, QString error_str){apiCanapiUielements_bool_cb(false, false, error_type, error_str);});
|
connect(m_web_socket, &Web_socket_wrapper::on_event_cb, this, [=](json& j){on_event_cb(j);});
|
||||||
|
|
||||||
connect(api, &OpenAPI::OAICANApiApi::apiCanapiUielementsPushbuttonarrayPostSignal, this, [this](bool output){apiCanapiUielements_bool_cb(output);});
|
|
||||||
connect(api, &OpenAPI::OAICANApiApi::apiCanapiUielementsPushbuttonarrayPostSignalError, this, [this](bool output, QNetworkReply::NetworkError error_type, QString error_str){apiCanapiUielements_bool_cb(false, false, error_type, error_str);});
|
|
||||||
|
|
||||||
connect(api, &OpenAPI::OAICANApiApi::apiCanapiUielementsTextboxPostSignal, this, [this](bool output){apiCanapiUielements_bool_cb(output);});
|
|
||||||
connect(api, &OpenAPI::OAICANApiApi::apiCanapiUielementsTextboxPostSignalError, this, [this](bool output, QNetworkReply::NetworkError error_type, QString error_str){apiCanapiUielements_bool_cb(false, false, error_type, error_str);});
|
|
||||||
|
|
||||||
connect(api, &OpenAPI::OAICANApiApi::apiCanapiUielementsSliderPostSignal, this, [this](bool output){apiCanapiUielements_bool_cb(output);});
|
|
||||||
connect(api, &OpenAPI::OAICANApiApi::apiCanapiUielementsSliderPostSignalError, this, [this](bool output, QNetworkReply::NetworkError error_type, QString error_str){apiCanapiUielements_bool_cb(false, false, error_type, error_str);});
|
|
||||||
|
|
||||||
connect(api, &OpenAPI::OAICANApiApi::apiCanapiUielementsTogglearrayPostSignal, this, [this](bool output){apiCanapiUielements_bool_cb(output);});
|
|
||||||
connect(api, &OpenAPI::OAICANApiApi::apiCanapiUielementsTogglearrayPostSignalError, this, [this](bool output, QNetworkReply::NetworkError error_type, QString error_str){apiCanapiUielements_bool_cb(false, false, error_type, error_str);});
|
|
||||||
|
|
||||||
connect(api, &OpenAPI::OAICANApiApi::apiCanapiCurrentsimGetSignal, this, [this](OpenAPI::OAISimulatorInfo summary){apiCanapiCurrentsimGet_cb(summary);});
|
|
||||||
connect(api, &OpenAPI::OAICANApiApi::apiCanapiCurrentsimGetSignalError, this, [this](OpenAPI::OAISimulatorInfo summary, QNetworkReply::NetworkError error_type, QString error_str){apiCanapiCurrentsimGet_cb(OpenAPI::OAISimulatorInfo(), error_type, error_str);});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulatorBase::apiCanapiUielements_bool_cb(bool output, bool currentsim, QNetworkReply::NetworkError error_type, QString error_str)
|
void SimulatorBase::on_cmd_cb(json& j)
|
||||||
{
|
{
|
||||||
if (error_type) {
|
auto response = magic_enum::enum_cast<Web_socket_wrapper::Command>(std::string(j.at("type"))).value_or(Web_socket_wrapper::Command::end);
|
||||||
QD << "( " << Qt::hex << output << "," << error_type << "," << error_str << ")";
|
switch (response)
|
||||||
error_dialog->set_error(error_str + "\n" + network_reply_to_fix(error_type));
|
|
||||||
error_dialog->open();
|
|
||||||
return;
|
|
||||||
} if (!output) {
|
|
||||||
QD << " got called with invalid data and no error!";
|
|
||||||
error_dialog->set_error(QString(__FUNCTION__) + " got called with invalid data and no error!");
|
|
||||||
error_dialog->open();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimulatorBase::apiCanapiCurrentsimGet_cb(OpenAPI::OAISimulatorInfo summary, QNetworkReply::NetworkError error_type, QString error_str)
|
|
||||||
{
|
|
||||||
if (error_type) {
|
|
||||||
QD << "( " << summary.asJson() << "," << error_type << "," << error_str << ")";
|
|
||||||
error_dialog->set_error(error_str + "\n" + network_reply_to_fix(error_type));
|
|
||||||
error_dialog->open();
|
|
||||||
return;
|
|
||||||
} if (!summary.isValid()) {
|
|
||||||
QD << " got called with invalid data and no error!";
|
|
||||||
error_dialog->set_error(QString(__FUNCTION__) + " got called with invalid data and no error!");
|
|
||||||
error_dialog->open();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
OAISimulatorInfo_parser(summary);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimulatorBase::OAISimulatorInfo_parser(OpenAPI::OAISimulatorInfo input)
|
|
||||||
{
|
|
||||||
const OpenAPI::OAIClientUIItem* uiItem;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < input.getUiItems().count(); i++)
|
|
||||||
{
|
{
|
||||||
uiItem = &(input.getUiItems().at(i));
|
case Web_socket_wrapper::Command::get_UI_elements:
|
||||||
|
UI_item_parser(j);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (uiItem->getType() == "UIButtonArray")
|
void SimulatorBase::on_event_cb(json& j)
|
||||||
|
{
|
||||||
|
auto response = magic_enum::enum_cast<Web_socket_wrapper::Event>(std::string(j.at("type"))).value_or(Web_socket_wrapper::Event::end);
|
||||||
|
switch (response)
|
||||||
|
{
|
||||||
|
case Web_socket_wrapper::Event::ui_changed:
|
||||||
|
UI_item_parser(j);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SimulatorBase::UI_item_parser(json& input)
|
||||||
|
{
|
||||||
|
for (auto& uiItem : input["UI_items"])
|
||||||
|
{
|
||||||
|
if (uiItem["type"] == "UI_button")
|
||||||
{
|
{
|
||||||
process_ui_button_array(uiItem);
|
process_ui_button(uiItem);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (uiItem->getType() == "UILedArray")
|
if (uiItem["type"] == "UI_led")
|
||||||
{
|
{
|
||||||
process_ui_led_array(uiItem);
|
process_ui_led(uiItem);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (uiItem->getType() == "UISlider")
|
if (uiItem["type"] == "UI_slider")
|
||||||
{
|
{
|
||||||
process_ui_slider(uiItem);
|
process_ui_slider(uiItem);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (uiItem->getType() == "UITextbox")
|
if (uiItem["type"] == "UI_textbox")
|
||||||
{
|
{
|
||||||
process_ui_textbox(uiItem);
|
process_ui_textbox(uiItem);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (uiItem->getType() == "UILabel")
|
if (uiItem["type"] == "UI_label")
|
||||||
{
|
{
|
||||||
process_ui_label(uiItem);
|
process_ui_label(uiItem);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (uiItem->getType() == "UICombobox")
|
if (uiItem["type"] == "UI_combobox")
|
||||||
{
|
{
|
||||||
process_ui_combobox(uiItem);
|
process_ui_combobox(uiItem);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (uiItem->getType() == "UIRadioButton")
|
if (uiItem["type"] == "UIRadioButton")
|
||||||
{
|
{
|
||||||
process_ui_radiobutton(uiItem);
|
process_ui_radiobutton(uiItem);
|
||||||
continue;
|
continue;
|
||||||
@@ -135,36 +103,16 @@ void SimulatorBase::OAISimulatorInfo_parser(OpenAPI::OAISimulatorInfo input)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulatorBase::process_ui_button_array(const OpenAPI::OAIClientUIItem* uiItem)
|
void SimulatorBase::process_ui_label(json& uiItem)
|
||||||
{
|
{
|
||||||
QJsonObject state = uiItem->getState().asJsonObject();
|
QLabel* label = id_to_label(QString::fromStdString(uiItem["id"]));
|
||||||
QJsonArray state_array = state["buttonArray"].toArray();
|
|
||||||
for (size_t i = 0; i < state_array.count(); i++)
|
|
||||||
{
|
|
||||||
process_ui_button_array_element(state_array[i].toObject());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimulatorBase::process_ui_led_array(const OpenAPI::OAIClientUIItem* uiItem)
|
|
||||||
{
|
|
||||||
QJsonObject state = uiItem->getState().asJsonObject();
|
|
||||||
QJsonArray state_array = state["ledArray"].toArray();
|
|
||||||
for (size_t i = 0; i < state_array.count(); i++)
|
|
||||||
{
|
|
||||||
process_ui_led_array_element(state_array[i].toObject());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimulatorBase::process_ui_label(const OpenAPI::OAIClientUIItem* uiItem)
|
|
||||||
{
|
|
||||||
QLabel* label = id_to_label(uiItem->getName());
|
|
||||||
if (label == nullptr)
|
if (label == nullptr)
|
||||||
{
|
{
|
||||||
QD << "id_to_label returned null on " << uiItem->getName();
|
QD << "id_to_label returned null on " << QString::fromStdString(uiItem["id"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString value = uiItem->getState().asJsonObject()["textString"].toString();
|
QString value = QString::fromStdString(uiItem["text"]);
|
||||||
|
|
||||||
if (label->text() != value)
|
if (label->text() != value)
|
||||||
{
|
{
|
||||||
@@ -172,27 +120,27 @@ void SimulatorBase::process_ui_label(const OpenAPI::OAIClientUIItem* uiItem)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulatorBase::process_ui_slider(const OpenAPI::OAIClientUIItem* uiItem)
|
void SimulatorBase::process_ui_slider(json& uiItem)
|
||||||
{
|
{
|
||||||
if (uiItem->getName().startsWith('t'))
|
if (QString::fromStdString(uiItem["id"]).startsWith('t'))
|
||||||
{
|
{
|
||||||
QwtSlider* slider = id_to_slider(uiItem->getName());
|
QwtSlider* slider = id_to_slider(QString::fromStdString(uiItem["id"]));
|
||||||
QLabel* label = id_to_slider_label(uiItem->getName());
|
QLabel* label = id_to_slider_label(QString::fromStdString(uiItem["id"]));
|
||||||
if (slider == nullptr)
|
if (slider == nullptr)
|
||||||
{
|
{
|
||||||
QD << "id_to_slider returned null on " << uiItem->getName();
|
QD << "id_to_slider returned null on " << QString::fromStdString(uiItem["id"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double value = uiItem->getState().asJsonObject()["currentValue"].toDouble();
|
double value = uiItem["value"];
|
||||||
bool enable = uiItem->getState().asJsonObject()["enable"].toBool();
|
bool enable = uiItem["enabled"];
|
||||||
bool visible = uiItem->getState().asJsonObject()["visible"].toBool();
|
bool visible = uiItem["visible"];
|
||||||
|
|
||||||
if (slider->value() != value)
|
if (slider->value() != value)
|
||||||
{
|
{
|
||||||
if (label != nullptr)
|
if (label != nullptr)
|
||||||
{
|
{
|
||||||
label->setText(format_slider_value(uiItem->getName(), value));
|
label->setText(format_slider_value(QString::fromStdString(uiItem["id"]), value));
|
||||||
}
|
}
|
||||||
slider->setValue(value);
|
slider->setValue(value);
|
||||||
}
|
}
|
||||||
@@ -210,24 +158,24 @@ void SimulatorBase::process_ui_slider(const OpenAPI::OAIClientUIItem* uiItem)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uiItem->getName().startsWith('d'))
|
if (QString::fromStdString(uiItem["id"]).startsWith('d'))
|
||||||
{
|
{
|
||||||
QwtDial* dial = id_to_dial(uiItem->getName());
|
QwtDial* dial = id_to_dial(QString::fromStdString(uiItem["id"]));
|
||||||
QLabel* label = id_to_dial_label(uiItem->getName());
|
QLabel* label = id_to_dial_label(QString::fromStdString(uiItem["id"]));
|
||||||
if (dial == nullptr)
|
if (dial == nullptr)
|
||||||
{
|
{
|
||||||
QD << "id_to_dial returned null on " << uiItem->getName();
|
QD << "id_to_dial returned null on " << QString::fromStdString(uiItem["id"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double value = uiItem->getState().asJsonObject()["currentValue"].toDouble();
|
double value = uiItem["value"];
|
||||||
bool visible = uiItem->getState().asJsonObject()["visible"].toBool();
|
bool visible = uiItem["visible"];
|
||||||
|
|
||||||
if (dial->value() != value)
|
if (dial->value() != value)
|
||||||
{
|
{
|
||||||
if (label != nullptr)
|
if (label != nullptr)
|
||||||
{
|
{
|
||||||
label->setText(format_dial_value(uiItem->getName(), value));
|
label->setText(format_dial_value(QString::fromStdString(uiItem["id"]), value));
|
||||||
}
|
}
|
||||||
dial->setValue(value);
|
dial->setValue(value);
|
||||||
}
|
}
|
||||||
@@ -240,31 +188,27 @@ void SimulatorBase::process_ui_slider(const OpenAPI::OAIClientUIItem* uiItem)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulatorBase::process_ui_textbox(const OpenAPI::OAIClientUIItem* uiItem)
|
void SimulatorBase::process_ui_textbox(json& uiItem)
|
||||||
{
|
{
|
||||||
QD << "Not implemented";
|
QD << "Not implemented";
|
||||||
emit quit();
|
emit quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulatorBase::process_ui_combobox(const OpenAPI::OAIClientUIItem* uiItem)
|
void SimulatorBase::process_ui_combobox(json& uiItem)
|
||||||
{
|
{
|
||||||
QComboBox* combobox = id_to_combobox(uiItem->getName());
|
QComboBox* combobox = id_to_combobox(QString::fromStdString(uiItem["id"]));
|
||||||
if (combobox == nullptr)
|
if (combobox == nullptr)
|
||||||
{
|
{
|
||||||
QD << "id_to_combobox returned null on " << uiItem->getName();
|
QD << "id_to_combobox returned null on " << QString::fromStdString(uiItem["id"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject state = uiItem->getState().asJsonObject();
|
QString selected = QString::fromStdString(uiItem["selected"]);
|
||||||
QString selected = state["selected"].toString();
|
|
||||||
QJsonArray toggleArray = state["toggleArray"].toArray();
|
|
||||||
|
|
||||||
|
for (json& item : uiItem["options"])
|
||||||
for (size_t i = 0; i < toggleArray.count(); i++)
|
|
||||||
{
|
{
|
||||||
QString item = toggleArray[i].toObject()["id"].toString();
|
if (combobox->findText(QString::fromStdString(item)) == -1)
|
||||||
if (combobox->findText(item) == -1)
|
combobox->addItem(QString::fromStdString(item));
|
||||||
combobox->addItem(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (combobox->currentText() != selected)
|
if (combobox->currentText() != selected)
|
||||||
@@ -273,26 +217,26 @@ void SimulatorBase::process_ui_combobox(const OpenAPI::OAIClientUIItem* uiItem)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulatorBase::process_ui_radiobutton(const OpenAPI::OAIClientUIItem* uiItem)
|
void SimulatorBase::process_ui_radiobutton(json& uiItem)
|
||||||
{
|
{
|
||||||
QD << "Not implemented";
|
QD << "Not implemented";
|
||||||
emit quit();
|
emit quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulatorBase::process_ui_button_array_element(QJsonObject jsonObject)
|
void SimulatorBase::process_ui_button(json& uiItem)
|
||||||
{
|
{
|
||||||
//TODO: fix bgcolor and color
|
//TODO: fix bgcolor and color
|
||||||
QPushButton* button = id_to_button(jsonObject["id"].toString());
|
QPushButton* button = id_to_button(QString::fromStdString(uiItem["id"]));
|
||||||
|
|
||||||
if (button == nullptr)
|
if (button == nullptr)
|
||||||
{
|
{
|
||||||
QD << "id_to_button returned null on " << jsonObject["id"].toString();
|
QD << "id_to_button returned null on " << QString::fromStdString(uiItem["id"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor bg_color = QColor(jsonObject["color"].toString());
|
QColor bg_color = QColor(QString::fromStdString(uiItem["color"]));
|
||||||
QString text = jsonObject["title"].toString();
|
QString text = QString::fromStdString(uiItem["text"]);
|
||||||
bool enabled = jsonObject["enable"].toBool();
|
bool enabled = uiItem["enabled"];
|
||||||
|
|
||||||
if (button->text() != text)
|
if (button->text() != text)
|
||||||
{
|
{
|
||||||
@@ -334,18 +278,18 @@ void SimulatorBase::process_ui_button_array_element(QJsonObject jsonObject)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulatorBase::process_ui_led_array_element(QJsonObject jsonObject)
|
void SimulatorBase::process_ui_led(json& uiItem)
|
||||||
{
|
{
|
||||||
QPushButton* led = id_to_led(jsonObject["id"].toString());
|
QPushButton* led = id_to_led(QString::fromStdString(uiItem["id"]));
|
||||||
if (led == nullptr)
|
if (led == nullptr)
|
||||||
{
|
{
|
||||||
QD << "id_to_led returned null on " << jsonObject["id"].toString();
|
QD << "id_to_led returned null on " << QString::fromStdString(uiItem["id"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor bg_color = QColor(jsonObject["state"].toString());
|
QColor bg_color = QColor(QString::fromStdString(uiItem["led_color"]));
|
||||||
QColor color = QColor(~bg_color.red(), ~bg_color.green(), ~bg_color.blue());
|
QColor color = QColor(~bg_color.red(), ~bg_color.green(), ~bg_color.blue());
|
||||||
QString text = jsonObject["title"].toString();
|
QString text = QString::fromStdString(uiItem["text"]);
|
||||||
|
|
||||||
if (false == is_read_only(led))
|
if (false == is_read_only(led))
|
||||||
{
|
{
|
||||||
|
|||||||
+16
-16
@@ -3,18 +3,21 @@
|
|||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include "OAICANApiApi.h"
|
#include "web_socket_wrapper.h"
|
||||||
#include "networkerror.h"
|
#include "networkerror.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include <magic_enum.hpp>
|
#include <magic_enum.hpp>
|
||||||
#include "IterableEnum.hpp"
|
#include "IterableEnum.hpp"
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
#define QD qDebug() << "Debug:" << __FILE__ << ":" << __LINE__ << ":" << __FUNCTION__ << ":"
|
#define QD qDebug() << "Debug:" << __FILE__ << ":" << __LINE__ << ":" << __FUNCTION__ << ":"
|
||||||
|
|
||||||
class SimulatorBase : public QMainWindow {
|
class SimulatorBase : public QMainWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit SimulatorBase(OpenAPI::OAICANApiApi* api, QWidget* parent = nullptr);
|
explicit SimulatorBase(Web_socket_wrapper* api, QWidget* parent = nullptr);
|
||||||
void setup_cb(void);
|
void setup_cb(void);
|
||||||
void sim_update(void);
|
void sim_update(void);
|
||||||
virtual QLabel* id_to_label(QString name) {return nullptr;}
|
virtual QLabel* id_to_label(QString name) {return nullptr;}
|
||||||
@@ -32,24 +35,21 @@ class SimulatorBase : public QMainWindow {
|
|||||||
signals:
|
signals:
|
||||||
void quit();
|
void quit();
|
||||||
protected:
|
protected:
|
||||||
void apiCanapiUielements_bool_cb(bool ret, bool currentsim = false, QNetworkReply::NetworkError error_type = QNetworkReply::NetworkError::NoError, QString error_str = QString());
|
void on_event_cb(json& j);
|
||||||
void apiCanapiCurrentsimGet_cb(OpenAPI::OAISimulatorInfo output, QNetworkReply::NetworkError error_type = QNetworkReply::NetworkError::NoError, QString error_str = QString());
|
void on_cmd_cb(json& j);
|
||||||
|
void UI_item_parser(json& input);
|
||||||
void OAISimulatorInfo_parser(OpenAPI::OAISimulatorInfo input);
|
virtual void process_ui_label(json& uiItem);
|
||||||
void process_ui_button_array(const OpenAPI::OAIClientUIItem* uiItem);
|
virtual void process_ui_slider(json& uiItem);
|
||||||
void process_ui_led_array(const OpenAPI::OAIClientUIItem* uiItem);
|
virtual void process_ui_textbox(json& uiItem);
|
||||||
void process_ui_label(const OpenAPI::OAIClientUIItem* uiItem);
|
virtual void process_ui_combobox(json& uiItem);
|
||||||
void process_ui_slider(const OpenAPI::OAIClientUIItem* uiItem);
|
virtual void process_ui_radiobutton(json& uiItem);
|
||||||
void process_ui_textbox(const OpenAPI::OAIClientUIItem* uiItem);
|
virtual void process_ui_button(json& uiItem);
|
||||||
void process_ui_combobox(const OpenAPI::OAIClientUIItem* uiItem);
|
virtual void process_ui_led(json& uiItem);
|
||||||
void process_ui_radiobutton(const OpenAPI::OAIClientUIItem* uiItem);
|
|
||||||
void process_ui_button_array_element(QJsonObject jsonObject);
|
|
||||||
void process_ui_led_array_element(QJsonObject jsonObject);
|
|
||||||
|
|
||||||
void showEvent(QShowEvent* event);
|
void showEvent(QShowEvent* event);
|
||||||
void closeEvent(QCloseEvent* event);
|
void closeEvent(QCloseEvent* event);
|
||||||
|
|
||||||
OpenAPI::OAICANApiApi* api;
|
Web_socket_wrapper* m_web_socket;
|
||||||
|
|
||||||
QTimer* timer_update;
|
QTimer* timer_update;
|
||||||
uint32_t refresh_rate;
|
uint32_t refresh_rate;
|
||||||
|
|||||||
Reference in New Issue
Block a user