mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
Add can events
This commit is contained in:
@@ -52,6 +52,10 @@ set(PROJECT_SOURCES
|
||||
led.h
|
||||
led.cpp
|
||||
|
||||
can_transceive.h
|
||||
can_transceive.cpp
|
||||
can_transceive.ui
|
||||
|
||||
networkerror.h
|
||||
networkerror.cpp
|
||||
networkerror.ui
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
#include "can_transceive.h"
|
||||
#include "ui_can_transceive.h"
|
||||
|
||||
Can_Transceive::Can_Transceive(QWidget* parent) : QWidget(parent), ui(new Ui::Can_Transceive) {
|
||||
ui->setupUi(this);
|
||||
|
||||
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, [=, this]{enable_can_send_data();});
|
||||
connect(ui->b_can_send_send, &QPushButton::clicked, this, [=, this]{emit send_can_message(ui->s_can_send_sid->value(), ui->c_can_send_dlc->currentIndex(), std::array<uint8_t, 8>({(uint8_t)(can_send_hexspinboxes[0]->value()), (uint8_t)(can_send_hexspinboxes[1]->value()),(uint8_t)(can_send_hexspinboxes[2]->value()),(uint8_t)(can_send_hexspinboxes[3]->value()),(uint8_t)(can_send_hexspinboxes[4]->value()),(uint8_t)(can_send_hexspinboxes[5]->value()),(uint8_t)(can_send_hexspinboxes[6]->value()),(uint8_t)(can_send_hexspinboxes[7]->value())}));});
|
||||
connect(ui->b_clear, &QPushButton::clicked, this, [=, this]{emit can_clear();});
|
||||
}
|
||||
|
||||
Can_Transceive::~Can_Transceive() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Can_Transceive::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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Can_Transceive::clear()
|
||||
{
|
||||
ui->recvd_list->setRowCount(0);
|
||||
ui->send_list->setRowCount(0);
|
||||
}
|
||||
|
||||
void Can_Transceive::add_send_item(uint32_t id, uint8_t dlc, std::array<uint8_t, 8> payload)
|
||||
{
|
||||
size_t rc = ui->send_list->rowCount();
|
||||
ui->send_list->setRowCount(rc + 1);
|
||||
|
||||
ui->send_list->setItem(rc, 0, new QTableWidgetItem(QString("%0").arg(id)));
|
||||
ui->send_list->setItem(rc, 1, new QTableWidgetItem(QString("%0").arg(dlc)));
|
||||
ui->send_list->setItem(rc, 2, new QTableWidgetItem(QString("%0").arg(payload[0])));
|
||||
ui->send_list->setItem(rc, 3, new QTableWidgetItem(QString("%0").arg(payload[1])));
|
||||
ui->send_list->setItem(rc, 4, new QTableWidgetItem(QString("%0").arg(payload[2])));
|
||||
ui->send_list->setItem(rc, 5, new QTableWidgetItem(QString("%0").arg(payload[3])));
|
||||
ui->send_list->setItem(rc, 6, new QTableWidgetItem(QString("%0").arg(payload[4])));
|
||||
ui->send_list->setItem(rc, 7, new QTableWidgetItem(QString("%0").arg(payload[5])));
|
||||
ui->send_list->setItem(rc, 8, new QTableWidgetItem(QString("%0").arg(payload[6])));
|
||||
ui->send_list->setItem(rc, 9, new QTableWidgetItem(QString("%0").arg(payload[7])));
|
||||
ui->send_list->resizeColumnsToContents();
|
||||
}
|
||||
|
||||
void Can_Transceive::add_receive_item(uint32_t id, uint8_t dlc, std::array<uint8_t, 8> payload)
|
||||
{
|
||||
size_t rc = ui->recvd_list->rowCount();
|
||||
ui->recvd_list->setRowCount(rc + 1);
|
||||
|
||||
ui->recvd_list->setItem(rc, 0, new QTableWidgetItem(QString("%0").arg(id)));
|
||||
ui->recvd_list->setItem(rc, 1, new QTableWidgetItem(QString("%0").arg(dlc)));
|
||||
ui->recvd_list->setItem(rc, 2, new QTableWidgetItem(QString("%0").arg(payload[0])));
|
||||
ui->recvd_list->setItem(rc, 3, new QTableWidgetItem(QString("%0").arg(payload[1])));
|
||||
ui->recvd_list->setItem(rc, 4, new QTableWidgetItem(QString("%0").arg(payload[2])));
|
||||
ui->recvd_list->setItem(rc, 5, new QTableWidgetItem(QString("%0").arg(payload[3])));
|
||||
ui->recvd_list->setItem(rc, 6, new QTableWidgetItem(QString("%0").arg(payload[4])));
|
||||
ui->recvd_list->setItem(rc, 7, new QTableWidgetItem(QString("%0").arg(payload[5])));
|
||||
ui->recvd_list->setItem(rc, 8, new QTableWidgetItem(QString("%0").arg(payload[6])));
|
||||
ui->recvd_list->setItem(rc, 9, new QTableWidgetItem(QString("%0").arg(payload[7])));
|
||||
ui->recvd_list->resizeColumnsToContents();
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifndef CAN_TRANSCEIVE_H
|
||||
#define CAN_TRANSCEIVE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "hex_spinbox.h"
|
||||
|
||||
namespace Ui {
|
||||
class Can_Transceive;
|
||||
}
|
||||
|
||||
class Can_Transceive : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Can_Transceive(QWidget* parent = nullptr);
|
||||
~Can_Transceive();
|
||||
void enable_can_send_data();
|
||||
void clear();
|
||||
void add_send_item(uint32_t id, uint8_t dlc, std::array<uint8_t, 8> payload);
|
||||
void add_receive_item(uint32_t id, uint8_t dlc, std::array<uint8_t, 8> payload);
|
||||
|
||||
signals:
|
||||
void send_can_message(uint32_t id, uint8_t dlc, std::array<uint8_t, 8> payload);
|
||||
void can_clear();
|
||||
|
||||
private:
|
||||
Ui::Can_Transceive* ui;
|
||||
std::vector<HexSpinBox*> can_send_hexspinboxes;
|
||||
};
|
||||
|
||||
#endif // CAN_TRANSCEIVE_H
|
||||
@@ -0,0 +1,359 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Can_Transceive</class>
|
||||
<widget class="QWidget" name="Can_Transceive">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>713</width>
|
||||
<height>562</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Received CAN messages</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTableWidget" name="recvd_list">
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>SID</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>DLC</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Data 0</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Data 1</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Data 2</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Data 3</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Data 4</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Data 5</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Data 6</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Data 7</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_8">
|
||||
<property name="title">
|
||||
<string>Send CAN message</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_8">
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="c_can_send_dlc">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>4</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>5</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>6</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>7</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>8</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="10">
|
||||
<widget class="QPushButton" name="b_can_send_send">
|
||||
<property name="text">
|
||||
<string>Send</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="HexSpinBox" name="s_can_send_data1">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="HexSpinBox" name="s_can_send_sid">
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="HexSpinBox" name="s_can_send_data0">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>SID</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>DLC</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Data 0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Data 1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Data 2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Data 3</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="6">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Data 4</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="7">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Data 5</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="8">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Data 6</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="9">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Data 7</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="HexSpinBox" name="s_can_send_data2">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="5">
|
||||
<widget class="HexSpinBox" name="s_can_send_data3">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="6">
|
||||
<widget class="HexSpinBox" name="s_can_send_data4">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="7">
|
||||
<widget class="HexSpinBox" name="s_can_send_data5">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="8">
|
||||
<widget class="HexSpinBox" name="s_can_send_data6">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="9">
|
||||
<widget class="HexSpinBox" name="s_can_send_data7">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Send CAN messages</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTableWidget" name="send_list">
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>SID</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>DLC</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Data 0</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Data 1</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Data 2</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Data 3</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Data 4</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Data 5</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Data 6</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Data 7</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="b_clear">
|
||||
<property name="text">
|
||||
<string>clear buffers</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>HexSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>hex_spinbox.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+51
-1
@@ -1,4 +1,5 @@
|
||||
#include "simulator_base.h"
|
||||
#include "can_transceive.h"
|
||||
|
||||
SimulatorBase::SimulatorBase(Web_socket_wrapper* web_socket, QWidget* parent) :
|
||||
QMainWindow{parent},
|
||||
@@ -64,7 +65,7 @@ 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:
|
||||
case Web_socket_wrapper::Event::ui_changed:
|
||||
UI_item_parser(j);
|
||||
break;
|
||||
default:
|
||||
@@ -127,6 +128,11 @@ void SimulatorBase::UI_item_parser(json& input)
|
||||
process_ui_radiobutton(uiItem);
|
||||
continue;
|
||||
}
|
||||
if (uiItem["type"] == "UI_can")
|
||||
{
|
||||
process_ui_can(uiItem);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -433,12 +439,42 @@ void SimulatorBase::process_ui_led(json& uiItem)
|
||||
}
|
||||
}
|
||||
|
||||
void SimulatorBase::process_ui_can(json& uiItem)
|
||||
{
|
||||
QWidget* widget = id_to_ui(uiItem["id"]);
|
||||
if (widget == nullptr)
|
||||
{
|
||||
QD << "id_to_ui returned null on " << QString::number((size_t)uiItem["id"]);
|
||||
return;
|
||||
}
|
||||
|
||||
auto can_ui = qobject_cast<Can_Transceive*>(widget);
|
||||
if (can_ui == nullptr)
|
||||
{
|
||||
QD << "widget is not of type led";
|
||||
return;
|
||||
}
|
||||
|
||||
can_ui->clear();
|
||||
for (auto& send_item : uiItem["can_send_messages"])
|
||||
{
|
||||
can_ui->add_send_item(send_item["id"], send_item["dlc"], send_item["bytes"]);
|
||||
}
|
||||
|
||||
for (auto& recvd_item : uiItem["can_received_messages"])
|
||||
{
|
||||
can_ui->add_receive_item(recvd_item["id"], recvd_item["dlc"], recvd_item["bytes"]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SimulatorBase::setup_ui_item(QWidget* item, size_t index)
|
||||
{
|
||||
setup_button(item, index);
|
||||
setup_combobox(item, index);
|
||||
setup_dial(item, index);
|
||||
setup_slider(item, index);
|
||||
setup_can_ui(item, index);
|
||||
}
|
||||
|
||||
void SimulatorBase::setup_button(QWidget* item, size_t index)
|
||||
@@ -479,3 +515,17 @@ void SimulatorBase::setup_slider(QWidget* item, size_t index)
|
||||
m_web_socket->send_event(Web_socket_wrapper::Event::value_changed, index,
|
||||
slider->value());});
|
||||
}
|
||||
|
||||
void SimulatorBase::setup_can_ui(QWidget* item, size_t index)
|
||||
{
|
||||
Can_Transceive* can = qobject_cast<Can_Transceive*>(item);
|
||||
if (can == nullptr)
|
||||
return;
|
||||
|
||||
connect(can, &Can_Transceive::send_can_message, this, [=, this](uint32_t id, uint8_t dlc, std::array<uint8_t, 8> payload){
|
||||
m_web_socket->send_event(Web_socket_wrapper::Event::can_send, index, id, dlc, payload);
|
||||
});
|
||||
connect(can, &Can_Transceive::can_clear, this, [=, this]{
|
||||
m_web_socket->send_event(Web_socket_wrapper::Event::can_clear, index);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -42,12 +42,14 @@ class SimulatorBase : public QMainWindow {
|
||||
virtual void process_ui_radiobutton(json& uiItem);
|
||||
virtual void process_ui_button(json& uiItem);
|
||||
virtual void process_ui_led(json& uiItem);
|
||||
virtual void process_ui_can(json& uiItem);
|
||||
|
||||
void setup_ui_item(QWidget* item, size_t index);
|
||||
void setup_button(QWidget* item, size_t index);
|
||||
void setup_combobox(QWidget* item, size_t index);
|
||||
void setup_dial(QWidget* item, size_t index);
|
||||
void setup_slider(QWidget* item, size_t index);
|
||||
void setup_can_ui(QWidget* item, size_t index);
|
||||
|
||||
void showEvent(QShowEvent* event);
|
||||
void closeEvent(QCloseEvent* event);
|
||||
|
||||
@@ -6,32 +6,8 @@ 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);
|
||||
}
|
||||
}
|
||||
this->push_ui_item(ui->can_transceive);
|
||||
}
|
||||
|
||||
Can_Debugger::~Can_Debugger() {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <QMainWindow>
|
||||
#include "simulator_base.h"
|
||||
#include "hex_spinbox.h"
|
||||
|
||||
namespace Ui {
|
||||
class Can_Debugger;
|
||||
@@ -15,11 +14,9 @@ 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<HexSpinBox*> can_send_hexspinboxes;
|
||||
};
|
||||
|
||||
#endif // SIM_CAN_DEBUGGER_H
|
||||
|
||||
@@ -14,219 +14,8 @@
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QGroupBox" name="groupBox_8">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>450</x>
|
||||
<y>10</y>
|
||||
<width>641</width>
|
||||
<height>121</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Send CAN message</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_8">
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="c_can_send_dlc">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>4</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>5</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>6</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>7</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>8</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="10">
|
||||
<widget class="QPushButton" name="b_can_send_send">
|
||||
<property name="text">
|
||||
<string>Send</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="HexSpinBox" name="s_can_send_data1">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="HexSpinBox" name="s_can_send_sid">
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="HexSpinBox" name="s_can_send_data0">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>SID</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>DLC</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Data0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Data1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Data2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Data3</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="6">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Data4</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="7">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Data5</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="8">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Data6</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="9">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Data7</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="HexSpinBox" name="s_can_send_data2">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="5">
|
||||
<widget class="HexSpinBox" name="s_can_send_data3">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="6">
|
||||
<widget class="HexSpinBox" name="s_can_send_data4">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="7">
|
||||
<widget class="HexSpinBox" name="s_can_send_data5">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="8">
|
||||
<widget class="HexSpinBox" name="s_can_send_data6">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="9">
|
||||
<widget class="HexSpinBox" name="s_can_send_data7">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>0</y>
|
||||
<width>413</width>
|
||||
<height>951</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
@@ -488,7 +277,11 @@
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Can_Transceive" name="can_transceive" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
@@ -504,9 +297,10 @@
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>HexSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>hex_spinbox.h</header>
|
||||
<class>Can_Transceive</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>can_transceive.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
|
||||
@@ -73,6 +73,7 @@ void Web_socket_wrapper::send_event(Event event, size_t id)
|
||||
switch (event)
|
||||
{
|
||||
case Event::clicked:
|
||||
case Event::can_clear:
|
||||
j["event"]["type"] = magic_enum::enum_name(event).data();
|
||||
j["event"]["id"] = id;
|
||||
m_web_socket->sendTextMessage(QString(j.dump().data()));
|
||||
@@ -120,6 +121,24 @@ void Web_socket_wrapper::send_event(Event event, size_t id, QString val)
|
||||
}
|
||||
}
|
||||
|
||||
void Web_socket_wrapper::send_event(Event event, size_t id, uint32_t sid, uint8_t dlc, std::array<uint8_t, 8> payload)
|
||||
{
|
||||
json j;
|
||||
switch (event)
|
||||
{
|
||||
case Event::can_send:
|
||||
j["event"]["type"] = magic_enum::enum_name(event).data();
|
||||
j["event"]["id"] = id;
|
||||
j["event"]["sid"] = sid;
|
||||
j["event"]["dlc"] = dlc;
|
||||
j["event"]["payload"] = payload;
|
||||
m_web_socket->sendTextMessage(QString(j.dump().data()));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Web_socket_wrapper::close()
|
||||
{
|
||||
if (m_connected)
|
||||
|
||||
@@ -27,7 +27,9 @@ class Web_socket_wrapper : public QObject
|
||||
value_changed,
|
||||
text_changed,
|
||||
selected,
|
||||
UI_changed,
|
||||
can_send,
|
||||
can_clear,
|
||||
ui_changed,
|
||||
end,
|
||||
begin = 0
|
||||
};
|
||||
@@ -39,6 +41,7 @@ class Web_socket_wrapper : public QObject
|
||||
void send_event(Event event, size_t id);
|
||||
void send_event(Event event, size_t id, double val);
|
||||
void send_event(Event event, size_t id, QString val);
|
||||
void send_event(Event event, size_t id, uint32_t sid, uint8_t dlc, std::array<uint8_t, 8> payload);
|
||||
void close();
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
Reference in New Issue
Block a user