mirror of
https://github.com/BotChain-Robots/dev-tools.git
synced 2026-07-08 23:17:22 +02:00
Cleanup for release
This commit is contained in:
78
include/tabs/ConfigurationTab.h
Normal file
78
include/tabs/ConfigurationTab.h
Normal file
@@ -0,0 +1,78 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "libcontrol.h"
|
||||
#include "rpc/RemoteConfig.h"
|
||||
#include <ftxui/component/component.hpp>
|
||||
|
||||
using namespace ftxui;
|
||||
|
||||
class ConfigurationTab {
|
||||
public:
|
||||
ConfigurationTab(std::shared_ptr<RobotController> robot_controller, uint8_t device_id);
|
||||
Component createComponent();
|
||||
|
||||
private:
|
||||
std::shared_ptr<RobotController> robot_controller_;
|
||||
std::shared_ptr<RemoteConfig> remote_config_;
|
||||
uint8_t device_id_;
|
||||
|
||||
// Input fields
|
||||
std::string module_id_input_;
|
||||
int selected_module_type_ = 0;
|
||||
std::string wifi_ssid_input_;
|
||||
std::string wifi_password_input_;
|
||||
int selected_communication_method_ = 0;
|
||||
|
||||
// Status messages
|
||||
std::string module_id_status_;
|
||||
std::string module_type_status_;
|
||||
std::string wifi_ssid_status_;
|
||||
std::string wifi_password_status_;
|
||||
std::string communication_method_status_;
|
||||
std::string restart_status_;
|
||||
|
||||
// Component members
|
||||
Component module_id_input_component_;
|
||||
Component module_id_button_;
|
||||
Component module_type_dropdown_;
|
||||
Component module_type_button_;
|
||||
Component wifi_ssid_input_component_;
|
||||
Component wifi_ssid_button_;
|
||||
Component wifi_password_input_component_;
|
||||
Component wifi_password_button_;
|
||||
Component comm_method_dropdown_;
|
||||
Component comm_method_button_;
|
||||
Component restart_button_;
|
||||
|
||||
// Module type options
|
||||
std::vector<std::string> module_type_options_ = {
|
||||
"SPLITTER",
|
||||
"SERVO_1",
|
||||
"DC_MOTOR",
|
||||
"BATTERY",
|
||||
"SERVO_2",
|
||||
"DISPLAY",
|
||||
"GRIPPER",
|
||||
"SPEAKER",
|
||||
"IMU",
|
||||
"DISTANCE_SENSOR",
|
||||
"SPLITTER_2",
|
||||
"SPLITTER_3",
|
||||
"SPLITTER_4"
|
||||
};
|
||||
|
||||
std::vector<std::string> communication_method_options_ = {
|
||||
"Wireless"
|
||||
};
|
||||
|
||||
// Helper methods
|
||||
void setModuleId();
|
||||
void setModuleType();
|
||||
void setWiFiSSID();
|
||||
void setWiFiPassword();
|
||||
void setCommunicationMethod();
|
||||
void restartDevice();
|
||||
std::string getModuleTypeString(ModuleType type);
|
||||
};
|
||||
32
include/tabs/CoredumpTab.h
Normal file
32
include/tabs/CoredumpTab.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include <atomic>
|
||||
#include "libcontrol.h"
|
||||
#include "rpc/RemoteDebugging.h"
|
||||
#include <ftxui/component/component.hpp>
|
||||
|
||||
using namespace ftxui;
|
||||
|
||||
class CoredumpTab {
|
||||
public:
|
||||
CoredumpTab(std::shared_ptr<RemoteDebugging> remote_debugging, uint8_t device_id);
|
||||
Component createComponent();
|
||||
|
||||
private:
|
||||
std::shared_ptr<RemoteDebugging> remote_debugging_;
|
||||
uint8_t device_id_;
|
||||
|
||||
// Caching for coredump data to avoid frequent RPC calls
|
||||
mutable std::string cached_coredump_;
|
||||
mutable std::chrono::time_point<std::chrono::system_clock> coredump_last_updated_;
|
||||
mutable std::atomic<bool> coredump_loading_{false};
|
||||
mutable bool coredump_initial_load_done_{false};
|
||||
static constexpr std::chrono::seconds cache_duration_{10}; // 10 seconds
|
||||
|
||||
std::string getCachedCoredump() const;
|
||||
std::string sanitizeData(const std::string& raw_data);
|
||||
std::vector<std::string> splitLines(const std::string& data);
|
||||
};
|
||||
28
include/tabs/FirmwareUpdateTab.h
Normal file
28
include/tabs/FirmwareUpdateTab.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <atomic>
|
||||
#include "libcontrol.h"
|
||||
#include "rpc/RemoteManagement.h"
|
||||
#include <ftxui/component/component.hpp>
|
||||
|
||||
using namespace ftxui;
|
||||
|
||||
class FirmwareUpdateTab {
|
||||
public:
|
||||
FirmwareUpdateTab(std::shared_ptr<RobotController> robot_controller, uint8_t device_id);
|
||||
Component createComponent();
|
||||
|
||||
private:
|
||||
std::shared_ptr<RobotController> robot_controller_;
|
||||
std::shared_ptr<RemoteManagement> remote_management_;
|
||||
uint8_t device_id_;
|
||||
|
||||
// Firmware update state
|
||||
std::string firmware_file_path_;
|
||||
bool update_in_progress_ = false;
|
||||
int progress_ = 0;
|
||||
std::string update_status_message_;
|
||||
bool update_success_ = false;
|
||||
};
|
||||
23
include/tabs/InformationTab.h
Normal file
23
include/tabs/InformationTab.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include "libcontrol.h"
|
||||
#include <ftxui/component/component.hpp>
|
||||
|
||||
using namespace ftxui;
|
||||
|
||||
class InformationTab {
|
||||
public:
|
||||
InformationTab(std::shared_ptr<RobotController> robot_controller, uint8_t device_id);
|
||||
Component createComponent();
|
||||
|
||||
private:
|
||||
std::shared_ptr<RobotController> robot_controller_;
|
||||
uint8_t device_id_;
|
||||
|
||||
std::string getModuleTypeString(ModuleType type);
|
||||
std::string getConnectionTypeString(Messaging::ConnectionType type);
|
||||
std::string formatTimeSince(const std::chrono::time_point<std::chrono::system_clock>& time_point);
|
||||
};
|
||||
32
include/tabs/LoggingTab.h
Normal file
32
include/tabs/LoggingTab.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include <atomic>
|
||||
#include "libcontrol.h"
|
||||
#include "rpc/RemoteDebugging.h"
|
||||
#include <ftxui/component/component.hpp>
|
||||
|
||||
using namespace ftxui;
|
||||
|
||||
class LoggingTab {
|
||||
public:
|
||||
LoggingTab(std::shared_ptr<RemoteDebugging> remote_debugging, uint8_t device_id);
|
||||
Component createComponent();
|
||||
|
||||
private:
|
||||
std::shared_ptr<RemoteDebugging> remote_debugging_;
|
||||
uint8_t device_id_;
|
||||
|
||||
// Caching for RemoteDebugging data to avoid frequent RPC calls
|
||||
mutable std::string cached_logs_;
|
||||
mutable std::chrono::time_point<std::chrono::system_clock> logs_last_updated_;
|
||||
mutable std::atomic<bool> logs_loading_{false};
|
||||
mutable bool logs_initial_load_done_{false};
|
||||
static constexpr std::chrono::seconds cache_duration_{4}; // 4 seconds
|
||||
|
||||
std::string getCachedLogs() const;
|
||||
std::string sanitizeLogData(const std::string& raw_data);
|
||||
std::vector<std::string> splitLogLines(const std::string& log_data);
|
||||
};
|
||||
30
include/tabs/TaskManagerTab.h
Normal file
30
include/tabs/TaskManagerTab.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include <atomic>
|
||||
#include "libcontrol.h"
|
||||
#include "rpc/RemoteDebugging.h"
|
||||
#include <ftxui/component/component.hpp>
|
||||
|
||||
using namespace ftxui;
|
||||
|
||||
class TaskManagerTab {
|
||||
public:
|
||||
TaskManagerTab(std::shared_ptr<RemoteDebugging> remote_debugging, uint8_t device_id);
|
||||
Component createComponent();
|
||||
|
||||
private:
|
||||
std::shared_ptr<RemoteDebugging> remote_debugging_;
|
||||
uint8_t device_id_;
|
||||
|
||||
// Caching for RemoteDebugging data to avoid frequent RPC calls
|
||||
mutable std::string cached_task_data_;
|
||||
mutable std::chrono::time_point<std::chrono::system_clock> task_data_last_updated_;
|
||||
mutable std::atomic<bool> task_data_loading_{false};
|
||||
mutable bool task_data_initial_load_done_{false};
|
||||
static constexpr std::chrono::seconds cache_duration_{4}; // 4 seconds
|
||||
|
||||
std::string getCachedTaskData() const;
|
||||
};
|
||||
Reference in New Issue
Block a user