当前位置: 首页>>代码示例>>C++>>正文


C++ CAMBEData::setData方法代码示例

本文整理汇总了C++中CAMBEData::setData方法的典型用法代码示例。如果您正苦于以下问题:C++ CAMBEData::setData方法的具体用法?C++ CAMBEData::setData怎么用?C++ CAMBEData::setData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CAMBEData的用法示例。


在下文中一共展示了CAMBEData::setData方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: lookup

bool CTimeServerThread::lookup(const wxString &id)
{
	CIndexRecord* info = m_index[id];
	if (info == NULL) {
		// wxLogError(wxT("Cannot find the AMBE index for *%s*"), id.c_str());
		return false;
	}

	unsigned int  start = info->getStart();
	unsigned int length = info->getLength();

	SLOW_DATA slowData = SD_TEXT;

	for (unsigned int i = 0U; i < length; i++) {
		unsigned char* dataIn = m_ambe + (start + i) * VOICE_FRAME_LENGTH_BYTES;

		CAMBEData* dataOut = new CAMBEData;
		dataOut->setDestination(m_address, G2_DV_PORT);
		dataOut->setSeq(m_seqNo);

		unsigned char buffer[DV_FRAME_LENGTH_BYTES];
		::memcpy(buffer + 0U, dataIn, VOICE_FRAME_LENGTH_BYTES);

		// Insert sync bytes when the sequence number is zero, slow data otherwise
		if (m_seqNo == 0U) {
			::memcpy(buffer + VOICE_FRAME_LENGTH_BYTES, DATA_SYNC_BYTES, DATA_FRAME_LENGTH_BYTES);
			m_encoder.sync();

			switch (slowData) {
				case SD_HEADER:
					slowData = SD_TEXT;
					break;
				case SD_TEXT:
					slowData = SD_HEADER;
					break;
			}
		} else {
			switch (slowData) {
				case SD_HEADER:
					m_encoder.getHeaderData(buffer + VOICE_FRAME_LENGTH_BYTES);
					break;
				case SD_TEXT:
					m_encoder.getTextData(buffer + VOICE_FRAME_LENGTH_BYTES);
					break;
			}
		}

		dataOut->setData(buffer, DV_FRAME_LENGTH_BYTES);

		m_seqNo++;
		if (m_seqNo == 21U)
			m_seqNo = 0U;

		m_data[m_in] = dataOut;
		m_in++;
	}

	return true;
}
开发者ID:BackupTheBerlios,项目名称:opendv-svn,代码行数:59,代码来源:TimeServerThread.cpp

示例2: sendAck

void CStarNetHandler::sendAck(const CUserData& user, const wxString& text) const
{
	unsigned int id = CHeaderData::createId();

	CHeaderData header(m_groupCallsign, wxT("    "), user.getUser(), user.getGateway(), user.getRepeater());
	header.setDestination(user.getAddress(), G2_DV_PORT);
	header.setId(id);
	m_g2Handler->writeHeader(header);

	CSlowDataEncoder slowData;
	slowData.setTextData(text);

	CAMBEData data;
	data.setId(id);
	data.setDestination(user.getAddress(), G2_DV_PORT);

	unsigned char buffer[DV_FRAME_MAX_LENGTH_BYTES];
	::memcpy(buffer + 0U, NULL_AMBE_DATA_BYTES, VOICE_FRAME_LENGTH_BYTES);

	for (unsigned int i = 0U; i < 20U; i++) {
		if (i == 0U) {
			// The first AMBE packet is a sync
			::memcpy(buffer + VOICE_FRAME_LENGTH_BYTES, DATA_SYNC_BYTES, DATA_FRAME_LENGTH_BYTES);
			data.setData(buffer, DV_FRAME_LENGTH_BYTES);
			data.setSeq(i);
		} else if (i == 19U) {
			// The last packet of the ack
			::memcpy(buffer + VOICE_FRAME_LENGTH_BYTES, END_PATTERN_BYTES, END_PATTERN_LENGTH_BYTES);
			data.setData(buffer, DV_FRAME_MAX_LENGTH_BYTES);
			data.setSeq(i);
			data.setEnd(true);
		} else {
			// The packets containing the text data
			unsigned char slowDataBuffer[DATA_FRAME_LENGTH_BYTES];
			slowData.getTextData(slowDataBuffer);
			::memcpy(buffer + VOICE_FRAME_LENGTH_BYTES, slowDataBuffer, DATA_FRAME_LENGTH_BYTES);
			data.setData(buffer, DV_FRAME_LENGTH_BYTES);
			data.setSeq(i);
		}

		m_g2Handler->writeAMBE(data);
	}
}
开发者ID:BackupTheBerlios,项目名称:opendv-svn,代码行数:43,代码来源:StarNetHandler.cpp

