RumPi Linux Client 1.0
A wxWidgets desktop dashboard that visualizes a RumPi robot's live sensor data as a condition-reactive scene
MainWindow Class Reference

The client's main window: a tabbed frame (Home scene, Summary tiles, Devices, Logger, Settings) that starts the background poll thread and the alert forwarder, and refreshes its tabs from the events they post. More...

#include <MainWindow.h>

Inheritance diagram for MainWindow:
[legend]
Collaboration diagram for MainWindow:
[legend]

Public Member Functions

 MainWindow (wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(500, 300), long style=wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL)
 Builds the main window: sets up the menu/status bar and notebook, creates the alert forwarder, and starts the background poll thread (surfacing a failure to start through the alert channel rather than a modal popup). More...
 
 ~MainWindow ()
 Destroys the window, tearing down the background work as a safety net for paths that bypass OnClose (null-safe and idempotent). More...
 

Protected Member Functions

void ConstructMenuAndStatusBar ()
 Builds the menu bar and status bar and binds the window's menu, update, logger, and close events. More...
 
void ConstructNotebook ()
 Builds the notebook and its five tabs (Home, Summary, Devices, Logger, Settings) and adds it to the window layout. More...
 
void ConstructHomePanel ()
 Builds the Home tab's condition-reactive scene panel and adds it to the notebook. More...
 
void ConstructSummaryPanel ()
 Builds the Summary tab: a three-per-row grid of at-a-glance sensor tiles, stashing each tile's value label for live updates. More...
 
void ConstructDevicesPanel ()
 Builds the Devices tab: a scrollable, three-column grid that will hold one tile per component instance. More...
 
void ConstructLoggerPanel ()
 Builds the Logger tab: a data-view control with icon/time/level/description columns, backed by the log model. More...
 
void ConstructSettingsPanel ()
 Builds the (currently empty) Settings tab and adds it to the notebook. More...
 
void TeardownBackgroundWork ()
 Stops the background poll thread and then tears down the alert forwarder, in that order (stop the producer before the consumer). More...
 
wxStaticText * CreateSummaryTile (wxWindow *parent, wxSizer *tileGridSizer, const wxString &title)
 Builds one titled summary tile with a large centered value label and adds it to the grid. More...
 
void UpdateSummaryPanel (const RumPi::SelectedSensorReadings &readings)
 Refreshes every summary tile's value label from a sensor snapshot (temperature, humidity, gases, particulates, air quality, motion, wind, and light) and re-flows the tiles. More...
 
virtual void OnClose (wxCloseEvent &event)
 Close handler: tears down the background work before the window is destroyed (the worker and forwarder both post events to us), then lets the default handler proceed. More...
 
virtual void OnExit (wxCommandEvent &event)
 Exit handler: closes the window. More...
 
virtual void OnAbout (wxCommandEvent &event)
 About handler: shows the application's about dialog. More...
 
