You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							929 lines
						
					
					
						
							30 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							929 lines
						
					
					
						
							30 KiB
						
					
					
				| #include <include/LowLevel/Utils/Utils.h> | |
| #include "include/LowLevel/HonaLowLevelAPI.h" | |
| #include "include/Wrapper/PlxWrapper.h" | |
| #include "qdebug.h" | |
| #include "QTime" | |
| #include "QtConcurrent/QtConcurrent" | |
|  | |
| bool HonaLowLevelAPI::getHsruIsStarted() const | |
| { | |
| 	return _hsruIsStarted; | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| void HonaLowLevelAPI::setHsruIsStarted(bool hsruIsStarted) | |
| { | |
| 	_hsruIsStarted = hsruIsStarted; | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| bool HonaLowLevelAPI::getHiruIsStarted() const | |
| { | |
| 	return _hiruIsStarted; | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| void HonaLowLevelAPI::setHiruIsStarted(bool hiruIsStarted) | |
| { | |
| 	_hiruIsStarted = hiruIsStarted; | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| HonaLowLevelAPI::HonaLowLevelAPI(QObject* parent) : QObject(parent) | |
| { | |
| 	packetLenInt4 = 7; | |
| 	packetLenRes4 = 5; | |
| 	packetLenSinglePulse = 5; | |
| 	packetLenInt123C = 6; | |
| 	packetLenRes123C = 6; | |
| 	packetLenIntS = 7; | |
| 	packetLenResS = 7; | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| bool HonaLowLevelAPI::isHsruStarted() | |
| { | |
| 	return getHsruIsStarted(); | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| bool HonaLowLevelAPI::isHiruStarted() | |
| { | |
| 	return getHiruIsStarted(); | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| void HonaLowLevelAPI::deviceReset() | |
| { | |
| 	if(!plxWrapper.deviceReset()) | |
| 		throw HonaAlreadyStartedException("reset Doesnt Occur"); | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| void HonaLowLevelAPI::setConfig(HonaSettings& settings) | |
| { | |
| 	plxWrapper.deviceReadRegister(0x10000000, honaRegisterBuffer, 8); | |
| 	_honaSetting = settings; | |
| 	writeSettingToRegisters(settings); | |
| 	plxWrapper.deviceWriteRegister(0x10000000, honaRegisterBuffer); | |
| 	plxWrapper.deviceReadRegister(0x10000000, honaRegisterBuffer, 8); | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| HonaSettings HonaLowLevelAPI::getConfig() | |
| { | |
| 	return _honaSetting; | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| 
 | |
| QString HonaLowLevelAPI::getSwVersion() | |
| { | |
| 	return("94072200"); | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| QString HonaLowLevelAPI::getDeviceId() | |
| { | |
| 	return("ssr"); | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| void HonaLowLevelAPI::hsruStart() | |
| { | |
| 	if(!isHsruStarted()) | |
| 		throw HonaAlreadyStartedException("HsruStarted doesn't started "); | |
| 	QtConcurrent::run(this, &HonaLowLevelAPI::hsruMainThread); | |
| 	setHsruIsStarted(true); | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| void HonaLowLevelAPI::hiruStart() | |
| { | |
| 	if(!isHiruStarted()) | |
| 		throw HonaAlreadyStartedException("HiruStarted doesn't started "); | |
| 	QtConcurrent::run(this, &HonaLowLevelAPI::hiruMainThread); | |
| 	setHiruIsStarted(true); | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| void HonaLowLevelAPI::init() | |
| { | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| void HonaLowLevelAPI::writeSettingToRegisters(HonaSettings& settings) | |
| { | |
| 	honaRegisterBuffer.clear(); | |
| 	honaRegisterBuffer.insert(0, 0x00000000); | |
| 	/************************************************************************/ | |
| 	if(settings.hiruSettings.recordStard == recorderStart::selfTestCounter) | |
| 		honaRegisterBuffer.insert(0, 0x80000000); | |
| 	else | |
| 		honaRegisterBuffer.insert(0, 0x7FFFFFFF); | |
| 	/************************************************************************/ | |
| 	if(settings.hiruSettings.recordChannel == drxDeviceIfChannel::ifChannel12) | |
| 		honaRegisterBuffer.insert(0, 0x20000000); | |
| 	else | |
| 		honaRegisterBuffer.insert(0, 0xDFFFFFFF); | |
| 	/************************************************************************/ | |
| 	if(settings.hiruSettings.recordMode == recorderMode::dualChannel) | |
| 		honaRegisterBuffer.insert(0, 0x10000000); | |
| 	else | |
| 		honaRegisterBuffer.insert(0, 0xEFFFFFFF); | |
| 	/************************************************************************/ | |
| 
 | |
| 	honaRegisterBuffer.insert(0, | |
| 							  (honaRegisterBuffer.at(0) + | |
| 							   (settings.hiruSettings.threshold & 0x00000FFF))); | |
| 
 | |
| 	honaRegisterBuffer.insert(1, settings.hsruSettings.honaInt123CTHR); | |
| 	honaRegisterBuffer.insert(2, settings.hsruSettings.honaRes123CTHR); | |
| 	honaRegisterBuffer.insert(3, settings.hsruSettings.honaIntSTHR); | |
| 	honaRegisterBuffer.insert(4, settings.hsruSettings.honaResSTHR); | |
| 	honaRegisterBuffer.insert(5, settings.hsruSettings.honaSPTHR); | |
| 	honaRegisterBuffer.insert(6, settings.hsruSettings.intM4_THR); | |
| 	honaRegisterBuffer.insert(7, settings.hsruSettings.resM4_THR); | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| void HonaLowLevelAPI::setConfig() | |
| { | |
| 	setConfig(_honaSetting); | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| void HonaLowLevelAPI::hsruMainThread() | |
| { | |
| 	try | |
| 	{ | |
| 		deviceReset(); | |
| 		setConfig(); | |
| 		deviceReset(); | |
| 		plxWrapper.deviceEnableInterrupt(); | |
| 
 | |
| 		QtConcurrent::run(this, &HonaLowLevelAPI::hsruReadThread); | |
| 		QtConcurrent::run(this, &HonaLowLevelAPI::hsruUpdateThread); | |
| 	} | |
| 	catch(...) | |
| 	{ | |
| 		_isHsruReaderThreadFree = true; | |
| 		_isHsruUpdateThreadFree = true; | |
| 		setHiruIsStarted(false); | |
| 	} | |
| 
 | |
| 	_mutex.lock(); | |
| 	_hsruStopEvent.wait(&_mutex); | |
| 	_mutex.unlock(); | |
| 	_isHsruReaderThreadFree = true; | |
| 	_isHsruUpdateThreadFree = true; | |
| 
 | |
| 	plxWrapper.deviceDisableInterrupt(); | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| void HonaLowLevelAPI::hsruReadThread() | |
| { | |
| 	_hsruLoss = 0; | |
| 	while(true) | |
| 	{ | |
| 		if(_isHsruReaderThreadFree) | |
| 			break; | |
| 
 | |
| 		plxWrapper.deviceWaitForInterrupt(1000); | |
| 		honaPacketList.clear(); | |
| 		_hsruLoss = 0; | |
| 		plxWrapper.deviceOpenPCIChannel(); | |
| 
 | |
| 		_hsruLoss += hsruParserInt123C(hsruReadHonaBuffer(honaReceivers::int123C), | |
| 									   honaPacketList); | |
| 		_hsruLoss += hsruParserRes123C(hsruReadHonaBuffer(honaReceivers::res123C), | |
| 									   honaPacketList); | |
| 		_hsruLoss += hsruParserIntS(hsruReadHonaBuffer(honaReceivers::intS), honaPacketList); | |
| 		_hsruLoss += hsruParserResS(hsruReadHonaBuffer(honaReceivers::resS), honaPacketList); | |
| 		_hsruLoss += hsruParserInt4(hsruReadHonaBuffer(honaReceivers::int4), honaPacketList); | |
| 		_hsruLoss += hsruParserRes4(hsruReadHonaBuffer(honaReceivers::res4), honaPacketList); | |
| 		_hsruLoss += hsruParserSinglePulse(hsruReadHonaBuffer(honaReceivers::singlePulse), | |
| 										   honaPacketList); | |
| 		plxWrapper.deviceClosePCIChannel(); | |
| 		plxWrapper.deviceEnableInterrupt(); | |
| 
 | |
| 		_mutex.lock(); | |
| 		_hsruReadDone.wakeAll(); | |
| 		_hsruUpdateAck.wait(&_mutex); | |
| 		_mutex.unlock(); | |
| 	} | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| void HonaLowLevelAPI::hsruUpdateThread() | |
| { | |
| 	while(true) | |
| 	{ | |
| 		_mutex.lock(); | |
| 		_hsruReadDone.wait(&_mutex); | |
| 		_mutex.unlock(); | |
| 		if(_isHsruUpdateThreadFree) | |
| 			break; | |
| 		quint32 Doa = 0; | |
| 		Doa = hiruGetDOA(); | |
| 		emit signalToTop(honaPacketList, _hsruLoss, Doa); | |
| 		_hsruUpdateAck.wakeAll(); | |
| 	} | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| void HonaLowLevelAPI::hiruMainThread() | |
| { | |
| 	QtConcurrent::run(this, &HonaLowLevelAPI::hiruReadThread); | |
| 	QtConcurrent::run(this, &HonaLowLevelAPI::hiruUpdateThread); | |
| 	while(true) | |
| 	{ | |
| 		_mutex.lock(); | |
| 		_hsruStopEvent.wait(&_mutex); | |
| 		_mutex.unlock(); | |
| 
 | |
| 		//_isReaderThreadFree = true; | |
| 		//_isUpdateThreadFree = true; | |
| 	} | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| void HonaLowLevelAPI::hiruReadThread() | |
| { | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| void HonaLowLevelAPI::hiruUpdateThread() | |
| { | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| quint32 HonaLowLevelAPI::hiruGetDOA() | |
| { | |
| 	quint32 Doa = 0; | |
| 	plxWrapper.deviceReadRegister(0x30000004, Doa); | |
| 	Doa = Doa & 0x0000FFFF; | |
| 
 | |
| 	return Doa; | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| quint32 HonaLowLevelAPI::hsruParserInt123C(const QVector<quint32>& honaData, | |
| 										   QList<HonaPacket> honaPacketList) | |
| { | |
| 	quint32 lossFound; | |
| 	for(quint32 Ind = 0; Ind < honaData.length(); Ind++) | |
| 	{ | |
| 		if((honaData.at(Ind) & 0xFF000000) == 0x0F000000) | |
| 		{ | |
| 			HonaPacket tempHonaPacketInt123C; | |
| 			tempHonaPacketInt123C.setPacketType(honaPacketType::responseMode123C); | |
| 			packetLenInt123C = 6; | |
| 			tempHonaPacketInt123C.setPacketNumber(honaData.at(Ind) & 0x0000FFFF); | |
| 			if((tempHonaPacketInt123C.getPacketNumber() != | |
| 				(lastPNInt123C + 1)) & (lastPNInt123C > 0)) | |
| 			//& (LastPNInt123C != 65535)) | |
| 			{ | |
| 				lossFound += | |
| 					((tempHonaPacketInt123C.getPacketNumber() - lastPNInt123C + 65536) % 65536 - 1); | |
| 			} | |
| 			lastPNInt123C = tempHonaPacketInt123C.getPacketNumber(); | |
| 			if(nextInt123C > 0) | |
| 				lossFound++; | |
| 			nextInt123C = 1; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x10000000) && (nextInt123C == 1)) | |
| 		{ | |
| 			tempHonaPacketInt123C.setToa((qulonglong)(honaData.at(Ind) & 0x0FFFFFFF)); | |
| 			nextInt123C = 2; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextInt123C == 2)) | |
| 		{ | |
| 			tempHonaPacketInt123C.setToa(((tempHonaPacketInt123C.getToa()) + | |
| 										  (qulonglong)((honaData.at(Ind) & 0x0000FFFF) << 28))); | |
| 
 | |
| 			tempHonaPacketInt123C.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16); | |
| 			nextInt123C = 3; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x30000000) && (nextInt123C == 3)) | |
| 		{ | |
| 			tempHonaPacketInt123C.setDoa(honaData.at(Ind) & 0x0000FFFF); | |
| 			tempHonaPacketInt123C.setPa3((honaData.at(Ind) & 0x0FFF0000) >> 16); | |
| 			nextInt123C = 4; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x40000000) && (nextInt123C == 4)) | |
| 		{ | |
| 			tempHonaPacketInt123C.setPa1(honaData.at(Ind) & 0x0000FFFF); | |
| 			tempHonaPacketInt123C.setPa2((honaData.at(Ind) & 0x000F0000) >> 4); | |
| 			tempHonaPacketInt123C.setPa3((honaData.at(Ind) & 0x00F00000) >> 8); | |
| 			nextInt123C = 5; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x50000000) && (nextInt123C == 5)) | |
| 		{ | |
| 			tempHonaPacketInt123C.setCodeM(((ulong)(honaData.at(Ind) & 0x0000001F)) << 59); | |
| 			tempHonaPacketInt123C.setCodeL(0); | |
| 			nextInt123C = 6; | |
| 		} | |
| 		else if(honaData.at(Ind) == 0xEEEEEEEE) | |
| 		{ | |
| 			//Console.Write("-"); | |
| 		} | |
| 		else | |
| 		{ | |
| 			//Console.Write("."); | |
| 		} | |
| 
 | |
| 		if(nextInt123C == packetLenInt123C) | |
| 		{ | |
| 			if(isValid(tempHonaPacketInt123C)) | |
| 			{ | |
| 				//tempHonaPacketInt123C.setToa((tempHonaPacketInt123C.getToa()/8)/SimulationSpeed + toaStartBoard); | |
| 				//honaPacketList.append(tempHonaPacketInt123C); | |
| 			} | |
| 			nextInt123C = 0; | |
| 		} | |
| 	} | |
| 
 | |
| 	return lossFound; | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector<quint32>& honaData, | |
| 										   QList<HonaPacket> honaPacketList) | |
| { | |
| 	quint32 lossFound = 0; | |
| 	for(quint32 Ind = 0; Ind < honaData.length(); Ind++) | |
| 	{ | |
| 		if((honaData.at(Ind) & 0xFF000000) == 0x0F000000) | |
| 		{ | |
| 			tempHonaPacketRes123C.setPacketNumber(honaPacketType::responseMode123C); | |
| 			packetLenRes123C = 6; | |
| 			tempHonaPacketRes123C.setPacketNumber(honaData.at(Ind) & 0x0000FFFF); | |
| 			if((tempHonaPacketRes123C.getPacketNumber() != | |
| 				(lastPNRes123C + 1)) & (lastPNRes123C > 0)) | |
| 			//& (LastPNRes123C != 65535)) | |
| 			{ | |
| 				lossFound += | |
| 					((tempHonaPacketRes123C.getPacketNumber() - lastPNRes123C + 65536) % 65536 - 1); | |
| 			} | |
| 			lastPNRes123C = tempHonaPacketRes123C.getPacketNumber(); | |
| 			if(nextRes123C > 0) | |
| 				lossFound++; | |
| 			nextRes123C = 1; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x10000000) && (nextRes123C == 1)) | |
| 		{ | |
| 			tempHonaPacketRes123C.setToa((qulonglong)(honaData.at(Ind) & 0x0FFFFFFF)); | |
| 			nextRes123C = 2; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextRes123C == 2)) | |
| 		{ | |
| 			tempHonaPacketRes123C.setToa(tempHonaPacketRes123C.getToa() + | |
| 										 (((ulong)(honaData.at(Ind) & 0x0000FFFF)) << 28)); | |
| 			tempHonaPacketRes123C.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16); | |
| 			nextRes123C = 3; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x30000000) && (nextRes123C == 3)) | |
| 		{ | |
| 			tempHonaPacketRes123C.setDoa(honaData.at(Ind) & 0x0000FFFF); | |
| 			tempHonaPacketRes123C.setPa3((honaData.at(Ind) & 0x0FFF0000) >> 16); | |
| 			nextRes123C = 4; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x40000000) && (nextRes123C == 4)) | |
| 		{ | |
| 			tempHonaPacketRes123C.setPa1(honaData.at(Ind) & 0x0000FFFF); | |
| 			tempHonaPacketRes123C.setPa2(tempHonaPacketRes123C.getPa2() + | |
| 										 ((honaData.at(Ind) & 0x000F0000) >> 4)); | |
| 			tempHonaPacketRes123C.setPa3(tempHonaPacketRes123C.getPa3() + | |
| 										 ((honaData.at(Ind) & 0x00F00000) >> 8)); | |
| 			nextRes123C = 5; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x50000000) && (nextRes123C == 5)) | |
| 		{ | |
| 			tempHonaPacketRes123C.setCodeM(((ulong)(honaData.at(Ind) & 0x00001FFF)) << 51); | |
| 			tempHonaPacketRes123C.setCodeL(0); | |
| 			nextRes123C = 6; | |
| 		} | |
| 		else if(honaData.at(Ind) == 0xEEEEEEEE) | |
| 		{ | |
| 			//Console.Write("-"); | |
| 		} | |
| 		else | |
| 		{ | |
| 			//Console.Write("."); | |
| 		} | |
| 
 | |
| 		if(nextRes123C == packetLenRes123C) | |
| 		{ | |
| 			if(isValid(tempHonaPacketRes123C)) | |
| 			{ | |
| 				//tempHonaPacketRes123C.setDoa((tempHonaPacketRes123C.TOA/8)/SimulationSpeed + toaStartBoard); | |
| 				//honaPacketList.append(tempHonaPacketRes123C); | |
| 			} | |
| 			nextRes123C = 0; | |
| 		} | |
| 	} | |
| 
 | |
| 	return lossFound; | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData, | |
| 										QList<HonaPacket> honaPacketList) | |
| { | |
| 	uint lossFound = 0; | |
| 	for(quint32 Ind = 0; Ind < honaData.length(); Ind++) | |
| 	{ | |
| 		if((honaData.at(Ind) & 0xFF000000) == 0x0F000000) | |
| 		{ | |
| 			uint TypeVal = (honaData.at(Ind) & 0x00F00000) >> 20; | |
| 			if(TypeVal == 2) | |
| 			{ | |
| 				tempHonaPacketIntS.setPacketType(honaPacketType::interrogationModeS56); | |
| 				packetLenIntS = 7; | |
| 			} | |
| 			else | |
| 			{ | |
| 				tempHonaPacketIntS.setPacketType(honaPacketType::interrogationModeS112); | |
| 				packetLenIntS = 9; | |
| 			} | |
| 			tempHonaPacketIntS.setPacketNumber(honaData.at(Ind) & 0x0000FFFF); | |
| 			if((tempHonaPacketIntS.getPacketNumber() != (lastPNIntS + 1)) & (lastPNIntS > 0)) | |
| 			//& (LastPNIntS != 65535)) | |
| 			{ | |
| 				lossFound += | |
| 					((tempHonaPacketIntS.getPacketNumber() - lastPNIntS + 65536) % 65536 - 1); | |
| 			} | |
| 			lastPNIntS = tempHonaPacketIntS.getPacketNumber(); | |
| 			if(nextIntS > 0) | |
| 				lossFound++; | |
| 			nextIntS = 1; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x10000000) && (nextIntS == 1)) | |
| 		{ | |
| 			tempHonaPacketIntS.setToa((qulonglong)(honaData.at(Ind) & 0x0FFFFFFF)); | |
| 			nextIntS = 2; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextIntS == 2)) | |
| 		{ | |
| 			tempHonaPacketIntS.setToa(tempHonaPacketIntS.getToa() + | |
| 									  (((ulong)(honaData.at(Ind) & 0x0000FFFF)) << 28)); | |
| 			tempHonaPacketIntS.setToa((honaData.at(Ind) & 0x0FFF0000) >> 16); | |
| 			nextIntS = 3; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x30000000) && (nextIntS == 3)) | |
| 		{ | |
| 			tempHonaPacketIntS.setDoa(honaData.at(Ind) & 0x0000FFFF); | |
| 			tempHonaPacketIntS.setPa3((honaData.at(Ind) & 0x0FFF0000) >> 16); | |
| 			nextIntS = 4; | |
| 		} | |
| 		else if(((honaData.at(static_cast<int>(Ind)) & 0xF0000000) == 0x40000000) && | |
| 				(nextIntS == 4)) | |
| 		{ | |
| 			tempHonaPacketIntS.setPa1(honaData.at(Ind) & 0x0000FFFF); | |
| 			tempHonaPacketIntS.setPa2(tempHonaPacketIntS.getPa2() + ((honaData.at( | |
| 																		  Ind) & 0x000F0000))); | |
| 			tempHonaPacketIntS.setPa3(tempHonaPacketIntS.getPa3() + | |
| 									  ((honaData.at(Ind) & 0x00F00000) >> 4)); | |
| 			nextIntS = 5; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x50000000) && (nextIntS == 5)) | |
| 		{ | |
| 			tempHonaPacketIntS.setCodeM(((ulong)(honaData.at(Ind) & 0x0FFFFFFF)) << 8); | |
| 			tempHonaPacketIntS.setCodeL(0); | |
| 			nextIntS = 6; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x60000000) && (nextIntS == 6)) | |
| 		{ | |
| 			tempHonaPacketIntS.setCodeM(tempHonaPacketIntS.getCodeM() + | |
| 										((ulong)(honaData.at(Ind) & 0x0FFFFFFF)) << 36); | |
| 			tempHonaPacketIntS.setCodeL(0); | |
| 			nextIntS = 7; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x70000000) && (nextIntS == 7)) | |
| 		{ | |
| 			tempHonaPacketIntS.setCodeL(tempHonaPacketIntS.getCodeM()); | |
| 			tempHonaPacketIntS.setCodeM(((ulong)(honaData.at(Ind) & 0x0FFFFFFF)) << 8); | |
| 			nextIntS = 8; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x80000000) && (nextIntS == 8)) | |
| 		{ | |
| 			tempHonaPacketIntS.setCodeM(tempHonaPacketIntS.getCodeM() + | |
| 										((ulong)(honaData.at(Ind) & 0x0FFFFFFF)) << 36); | |
| 			nextIntS = 9; | |
| 		} | |
| 		else if(honaData.at(Ind) == 0xEEEEEEEE) | |
| 		{ | |
| 			//Console.Write("-"); | |
| 		} | |
| 		else | |
| 		{ | |
| 			//Console.Write("."); | |
| 		} | |
| 
 | |
| 		if(nextIntS == packetLenIntS) | |
| 		{ | |
| 			if(isValid(tempHonaPacketIntS)) | |
| 			{ | |
| 				//tempHonaPacketIntS.setToa( (tempHonaPacketIntS.getToa()/8)/SimulationSpeed + toaStartBoard; | |
| 				//honaPacketList.append(tempHonaPacketIntS); | |
| 			} | |
| 			nextIntS = 0; | |
| 		} | |
| 	} | |
| 
 | |
| 	return lossFound; | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData, | |
| 										QList<HonaPacket> honaPacketList) | |
| { | |
| 	uint lossFound = 0; | |
| 	for(quint32 Ind = 0; Ind < honaData.length(); Ind++) | |
| 	{ | |
| 		if((honaData.at(Ind) & 0xFF000000) == 0x0F000000) | |
| 		{ | |
| 			uint TypeVal = (honaData.at(Ind) & 0x00F00000) >> 20; | |
| 			if(TypeVal == 4) | |
| 			{ | |
| 				tempHonaPacketResS.setPacketType(honaPacketType::responseModeS56); | |
| 				packetLenResS = 7; | |
| 			} | |
| 			else | |
| 			{ | |
| 				tempHonaPacketResS.setPacketType(honaPacketType::responseModeS112); | |
| 				packetLenResS = 9; | |
| 			} | |
| 			tempHonaPacketResS.setPacketNumber(honaData.at(Ind) & 0x0000FFFF); | |
| 			if((tempHonaPacketResS.getPacketNumber() != (lastPNResS + 1)) & (lastPNResS > 0)) | |
| 			//& (LastPNResS != 65535)) | |
| 			{ | |
| 				lossFound += | |
| 					((tempHonaPacketResS.getPacketNumber() - lastPNResS + 65536) % 65536 - 1); | |
| 			} | |
| 			lastPNResS = tempHonaPacketResS.getPacketNumber(); | |
| 			if(nextResS > 0) | |
| 				lossFound++; | |
| 			nextResS = 1; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x10000000) && (nextResS == 1)) | |
| 		{ | |
| 			tempHonaPacketResS.setToa(static_cast<qulonglong>(honaData.at(Ind) & 0x0FFFFFFF)); | |
| 			nextResS = 2; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextResS == 2)) | |
| 		{ | |
| 			tempHonaPacketResS.setDoa(tempHonaPacketResS.getDoa() + | |
| 									  ((static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF)) << | |
| 									   28)); | |
| 			tempHonaPacketResS.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16); | |
| 			nextResS = 3; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x30000000) && (nextResS == 3)) | |
| 		{ | |
| 			tempHonaPacketResS.setDoa(honaData.at(Ind) & 0x0000FFFF); | |
| 			tempHonaPacketResS.setPa3((honaData.at(Ind) & 0x0FFF0000) >> 16); | |
| 			nextResS = 4; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x40000000) && (nextResS == 4)) | |
| 		{ | |
| 			tempHonaPacketResS.setPa1(honaData.at(Ind) & 0x0000FFFF); | |
| 			tempHonaPacketResS.setPa2(tempHonaPacketResS.getPa2() + ((honaData.at( | |
| 																		  Ind) & 0x000F0000))); | |
| 			tempHonaPacketResS.setPa3(tempHonaPacketResS.getPa3() + | |
| 									  ((honaData.at(Ind) & 0x00F00000) >> 4)); | |
| 			nextResS = 5; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x50000000) && (nextResS == 5)) | |
| 		{ | |
| 			tempHonaPacketResS.setCodeM((static_cast<qulonglong>(honaData.at( | |
| 																	 Ind) & 0x0FFFFFFF)) << 8); | |
| 			tempHonaPacketResS.setCodeL(0); | |
| 			nextResS = 6; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x60000000) && (nextResS == 6)) | |
| 		{ | |
| 			tempHonaPacketResS.setCodeM(tempHonaPacketResS.getCodeM() + | |
| 										(static_cast<qulonglong>(honaData.at( | |
| 																	 Ind) & 0x0FFFFFFF)) << 36); | |
| 			tempHonaPacketResS.setCodeL(0); | |
| 			nextResS = 7; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x70000000) && (nextResS == 7)) | |
| 		{ | |
| 			tempHonaPacketResS.setCodeL(tempHonaPacketResS.getCodeM()); | |
| 			tempHonaPacketResS.setCodeM((static_cast<qulonglong>(honaData.at( | |
| 																	 Ind) & 0x0FFFFFFF)) << 8); | |
| 			nextResS = 8; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x80000000) && (nextResS == 8)) | |
| 		{ | |
| 			tempHonaPacketResS.setCodeM(tempHonaPacketResS.getCodeM() + | |
| 										(static_cast<qulonglong>(honaData.at( | |
| 																	 Ind) & 0x0FFFFFFF)) << 36); | |
| 			nextResS = 9; | |
| 		} | |
| 		else if(honaData.at(Ind) == 0xEEEEEEEE) | |
| 		{ | |
| 			//Console.Write("-"); | |
| 		} | |
| 		else | |
| 		{ | |
| 			//Console.Write("."); | |
| 		} | |
| 
 | |
