mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Emergency stop works.
This commit is contained in:
@@ -13,6 +13,9 @@ struct ErrorLogMessage
|
||||
std::string message;
|
||||
};
|
||||
|
||||
struct EmergencyStopMessage
|
||||
{};
|
||||
|
||||
struct BeginSpeedOperationLogMessage
|
||||
{
|
||||
};
|
||||
@@ -73,6 +76,7 @@ class TrackFlux;
|
||||
|
||||
typedef std::variant<std::string,
|
||||
ErrorLogMessage,
|
||||
EmergencyStopMessage,
|
||||
TrackReadLogMessage,
|
||||
DiskReadLogMessage,
|
||||
BeginSpeedOperationLogMessage,
|
||||
|
||||
@@ -10,6 +10,8 @@ BEGIN_EVENT_TABLE(CustomStatusBar, wxStatusBar)
|
||||
END_EVENT_TABLE()
|
||||
// clang-format on
|
||||
|
||||
wxDEFINE_EVENT(PROGRESSBAR_STOP_EVENT, wxCommandEvent);
|
||||
|
||||
CustomStatusBar::CustomStatusBar(wxWindow* parent, wxWindowID id):
|
||||
wxStatusBar(parent, id)
|
||||
{
|
||||
@@ -36,7 +38,7 @@ CustomStatusBar::CustomStatusBar(wxWindow* parent, wxWindowID id):
|
||||
_stopButton->Bind(wxEVT_BUTTON,
|
||||
[this](auto&)
|
||||
{
|
||||
auto* event = new wxCommandEvent(UPDATE_STATE_EVENT, 0);
|
||||
auto* event = new wxCommandEvent(PROGRESSBAR_STOP_EVENT, 0);
|
||||
event->SetEventObject(this);
|
||||
QueueEvent(event);
|
||||
});
|
||||
|
||||
@@ -65,7 +65,7 @@ wxThread::ExitCode FluxEngineApp::Entry()
|
||||
}
|
||||
catch (const EmergencyStopException& e)
|
||||
{
|
||||
Logger() << "Emergency stop!\n";
|
||||
Logger() << EmergencyStopMessage();
|
||||
}
|
||||
|
||||
runOnUiThread(
|
||||
|
||||
@@ -123,6 +123,12 @@ public:
|
||||
UpdateState();
|
||||
|
||||
CreateStatusBar();
|
||||
|
||||
_statusBar->Bind(PROGRESSBAR_STOP_EVENT,
|
||||
[this](auto&)
|
||||
{
|
||||
emergencyStop = true;
|
||||
});
|
||||
}
|
||||
|
||||
void OnExit(wxCommandEvent& event)
|
||||
@@ -172,11 +178,6 @@ public:
|
||||
UpdateState();
|
||||
}
|
||||
|
||||
void OnStopButton(wxCommandEvent&)
|
||||
{
|
||||
emergencyStop = true;
|
||||
}
|
||||
|
||||
void OnReadButton(wxCommandEvent&)
|
||||
{
|
||||
try
|
||||
@@ -478,11 +479,23 @@ public:
|
||||
{
|
||||
},
|
||||
|
||||
/* We terminated due to the stop button. */
|
||||
[&](const EmergencyStopMessage& m)
|
||||
{
|
||||
_statusBar->SetLeftLabel("Emergency stop!");
|
||||
_statusBar->HideProgressBar();
|
||||
_statusBar->SetRightLabel("");
|
||||
_state = _errorState;
|
||||
UpdateState();
|
||||
},
|
||||
|
||||
/* A fatal error. */
|
||||
[&](const ErrorLogMessage& m)
|
||||
{
|
||||
_statusBar->SetLeftLabel(m.message);
|
||||
wxMessageBox(m.message, "Error", wxOK | wxICON_ERROR);
|
||||
_statusBar->HideProgressBar();
|
||||
_statusBar->SetRightLabel("");
|
||||
_state = _errorState;
|
||||
UpdateState();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user