From 35545ef87332457464bc26d7140fbac528218758 Mon Sep 17 00:00:00 2001 From: Sander Speetjens Date: Sat, 27 Jul 2024 14:44:34 +0200 Subject: [PATCH] Can debugger Add send can message --- Qt/simulators/sim-can_debugger.cpp | 26 +++ Qt/simulators/sim-can_debugger.h | 3 + Qt/simulators/sim-can_debugger.ui | 249 ++++++++++++++++++++++++++--- 3 files changed, 259 insertions(+), 19 deletions(-) diff --git a/Qt/simulators/sim-can_debugger.cpp b/Qt/simulators/sim-can_debugger.cpp index 1cbace6..cc44761 100644 --- a/Qt/simulators/sim-can_debugger.cpp +++ b/Qt/simulators/sim-can_debugger.cpp @@ -6,6 +6,32 @@ Can_Debugger::Can_Debugger(Web_socket_wrapper* web_socket, QWidget *parent) : ui(new Ui::Can_Debugger) { ui->setupUi(this); this->setWindowTitle("CAN Debugger"); + can_send_hexspinboxes = { + ui->s_can_send_data0, + ui->s_can_send_data1, + ui->s_can_send_data2, + ui->s_can_send_data3, + ui->s_can_send_data4, + ui->s_can_send_data5, + ui->s_can_send_data6, + ui->s_can_send_data7, + }; + + enable_can_send_data(); + connect(ui->c_can_send_dlc, &QComboBox::currentIndexChanged, this, [=]{enable_can_send_data();}); +} + +void Can_Debugger::enable_can_send_data() +{ + uint8_t selected = atoi(ui->c_can_send_dlc->currentText().toLocal8Bit()); + for (size_t i = 0; i < can_send_hexspinboxes.size(); i++) + { + can_send_hexspinboxes[i]->setEnabled(i < selected); + if (i >= selected) + { + can_send_hexspinboxes[i]->setValue(0); + } + } } Can_Debugger::~Can_Debugger() { diff --git a/Qt/simulators/sim-can_debugger.h b/Qt/simulators/sim-can_debugger.h index 71c91e8..739ab44 100644 --- a/Qt/simulators/sim-can_debugger.h +++ b/Qt/simulators/sim-can_debugger.h @@ -3,6 +3,7 @@ #include #include "simulator_base.h" +#include "hex_spinbox.h" namespace Ui { class Can_Debugger; @@ -14,9 +15,11 @@ class Can_Debugger : public SimulatorBase { public: explicit Can_Debugger(Web_socket_wrapper* web_socket, QWidget *parent = nullptr); ~Can_Debugger(); + void enable_can_send_data(); private: Ui::Can_Debugger* ui; + std::vector can_send_hexspinboxes; }; #endif // SIM_CAN_DEBUGGER_H diff --git a/Qt/simulators/sim-can_debugger.ui b/Qt/simulators/sim-can_debugger.ui index d07130b..f7c4e8f 100644 --- a/Qt/simulators/sim-can_debugger.ui +++ b/Qt/simulators/sim-can_debugger.ui @@ -14,7 +14,211 @@ MainWindow - + + + + 450 + 10 + 641 + 121 + + + + Send CAN message + + + + + + + 0 + + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + 5 + + + + + 6 + + + + + 7 + + + + + 8 + + + + + + + + Send + + + + + + + 255 + + + + + + + 65535 + + + + + + + 255 + + + + + + + SID + + + + + + + DLC + + + + + + + Data0 + + + + + + + Data1 + + + + + + + Data2 + + + + + + + Data3 + + + + + + + Data4 + + + + + + + Data5 + + + + + + + Data6 + + + + + + + Data7 + + + + + + + 255 + + + + + + + 255 + + + + + + + 255 + + + + + + + 255 + + + + + + + 255 + + + + + + + 255 + + + + + + 20 @@ -245,38 +449,38 @@ HVac am80 cutom kaart robbe - - - - Enables set values - - - - Set Single weerstand & Enable + Single weerstand & Enable - Set Single stroom & Enable + Single stroom & Enable - - - - Set Single stroom & Disable - - - - + - Set Single weerstand & Disable + Single weerstand & Disable + + + + + + + Single stroom & Disable + + + + + + + Enables set values @@ -298,6 +502,13 @@ + + + HexSpinBox + QSpinBox +
hex_spinbox.h
+
+