| 		if(nextResS == packetLenResS) | |
| 		{ | |
| 			if(isValid(tempHonaPacketResS)) | |
| 			{ | |
| 				//tempHonaPacketResS.setToa( (tempHonaPacketResS.getToa()/8)/SimulationSpeed + toaStartBoard; | |
| 				//honaPacketList.append(tempHonaPacketResS); | |
| 			} | |
| 			nextResS = 0; | |
| 		} | |
| 	} | |
| 
 | |
| 	return lossFound; | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData, | |
| 										QList<HonaPacket> honaPacketList) | |
| { | |
| 	uint lossFound = 0; | |
| 
 | |
| 	for(quint32 Ind = 0; Ind < honaData.length(); Ind++) | |
| 	{ | |
| 		if((honaData.at(Ind) & 0xFF000000) == 0x0F000000) | |
| 		{ | |
| 			tempHonaPacketInt4.setPacketType(honaPacketType::interrogationMode4); | |
| 			packetLenInt4 = 7; | |
| 			tempHonaPacketInt4.setPacketNumber(honaData.at(Ind) & 0x0000FFFF); | |
| 			if((tempHonaPacketInt4.getPacketNumber() != (lastPNInt4 + 1)) & (lastPNInt4 > 0)) //& (LastPNInt123C != 65535)) | |
| 			{ | |
| 				lossFound += | |
| 					((tempHonaPacketInt4.getPacketNumber() - lastPNInt4 + 65536) % 65536 - 1); | |
| 			} | |
| 			lastPNInt4 = tempHonaPacketInt4.getPacketNumber(); | |
| 			if(nextInt4 > 0) | |
| 				lossFound++; | |
| 			nextInt4 = 1; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x10000000) && (nextInt4 == 1)) | |
| 		{ | |
| 			tempHonaPacketInt4.setToa(static_cast<qulonglong>(honaData.at(Ind) & 0x0FFFFFFF)); | |
| 			nextInt4 = 2; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextInt4 == 2)) | |
| 		{ | |
| 			tempHonaPacketInt4.setToa(tempHonaPacketInt4.getToa() + | |
| 									  ((static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF)) << | |
| 									   28)); | |
| 			tempHonaPacketInt4.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16); | |
| 			nextInt4 = 3; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x30000000) && (nextInt4 == 3)) | |
| 		{ | |
| 			tempHonaPacketInt4.setDoa(honaData.at(Ind) & 0x0000FFFF); | |
| 			tempHonaPacketInt4.setPa3((honaData.at(Ind) & 0x0FFF0000) >> 16); | |
| 			nextInt4 = 4; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x40000000) && (nextInt4 == 4)) | |
| 		{ | |
| 			tempHonaPacketInt4.setPa1(honaData.at(Ind) & 0x0000FFFF); | |
| 			tempHonaPacketInt4.setPa2(tempHonaPacketInt4.getPa2() + | |
| 									  ((honaData.at(Ind) & 0x000F0000) >> 4)); | |
| 			tempHonaPacketInt4.setPa3(tempHonaPacketInt4.getPa3() + | |
| 									  ((honaData.at(Ind) & 0x00F00000) >> 8)); | |
| 			nextInt4 = 5; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x50000000) && (nextInt4 == 5)) | |
| 		{ | |
| 			tempHonaPacketInt4.setCodeM(0); | |
| 			tempHonaPacketInt4.setCodeL(static_cast<qulonglong>(honaData.at(Ind) & 0x0FFFFFFF)); | |
| 			nextInt4 = 6; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x60000000) && (nextInt4 == 6)) | |
| 		{ | |
| 			tempHonaPacketInt4.setPa4(honaData.at(Ind) & 0x0000FFFF); | |
| 			tempHonaPacketInt4.setCodeL(tempHonaPacketInt4.getCodeL() + | |
| 										((static_cast<qulonglong>(honaData.at(Ind) & 0x000F0000)) << | |
| 										 12)); | |
| 			tempHonaPacketInt4.M4Status = ((byte)((honaData.at(Ind) & 0x0F000000) >> 20)); | |
| 			nextInt4 = 7; | |
| 		} | |
| 		else if(honaData.at(Ind) == 0xEEEEEEEE) | |
| 		{ | |
| 			//Console.Write("-"); | |
| 		} | |
| 		else | |
| 		{ | |
| 			//Console.Write("."); | |
| 		} | |
| 
 | |