示例3: end

void CTimeServerThread::end()
{
	CAMBEData* dataOut = new CAMBEData;
	dataOut->setData(END_PATTERN_BYTES, DV_FRAME_LENGTH_BYTES);
	dataOut->setDestination(m_address, G2_DV_PORT);
	dataOut->setSeq(m_seqNo);
	dataOut->setEnd(true);

	m_data[m_in] = dataOut;
	m_in++;
}
开发者ID:BackupTheBerlios,项目名称:opendv-svn,代码行数:11,代码来源:TimeServerThread.cpp

示例4: sendFromText

void CStarNetHandler::sendFromText(const wxString& my) const
{
	wxString text;
	switch (m_callsignSwitch) {
		case SCS_GROUP_CALLSIGN:
			text.Printf(wxT("FROM %s"), my.c_str());
			break;
		case SCS_USER_CALLSIGN:
			text.Printf(wxT("VIA STARnet %s"), m_groupCallsign.c_str());
			break;
		default:
			break;
	}

	CSlowDataEncoder slowData;
	slowData.setTextData(text);

	CAMBEData data;
	data.setId(m_id);

	unsigned char buffer[DV_FRAME_LENGTH_BYTES];
	::memcpy(buffer + 0U, NULL_AMBE_DATA_BYTES, VOICE_FRAME_LENGTH_BYTES);

	for (unsigned int i = 0U; i < 21U; i++) {
		if (i == 0U) {
			// The first AMBE packet is a sync
			::memcpy(buffer + VOICE_FRAME_LENGTH_BYTES, DATA_SYNC_BYTES, DATA_FRAME_LENGTH_BYTES);
			data.setData(buffer, DV_FRAME_LENGTH_BYTES);
			data.setSeq(i);
		} else {
			// The packets containing the text data
			unsigned char slowDataBuffer[DATA_FRAME_LENGTH_BYTES];
			slowData.getTextData(slowDataBuffer);
			::memcpy(buffer + VOICE_FRAME_LENGTH_BYTES, slowDataBuffer, DATA_FRAME_LENGTH_BYTES);
			data.setData(buffer, DV_FRAME_LENGTH_BYTES);
			data.setSeq(i);
		}

		sendToRepeaters(data);
	}
}
开发者ID:BackupTheBerlios,项目名称:opendv-svn,代码行数:41,代码来源:StarNetHandler.cpp

示例5: unlink

