Beispiel #1
0
xmlLogger::xmlLogger(const char *path, int mode) :
xmlWriter(path, mode)
{
#if USE_PC_LOGGER
  /** Algorithm: */
  /** Initialize class variables. */
  m_logging_enabled = false;
  
  /** Check to see if the file pointer could be opened given the information passed into
  * the constructor.  The variable "path" should contain an absolute system path of the logfile
  * to be opened.  If no filename was passed to the constructor, then look on the user's desktop
  * for a file named XML_LOGGER_DEFAULT_NAME.  If found, then try to re-open the logfile with
  * this path. */
  if(path == NULL)
  {
    char desktop[MAX_DIR];
    if(getDesktopDir(desktop))
    {
      strncat(desktop, XML_LOGGER_DEFAULT_NAME, MAX_DIR);
      /** If the USE_PC_LOGGER_SESSION symbol is 1, then automatically create the XML file on the desktop.
      Otherwise, look to see if the logfile target already exists on the user's desktop, and if so,
      then re-open it for logging. */
#if ! XML_LOGGER_SESSION
      FILE *fp = fopen(desktop, "r");
      if(fp != NULL)
      {
        fclose(fp);
#endif
        if(openFile(desktop, mode))
        {
          /** If the file was found on the desktop, then enable logging. */
          m_logging_enabled = true;
        }
#if ! XML_LOGGER_SESSION
      }
#endif
    }
  }
  else
  {
    /** If the file could be opened directly with the path given in the constructor, then
    * enable logging. */
    if(openFile(path, mode))
    {
      m_logging_enabled = true;
    }
  }
  
  /** Initialize our timer objects. */
  gettimeofday(&m_tv, &m_tz);
  m_start_ms = m_tv.tv_sec * 1000 + m_tv.tv_usec / 1000;

  /** If the logfile could be opened, then write the global session tag to file. */
  if(m_logging_enabled)
  {
    startSession();
  }
#endif
}
Beispiel #2
0
CGUISetupFrame::CGUISetupFrame() :
wxFrame(NULL, -1, wxString(_("UWSDR GUI Setup")), wxDefaultPosition, wxDefaultSize, wxMINIMIZE_BOX  | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN),
m_name(NULL),
m_filenameText(NULL),
m_deskTop(NULL),
m_userAudio(NULL),
m_sdrAudio(NULL),
m_filename(),
m_sdrType(TYPE_DEMO),
m_userAudioType(),
m_userAudioInDev(NO_DEV),
m_userAudioOutDev(NO_DEV),
m_sdrAudioType(),
m_sdrAudioInDev(NO_DEV),
m_sdrAudioOutDev(NO_DEV),
m_tuningHW(TUNINGHW_NONE),
m_externalName(),
m_externalAddr(EXTERNALADDRS_LOCAL)
{
	SetIcon(wxICON(GUISetup));

	wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);

	wxPanel* panel = new wxPanel(this, -1);

	wxFlexGridSizer* panelSizer = new wxFlexGridSizer(3);

	wxStaticText* label1 = new wxStaticText(panel, -1, _("Name:"));
	panelSizer->Add(label1, 0, wxALL, BORDER_SIZE);

	m_name = new wxComboBox(panel, NAME_COMBO, wxEmptyString, wxDefaultPosition, wxSize(DATA_WIDTH, -1), 0, NULL, wxCB_DROPDOWN);
	panelSizer->Add(m_name, 0, wxALL, BORDER_SIZE);

	wxStaticText* dummy1 = new wxStaticText(panel, -1, wxEmptyString);
	panelSizer->Add(dummy1, 0, wxALL, BORDER_SIZE);

	wxStaticText* label2 = new wxStaticText(panel, -1, _("SDR File Name:"));
	panelSizer->Add(label2, 0, wxALL, BORDER_SIZE);

	m_filenameText = new wxTextCtrl(panel, -1, wxEmptyString, wxDefaultPosition, wxSize(DATA_WIDTH, -1), wxTE_READONLY);
	panelSizer->Add(m_filenameText, 0, wxALL, BORDER_SIZE);

	wxButton* browse = new wxButton(panel, BROWSE_BUTTON, _("Browse..."));
	panelSizer->Add(browse, 0, wxALL, BORDER_SIZE);

	wxStaticText* label3 = new wxStaticText(panel, -1, _("User Audio:"));
	panelSizer->Add(label3, 0, wxALL, BORDER_SIZE);

	m_userAudio = new wxButton(panel, USER_AUDIO_BUTTON, _("Set"), wxDefaultPosition, wxSize(DATA_WIDTH, -1));
	panelSizer->Add(m_userAudio, 0, wxALL, BORDER_SIZE);

	wxStaticText* dummy2 = new wxStaticText(panel, -1, wxEmptyString);
	panelSizer->Add(dummy2, 0, wxALL, BORDER_SIZE);

	wxStaticText* label4 = new wxStaticText(panel, -1, _("SDR Audio:"));
	panelSizer->Add(label4, 0, wxALL, BORDER_SIZE);

	m_sdrAudio = new wxButton(panel, SDR_AUDIO_BUTTON, _("Set"), wxDefaultPosition, wxSize(DATA_WIDTH, -1));
	m_sdrAudio->Disable();
	panelSizer->Add(m_sdrAudio, 0, wxALL, BORDER_SIZE);

	wxStaticText* dummy3 = new wxStaticText(panel, -1, wxEmptyString);
	panelSizer->Add(dummy3, 0, wxALL, BORDER_SIZE);

	wxStaticText* label8 = new wxStaticText(panel, -1, _("Tuning Hardware:"));
	panelSizer->Add(label8, 0, wxALL, BORDER_SIZE);

	wxButton* tuning = new wxButton(panel, TUNING_BUTTON, _("Set"), wxDefaultPosition, wxSize(DATA_WIDTH, -1));
	panelSizer->Add(tuning, 0, wxALL, BORDER_SIZE);

	wxStaticText* dummy7 = new wxStaticText(panel, -1, wxEmptyString);
	panelSizer->Add(dummy7, 0, wxALL, BORDER_SIZE);

	wxStaticText* label9 = new wxStaticText(panel, -1, _("External Programs:"));
	panelSizer->Add(label9, 0, wxALL, BORDER_SIZE);

	wxButton* external = new wxButton(panel, EXTERNAL_BUTTON, _("Set"), wxDefaultPosition, wxSize(DATA_WIDTH, -1));
	panelSizer->Add(external, 0, wxALL, BORDER_SIZE);

	wxStaticText* dummy8 = new wxStaticText(panel, -1, wxEmptyString);
	panelSizer->Add(dummy8, 0, wxALL, BORDER_SIZE);

#if !defined(__WXMAC__)
#if defined(__WXGTK__)
	wxString dir;
	if (getDesktopDir(dir)) {
#endif
		wxStaticText* label10 = new wxStaticText(panel, -1, _("Create Desktop icon:"));
		panelSizer->Add(label10, 0, wxALL, BORDER_SIZE);

		m_deskTop = new wxCheckBox(panel, -1, wxEmptyString);
		panelSizer->Add(m_deskTop, 0, wxALL, BORDER_SIZE);

		wxStaticText* dummy9 = new wxStaticText(panel, -1, wxEmptyString);
		panelSizer->Add(dummy9, 0, wxALL, BORDER_SIZE);
#if defined(__WXGTK__)
	}
#endif
#endif

	wxStaticText* dummy10 = new wxStaticText(panel, -1, wxEmptyString);
	panelSizer->Add(dummy10, 0, wxALL, BORDER_SIZE);

	wxButton* create = new wxButton(panel, CREATE_BUTTON, _("Create"), wxDefaultPosition, wxSize(DATA_WIDTH, -1));
	panelSizer->Add(create, 0, wxALL, BORDER_SIZE);

	panel->SetSizer(panelSizer);

	mainSizer->Add(panel);

	SetSizer(mainSizer);

	mainSizer->SetSizeHints(this);

	enumerateConfigs();
}
Beispiel #3
0
void CGUISetupFrame::onCreate(wxCommandEvent& WXUNUSED(event))
{
	wxString name = m_name->GetValue();
	if (name.IsEmpty()) {
		::wxMessageBox(_("The Name is not allowed to be empty"), _("GUISetup Error"), wxICON_ERROR);
		return;
	}

	// Whitespace isn't allowed in the SDR name
	int pos1 = name.Find(wxT(' '));
	int pos2 = name.Find(wxT('\t'));
	if (pos1 != wxNOT_FOUND || pos2 != wxNOT_FOUND) {
		::wxMessageBox(_("The Name cannot contain white space (spaces, tabs, etc)"), _("GUISetup Error"), wxICON_ERROR);
		return;
	}

	if (m_filename.IsEmpty()) {
		::wxMessageBox(_("The SDR File Name is not allowed to be empty"), _("GUISetup Error"), wxICON_ERROR);
		return;
	}

	CSDRDescrFile file(m_filename);
	if (!file.isValid()) {
		::wxMessageBox(_("The SDR File does not exist or is invalid"), _("GUISetup Error"), wxICON_ERROR);
		return;
	}

	m_sdrType = file.getType();

	if (m_userAudioInDev == NO_DEV || m_userAudioOutDev == NO_DEV) {
		::wxMessageBox(_("The User Audio has not been set"), _("GUISetup Error"), wxICON_ERROR);
		return;
	}

	if (featureList[m_sdrType].sdrAudioButton) {
		if (m_sdrAudioInDev == NO_DEV || m_sdrAudioOutDev == NO_DEV) {
			::wxMessageBox(_("The SDR Audio has not been set"), _("GUISetup Error"), wxICON_ERROR);
			return;
		}
	}

	if (featureList[m_sdrType].audioCheck) {
		if (m_sdrAudioType != SOUND_JACK && m_userAudioType == m_sdrAudioType && (m_sdrAudioInDev == m_userAudioInDev || m_sdrAudioOutDev == m_userAudioOutDev)) {
			::wxMessageBox(_("The SDR Audio cannot be the same as the User Audio"), _("GUISetup Error"), wxICON_ERROR);
			return;
		}
	}

	wxConfig* config = new wxConfig(wxT("UWSDR"));

	wxString fileNameKey        = wxT("/") + name + wxT("/FileName");
	wxString userAudioTypeKey   = wxT("/") + name + wxT("/UserAudioType");
	wxString userAudioOutDevKey = wxT("/") + name + wxT("/UserAudioOutDev");
	wxString userAudioInDevKey  = wxT("/") + name + wxT("/UserAudioInDev");
	wxString sdrAudioTypeKey    = wxT("/") + name + wxT("/SDRAudioType");
	wxString sdrAudioOutDevKey  = wxT("/") + name + wxT("/SDRAudioOutDev");
	wxString sdrAudioInDevKey   = wxT("/") + name + wxT("/SDRAudioInDev");
	wxString txInEnableKey      = wxT("/") + name + wxT("/TXInEnable");
	wxString txInDevKey         = wxT("/") + name + wxT("/TXInDev");
	wxString txInPinKey         = wxT("/") + name + wxT("/TXInPin");
	wxString keyInEnableKey     = wxT("/") + name + wxT("/KeyInEnable");
	wxString keyInDevKey        = wxT("/") + name + wxT("/KeyInDev");
	wxString keyInPinKey        = wxT("/") + name + wxT("/KeyInPin");
	wxString txOutDevKey        = wxT("/") + name + wxT("/TXOutDev");
	wxString txOutPinKey        = wxT("/") + name + wxT("/TXOutPin");
	wxString tuningKey          = wxT("/") + name + wxT("/TuningHW");
	wxString extNameKey         = wxT("/") + name + wxT("/ExternalName");
	wxString extAddrKey         = wxT("/") + name + wxT("/ExternalAddrs");

	wxString test;
	if (config->Read(fileNameKey, &test)) {
		int ret = ::wxMessageBox(_("An SDR with the same name already exists. Overwrite?"), _("Overwrite confirmation"), wxYES_NO | wxICON_QUESTION);
		if (ret == wxNO)
			return;
	}

	bool ret = config->Write(fileNameKey, m_filename);
	if (!ret) {
		::wxMessageBox(_("Unable to write configuration data - FileName"), _("GUISetup Error"), wxICON_ERROR);
		return;
	}

	ret = config->Write(userAudioTypeKey, m_userAudioType);
	if (!ret) {
		::wxMessageBox(_("Unable to write configuration data - UserAudioType"), _("GUISetup Error"), wxICON_ERROR);
		return;
	}

	ret = config->Write(userAudioOutDevKey, m_userAudioOutDev);
	if (!ret) {
		::wxMessageBox(_("Unable to write configuration data - UserAudioOutDev"), _("GUISetup Error"), wxICON_ERROR);
		return;
	}

	ret = config->Write(userAudioInDevKey, m_userAudioInDev);
	if (!ret) {
		::wxMessageBox(_("Unable to write configuration data - UserAudioInDev"), _("GUISetup Error"), wxICON_ERROR);
		return;
	}

	if (featureList[m_sdrType].sdrAudioButton) {
		ret = config->Write(sdrAudioTypeKey, m_sdrAudioType);
		if (!ret) {
			::wxMessageBox(_("Unable to write configuration data - SDRAudioType"), _("GUISetup Error"), wxICON_ERROR);
			return;
		}

		ret = config->Write(sdrAudioOutDevKey, m_sdrAudioOutDev);
		if (!ret) {
			::wxMessageBox(_("Unable to write configuration data - SDRAudioOutDev"), _("GUISetup Error"), wxICON_ERROR);
			return;
		}

		ret = config->Write(sdrAudioInDevKey, m_sdrAudioInDev);
		if (!ret) {
			::wxMessageBox(_("Unable to write configuration data - SDRAudioInDev"), _("GUISetup Error"), wxICON_ERROR);
			return;
		}
	}

	ret = config->Write(tuningKey, long(m_tuningHW));
	if (!ret) {
		::wxMessageBox(_("Unable to write configuration data - TuningHW"), _("GUISetup Error"), wxICON_ERROR);
		return;
	}

	ret = config->Write(extNameKey, m_externalName);
	if (!ret) {
		::wxMessageBox(_("Unable to write configuration data - ExternalName"), _("GUISetup Error"), wxICON_ERROR);
		return;
	}

	ret = config->Write(extAddrKey, long(m_externalAddr));
	if (!ret) {
		::wxMessageBox(_("Unable to write configuration data - ExternalAddrs"), _("GUISetup Error"), wxICON_ERROR);
		return;
	}

#if defined(__WXMSW__)
	wxString instDirKey = wxT("/InstPath");

	wxString dir;
	bool found = config->Read(instDirKey, &dir);

	if (!found) {
		::wxMessageBox(_("Cannot find the registry key for the\ninstallation directory. Cannot create\nthe start menu entry."), _("GUISetup Error"), wxICON_ERROR);
	} else {
		bool create = m_deskTop->GetValue();
		if (create)
			writeDeskTop(name, dir);
	}
#elif defined(__WXGTK__)
	if (m_deskTop != NULL) {
		bool create = m_deskTop->GetValue();
		if (create) {
			wxString dir;
			getDesktopDir(dir);

			writeDeskTop(name, dir);
		}
	}
#endif

	config->Flush();

	delete config;

	::wxMessageBox(_("UWSDR configuration written."));

	Close(true);
}