|
|
|
@ -26,6 +26,7 @@ enum Id {
|
|
|
|
|
MRunConnect,
|
|
|
|
|
MRunStart,
|
|
|
|
|
MRunMeasure,
|
|
|
|
|
MRunLogResults,
|
|
|
|
|
MRunUpload,
|
|
|
|
|
MRunUnload,
|
|
|
|
|
MRunEditBSize,
|
|
|
|
@ -100,6 +101,8 @@ MainFrame::MainFrame() : wxFrame(nullptr, wxID_ANY, "stmdspgui", wxPoint(50, 50)
|
|
|
|
|
Bind(wxEVT_MENU, &MainFrame::onRunStart, this, Id::MRunStart, wxID_ANY,
|
|
|
|
|
menuRun->Append(MRunStart, "&Start"));
|
|
|
|
|
m_run_measure = menuRun->AppendCheckItem(MRunMeasure, "&Measure code time");
|
|
|
|
|
Bind(wxEVT_MENU, &MainFrame::onRunLogResults, this, Id::MRunLogResults, wxID_ANY,
|
|
|
|
|
menuRun->AppendCheckItem(MRunLogResults, "&Log results..."));
|
|
|
|
|
menuRun->AppendSeparator();
|
|
|
|
|
Bind(wxEVT_MENU, &MainFrame::onRunUpload, this, Id::MRunUpload, wxID_ANY,
|
|
|
|
|
menuRun->Append(MRunUpload, "&Upload code"));
|
|
|
|
@ -144,23 +147,13 @@ void MainFrame::onCloseEvent(wxCloseEvent& event)
|
|
|
|
|
void MainFrame::onMeasureTimer([[maybe_unused]] wxTimerEvent&)
|
|
|
|
|
{
|
|
|
|
|
if (m_conv_result_log != nullptr) {
|
|
|
|
|
static unsigned int counter = 0;
|
|
|
|
|
if (auto samples = m_device->continuous_read(); samples.size() > 0) {
|
|
|
|
|
for (auto& s : samples) {
|
|
|
|
|
auto str = wxString::Format("%u\n", s);
|
|
|
|
|
m_conv_result_log->Write(str.ToAscii(), str.Len());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
counter++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//if (counter == 20) {
|
|
|
|
|
// m_conv_result_log->Close();
|
|
|
|
|
// delete m_conv_result_log;
|
|
|
|
|
// m_conv_result_log = nullptr;
|
|
|
|
|
// counter = 0;
|
|
|
|
|
//}
|
|
|
|
|
} else if (m_status_bar && m_device) {
|
|
|
|
|
} else if (m_status_bar && m_run_measure && m_run_measure->IsChecked()) {
|
|
|
|
|
m_status_bar->SetStatusText(wxString::Format(wxT("Execution time: %u cycles"),
|
|
|
|
|
m_device->continuous_start_get_measurement()));
|
|
|
|
|
}
|
|
|
|
@ -409,12 +402,6 @@ void MainFrame::onRunStart(wxCommandEvent& ce)
|
|
|
|
|
|
|
|
|
|
if (!m_is_running) {
|
|
|
|
|
if (m_device != nullptr && m_device->connected()) {
|
|
|
|
|
if (m_conv_result_log != nullptr) {
|
|
|
|
|
m_conv_result_log->Close();
|
|
|
|
|
delete m_conv_result_log;
|
|
|
|
|
}
|
|
|
|
|
m_conv_result_log = new wxFileOutputStream("results.csv");
|
|
|
|
|
|
|
|
|
|
if (m_run_measure && m_run_measure->IsChecked()) {
|
|
|
|
|
m_device->continuous_start_measure();
|
|
|
|
|
m_measure_timer->StartOnce(1000);
|
|
|
|
@ -431,16 +418,36 @@ void MainFrame::onRunStart(wxCommandEvent& ce)
|
|
|
|
|
m_status_bar->SetStatusText("Please connect.");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
m_device->continuous_stop();
|
|
|
|
|
|
|
|
|
|
menuItem->SetItemLabel("&Start");
|
|
|
|
|
m_status_bar->SetStatusText("Ready.");
|
|
|
|
|
m_is_running = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainFrame::onRunLogResults(wxCommandEvent& ce)
|
|
|
|
|
{
|
|
|
|
|
auto menuItem = dynamic_cast<wxMenuItem *>(ce.GetEventUserData());
|
|
|
|
|
if (menuItem->IsChecked()) {
|
|
|
|
|
wxFileDialog dialog (this, "Choose log file", "", "", "*.csv",
|
|
|
|
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
|
|
|
|
|
|
|
|
|
if (dialog.ShowModal() != wxID_CANCEL) {
|
|
|
|
|
if (m_conv_result_log != nullptr) {
|
|
|
|
|
m_conv_result_log->Close();
|
|
|
|
|
delete m_conv_result_log;
|
|
|
|
|
m_conv_result_log = nullptr;
|
|
|
|
|
}
|
|
|
|
|
m_device->continuous_stop();
|
|
|
|
|
|
|
|
|
|
menuItem->SetItemLabel("&Start");
|
|
|
|
|
m_conv_result_log = new wxFileOutputStream(dialog.GetPath());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_status_bar->SetStatusText("Ready.");
|
|
|
|
|
m_is_running = false;
|
|
|
|
|
} else if (m_conv_result_log != nullptr) {
|
|
|
|
|
m_conv_result_log->Close();
|
|
|
|
|
delete m_conv_result_log;
|
|
|
|
|
m_conv_result_log = nullptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|