| 		if(nextInt4 == packetLenInt4) | |
| 		{ | |
| 			if(isValid(tempHonaPacketInt4)) | |
| 			{ | |
| 				//tempHonaPacketInt4.setToa((tempHonaPacketInt4.TOA / 6) / SimulationSpeed + toaStartBoard); | |
| 				//honaPacketList.append(tempHonaPacketInt4); | |
| 			} | |
| 			nextInt4 = 0; | |
| 		} | |
| 	} | |
| 
 | |
| 	return lossFound; | |
| } | |
| 
 | |
| quint32 HonaLowLevelAPI::hsruParserRes4(const QVector<quint32>& honaData, | |
| 										QList<HonaPacket> honaPacketList) | |
| { | |
| 	uint lossFound = 0; | |
| 	for(quint32 Ind = 0; Ind < honaData.length(); Ind++) | |
| 	{ | |
| 		if((honaData.at(Ind) & 0xFF000000) == 0x0F000000) | |
| 		{ | |
| 			tempHonaPacketRes4.setPacketType(honaPacketType::responseMode4); | |
| 			packetLenRes4 = 5; | |
| 			tempHonaPacketRes4.setPacketNumber(honaData.at(Ind) & 0x0000FFFF); | |
| 			if((tempHonaPacketRes4.getPacketNumber() != (lastPNRes4 + 1)) & (lastPNRes4 > 0)) //& (LastPNRes123C != 65535)) | |
| 			{ | |
| 				lossFound += | |
| 					((tempHonaPacketRes4.getPacketNumber() - lastPNRes4 + 65536) % 65536 - 1); | |
| 			} | |
| 			lastPNRes4 = tempHonaPacketRes4.getPacketNumber(); | |
| 			if(nextRes4 > 0) | |
| 				lossFound++; | |
| 			nextRes4 = 1; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x10000000) && (nextRes4 == 1)) | |
| 		{ | |
| 			tempHonaPacketRes4.setToa((static_cast<qulonglong>(honaData.at(Ind) & 0x0FFFFFFF))); | |
| 			nextRes4 = 2; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextRes4 == 2)) | |
| 		{ | |
| 			tempHonaPacketRes4.setToa(tempHonaPacketRes4.getToa() + | |
| 									  (static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF) << | |
| 									   28)); | |
| 			tempHonaPacketRes4.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16); | |
| 			nextRes4 = 3; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x30000000) && (nextRes4 == 3)) | |
| 		{ | |
| 			tempHonaPacketRes4.setDoa(honaData.at(Ind) & 0x0000FFFF); | |
| 			tempHonaPacketRes4.setPa3((honaData.at(Ind) & 0x0FFF0000) >> 16); | |
| 			nextRes4 = 4; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x40000000) && (nextRes4 == 4)) | |
| 		{ | |
| 			tempHonaPacketRes4.setPa1(honaData.at(Ind) & 0x0000FFFF); | |
| 			tempHonaPacketRes4.setPa2(tempHonaPacketRes4.getPa2() + (honaData.at( | |
| 																		 Ind) & 0x000F0000) >> 4);        //NOTE: shifted by 4 | |
| 			tempHonaPacketRes4.setPa3(tempHonaPacketRes4.getPa3() + (honaData.at( | |
| 																		 Ind) & 0x00F00000) >> 8);        //NOTE: shifted by 8 | |
| 			nextRes4 = 5; | |
| 		} | |
| 		else if(honaData.at(Ind) == 0xEEEEEEEE) | |
| 		{ | |
| 			//Console.Write("-"); | |
| 		} | |
| 		else | |
| 		{ | |
| 			//Console.Write("."); | |
| 		} | |
| 
 | |
