11#ifndef KICKCAT_EEPROM_EDITOR_APP_H
22#define KICKCAT_EEPROM_EDITOR_APP_H
33
4+ #include < atomic>
5+ #include < memory>
6+ #include < mutex>
47#include < string>
8+ #include < thread>
59#include < vector>
610
711#include " imgui.h"
812#include " vendor/imgui_memory_editor.h"
913
14+ #include " kickcat/AbstractSocket.h"
1015#include " kickcat/SIIParser.h"
1116
17+ namespace kickcat
18+ {
19+ class Bus ;
20+ class Link ;
21+ }
22+
1223namespace kickcat ::eeprom_editor
1324{
1425 enum class Category
@@ -22,10 +33,13 @@ namespace kickcat::eeprom_editor
2233 RxPDO
2334 };
2435
36+ enum class SlaveAction { Load, Flash };
37+
2538 class App
2639 {
2740 public:
2841 App ();
42+ ~App ();
2943
3044 void render ();
3145
@@ -38,20 +52,61 @@ namespace kickcat::eeprom_editor
3852 void openFilePath (std::string const & path);
3953 void saveFilePath (std::string const & path);
4054
55+ // Device operations
56+ bool isConnected () const ;
57+ bool isBusy () const ;
58+ void connectToInterface (std::string const & name);
59+ void disconnect ();
60+ void loadFromSlave (int slave_index);
61+ void flashToSlave (int slave_index);
62+ void joinWorker ();
63+ void finalizeWorker ();
64+
65+ // Rendering
4166 void renderMenuBar ();
4267 void renderSidebar ();
4368 void renderContentPanel ();
4469 void renderHexPanel ();
4570 void renderStatusBar ();
71+ void renderConnectDialog ();
72+ void renderSlaveDialog ();
73+ bool renderSlaveTable (); // returns true on double-click
74+ void renderPrivilegeDialog ();
4675
76+ // EEPROM state
4777 eeprom::SII sii_{};
4878 std::vector<uint8_t > serialized_;
49-
5079 std::string file_path_;
5180 bool modified_{false };
52-
5381 Category active_category_{Category::Info};
5482 MemoryEditor mem_edit_;
83+
84+ // EtherCAT connection
85+ std::shared_ptr<Link> link_;
86+ std::unique_ptr<Bus> bus_;
87+ std::string connected_interface_;
88+
89+ // Dialog state
90+ bool show_connect_dialog_{false };
91+ bool show_slave_dialog_{false };
92+ SlaveAction slave_action_{SlaveAction::Load};
93+ int selected_slave_index_{-1 };
94+ std::string device_error_;
95+ std::vector<NetworkInterface> cached_interfaces_;
96+
97+ // Privilege escalation
98+ bool show_privilege_dialog_{false };
99+ bool privilege_granted_{false };
100+ std::string privilege_error_;
101+ std::atomic<bool > needs_privilege_escalation_{false };
102+
103+ // Background worker state
104+ std::thread worker_;
105+ std::atomic<float > worker_progress_{0 .0f };
106+ std::atomic<bool > worker_done_{false };
107+ std::mutex worker_status_mutex_;
108+ std::string worker_status_;
109+ std::string worker_error_;
55110 };
56111}
57112
0 commit comments