3#include "Panels/MainPanel.h"
4#include "Panels/RightSidePanel.h"
6#include "Tabs/PropertiesTab.h"
21 : wxFrame(
nullptr, wxID_ANY, title, pos, size), m_auiManager(
nullptr), m_pollTimer(this,
ID_POLL_TIMER) {
27 m_pollTimer.Start(33);
42 wxMenuBar *menuBar =
new wxMenuBar();
44 wxMenu *fileMenu =
new wxMenu();
45 fileMenu->Append(
ID_QUIT,
"E&xit\tAlt-F4",
"Quit the application");
46 menuBar->Append(fileMenu,
"&File");
48 wxMenu *helpMenu =
new wxMenu();
49 helpMenu->Append(
ID_ABOUT,
"&About...",
"Show about dialog");
50 menuBar->Append(helpMenu,
"&Help");
58 int widths[] = {-1, sbFieldWidth, sbFieldWidth};
70 wxSize cs = GetClientSize();
73 int connWidth = cs.x * 15 / 100;
74 int connMinWidth = cs.x * 12 / 100;
75 int rightWidth = cs.x * 18 / 100;
76 int rightMinWidth = cs.x * 13 / 100;
79 .Name(
"connection_panel")
80 .Caption(
"Connection")
82 .BestSize(wxSize(connWidth, -1))
83 .MinSize(wxSize(connMinWidth, -1))
87 .CaptionVisible(
false)
92 wxAuiPaneInfo().Name(
"scene_panel").CenterPane().Dockable(
false).Floatable(
false).CloseButton(
false));
98 .BestSize(wxSize(rightWidth, -1))
99 .MinSize(wxSize(rightMinWidth, -1))
103 .CaptionVisible(
false)
106 m_layout.Track(
"connection_panel", 0.15, 0.12,
true);
107 m_layout.Track(
"right_panel", 0.18, 0.13,
true);
133 m_mainPanel->GetTreeCanvas()->SetSelectedNode(node);
147 wxSize newSize = GetClientSize();
170 wxMessageBox(
"EmberMonitor v1.0\n\nReal-time Behavior Tree Monitoring",
"About EmberMonitor",
171 wxOK | wxICON_INFORMATION,
this);
191 LOG_INFO(
"Monitor",
"Client connected: " + address);
198 LOG_INFO(
"Monitor",
"Client disconnected");
214 " payload=" + std::to_string(frame.
payload.size()) +
" bytes");
241 LOG_INFO(
"Monitor",
"Handshake received (payload=" + std::to_string(frame.
payload.size()) +
" bytes)");
243 LOG_ERROR(
"Monitor",
"Handshake verification failed!");
251 std::string clientName = handshake->client_name() ? handshake->client_name()->str() :
"";
252 std::string clientId = handshake->client_id() ? handshake->client_id()->str() :
"";
253 LOG_INFO(
"Monitor",
"Handshake OK: client='" + clientName +
"' id='" + clientId +
"'");
255 m_server.SetClientName(clientName.empty() ? clientId : clientName);
257 auto ackFrame =
m_codec.BuildHandshakeAck(
"1.0.0",
"session_" + std::to_string(time(
nullptr)),
true);
267 LOG_INFO(
"Monitor",
"TreeInit received (payload=" + std::to_string(frame.
payload.size()) +
" bytes)");
269 LOG_ERROR(
"Monitor",
"TreeInit verification failed!");
277 "TreeInit: tree_id='" + std::string(treeInit->tree_id() ? treeInit->tree_id()->c_str() :
"(null)") +
278 "' tree_name='" + std::string(treeInit->tree_name() ? treeInit->tree_name()->c_str() :
"(null)") +
279 "' has_root=" + std::to_string(treeInit->root() !=
nullptr));
283 if (!result.success) {
284 LOG_ERROR(
"Monitor",
"TreeBuilder failed: " + result.error);
286 m_codec.BuildTreeInitAck(treeInit->tree_id() ? treeInit->tree_id()->str() :
"",
false, 0, result.error);
291 LOG_INFO(
"Monitor",
"Tree built: " + std::to_string(result.node_count) +
292 " nodes, hasRoot=" + std::to_string(result.tree->HasRootNode()));
295 m_currentTreeId = treeInit->tree_id() ? treeInit->tree_id()->str() :
"";
302 std::map<std::string, std::shared_ptr<EmberCore::BehaviorTree>> treeMap;
316 LOG_INFO(
"Monitor",
"Tree visualization set up. State=TreeReady");
376 m_statusBar->SetStatusText(wxString::Format(
"Listening on port %d",
m_server.GetPort()), 0);
386 m_statusBar->SetStatusText(
"Receiving tree...", 1);
404 wxString::Format(
"Tick: %lld",
static_cast<long long>(
m_stateManager->GetCurrentTick())), 2);
BehaviorTreeProjectDialog::OnProjectNameChanged BehaviorTreeProjectDialog::OnRemoveFiles wxEND_EVENT_TABLE() BehaviorTreeProjectDialog
LoadingDialog::OnCancel EVT_CLOSE(LoadingDialog::OnClose) wxEND_EVENT_TABLE() LoadingDialog
#define LOG_ERROR(category, message)
#define LOG_TRACE(category, message)
#define LOG_WARNING(category, message)
#define LOG_INFO(category, message)
MainFrame::OnExit EVT_MENU(wxID_ABOUT, MainFrame::OnAbout) EVT_MENU(ID_NewProject
Abstract interface for tree nodes that can be visualized.
virtual size_t GetId() const =0
UI panel for managing TCP server connection, showing server/client status, port input,...
Central panel containing the MonitorTreeCanvas and search bar.
Main application frame owning the TCP server, tree builder, codec, state manager, and AUI layout (Con...
void OnClientConnect(const std::string &address)
std::string m_currentTreeId
void OnAbout(wxCommandEvent &event)
PropertiesTab * m_propertiesTab
wxStatusBar * m_statusBar
void OnPollTimer(wxTimerEvent &event)
void OnClientDisconnect()
std::shared_ptr< Network::StateManager > m_stateManager
void OnQuit(wxCommandEvent &event)
void OnServerMessage(const Network::MessageFrame &frame)
void HandleTreeInit(const Network::MessageFrame &frame)
MonitorNavigatorTab * m_navigatorTab
bool m_hasPendingTickUpdate
Network::MessageFrame m_pendingTickUpdate
wxAuiManager * m_auiManager
RightSidePanel * m_rightPanel
void HandleTickUpdate(const Network::MessageFrame &frame)
void HandleDisconnect(const Network::MessageFrame &frame)
void RefreshVisualization()
void HandleHandshake(const Network::MessageFrame &frame)
std::shared_ptr< EmberCore::BehaviorTree > m_currentTree
void HandleTreeReset(const Network::MessageFrame &frame)
Network::TreeBuilder m_treeBuilder
void OnNodeSelected(EmberCore::ITreeNode *node)
void OnClose(wxCloseEvent &event)
EmberUI::ProportionalLayout m_layout
ConnectionState m_connectionState
Network::FlatBufferCodec m_codec
void HandleBlackboardUpdate(const Network::MessageFrame &frame)
~MonitorFrame()
Destroys the frame and releases resources.
void OnFrameResize(wxSizeEvent &event)
ConnectionPanel * m_connectionPanel
Right-side tabbed panel containing navigator and properties tabs.
static bool Verify(const uint8_t *data, size_t size)
static const T * GetRoot(const uint8_t *data)
int Scale(wxWindow *win, int px)
Scales a pixel value from logical to physical units for the given window.
constexpr int STATUS_BAR_FIELD_WIDTH
Width of status bar fields.
wxBEGIN_EVENT_TABLE(MonitorFrame, wxFrame) EVT_CLOSE(MonitorFrame
@ MessageType_BlackboardUpdate
@ ErrorCode_InvalidMessage
Protocol::MessageType messageType
std::vector< uint8_t > payload