Add configuration for stats reset time.

pull/262/head
Mooneer Salem 2022-09-15 23:17:40 -07:00
parent 075f51246e
commit 370a2a636b
4 changed files with 32 additions and 3 deletions

View File

@ -233,6 +233,17 @@ OptionsDlg::OptionsDlg(wxWindow* parent, wxWindowID id, const wxString& title, c
sizerModem->Add(sbSizer_multirx,0, wxALL|wxEXPAND, 3);
wxStaticBox *sb_modemstats = new wxStaticBox(m_modemTab, wxID_ANY, _("Modem Statistics"));
wxStaticBoxSizer* sbSizer_modemstats = new wxStaticBoxSizer(sb_modemstats, wxVERTICAL);
wxBoxSizer* sbSizer_statsResetTime = new wxBoxSizer(wxHORIZONTAL);
wxStaticText *m_staticTextResetTime = new wxStaticText(m_modemTab, wxID_ANY, _("Time before resetting stats (sec):"), wxDefaultPosition, wxDefaultSize, 0);
sbSizer_statsResetTime->Add(m_staticTextResetTime, 0, wxALIGN_CENTER_VERTICAL , 5);
m_statsResetTime = new wxTextCtrl(m_modemTab, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(30,-1), 0, wxTextValidator(wxFILTER_DIGITS));
sbSizer_statsResetTime->Add(m_statsResetTime, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
sbSizer_modemstats->Add(sbSizer_statsResetTime, 0, wxALIGN_LEFT, 0);
sizerModem->Add(sbSizer_modemstats,0, wxALL|wxEXPAND, 3);
m_modemTab->SetSizer(sizerModem);
// Simulation tab
@ -425,6 +436,7 @@ OptionsDlg::OptionsDlg(wxWindow* parent, wxWindowID id, const wxString& title, c
m_ckboxPhaseEstDPSK->MoveBeforeInTabOrder(m_ckHalfDuplex);
m_ckHalfDuplex->MoveBeforeInTabOrder(m_ckboxMultipleRx);
m_ckboxMultipleRx->MoveBeforeInTabOrder(m_ckboxSingleRxThread);
m_ckboxSingleRxThread->MoveBeforeInTabOrder(m_statsResetTime);
m_ckboxTestFrame->MoveBeforeInTabOrder(m_ckboxChannelNoise);
m_ckboxChannelNoise->MoveBeforeInTabOrder(m_txtNoiseSNR);
@ -586,6 +598,9 @@ void OptionsDlg::ExchangeData(int inout, bool storePersistent)
m_txt_callsign->SetValue(wxGetApp().m_psk_callsign);
m_txt_grid_square->SetValue(wxGetApp().m_psk_grid_square);
// Stats reset time
m_statsResetTime->SetValue(wxString::Format(wxT("%i"), wxGetApp().m_statsResetTimeSec));
// Waterfall color
switch (wxGetApp().m_waterfallColor)
{
@ -720,6 +735,11 @@ void OptionsDlg::ExchangeData(int inout, bool storePersistent)
wxGetApp().m_waterfallColor = 2;
}
// Stats reset time
long resetTime;
m_statsResetTime->GetValue().ToLong(&resetTime);
wxGetApp().m_statsResetTimeSec = resetTime;
if (storePersistent) {
pConfig->Write(wxT("/Data/CallSign"), wxGetApp().m_callSign);
#ifdef SHORT_VARICODE
@ -745,6 +765,8 @@ void OptionsDlg::ExchangeData(int inout, bool storePersistent)
pConfig->Write(wxT("/PSKReporter/Callsign"), wxGetApp().m_psk_callsign);
pConfig->Write(wxT("/PSKReporter/GridSquare"), wxGetApp().m_psk_grid_square);
pConfig->Write(wxT("/Stats/ResetTime"), wxGetApp().m_statsResetTimeSec);
// Waterfall configuration
pConfig->Write(wxT("/Waterfall/Color"), wxGetApp().m_waterfallColor);

View File

@ -148,6 +148,7 @@ class OptionsDlg : public wxDialog
wxCheckBox* m_ckboxMultipleRx;
wxCheckBox* m_ckboxSingleRxThread;
wxTextCtrl* m_statsResetTime;
unsigned int event_in_serial, event_out_serial;

View File

@ -431,6 +431,9 @@ void MainFrame::loadConfiguration_()
// Waterfall configuration
wxGetApp().m_waterfallColor = (int)pConfig->Read(wxT("/Waterfall/Color"), (int)0); // 0-2
// Time in seconds after losing sync before we reset the stats area
wxGetApp().m_statsResetTimeSec = (int)pConfig->Read(wxT("/Stats/ResetTime"), (int)10);
int mode = pConfig->Read(wxT("/Audio/mode"), (long)0);
if (mode == 0)
m_rb1600->SetValue(1);
@ -779,6 +782,9 @@ MainFrame::~MainFrame()
// Waterfall configuration
pConfig->Write(wxT("/Waterfall/Color"), wxGetApp().m_waterfallColor);
// Time in seconds after losing sync before we reset the stats area
pConfig->Write(wxT("/Stats/ResetTime"), wxGetApp().m_statsResetTimeSec);
int mode;
if (m_rb1600->GetValue())
mode = 0;
@ -1131,7 +1137,7 @@ void MainFrame::OnTimer(wxTimerEvent &evt)
freedvInterface.resetReliableText();
// Auto-reset stats if we've gone long enough since losing sync.
if (m_timeSinceSyncLoss >= MAX_SYNC_LOSS_TIME_BEFORE_RESET_MS)
if (m_timeSinceSyncLoss >= wxGetApp().m_statsResetTimeSec)
{
resetStats_();
}
@ -1141,7 +1147,7 @@ void MainFrame::OnTimer(wxTimerEvent &evt)
else
{
// Counts the amount of time since losing sync. Once we exceed
// MAX_SYNC_LOSS_TIME_BEFORE_RESET_MS, we will reset the stats.
// wxGetApp().m_statsResetTimeSec, we will reset the stats.
m_timeSinceSyncLoss += _REFRESH_TIMER_PERIOD;
}

View File

@ -98,7 +98,6 @@
#define _DUMMY_DATA 1
//#define _AUDIO_PASSTHROUGH 1
#define _REFRESH_TIMER_PERIOD (DT*1000)
#define MAX_SYNC_LOSS_TIME_BEFORE_RESET_MS (10000) /* TBD -- should be user config option */
//#define _USE_ABOUT_DIALOG 1
@ -235,6 +234,7 @@ class MainApp : public wxApp
wxString m_callSign;
unsigned int m_textEncoding;
bool m_snrSlow;
unsigned int m_statsResetTimeSec;
// LPC Post Filter
bool m_codec2LPCPostFilterEnable;