added resyncs counter
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sat, 25 Feb 2017 08:35:58 +0000 (08:35 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sat, 25 Feb 2017 08:35:58 +0000 (08:35 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3054 01035d8c-6547-0410-b346-abe4f91aad63

freedv-dev/src/fdmdv2_main.cpp
freedv-dev/src/topFrame.cpp
freedv-dev/src/topFrame.h

index e91e14c2d2f93be7c048acf925c65a27dacd5d65..953fcb801b6b3930cb7b688dcc67ebfda94614f4 100644 (file)
@@ -48,9 +48,8 @@ int                 g_clip;
 int                 g_testFrames;
 int                 g_test_frame_sync_state;
 int                 g_test_frame_count;
-int                 g_total_bits;
-int                 g_total_bit_errors;
 int                 g_channel_noise;
+int                 g_resyncs;
 float               g_sig_pwr_av = 0.0;
 struct FIFO        *g_error_pattern_fifo;
 short              *g_error_hist, *g_error_histn;
@@ -73,7 +72,7 @@ struct FIFO         *g_txDataInFifo;
 struct FIFO         *g_rxDataOutFifo;
 
 // tx/rx processing states
-int                 g_State;
+int                 g_State, g_prev_State;
 paCallBackData     *g_rxUserdata;
 
 // FIFOs used for plotting waveforms
@@ -593,8 +592,7 @@ MainFrame::MainFrame(wxString plugInName, wxWindow *parent) : TopFrame(plugInNam
 
     g_testFrames = 0;
     g_test_frame_sync_state = 0;
-    g_total_bit_errors = 0;
-    g_total_bits = 0;
+    g_resyncs = 0;
     wxGetApp().m_testFrames = false;
 
     g_modal = false;
@@ -1132,14 +1130,19 @@ void MainFrame::OnTimer(wxTimerEvent &evt)
 
     // sync LED (Colours don't work on Windows) ------------------------
 
+    //fprintf(stderr, "g_State: %d  m_rbSync->GetValue(): %d\n", g_State, m_rbSync->GetValue());
     if (g_State) {
+        if (g_prev_State == 0) {
+            g_resyncs++;
+        }
         m_rbSync->SetForegroundColour( wxColour( 0, 255, 0 ) ); // green
-        m_rbSync->SetValue(true);
+        m_rbSync->SetValue(true);        
     }
     else {
         m_rbSync->SetForegroundColour( wxColour( 255, 0, 0 ) ); // red
         m_rbSync->SetValue(false);
     }
+    g_prev_State = g_State;
 
     // send Callsign ----------------------------------------------------
 
@@ -1282,7 +1285,7 @@ void MainFrame::OnTimer(wxTimerEvent &evt)
         g_channel_noise =  wxGetApp().m_channel_noise;
 
         if (g_State) {
-            char bits[80], errors[80], ber[80];
+            char bits[80], errors[80], ber[80], resyncs[80];
 
             // update stats on main page
 
@@ -1290,6 +1293,7 @@ void MainFrame::OnTimer(wxTimerEvent &evt)
             sprintf(errors, "Errs: %d", freedv_get_total_bit_errors(g_pfreedv)); wxString errors_string(errors); m_textErrors->SetLabel(errors_string);
             float b = (float)freedv_get_total_bit_errors(g_pfreedv)/(1E-6+freedv_get_total_bits(g_pfreedv));
             sprintf(ber, "BER: %4.3f", b); wxString ber_string(ber); m_textBER->SetLabel(ber_string);
+            sprintf(resyncs, "Resyncs: %d", g_resyncs); wxString resyncs_string(resyncs); m_textResyncs->SetLabel(resyncs_string);
 
             // update error pattern plots if supported
 
@@ -1848,7 +1852,7 @@ void MainFrame::OnTogBtnAnalogClick (wxCommandEvent& event)
         m_panelWaterfall->setFs(freedv_get_modem_sample_rate(g_pfreedv));
     }
 
-    g_State = 0;
+    g_State = g_prev_State = 0;
     g_stats.snr_est = 0;
 
     event.Skip();
@@ -1870,6 +1874,7 @@ void MainFrame::OnBerReset(wxCommandEvent& event)
 {
     freedv_set_total_bits(g_pfreedv, 0);
     freedv_set_total_bit_errors(g_pfreedv, 0);
+    g_resyncs = 0;
     int i;
     for(i=0; i<2*g_Nc; i++) {
         g_error_hist[i] = 0;
@@ -2514,7 +2519,7 @@ void MainFrame::OnTogBtnOnOff(wxCommandEvent& event)
         }
 
         modem_stats_open(&g_stats);
-        g_State = 0;
+        g_State = g_prev_State = 0;
         g_snr = 0.0;
         g_half_duplex = wxGetApp().m_boolHalfDuplex;
 
@@ -3738,6 +3743,7 @@ void per_frame_rx_processing(
         
             nin = freedv_nin(g_pfreedv);
             g_State = freedv_get_sync(g_pfreedv);
+
             //fprintf(g_logfile, "g_State: %d g_stats.sync: %d snr: %f \n", g_State, g_stats.sync, f->snr);
 
             // grab extended stats so we can plot spectrum, scatter diagram etc
index 01aaac6d31aab9b9a2bdad3e7adcbc3ba7ca4093..2092ddebaf61096c074daa2730b49569ea6d1653 100644 (file)
@@ -166,6 +166,9 @@ TopFrame::TopFrame(wxString plugInName, wxWindow* parent, wxWindowID id, const w
     m_textBER = new wxStaticText(this, wxID_ANY, wxT("BER: 0.0"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
     sbSizer_ber->Add(m_textBER, 0, wxALIGN_LEFT, 1);
 
+    m_textResyncs = new wxStaticText(this, wxID_ANY, wxT("Resyncs: 0"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
+    sbSizer_ber->Add(m_textResyncs, 0, wxALIGN_LEFT, 1);
+
     leftSizer->Add(sbSizer_ber,0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3);
 
     //------------------------------
index e4ed58300d6fb44e50dac14ded5e0e5f9a60a090..37950a99c3aa1fdd3499bec5485a07afc3c08bb0 100644 (file)
@@ -102,6 +102,7 @@ class TopFrame : public wxFrame
         wxStaticText  *m_textBits;
         wxStaticText  *m_textErrors;
         wxStaticText  *m_textBER;
+        wxStaticText  *m_textResyncs;
 
         wxRadioButton *m_rbSync;
         wxRadioButton *m_rb1400old;