void CDPlusHandler::unlink(IReflectorCallback* handler, const wxString& exclude)
{
	for (unsigned int i = 0U; i < m_maxReflectors; i++) {
		CDPlusHandler* reflector = m_reflectors[i];

		if (reflector != NULL) {
			if (reflector->m_direction == DIR_OUTGOING && reflector->m_destination == handler && !reflector->m_reflector.IsSameAs(exclude)) {
				wxLogMessage(wxT("Removing outgoing D-Plus link %s, %s"), reflector->m_repeater.c_str(), reflector->m_reflector.c_str());

				if (reflector->m_linkState == DPLUS_LINKING || reflector->m_linkState == DPLUS_LINKED) {
					CConnectData connect(CT_UNLINK, reflector->m_yourAddress, DPLUS_PORT);
					reflector->m_handler->writeConnect(connect);
					reflector->m_handler->writeConnect(connect);

					reflector->m_linkState = DPLUS_UNLINKING;
					reflector->m_tryTimer.setTimeout(1U);
					reflector->m_tryTimer.start();
					reflector->m_pollTimer.stop();
					reflector->m_pollInactivityTimer.stop();
					reflector->m_tryCount = 0U;
				}

				// If an active link with incoming traffic, send an EOT to the repeater
				if (reflector->m_dPlusId != 0x00U) {
					unsigned int seq = reflector->m_dPlusSeq + 1U;
					if (seq == 21U)
						seq = 0U;

					CAMBEData data;
					data.setData(END_PATTERN_BYTES, DV_FRAME_LENGTH_BYTES);
					data.setSeq(seq);
					data.setEnd(true);
					data.setId(reflector->m_dPlusId);

					reflector->m_destination->process(data, AS_DPLUS);
				}

				m_stateChange = true;
			}
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:opendv-svn,代码行数:42,代码来源:DPlusHandler.cpp

示例6: unlink

void CDExtraHandler::unlink(IReflectorCallback* handler, const wxString& exclude)
{
	for (unsigned int i = 0U; i < m_maxReflectors; i++) {
		CDExtraHandler* reflector = m_reflectors[i];

		if (reflector != NULL) {
			if (reflector->m_direction == DIR_OUTGOING && reflector->m_destination == handler && !reflector->m_reflector.IsSameAs(exclude)) {
				wxLogMessage(wxT("Removing outgoing DExtra link %s, %s"), reflector->m_repeater.c_str(), reflector->m_reflector.c_str());

				if (reflector->m_linkState == DEXTRA_LINKING || reflector->m_linkState == DEXTRA_LINKED) {
					CConnectData connect(reflector->m_repeater, reflector->m_address, reflector->m_port);
					m_handler->writeConnect(connect);

					reflector->m_linkState = DEXTRA_UNLINKING;

					reflector->m_destination->linkDown(DP_DEXTRA, reflector->m_reflector, false);
				}

				// If an active link with incoming traffic, send an EOT to the repeater
				if (reflector->m_dExtraId != 0x00U) {
					unsigned int seq = reflector->m_dExtraSeq + 1U;
					if (seq == 21U)
						seq = 0U;

					CAMBEData data;
					data.setData(END_PATTERN_BYTES, DV_FRAME_LENGTH_BYTES);
					data.setSeq(seq);
					data.setEnd(true);
					data.setId(reflector->m_dExtraId);

					reflector->m_destination->process(data, AS_DEXTRA);
				}

				m_stateChange = true;

				delete m_reflectors[i];
				m_reflectors[i] = NULL;
			}
		}
	}	
}
开发者ID:BackupTheBerlios,项目名称:opendv-svn,代码行数:41,代码来源:DExtraHandler.cpp

示例7: send


//.........这里部分代码省略.........
		lookup(wxT(" "));
		lookup(wxT(" "));
		lookup(wxT(" "));
		lookup(wxT(" "));

		for (unsigned int i = 0U; i < words.GetCount(); i++)
			lookup(words.Item(i));

		lookup(wxT(" "));
		lookup(wxT(" "));
		lookup(wxT(" "));
		lookup(wxT(" "));

		end();
	} else {
		wxLogMessage(wxT("Sending text \"%s\""), slowData.c_str());

		for (unsigned int i = 0U; i < 21U; i++) {
			CAMBEData* dataOut = new CAMBEData;
			dataOut->setDestination(m_address, G2_DV_PORT);
			dataOut->setSeq(i);

			unsigned char buffer[DV_FRAME_LENGTH_BYTES];
			::memcpy(buffer + 0U, NULL_AMBE_DATA_BYTES, VOICE_FRAME_LENGTH_BYTES);

			// Insert sync bytes when the sequence number is zero, slow data otherwise
			if (i == 0U) {
				::memcpy(buffer + VOICE_FRAME_LENGTH_BYTES, DATA_SYNC_BYTES, DATA_FRAME_LENGTH_BYTES);
				m_encoder.sync();
			} else {
				m_encoder.getTextData(buffer + VOICE_FRAME_LENGTH_BYTES);
			}

			dataOut->setData(buffer, DV_FRAME_LENGTH_BYTES);

			m_data[m_in] = dataOut;
			m_in++;
		}

		CAMBEData* dataOut = new CAMBEData;
		dataOut->setData(END_PATTERN_BYTES, DV_FRAME_LENGTH_BYTES);
		dataOut->setDestination(m_address, G2_DV_PORT);
		dataOut->setSeq(0U);
		dataOut->setEnd(true);

		m_data[m_in] = dataOut;
		m_in++;
	}

	if (m_in == 0U) {
		wxLogWarning(wxT("Not sending, no audio files loaded"));
		return false;
	}

	if (!m_callsignA.IsEmpty()) {
		header.setRptCall2(m_callsignA);
		header.setId(idA);
		sendHeader(header);
	}

	if (!m_callsignB.IsEmpty()) {
		header.setRptCall2(m_callsignB);
		header.setId(idB);
		sendHeader(header);
	}
开发者ID:BackupTheBerlios,项目名称:opendv-svn,代码行数:66,代码来源:TimeServerThread.cpp

示例8: run

bool CAPRSTransmit::run()
{
	//First see if the packet is Icom supported...
	CAPRSPacket aprsPacket;
	if(!CAPRSParser::Parse(m_text, aprsPacket)){
		wxLogWarning(wxT("Unsupported APRS Format, ignoring => ") + m_text.Trim(true));
		return false;
	}

	wxString textWithCRC(aprsPacket.Raw());
	wxLogMessage(wxT("Supported APRS Format => ") + textWithCRC.Trim(true));
	//add nececessary stuff to text, but keep it the original
	textWithCRC.Replace(wxT("\n"), wxEmptyString);
	if(!textWithCRC.EndsWith(wxT("\r"))) textWithCRC.Append(wxT("\r"));
	wxString crc = wxString::Format(wxT("$$CRC%04X,"), calcCRC(textWithCRC));
	textWithCRC.Prepend(crc);

	bool opened = m_socket.open();
	if (!opened)
		return false;

	in_addr address = CUDPReaderWriter::lookup(wxT("127.0.0.1"));

	unsigned int id = CHeaderData::createId();

	wxString callsignG = m_repeaterCallsign.Left(LONG_CALLSIGN_LENGTH - 1U);
	callsignG.Append(wxT("G"));

	CHeaderData header;
	header.setId(id);
	header.setMyCall1(m_APRSCallsign);
	header.setMyCall2(wxT("APRS"));
	header.setRptCall1(callsignG);
	header.setRptCall2(m_repeaterCallsign);
	header.setYourCall(wxT("CQCQCQ  "));
	header.setDestination(address, G2_DV_PORT);

	sendHeader(header);

	CSlowDataEncoder encoder;
	encoder.setHeaderData(header);
	encoder.setGPSData(textWithCRC);
	encoder.setTextData(wxT("APRS to DPRS"));

	CAMBEData data;
	data.setDestination(address, G2_DV_PORT);
	data.setId(id);

	wxStopWatch timer;
	timer.Start();

	unsigned int out = 0U;
        unsigned int dataOut = 0U;
	unsigned int needed = (encoder.getInterleavedDataLength() / (DATA_FRAME_LENGTH_BYTES)) * 2U;

	while (dataOut < needed) {
		data.setSeq(out);

		unsigned char buffer[DV_FRAME_LENGTH_BYTES];
		::memcpy(buffer + 0U, NULL_AMBE_DATA_BYTES, VOICE_FRAME_LENGTH_BYTES);

		// Insert sync bytes when the sequence number is zero, slow data otherwise
		if (out == 0U) {
			::memcpy(buffer + VOICE_FRAME_LENGTH_BYTES, DATA_SYNC_BYTES, DATA_FRAME_LENGTH_BYTES);
		} else {
			encoder.getInterleavedData(buffer + VOICE_FRAME_LENGTH_BYTES);		
			dataOut++;
		}

		data.setData(buffer, DV_FRAME_LENGTH_BYTES);

		sendData(data);
		out++;

		if (out == 21U) out = 0U;
	}

	data.setData(END_PATTERN_BYTES, DV_FRAME_LENGTH_BYTES);
	data.setSeq(out >= 21U ? 0U : out);
	data.setEnd(true);

	sendData(data);

	m_socket.close();

	return true;
}
开发者ID:dl5di,项目名称:OpenDV,代码行数:87,代码来源:APRSTransmit.cpp

示例9: Entry

void* CDRATSServer::Entry()
{
	wxLogMessage(wxT("Starting the D-RATS Server thread for %s"), m_callsign.c_str());

	bool sending = false;
	unsigned int id = 0U;

	unsigned char seqNo = 0U;
	unsigned int  sent = 0U;

	wxStopWatch time;

	try {
		while (!m_stopped) {
			serviceSocket();

			if (m_readEnd && !sending) {
				id = CHeaderData::createId();

				// Write header
				CHeaderData header;
				header.setMyCall1(m_callsign);
				header.setMyCall2(wxT("DATA"));
				header.setYourCall(wxT("CQCQCQ  "));
				header.setId(id);

#if defined(LOOPBACK)
				writeHeader(header);
#else
				m_handler->process(header, DIR_INCOMING, AS_DRATS);
#endif

				m_readState = SS_FIRST;
				m_readPos   = 0U;
				sending     = true;
				seqNo       = 0U;
				sent        = 0U;

				time.Start();
			}

			if (m_readEnd && sending) {
				unsigned int needed = time.Time() / DSTAR_FRAME_TIME_MS;

				while (sent < needed && sending) {
					// Write AMBE data
					CAMBEData data;
					data.setId(id);

					unsigned char buffer[DV_FRAME_LENGTH_BYTES];
					::memcpy(buffer + 0U, NULL_AMBE_DATA_BYTES, VOICE_FRAME_LENGTH_BYTES);

					// Insert sync bytes when the sequence number is zero, slow data otherwise
					if (seqNo == 0U) {
						::memcpy(buffer + VOICE_FRAME_LENGTH_BYTES, DATA_SYNC_BYTES, DATA_FRAME_LENGTH_BYTES);
						m_readState = SS_FIRST;
					} else {
						if (m_readState == SS_FIRST) {
							unsigned char readText[3U];
							::memset(readText, 'f', 3U);

							unsigned int length = m_readLength - m_readPos;
							unsigned char bytes = 5U;
							if (length < 5U)
								bytes = length;

							readText[0U] = SLOW_DATA_TYPE_GPS | bytes;

							for (unsigned int i = 0U; i < 2U && m_readPos < m_readLength; i++)
								readText[i + 1U] = m_readBuffer[m_readPos++];

							readText[0U] ^= SCRAMBLER_BYTE1;
							readText[1U] ^= SCRAMBLER_BYTE2;
							readText[2U] ^= SCRAMBLER_BYTE3;

							::memcpy(buffer + VOICE_FRAME_LENGTH_BYTES, readText, DATA_FRAME_LENGTH_BYTES);

							m_readState = SS_SECOND;
						} else {
							unsigned char readText[3U];
							::memset(readText, 'f', 3U);

							for (unsigned int i = 0U; i < 3U && m_readPos < m_readLength; i++)
								readText[i] = m_readBuffer[m_readPos++];

							readText[0U] ^= SCRAMBLER_BYTE1;
							readText[1U] ^= SCRAMBLER_BYTE2;
							readText[2U] ^= SCRAMBLER_BYTE3;

							::memcpy(buffer + VOICE_FRAME_LENGTH_BYTES, readText, DATA_FRAME_LENGTH_BYTES);				

							m_readState = SS_FIRST;
						}
					}

					data.setSeq(seqNo);
					data.setData(buffer, DV_FRAME_LENGTH_BYTES);
					sent++;

#if defined(LOOPBACK)
//.........这里部分代码省略.........
开发者ID:EA3HKB,项目名称:OpenDV,代码行数:101,代码来源:DRATSServer.cpp


注:本文中的CAMBEData::setData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。