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


C++ PacketStream::getPacketType方法代码示例

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


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

示例1: decodePacket

void* decodePacket(void* buffin)
{
	PacketBufferV* buff = (PacketBufferV*) buffin;
	int npix_idx = 0;
	int nsamp_idx = 0;
	// load packet type (once per thread)
	PacketStream* ps;
	pthread_mutex_lock(&lockp);
	try {
		ps = new PacketStream(configFileName.c_str());
		Packet *p = ps->getPacketType("triggered_telescope1_30GEN");
		npix_idx = p->getPacketSourceDataField()->getFieldIndex("Number of pixels");
		nsamp_idx = p->getPacketSourceDataField()->getFieldIndex("Number of samples");
	} catch (PacketException* e)
	{
		cout << "Error during extractWavePacket: ";
		cout << e->geterror() << endl;
	}
	pthread_mutex_unlock(&lockp);
	
	ByteStreamPtr localBuffer[PACKET_NUM];
	int npix[PACKET_NUM];
	int nsamp[PACKET_NUM];
	for(int n=0; n<NTIMES; n++)
	{
		// copy PACKET_NUM packets data locally
		pthread_mutex_lock(&lockp);
		for(int m=0; m<PACKET_NUM; m++)
		{
			ByteStreamPtr rawPacket = buff->getNext();
			localBuffer[m] = rawPacket;
			
		}
		pthread_mutex_unlock(&lockp);
		
		for(int m=0; m<PACKET_NUM; m++)
		{
			ByteStreamPtr rawPacket = localBuffer[m];
			Packet *p = ps->getPacket(rawPacket);
			// get npixel and nsamples
			
			int npix = p->getPacketSourceDataField()->getFieldValue(npix_idx);
			int nsamp = p->getPacketSourceDataField()->getFieldValue(nsamp_idx);
			ByteStreamPtr data = p->getData();
#ifdef ARCH_BIGENDIAN
			if(!data->isBigendian())
				data->swapWord();
#else
			if(data->isBigendian())
				data->swapWord();
#endif
			sizeMB += (data->size() / 1000000.0);
			byte* rawdata = data->getStream();
			rawdata[0] = rand() % 100 + 50;
#ifdef DEBUG
			std::cout << "npixels " << npix << std::endl;
			std::cout << "nsamples " << nsamp << std::endl;
			std::cout << "data size " << data->size() << std::endl;
			std::cout << "tot size (MB) " << sizeMB << std::endl;
#endif
		}
	}
	delete ps;
	return 0;
}
开发者ID:ASTRO-BO,项目名称:RTAtest,代码行数:65,代码来源:mt.cpp


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