//------------------------------
wxStaticBoxSizer* sbSizer_testFrames;
- sbSizer_testFrames = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Test Frames")), wxVERTICAL);
+ wxStaticBox *sb_testFrames = new wxStaticBox(this, wxID_ANY, _("Test Frames"));
+ sbSizer_testFrames = new wxStaticBoxSizer(sb_testFrames, wxVERTICAL);
m_ckboxTestFrame = new wxCheckBox(this, wxID_ANY, _("Enable"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE);
+ sb_testFrames->SetToolTip(_("Send frames of known bits instead of compressed voice"));
sbSizer_testFrames->Add(m_ckboxTestFrame, 0, wxALIGN_LEFT, 0);
bSizer30->Add(sbSizer_testFrames,0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3);
//------------------------------
wxStaticBoxSizer* sbSizer_events;
- sbSizer_events = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Event Processing")), wxVERTICAL);
-
- // event processing enable
-
- m_ckbox_events = new wxCheckBox(this, wxID_ANY, _("Enable System Calls"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE);
- sbSizer_events->Add(m_ckbox_events, 0, 0, 5);
+ wxStaticBox *sb_events = new wxStaticBox(this, wxID_ANY, _("Event Processing"));
+ sbSizer_events = new wxStaticBoxSizer(sb_events, wxVERTICAL);
+
+ // event processing enable and spam timer
+
+ wxStaticBoxSizer* sbSizer_events_top;
+ wxStaticBox* sb_events1 = new wxStaticBox(this, wxID_ANY, _(""));
+ sbSizer_events_top = new wxStaticBoxSizer(sb_events1, wxHORIZONTAL);
+
+ m_ckbox_events = new wxCheckBox(this, wxID_ANY, _("Enable System Calls Syscall Spam Timer"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE);
+ sb_events->SetToolTip(_("Enable processing of events and generation of system calls"));
+ sbSizer_events_top->Add(m_ckbox_events, 0, 0, 5);
+ m_txt_spam_timer = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(40,-1), 0, wxTextValidator(wxFILTER_DIGITS));
+ m_txt_spam_timer->SetToolTip(_("Many matching events can cause a flood of syscalls. Set minimum time (seconds) between syscalls for each event here"));
+ sbSizer_events_top->Add(m_txt_spam_timer, 0, 0, 5);
+ m_rb_spam_timer = new wxRadioButton( this, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
+ m_rb_spam_timer->SetForegroundColour( wxColour(0, 255, 0 ) );
+ sbSizer_events_top->Add(m_rb_spam_timer, 0, 0, 10);
+ sbSizer_events->Add(sbSizer_events_top, 0, 0, 5);
// list of regexps
// log of events and responses
- wxStaticBoxSizer* sbSizer_event_log = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Events and Responses")), wxVERTICAL);
+ wxStaticBoxSizer* sbSizer_event_log = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Log of Events and Responses")), wxVERTICAL);
wxBoxSizer* bSizer33 = new wxBoxSizer(wxHORIZONTAL);
m_txt_events_in = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(200,50), wxTE_MULTILINE | wxTE_READONLY);
bSizer33->Add(m_txt_events_in, 1, wxEXPAND, 5);
//------------------------------
wxStaticBoxSizer* sbSizer_udp;
- sbSizer_udp = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("UDP Control Port")), wxHORIZONTAL);
- m_ckbox_udp_enable = new wxCheckBox(this, wxID_ANY, _("Enable UDP Control Port UDP Port Nnumber:"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE);
+ wxStaticBox* sb_udp = new wxStaticBox(this, wxID_ANY, _("UDP Control Port"));
+ sbSizer_udp = new wxStaticBoxSizer(sb_udp, wxHORIZONTAL);
+ m_ckbox_udp_enable = new wxCheckBox(this, wxID_ANY, _("Enable UDP Control Port UDP Port Number:"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE);
+ sb_udp->SetToolTip(_("Enable control of FreeDV via UDP port"));
sbSizer_udp->Add(m_ckbox_udp_enable, 0, wxALIGN_CENTER_HORIZONTAL, 5);
- m_txt_udp_port = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(100,-1), 0, wxTextValidator(wxFILTER_DIGITS));
+ m_txt_udp_port = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(50,-1), 0, wxTextValidator(wxFILTER_DIGITS));
sbSizer_udp->Add(m_txt_udp_port, 0, wxALIGN_CENTER_HORIZONTAL, 5);
bSizer30->Add(sbSizer_udp,0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3);
m_ckboxTestFrame->SetValue(wxGetApp().m_testFrames);
m_ckbox_events->SetValue(wxGetApp().m_events);
+ m_txt_spam_timer->SetValue(wxString::Format(wxT("%i"),wxGetApp().m_events_spam_timer));
+
m_txt_events_regexp_match->SetValue(wxGetApp().m_events_regexp_match);
m_txt_events_regexp_replace->SetValue(wxGetApp().m_events_regexp_replace);
wxGetApp().m_testFrames = m_ckboxTestFrame->GetValue();
wxGetApp().m_events = m_ckbox_events->GetValue();
+ long spam_timer;
+ m_txt_spam_timer->GetValue().ToLong(&spam_timer);
+ wxGetApp().m_events_spam_timer = (int)spam_timer;
// make sure regexp lists are terminated by a \n
if (storePersistent) {
pConfig->Write(wxT("/Data/CallSign"), wxGetApp().m_callSign);
pConfig->Write(wxT("/Data/TextEncoding"), wxGetApp().m_textEncoding);
+
pConfig->Write(wxT("/Events/enable"), wxGetApp().m_events);
+ pConfig->Write(wxT("/Events/spam_timer"), wxGetApp().m_events_spam_timer);
pConfig->Write(wxT("/Events/regexp_match"), wxGetApp().m_events_regexp_match);
pConfig->Write(wxT("/Events/regexp_replace"), wxGetApp().m_events_regexp_replace);
bool enableEventsChecked() {return m_ckbox_events->GetValue();}
+ void SetSpamTimerLight(bool state) {
+
+ // Colours don't work on Windows
+
+ if (state) {
+ m_rb_spam_timer->SetForegroundColour( wxColour( 255,0 , 0 ) ); // red
+ m_rb_spam_timer->SetValue(true);
+ }
+ else {
+ m_rb_spam_timer->SetForegroundColour( wxColour( 0, 255, 0 ) ); // green
+ m_rb_spam_timer->SetValue(false);
+ }
+ }
+
+
protected:
// Handlers for events.
void OnOK(wxCommandEvent& event);
wxTextCtrl *m_txt_events_regexp_replace;
wxTextCtrl *m_txt_events_in;
wxTextCtrl *m_txt_events_out;
+ wxTextCtrl *m_txt_spam_timer;
+ wxRadioButton *m_rb_spam_timer;
wxCheckBox *m_ckbox_udp_enable;
wxTextCtrl *m_txt_udp_port;
// Text messaging Data
#define MAX_CALLSIGN 80
#define MAX_EVENT_LOG 10
+#define MAX_EVENT_RULES 100
enum
{
wxGetApp().m_SpkOutEQEnable = (float)pConfig->Read(wxT("/Filter/SpkOutEQEnable"), f);
wxGetApp().m_callSign = pConfig->Read("/Data/CallSign", wxT(""));
- wxGetApp().m_textEncoding = pConfig->Read("/Data/TextEncoding", 1);
+ wxGetApp().m_textEncoding = pConfig->Read("/Data/TextEncoding", 2);
+
wxGetApp().m_events = pConfig->Read("/Events/enable", f);
+ wxGetApp().m_events_spam_timer = (int)pConfig->Read(wxT("/Events/spam_timer"), 10);
wxGetApp().m_events_regexp_match = pConfig->Read("/Events/regexp_match", wxT("s=(.*)"));
wxGetApp().m_events_regexp_replace = pConfig->Read("/Events/regexp_replace",
wxT("curl http://qso.freedv.org/cgi-bin/onspot.cgi?s=\\1"));
}
wxGetApp().m_udp_enable = (float)pConfig->Read(wxT("/UDP/enable"), f);
- wxGetApp().m_udp_port = (float)pConfig->Read(wxT("/UDP/port"), 3000);
+ wxGetApp().m_udp_port = (int)pConfig->Read(wxT("/UDP/port"), 3000);
pConfig->SetPath(wxT("/"));
pConfig->Write(wxT("/Data/CallSign"), wxGetApp().m_callSign);
pConfig->Write(wxT("/Data/TextEncoding"), wxGetApp().m_textEncoding);
pConfig->Write(wxT("/Events/enable"), wxGetApp().m_events);
+ pConfig->Write(wxT("/Events/spam_timer"), wxGetApp().m_events_spam_timer);
pConfig->Write(wxT("/Events/regexp_match"), wxGetApp().m_events_regexp_match);
pConfig->Write(wxT("/Events/regexp_replace"), wxGetApp().m_events_regexp_replace);
Restore();
m_schedule_restore = false;
}
+
+ // Light Spam Timer LED if at least one time is running
+
+ int i;
+ optionsDlg->SetSpamTimerLight(false);
+ for(i=0; i<MAX_EVENT_RULES; i++)
+ if (spamTimer[i].IsRunning())
+ optionsDlg->SetSpamTimerLight(true);
}
#endif
exclusive NOR
*/
- if(wxGetApp().m_boolUseSerialPTT && com_handle != COM_HANDLE_INVALID) {
+ if(wxGetApp().m_boolUseSerialPTT && (com_handle != COM_HANDLE_INVALID)) {
if (wxGetApp().m_boolUseRTS) {
printf("g_tx: %d m_boolRTSPos: %d serialLine: %d\n", g_tx, wxGetApp().m_boolRTSPos, g_tx == wxGetApp().m_boolRTSPos);
if (g_tx == wxGetApp().m_boolRTSPos)
// Stop Running -------------------------------------------------
//
+ optionsDlg->SetSpamTimerLight(false);
+
#ifdef _USE_TIMER
m_plotTimer.Stop();
#endif // _USE_TIMER
m_txErr = m_txInPa->streamOpen();
if(m_txErr != paNoError) {
-fprintf(stderr, "Err: %d\n", m_txErr);
+ fprintf(stderr, "Err: %d\n", m_txErr);
wxMessageBox(wxT("Sound Card 2 Open/Setup error."), wxT("Error"), wxOK);
m_rxInPa->stop();
m_rxInPa->streamClose();
void MainFrame::processTxtEvent(char event[]) {
+ int rule = 0;
printf("processTxtEvent:\n");
printf(" event: %s\n", event);
bool found_match = false;
- while ((match_end = regexp_match_list.Find('\n')) != wxNOT_FOUND) {
+ while (((match_end = regexp_match_list.Find('\n')) != wxNOT_FOUND) && (rule < MAX_EVENT_RULES)) {
//printf("match_end: %d\n", match_end);
if ((replace_end = regexp_replace_list.Find('\n')) != wxNOT_FOUND) {
//printf("replace_end = %d\n", replace_end);
+
// candidate match and replace regexps strings exist, so lets try them
wxString regexp_match = regexp_match_list.SubString(0, match_end-1);
bool enableSystem = false;
if (wxGetApp().m_events)
enableSystem = true;
-
+
+ // no syscall if spam timer still running
+
+ if (spamTimer[rule].IsRunning()) {
+ enableSystem = false;
+ printf(" spam timer running\n");
+ }
+
const char *event_out = event_str_rep.ToUTF8();
wxString event_out_with_return_code;
if (enableSystem) {
int ret = wxExecute(event_str_rep);
event_out_with_return_code.Printf(_T("%s -> returned %d"), event_out, ret);
+ spamTimer[rule].Start((wxGetApp().m_events_spam_timer)*1000, wxTIMER_ONE_SHOT);
}
else
- event_out_with_return_code.Printf(_T("%s)"), event_out);
+ event_out_with_return_code.Printf(_T("%s T: %d"), event_out, spamTimer[rule].IsRunning());
// update event log GUI if currently displayed
}
regexp_match_list = regexp_match_list.SubString(match_end+1, regexp_match_list.length());
regexp_replace_list = regexp_replace_list.SubString(replace_end+1, regexp_replace_list.length());
+
+ rule++;
}
if ((optionsDlg != NULL) && !found_match) {
wxString m_callSign;
bool m_events;
+ int m_events_spam_timer;
unsigned int m_textEncoding;
wxString m_events_regexp_match;
wxString m_events_regexp_replace;
char *m_pcallsign;
unsigned int m_checksumGood;
unsigned int m_checksumBad;
-
+
// Events
void processTxtEvent(char event[]);
class OptionsDlg *optionsDlg;
+ wxTimer spamTimer[MAX_EVENT_RULES];
// level Gauge
float m_maxLevel;
m_menuItemFilter = new wxMenuItem(tools, wxID_ANY, wxString(_("&Filter")) , wxEmptyString, wxITEM_NORMAL);
tools->Append(m_menuItemFilter);
- wxMenuItem* m_menuItemCaptTxInStream;
- m_menuItemCaptTxInStream = new wxMenuItem(tools, wxID_ANY, wxString(_("&Capture Tx Input Stream")), wxEmptyString, wxITEM_NORMAL);
-
wxMenuItem* m_menuItemPlayFileToMicIn;
m_menuItemPlayFileToMicIn = new wxMenuItem(tools, wxID_ANY, wxString(_("Start/Stop Play File - Mic In")) , wxEmptyString, wxITEM_NORMAL);
g_playFileToMicInEventId = m_menuItemPlayFileToMicIn->GetId();
bSizer15->Add(m_txtCtrlCallSign, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5);
lowerSizer->Add(bSizer15, 1, wxEXPAND, 5);
- wxStaticBoxSizer* sbSizer_Checksum = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Good/Bad Checksums")), wxHORIZONTAL);
- m_txtChecksumGood = new wxStaticText(this, wxID_ANY, wxT("0"), wxDefaultPosition, wxSize(100,-1), wxALIGN_CENTRE);
- sbSizer_Checksum->Add(m_txtChecksumGood, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 1);
- m_txtChecksumBad = new wxStaticText(this, wxID_ANY, wxT("0"), wxDefaultPosition, wxSize(100,-1), wxALIGN_CENTRE);
- sbSizer_Checksum->Add(m_txtChecksumBad, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 1);
+ wxStaticBoxSizer* sbSizer_Checksum = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Checksums")), wxHORIZONTAL);
+
+ wxStaticText *goodLabel = new wxStaticText(this, wxID_ANY, wxT("Good: "), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE);
+ sbSizer_Checksum->Add(goodLabel, 0, 0, 2);
+ m_txtChecksumGood = new wxStaticText(this, wxID_ANY, wxT("0"), wxDefaultPosition, wxSize(30,-1), wxALIGN_CENTRE);
+ sbSizer_Checksum->Add(m_txtChecksumGood, 0, 0, 2);
+
+ wxStaticText *badLabel = new wxStaticText(this, wxID_ANY, wxT("Bad: "), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE);
+ sbSizer_Checksum->Add(badLabel, 0, 0, 1);
+ m_txtChecksumBad = new wxStaticText(this, wxID_ANY, wxT("0"), wxDefaultPosition, wxSize(30,-1), wxALIGN_CENTRE);
+ sbSizer_Checksum->Add(m_txtChecksumBad, 0, 0, 1);
+
lowerSizer->Add(sbSizer_Checksum, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 1);
//=====================================================