| 		if(nextRes4 == packetLenRes4) | |
| 		{ | |
| 			if(isValid(tempHonaPacketRes4)) | |
| 			{ | |
| 				//tempHonaPacketRes4.setToa((tempHonaPacketRes4.getToa() / 6) / SimulationSpeed + toaStartBoard); | |
| 				//honaPacketList.append(tempHonaPacketRes4); | |
| 			} | |
| 			nextRes4 = 0; | |
| 		} | |
| 	} | |
| 
 | |
| 	return lossFound; | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector<quint32>& honaData, | |
| 											   QList<HonaPacket> honaPacketList) | |
| { | |
| 	uint lossFound = 0; | |
| 	for(quint32 Ind = 0; Ind < honaData.length(); Ind++) | |
| 	{ | |
| 		if((honaData.at(Ind) & 0xFF000000) == 0x0F000000) | |
| 		{ | |
| 			tempHonaPacketSinglePulse.setPacketType(honaPacketType::singlePulseMode4); | |
| 			packetLenSinglePulse = 5; | |
| 			tempHonaPacketSinglePulse.setPacketNumber(honaData.at(Ind) & 0x0000FFFF); | |
| 			if((tempHonaPacketSinglePulse.getPacketNumber() != | |
| 				(lastPNSinglePulse + 1)) & (lastPNSinglePulse > 0)) | |
| 				; | |
| 			{ | |
| 				lossFound += | |
| 					((tempHonaPacketSinglePulse.getPacketNumber() - lastPNSinglePulse + 65536) % | |
| 					 65536 - | |
| 					 1); | |
| 			} | |
| 			lastPNSinglePulse = tempHonaPacketSinglePulse.getPacketNumber(); | |
| 			if(nextSinglePulse > 0) | |
| 				lossFound++; | |
| 			nextSinglePulse = 1; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x10000000) && (nextSinglePulse == 1)) | |
| 		{ | |
| 			tempHonaPacketSinglePulse.setToa(static_cast<qulonglong>(honaData.at(Ind) & | |
| 																	 0x0FFFFFFF)); | |
| 			nextSinglePulse = 2; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextSinglePulse == 2)) | |
| 		{ | |
| 			tempHonaPacketSinglePulse.setToa(tempHonaPacketSinglePulse.getToa() + | |
| 											 ((static_cast<qulonglong>(honaData.at(Ind) & | |
| 																	   0x0000FFFF)) << 28)); | |
| 			tempHonaPacketSinglePulse.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16); | |
| 			nextSinglePulse = 3; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x30000000) && (nextSinglePulse == 3)) | |
| 		{ | |
| 			tempHonaPacketSinglePulse.setDoa(honaData.at(Ind) & 0x0000FFFF); | |
| 			tempHonaPacketSinglePulse.setPa3((honaData.at(Ind) & 0x0FFF0000) >> 16); | |
| 			nextSinglePulse = 4; | |
| 		} | |
| 		else if(((honaData.at(Ind) & 0xF0000000) == 0x40000000) && (nextSinglePulse == 4)) | |
| 		{ | |
| 			tempHonaPacketSinglePulse.setPa1(honaData.at(Ind) & 0x0000FFFF); | |
| 			tempHonaPacketSinglePulse.setPa2(tempHonaPacketSinglePulse.getPa2() + | |
| 											 ((honaData.at(Ind) & 0x000F0000) >> 4));                                     //NOTE: shifted by 4 | |
| 			tempHonaPacketSinglePulse.setPa3(tempHonaPacketSinglePulse.getPa3() + | |
| 											 ((honaData.at(Ind) & 0x00F00000) >> 8));                                     //NOTE: shifted by 8 | |
| 			nextSinglePulse = 5; | |
| 		} | |
| 		else if(honaData.at(Ind) == 0xEEEEEEEE) | |
| 		{ | |
| 			//Console.Write("-"); | |
| 		} | |
| 		else | |
| 		{ | |
| 			//Console.Write("."); | |
| 		} | |
| 
 | |
