This commit is contained in:
Ivan I. Ovchinnikov
2026-07-27 21:15:36 +03:00
commit 47b1e70663
15 changed files with 1038 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
#ifndef SERIAL_SAMPLE_CONNECTIONWINDOW_H
#define SERIAL_SAMPLE_CONNECTIONWINDOW_H
#include <vector>
#include <string>
#include <libserialport.h>
struct SerialPortInfo {
std::string port_name;
std::string description;
};
class ConnectionWindow {
public:
ConnectionWindow();
~ConnectionWindow();
void Initialize();
void Render(bool* p_open);
bool IsConnected() const { return is_connected; }
struct sp_port* GetActivePort() const { return active_port; }
void ForceLogMessage(const std::string& msg);
std::string& GetSharedLog() { return tx_log; }
private:
void RefreshPorts();
std::vector<SerialPortInfo> ports;
int selected_port_idx;
// Новые переменные для выпадающего списка Baud Rate
std::vector<int> baud_rates;
int selected_baud_idx;
bool is_connected;
struct sp_port* active_port;
std::string tx_log;
};
#endif // SERIAL_SAMPLE_CONNECTIONWINDOW_H
+14
View File
@@ -0,0 +1,14 @@
#ifndef SERIAL_SAMPLE_LOGWINDOW_H
#define SERIAL_SAMPLE_LOGWINDOW_H
class ConnectionWindow;
class LogWindow {
public:
LogWindow() = default;
~LogWindow() = default;
void Render(bool* p_open, ConnectionWindow& conn_win);
};
#endif // SERIAL_SAMPLE_LOGWINDOW_H
+22
View File
@@ -0,0 +1,22 @@
#ifndef SERIAL_SAMPLE_PAYLOADWINDOW_H
#define SERIAL_SAMPLE_PAYLOADWINDOW_H
#include <string>
#include <libserialport.h>
// Вперед-идущее объявление, чтобы не плодить инклуды
class ConnectionWindow;
class PayloadWindow {
public:
PayloadWindow();
~PayloadWindow() = default;
void Render(bool* p_open, ConnectionWindow& conn_win);
private:
void SendHexPayload(const std::string& hex_str, ConnectionWindow& conn_win);
char hex_input_buffer[256];
};
#endif // SERIAL_SAMPLE_PAYLOADWINDOW_H
+34
View File
@@ -0,0 +1,34 @@
#ifndef SERIAL_SAMPLE_SERIALAPP_H
#define SERIAL_SAMPLE_SERIALAPP_H
#include "ConnectionWindow.h"
#include "PayloadWindow.h"
#include "LogWindow.h"
#include <string>
class SerialApp {
public:
SerialApp();
~SerialApp() = default;
void Initialize();
void RenderUI();
bool ShouldClose() const { return should_close; }
private:
void RenderMainMenuBar();
bool LoadTheme(const std::string& filepath); // Метод парсинга файла темы
bool show_connection_window = true;
bool show_payload_window = true;
bool show_log_window = true;
bool should_close;
ConnectionWindow connection_window;
PayloadWindow payload_window;
LogWindow log_window;
};
#endif // SERIAL_SAMPLE_SERIALAPP_H