virtual void OnShowLogs (wxCommandEvent &event)
 "Show Log Files" handler: opens the log folder in the platform's file manager, falling back to a message box with the path if that isn't possible (e.g. More...
 
virtual void OnRumPiUpdate (wxThreadEvent &event)
 RumPi-update handler (main thread): refreshes the Summary tiles and Home scene from the event's snapshot, then defensively parses the component JSON payload and creates/refreshes one device tile per named component instance. More...
 
void RefreshDeviceTiles (const std::string &componentJson)
 Parses the component JSON payload and creates/refreshes one device tile per named component instance. More...
 
virtual void OnLoggerUpdate (wxThreadEvent &event)
 Logger-update handler (main thread): appends the event's log line to the logger model. More...
 

Protected Attributes

wxNotebook * myNotebook
 The tab container. More...
 
HomeScenePanelmyHomeScenePanel
 The Home tab's condition-reactive backdrop. More...
 
wxPanel * mySummaryPanel
 The Summary tab (at-a-glance tiles). More...
 
wxPanel * myDevicesPanel
 The Devices tab. More...
 
wxPanel * myLoggerPanel
 The Logger tab. More...
 
wxPanel * mySettingsPanel
 The Settings tab. More...
 
wxGridSizer * myDataViewGridSizer
 The grid sizer holding the device tiles. More...
 
wxScrolledWindow * myDevicesScrollWindow
 The scrollable container for the device tiles. More...
 
wxDataViewCtrl * myLoggerDataViewCtrl
 The data-view control showing the log. More...
 
LoggerListDatamyLoggerListDataModel
 The model backing the log control. More...
 
LoggerEventForwardermyLoggerEventForwarder
 Forwards AlertManager alerts to the Logger tab. More...
 
wxStaticText * myTemperatureValue
 The Temperature tile's value label. More...
 
wxStaticText * myHumidityValue
 The Humidity tile's value label. More...
 
wxStaticText * myAirQualityValue
 The Air Quality tile's value label. More...
 
wxStaticText * myPmTwoPointFiveValue
 The PM2.5 tile's value label. More...
 
wxStaticText * myTVOCValue
 The TVOC tile's value label. More...
 
wxStaticText * myFormaldehydeValue
 The Formaldehyde tile's value label. More...
 
wxStaticText * myCO2Value
 The CO2 tile's value label. More...
 
wxStaticText * myMotionValue
 The Motion tile's value label. More...
 
wxStaticText * myWindSpeedValue
 The Wind Speed tile's value label. More...
 
wxStaticText * myLightValue
 The Light tile's value label. More...
 
std::unordered_map< std::string, ComponentPanel * > myComponentDataCollection
 
RumPiManagerThreadmyRumPiManagerThread
 

Detailed Description

The client's main window: a tabbed frame (Home scene, Summary tiles, Devices, Logger, Settings) that starts the background poll thread and the alert forwarder, and refreshes its tabs from the events they post.

Author
Eddie O'Hagan
Date
8/13/2026

Constructor & Destructor Documentation

◆ MainWindow()

MainWindow::MainWindow ( wxWindow *  parent,
wxWindowID  id = wxID_ANY,
const wxString &  title = wxEmptyString,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxSize(500, 300),
long  style = wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL 
)

Builds the main window: sets up the menu/status bar and notebook, creates the alert forwarder, and starts the background poll thread (surfacing a failure to start through the alert channel rather than a modal popup).

Author
Eddie O'Hagan
Date
8/13/2026
MainWindow* window = new MainWindow(nullptr, wxID_ANY, "MainWindow");
window->Show(true);
The client's main window: a tabbed frame (Home scene, Summary tiles, Devices, Logger,...
Definition: MainWindow.h:55
MainWindow(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(500, 300), long style=wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL)
Builds the main window: sets up the menu/status bar and notebook, creates the alert forwarder,...
Definition: MainWindow.cpp:32
Parameters
[in]parentThe parent window (nullptr for a top-level frame).
[in]idThe window identifier.
[in]titleThe window title.
[in]posThe initial position.
[in]sizeThe initial size.
[in]styleThe frame style flags.

◆ ~MainWindow()

MainWindow::~MainWindow ( )

Destroys the window, tearing down the background work as a safety net for paths that bypass OnClose (null-safe and idempotent).

Author
Eddie O'Hagan
Date
8/13/2026
//Runs when the window is destroyed.

Member Function Documentation

◆ ConstructDevicesPanel()

void MainWindow::ConstructDevicesPanel ( )
protected

Builds the Devices tab: a scrollable, three-column grid that will hold one tile per component instance.

Author
Eddie O'Hagan
Date
8/13/2026
//Called by ConstructNotebook().

◆ ConstructHomePanel()

void MainWindow::ConstructHomePanel ( )
protected

Builds the Home tab's condition-reactive scene panel and adds it to the notebook.

Author
Eddie O'Hagan
Date
8/13/2026
//Called by ConstructNotebook().

◆ ConstructLoggerPanel()

void MainWindow::ConstructLoggerPanel ( )
protected

Builds the Logger tab: a data-view control with icon/time/level/description columns, backed by the log model.

Author
Eddie O'Hagan
Date
8/13/2026
//Called by ConstructNotebook().

◆ ConstructMenuAndStatusBar()

void MainWindow::ConstructMenuAndStatusBar ( )
protected

Builds the menu bar and status bar and binds the window's menu, update, logger, and close events.

Author
Eddie O'Hagan
Date
8/13/2026
//Called by the constructor.

◆ ConstructNotebook()

void MainWindow::ConstructNotebook ( )
protected

Builds the notebook and its five tabs (Home, Summary, Devices, Logger, Settings) and adds it to the window layout.

Author
Eddie O'Hagan
Date
8/13/2026
//Called by the constructor.

◆ ConstructSettingsPanel()

void MainWindow::ConstructSettingsPanel ( )
protected

Builds the (currently empty) Settings tab and adds it to the notebook.

Author
Eddie O'Hagan
Date
8/13/2026
//Called by ConstructNotebook().

◆ ConstructSummaryPanel()

void MainWindow::ConstructSummaryPanel ( )
protected

Builds the Summary tab: a three-per-row grid of at-a-glance sensor tiles, stashing each tile's value label for live updates.

Author
Eddie O'Hagan
Date
8/13/2026
//Called by ConstructNotebook().

◆ CreateSummaryTile()

wxStaticText * MainWindow::CreateSummaryTile ( wxWindow *  parent,
wxSizer *  tileGridSizer,
const wxString &  title 
)
protected

Builds one titled summary tile with a large centered value label and adds it to the grid.

Author
Eddie O'Hagan
Date
8/13/2026
wxStaticText* label = CreateSummaryTile(mySummaryPanel, tileGridSizer, "Temperature");
wxPanel * mySummaryPanel
The Summary tab (at-a-glance tiles).
Definition: MainWindow.h:59
wxStaticText * CreateSummaryTile(wxWindow *parent, wxSizer *tileGridSizer, const wxString &title)
Builds one titled summary tile with a large centered value label and adds it to the grid.
Definition: MainWindow.cpp:247
Parameters
[in]parentThe parent window for the tile.
[in]tileGridSizerThe grid sizer to add the tile to.
[in]titleThe tile's title.
Returns
The tile's value label, for later live updates.

◆ OnAbout()

void MainWindow::OnAbout ( wxCommandEvent &  event)
protectedvirtual

About handler: shows the application's about dialog.

Author
Eddie O'Hagan
Date
8/13/2026
//Invoked by the Help > About menu item.
Parameters
[in]eventThe command event.

◆ OnClose()

void MainWindow::OnClose ( wxCloseEvent &  event)
protectedvirtual

Close handler: tears down the background work before the window is destroyed (the worker and forwarder both post events to us), then lets the default handler proceed.

Author
Eddie O'Hagan
Date
8/13/2026
//Invoked by wxWidgets on a close request.
Parameters
[in]eventThe close event.

◆ OnExit()

void MainWindow::OnExit ( wxCommandEvent &  event)
protectedvirtual

Exit handler: closes the window.

Author
Eddie O'Hagan
Date
8/13/2026
//Invoked by the File > Exit menu item.
Parameters
[in]eventThe command event.

◆ OnLoggerUpdate()

void MainWindow::OnLoggerUpdate ( wxThreadEvent &  event)
protectedvirtual

Logger-update handler (main thread): appends the event's log line to the logger model.

Author
Eddie O'Hagan
Date
8/13/2026
//Invoked on the main thread when the forwarder posts a wxEVT_RUMPI_LOGGER_UPDATE.
Parameters
[in]eventThe thread event carrying the log line.

◆ OnRumPiUpdate()

void MainWindow::OnRumPiUpdate ( wxThreadEvent &  event)
protectedvirtual

RumPi-update handler (main thread): refreshes the Summary tiles and Home scene from the event's snapshot, then defensively parses the component JSON payload and creates/refreshes one device tile per named component instance.

Author
Eddie O'Hagan
Date
8/13/2026
//Invoked on the main thread when the worker posts a wxEVT_RUMPI_UPDATE.
Parameters
[in]eventThe thread event carrying the snapshot and component JSON.

◆ OnShowLogs()

void MainWindow::OnShowLogs ( wxCommandEvent &  event)
protectedvirtual

"Show Log Files" handler: opens the log folder in the platform's file manager, falling back to a message box with the path if that isn't possible (e.g.

a headless kiosk) or if no log path is available yet.

Author
Eddie O'Hagan
Date
8/13/2026
//Invoked by the Help > Show Log Files menu item.
Parameters
[in]eventThe command event.

◆ RefreshDeviceTiles()

void MainWindow::RefreshDeviceTiles ( const std::string &  componentJson)
protected

Parses the component JSON payload and creates/refreshes one device tile per named component instance.

Split out of OnRumPiUpdate and called inside a try/catch there so a bad_alloc (newing panels) or a malformed payload can't escape the wx event handler and terminate the app.

Author
Eddie O'Hagan
Date
8/13/2026
//Called by OnRumPiUpdate().
Parameters
[in]componentJsonThe raw component JSON string from the update event.

◆ TeardownBackgroundWork()

void MainWindow::TeardownBackgroundWork ( )
protected

Stops the background poll thread and then tears down the alert forwarder, in that order (stop the producer before the consumer).

Null-safe and idempotent, so both OnClose and the destructor can call it.

Author
Eddie O'Hagan
Date
8/13/2026
void TeardownBackgroundWork()
Stops the background poll thread and then tears down the alert forwarder, in that order (stop the pro...
Definition: MainWindow.cpp:416

◆ UpdateSummaryPanel()

void MainWindow::UpdateSummaryPanel ( const RumPi::SelectedSensorReadings &  readings)
protected

Refreshes every summary tile's value label from a sensor snapshot (temperature, humidity, gases, particulates, air quality, motion, wind, and light) and re-flows the tiles.

Author
Eddie O'Hagan
Date
8/13/2026
void UpdateSummaryPanel(const RumPi::SelectedSensorReadings &readings)
Refreshes every summary tile's value label from a sensor snapshot (temperature, humidity,...
Definition: MainWindow.cpp:284
Parameters
[in]readingsThe sensor snapshot to display.

Member Data Documentation

◆ myAirQualityValue

wxStaticText* MainWindow::myAirQualityValue
protected

The Air Quality tile's value label.

◆ myCO2Value

wxStaticText* MainWindow::myCO2Value
protected

The CO2 tile's value label.

◆ myComponentDataCollection

std::unordered_map<std::string, ComponentPanel*> MainWindow::myComponentDataCollection
protected

◆ myDataViewGridSizer

wxGridSizer* MainWindow::myDataViewGridSizer
protected

The grid sizer holding the device tiles.

◆ myDevicesPanel

wxPanel* MainWindow::myDevicesPanel
protected

The Devices tab.

◆ myDevicesScrollWindow

wxScrolledWindow* MainWindow::myDevicesScrollWindow
protected

The scrollable container for the device tiles.

◆ myFormaldehydeValue

wxStaticText* MainWindow::myFormaldehydeValue
protected

The Formaldehyde tile's value label.

◆ myHomeScenePanel

HomeScenePanel* MainWindow::myHomeScenePanel
protected

The Home tab's condition-reactive backdrop.

◆ myHumidityValue

wxStaticText* MainWindow::myHumidityValue
protected

The Humidity tile's value label.

◆ myLightValue

wxStaticText* MainWindow::myLightValue
protected

The Light tile's value label.

◆ myLoggerDataViewCtrl

wxDataViewCtrl* MainWindow::myLoggerDataViewCtrl
protected

The data-view control showing the log.

◆ myLoggerEventForwarder

LoggerEventForwarder* MainWindow::myLoggerEventForwarder
protected

Forwards AlertManager alerts to the Logger tab.

◆ myLoggerListDataModel

LoggerListData* MainWindow::myLoggerListDataModel
protected

The model backing the log control.

◆ myLoggerPanel

wxPanel* MainWindow::myLoggerPanel
protected

The Logger tab.

◆ myMotionValue

wxStaticText* MainWindow::myMotionValue
protected

The Motion tile's value label.

◆ myNotebook

wxNotebook* MainWindow::myNotebook
protected

The tab container.

◆ myPmTwoPointFiveValue

wxStaticText* MainWindow::myPmTwoPointFiveValue
protected

The PM2.5 tile's value label.

◆ myRumPiManagerThread

RumPiManagerThread* MainWindow::myRumPiManagerThread
protected

◆ mySettingsPanel

wxPanel* MainWindow::mySettingsPanel
protected

The Settings tab.

◆ mySummaryPanel

wxPanel* MainWindow::mySummaryPanel
protected

The Summary tab (at-a-glance tiles).

◆ myTemperatureValue

wxStaticText* MainWindow::myTemperatureValue
protected

The Temperature tile's value label.

◆ myTVOCValue

wxStaticText* MainWindow::myTVOCValue
protected

The TVOC tile's value label.

◆ myWindSpeedValue

wxStaticText* MainWindow::myWindSpeedValue
protected

The Wind Speed tile's value label.


The documentation for this class was generated from the following files: