Exemple #1
0
void CDummyRepeaterApp::createThread()
{
	m_thread = new CDummyRepeaterThread;
	m_thread->Create();
	m_thread->Run();

	wxString callsign1, callsign2;
	getCallsign(callsign1, callsign2);
	m_thread->setCallsign(callsign1, callsign2);

	wxString call;
	wxSortedArrayString list;

	getYourCalls(call, list);
	m_thread->setYour(call);

	getRpt1Calls(call, list);
	m_thread->setRpt1(call);

	getRpt2Calls(call, list);
	m_thread->setRpt2(call);

	wxString message;
	getMessage(message);
	m_thread->setMessage(message);

	DONGLE_TYPE dongleType;
	wxString dongleDevice, dongleAddress;
	unsigned int donglePort;
	getDongle(dongleType, dongleDevice, dongleAddress, donglePort);

	CDongleThread* dongle = NULL;

	switch (dongleType) {
		case DT_DVDONGLE:
			if (!dongleDevice.IsEmpty())
				dongle = new CDVDongleThread(new CDVDongleController(dongleDevice));
			break;
		case DT_DV3000:
			if (!dongleAddress.IsEmpty() && donglePort > 0U)
				dongle = new CAMBE3000Thread(new CDV3000Controller(dongleAddress, donglePort));
			break;
		default:
			wxLogError(wxT("Invalid Dongle type specified - %d"), int(dongleType));
			error(_("Invalid Dongle type specified"));
			break;
	}

	if (dongle != NULL) {
		dongle->setEncodeCallback(m_thread);
		dongle->setDecodeCallback(m_thread);

		bool res = dongle->open();
		if (!res) {
			wxLogError(wxT("Can't find the AMBE Dongle on the port specified"));
			error(_("Can't find the AMBE Dongle on the port specified"));
		} else {
			m_thread->setDongle(dongle);
		}
	}

	wxString readDevice, writeDevice;
	getSoundcard(readDevice, writeDevice);

	if (!readDevice.IsEmpty() && !writeDevice.IsEmpty()) {
#if defined(__WINDOWS__)
		CSoundCardReaderWriter* soundcard = new CSoundCardReaderWriter(readDevice, writeDevice, DSTAR_RADIO_SAMPLE_RATE, DSTAR_RADIO_BLOCK_SIZE);
#else
		CSoundCardReaderWriter* soundcard = new CSoundCardReaderWriter(readDevice, writeDevice, DSTAR_RADIO_SAMPLE_RATE, 64U);
#endif
		soundcard->setCallback(m_thread, 0);

		bool res = soundcard->open();
		if (!res) {
			wxLogError(wxT("Cannot open the sound card"));
			error(_("Cannot open the sound card"));
		} else {
			m_thread->setSoundCard(soundcard);
		}
	}

	wxString gwyAddress, localAddress;
	unsigned int gwyPort, localPort;
	getNetwork(gwyAddress, gwyPort, localAddress, localPort);

	if (!gwyAddress.IsEmpty()) {
		CRepeaterProtocolHandler* protocol = new CRepeaterProtocolHandler(gwyAddress, gwyPort, localAddress, localPort);

		bool res = protocol->open();
		if (!res) {
			wxLogError(wxT("Cannot open the protocol handler"));
			error(_("Cannot open the protocol handler"));
		} else {
			m_thread->setProtocol(protocol);
		}
	}

	wxString type;
	unsigned int config;
	bool pttInvert, squelchInvert;
	getController(type, config, pttInvert, squelchInvert);

	CExternalController* controller = NULL;

	wxString port;
	if (type.StartsWith(wxT("Velleman K8055 - "), &port)) {
		unsigned long num;
		port.ToULong(&num);
		controller = new CExternalController(new CK8055Controller(num), pttInvert, squelchInvert);
	} else if (type.StartsWith(wxT("URI USB - "), &port)) {
		unsigned long num;
		port.ToULong(&num);
		controller = new CExternalController(new CURIUSBController(num, true), pttInvert, squelchInvert);
	} else if (type.StartsWith(wxT("Serial - "), &port)) {
		controller = new CExternalController(new CSerialLineController(port, config), pttInvert, squelchInvert);
	} else if (type.StartsWith(wxT("Arduino - "), &port)) {
		controller = new CExternalController(new CArduinoController(port), pttInvert, squelchInvert);
#if defined(RASPBERRY_PI)
	} else if (type.IsSameAs(wxT("Raspberry Pi"))) {
		controller = new CExternalController(new CRaspberryController, pttInvert, squelchInvert);
#endif
	} else {
		controller = new CExternalController(new CDummyController, pttInvert, squelchInvert);
	}

	bool res = controller->open();
	if (!res) {
		wxLogError(wxT("Cannot open the hardware interface - %s"), type.c_str());
		error(_("Cannot open the hardware interface"));
	} else {
		m_thread->setController(controller);
	}

	bool bleep;
	getBleep(bleep);
	m_thread->setBleep(bleep);
}
void CDVRPTRClientApp::createThread()
{
	m_thread = new CDVRPTRClientThread;
	m_thread->Create();
	m_thread->Run();

	wxString callsign1, callsign2;
	getCallsign(callsign1, callsign2);
	m_thread->setCallsign(callsign1, callsign2);

	wxString call;
	wxSortedArrayString list;

	getYourCalls(call, list);
	m_thread->setYour(call);

	getRpt1Calls(call, list);
	m_thread->setRpt1(call);

	getRpt2Calls(call, list);
	m_thread->setRpt2(call);

	wxString message;
	getMessage(message);
	m_thread->setMessage(message);

	wxString device;
	getDVDongle(device);

	if (!device.IsEmpty()) {
		CDVDongleController* dongle = new CDVDongleController(new CSerialDataController(device, SERIAL_230400));

		bool res = dongle->open();
		if (!res) {
			wxLogError(wxT("Can't find the DV-Dongle on the port specified"));
			error(_("Can't find the DV-Dongle on the port specified"));
		} else {
			m_thread->setDVDongle(dongle);
		}
	}

	wxString readDevice, writeDevice;
	getSoundcard(readDevice, writeDevice);

	if (!readDevice.IsEmpty() && !writeDevice.IsEmpty()) {
#if defined(__WINDOWS__)
		CSoundCardReaderWriter* soundcard = new CSoundCardReaderWriter(readDevice, writeDevice, DSTAR_RADIO_SAMPLE_RATE, DSTAR_RADIO_BLOCK_SIZE);
#else
		CSoundCardReaderWriter* soundcard = new CSoundCardReaderWriter(readDevice, writeDevice, DSTAR_RADIO_SAMPLE_RATE, 64U);
#endif
		soundcard->setCallback(m_thread, 0);

		bool res = soundcard->open();
		if (!res) {
			wxLogError(wxT("Cannot open the sound card"));
			error(_("Cannot open the sound card"));
		} else {
			m_thread->setSoundCard(soundcard);
		}
	}

	wxString modemPort;
	DVRPTR_VERSION version;
	bool rxInvert, txInvert, channel;
	unsigned int modLevel, txDelay;
	getModem(version, modemPort, rxInvert, txInvert, channel, modLevel, txDelay);

	if (!modemPort.IsEmpty()) {
		IDVRPTRController* controller = NULL;
		switch (version) {
			case DVRPTR_V1:
				controller = new CDVRPTRControllerV1(modemPort, rxInvert, txInvert, channel, modLevel, txDelay);
				break;
			case DVRPTR_V2:
				controller = new CDVRPTRControllerV2(modemPort, txInvert, modLevel);
				break;
			default:
				wxLogError(wxT("Unknown DV-RPTR modem version - %d"), int(version));
				break;
		}

		if (controller != NULL) {
			bool res = controller->open();
			if (!res) {
				wxLogError(wxT("Cannot open the DV-RPTR modem"));
				error(_("Cannot open the DV-RPTR modem"));
			} else {
				m_thread->setModem(controller);
			}
		}
	}

	bool bleep;
	getBleep(bleep);
	m_thread->setBleep(bleep);
}
void CDummyRepeaterApp::createThread()
{
	m_thread = new CDummyRepeaterThread;
	m_thread->Create();
	m_thread->Run();

	wxString callsign1, callsign2;
	getCallsign(callsign1, callsign2);
	m_thread->setCallsign(callsign1, callsign2);

	wxString call;
	wxSortedArrayString list;

	getYourCalls(call, list);
	m_thread->setYour(call);

	getRpt1Calls(call, list);
	m_thread->setRpt1(call);

	getRpt2Calls(call, list);
	m_thread->setRpt2(call);

	wxString message;
	getMessage(message);
	m_thread->setMessage(message);

	wxString device;
	getDVDongle(device);

	if (!device.IsEmpty()) {
		CDVDongleController* dongle = new CDVDongleController(new CSerialDataController(device, SERIAL_230400));

		bool res = dongle->open();
		if (!res) {
			wxLogError(wxT("Can't find the DV-Dongle on the port specified"));
			error(_("Can't find the DV-Dongle on the port specified"));
		} else {
			m_thread->setDVDongle(dongle);
		}
	}

	wxString readDevice, writeDevice;
	getSoundcard(readDevice, writeDevice);

	if (!readDevice.IsEmpty() && !writeDevice.IsEmpty()) {
#if defined(__WINDOWS__)
		CSoundCardReaderWriter* soundcard = new CSoundCardReaderWriter(readDevice, writeDevice, DSTAR_RADIO_SAMPLE_RATE, DSTAR_RADIO_BLOCK_SIZE);
#else
		CSoundCardReaderWriter* soundcard = new CSoundCardReaderWriter(readDevice, writeDevice, DSTAR_RADIO_SAMPLE_RATE, 64U);
#endif
		soundcard->setCallback(m_thread, 0);

		bool res = soundcard->open();
		if (!res) {
			wxLogError(wxT("Cannot open the sound card"));
			error(_("Cannot open the sound card"));
		} else {
			m_thread->setSoundCard(soundcard);
		}
	}

	wxString gwyAddress, localAddress;
	unsigned int gwyPort, localPort;
	getNetwork(gwyAddress, gwyPort, localAddress, localPort);

	if (!gwyAddress.IsEmpty()) {
		CRepeaterProtocolHandler* protocol = new CRepeaterProtocolHandler(gwyAddress, gwyPort, localAddress, localPort);

		bool res = protocol->open();
		if (!res) {
			wxLogError(wxT("Cannot open the protocol handler"));
			error(_("Cannot open the protocol handler"));
		} else {
			m_thread->setProtocol(protocol);
		}
	}

	wxString type;
	unsigned int config;
	bool pttInvert, squelchInvert;
	getController(type, config, pttInvert, squelchInvert);

	CExternalController* controller = NULL;

	wxString port;
	if (type.StartsWith(wxT("Velleman K8055 - "), &port)) {
		unsigned long num;
		port.ToULong(&num);
		controller = new CExternalController(new CK8055Controller(num), pttInvert, squelchInvert);
	} else if (type.StartsWith(wxT("URI USB - "), &port)) {
		unsigned long num;
		port.ToULong(&num);
		controller = new CExternalController(new CURIUSBController(num, true), pttInvert, squelchInvert);
	} else if (type.StartsWith(wxT("Serial - "), &port)) {
		controller = new CExternalController(new CSerialController(port, config), pttInvert, squelchInvert);
	} else {
		controller = new CExternalController(new CDummyController, pttInvert, squelchInvert);
	}

	bool res = controller->open();
	if (!res) {
		wxLogError(wxT("Cannot open the hardware interface - %s"), type.c_str());
		error(_("Cannot open the hardware interface"));
	} else {
		m_thread->setController(controller);
	}

	bool bleep;
	getBleep(bleep);
	m_thread->setBleep(bleep);
}