| 		if(nextSinglePulse == packetLenSinglePulse) | |
| 		{ | |
| 			if(isValid(tempHonaPacketSinglePulse)) | |
| 			{ | |
| 				//tempHonaPacketSinglePulse.setToa((tempHonaPacketSinglePulse.getToa() / 6) / SimulationSpeed + toaStartBoard); | |
| 				//honaPacketList.append(tempHonaPacketSinglePulse); | |
| 			} | |
| 			nextSinglePulse = 0; | |
| 		} | |
| 	} | |
| 
 | |
| 	return lossFound; | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| QVector<quint32> HonaLowLevelAPI::hsruReadHonaBuffer(honaReceivers receiver) | |
| { | |
| 	QVector<quint32> honaData; | |
| 	honaData.resize(16384); | |
| 	quint32 address = 0; | |
| 
 | |
| 	if(receiver == honaReceivers::int123C) | |
| 		address = 0X50000000; | |
| 	else if(receiver == honaReceivers::res123C) | |
| 		address = 0X60000000; | |
| 	else if(receiver == honaReceivers::intS) | |
| 		address = 0X70000000; | |
| 	else if(receiver == honaReceivers::resS) | |
| 		address = 0X80000000; | |
| 	else if(receiver == honaReceivers::int4) //Mode4 :: added by H.H | |
| 		address = 0X90000000; | |
| 	else if(receiver == honaReceivers::res4) //Mode4 :: added by H.H | |
| 		address = 0XA0000000; | |
| 	else if(receiver == honaReceivers::singlePulse) //Mode4 :: added by H.H | |
| 		address = 0XB0000000; | |
| 
 | |
| 	else | |
| 		throw HonaException("honaReceivers is Not Valid"); | |
| 
 | |
| 	plxWrapper.deviceReadMemory(address, honaData, honaData.size()); | |
| 
 | |
| 	return honaData; | |
| } | |
| 
 | |
| /*************************************************************************************************/ | |
| bool HonaLowLevelAPI::isValid(HonaPacket hp) | |
| { | |
| 	if(hp.getToa() <= 0) | |
| 		return false; | |
| 
 | |
| 	return true; | |
| } | |
| 
 | |
| /*************************************************************************************************/
 | |
| 
 |