From 237bdbe26ec384315916f0a603b8b2a917444195 Mon Sep 17 00:00:00 2001
From: Alireza <nikolateslasoul@gmail.com>
Date: Tue, 14 Dec 2021 19:04:30 +0330
Subject: [PATCH 1/3] work on honaapi function

---
 Plx/include/LowLevel/HonaLowLevelAPI.h     |  85 ++-
 Plx/include/LowLevel/HonaPacket.h.autosave |  62 ++
 Plx/include/LowLevel/Utils/Utils.h         |  67 +-
 Plx/src/LowLevel/HonaLowLevelAPI.cpp       | 843 +++++++++++++++++++--
 Plx/src/LowLevel/HonaPacket.cpp            | 192 ++---
 5 files changed, 1059 insertions(+), 190 deletions(-)
 create mode 100644 Plx/include/LowLevel/HonaPacket.h.autosave

diff --git a/Plx/include/LowLevel/HonaLowLevelAPI.h b/Plx/include/LowLevel/HonaLowLevelAPI.h
index 85aa18a..8fcc097 100644
--- a/Plx/include/LowLevel/HonaLowLevelAPI.h
+++ b/Plx/include/LowLevel/HonaLowLevelAPI.h
@@ -1,4 +1,4 @@
-#ifndef HONALOWLEVELAPI_H
+#ifndef HONALOWLEVELAPI_H
 #define HONALOWLEVELAPI_H
 
 #include <QObject>
@@ -10,6 +10,9 @@
 #include "QWaitCondition"
 #include "QMutex"
 #include "include/LowLevel/Exception/HonaAlreadyStartedException.h"
+#include "include/LowLevel/Exception/HonaException.h"
+#include "include/Wrapper/PlxWrapper.h"
+#include "include/LowLevel/Utils/Utils.h"
 
 class HonaLowLevelAPI : public QObject
 {
@@ -18,13 +21,61 @@ class HonaLowLevelAPI : public QObject
 private:
 	bool _hsruIsStarted;
 	bool _hiruIsStarted;
+	quint32 _hsruLoss;
 	HonaSettings _honaSetting;
-	QWaitCondition _hsruReadDone, _hsruUpdateAck, _hsruStopEvent;
+	QWaitCondition _hsruReadDone, _hsruUpdateAck, _hsruStopEvent, _hiruReadDone0, _hiruCountDone,
+				   _hiruUpdateAck1;
+
+	QList<HonaPacket> honaPacketList;
 	QMutex _mutex;
 	int _threadSforValue = 0;
-	bool _isReaderThreadFree = false;
-	bool _isUpdateThreadFree = false;
-	quint32 honaRegisterBuffer[8];
+	bool _isHsruMainThreadFree = false;
+	bool _isHsruReaderThreadFree = false;
+	bool _isHsruUpdateThreadFree = false;
+
+	bool _isHiruReaderThreadFree = false;
+	bool _isHiruUpdateThreadFree = false;
+	QVector<quint32> honaRegisterBuffer;
+	PlxWrapper plxWrapper;
+
+	static quint32 packetLenInt4;
+	static quint32 packetLenRes4;
+	static quint32 packetLenSinglePulse;
+
+	static quint32 packetLenInt123C;
+	static quint32 packetLenRes123C;
+	static quint32 packetLenIntS;
+	static quint32 packetLenResS;
+
+	static quint32 nextInt4;
+	static quint32 nextRes4;
+	static quint32 nextSinglePulse;
+
+	static quint32 nextInt123C;
+	static quint32 nextRes123C;
+	static quint32 nextIntS;
+	static quint32 nextResS;
+
+	quint32 lastPNInt4 = 0;
+	quint32 lastPNRes4 = 0;
+	quint32 lastPNSinglePulse = 0;
+
+	quint32 lastPNInt123C = 0;
+	quint32 lastPNRes123C = 0;
+	quint32 lastPNIntS = 0;
+	quint32 lastPNResS = 0;
+
+	HonaPacket tempHonaPacketInt4;
+	HonaPacket tempHonaPacketRes4;
+	HonaPacket tempHonaPacketSinglePulse;
+
+	HonaPacket tempHonaPacketInt123C;
+	HonaPacket tempHonaPacketRes123C;
+	HonaPacket tempHonaPacketIntS;
+	HonaPacket tempHonaPacketResS;
+
+public:
+	qulonglong toaStartBoard = 0;
 
 public:
 	explicit HonaLowLevelAPI(QObject* parent = nullptr);
@@ -32,12 +83,11 @@ public:
 	bool isHiruStarted();
 	void deviceReset();
 
-	void setConfig(HonaSettings* honaSetting);
+	void setConfig(HonaSettings& settings);
 	HonaSettings getConfig();
 	QString getSwVersion();
 	QString getDeviceId();
 	void hsruStart();
-
 	void hiruStart();
 	void init();
 
@@ -53,10 +103,27 @@ private:
 	void hsruMainThread();
 	void hsruReadThread();
 	void hsruUpdateThread();
-	int hiruGetDOA();
+	void hiruMainThread();
+	void hiruReadThread();
+	void hiruUpdateThread();
+	quint32 hiruGetDOA();
+
+	quint32 hsruParserInt123C(const QVector<quint32>& honaData, QList<HonaPacket> honaPacketList);
+	quint32 hsruParserRes123C(const QVector<quint32>& honaData, QList<HonaPacket> honaPacketList);
+	quint32 hsruParserIntS(const QVector<quint32>& honaData, QList<HonaPacket> honaPacketList);
+	quint32 hsruParserResS(const QVector<quint32>& honaData, QList<HonaPacket> honaPacketList);
+	quint32 hsruParserInt4(const QVector<quint32>& honaData, QList<HonaPacket> honaPacketList);
+	quint32 hsruParserRes4(const QVector<quint32>& honaData, QList<HonaPacket> honaPacketList);
+	quint32 hsruParserSinglePulse(const QVector<quint32>& honaData,
+								  QList<HonaPacket> honaPacketList);
+
+	QVector<quint32> hsruReadHonaBuffer(honaReceivers receiver);
+
+	bool isValid(HonaPacket hp);
 
 signals:
-	void signalToTop(QList<HonaPacket*> honaPacketList, int i, int j);
+	void signalToTop(QList<HonaPacket> honaPacketList, quint32 i, quint32 j);
+
 	//uncrustify off
 public	slots:
 	//uncrustify on
diff --git a/Plx/include/LowLevel/HonaPacket.h.autosave b/Plx/include/LowLevel/HonaPacket.h.autosave
new file mode 100644
index 0000000..7860765
--- /dev/null
+++ b/Plx/include/LowLevel/HonaPacket.h.autosave
@@ -0,0 +1,62 @@
+#ifndef HONAPACKET_H
+#define HONAPACKET_H
+
+#include <QtGlobal>
+
+#include "include/LowLevel/Utils/Utils.h"
+
+class HonaPacket
+{
+private:
+	qreal toaClock;
+	honaPacketType m_PacketType;
+	quint32 m_PacketNumber;
+	qulonglong m_Toa;
+	quint32 m_Doa;
+	quint32 m_Pa1;
+	quint32 m_Pa2;
+	quint32 m_Pa3;
+	quint32 m_Pa4;
+	quint32 m_Code;
+	quint32 m_CodeL;
+	quint32 m_CodeM;
+
+public:
+	HonaPacket();
+	/******************************************************************/
+	honaPacketType getPacketType();
+	void setPacketType(honaPacketType temp);
+	/******************************************************************/
+	quint32 getPacketNumber();
+	void setPacketNumber(quint32 temp);
+	/******************************************************************/
+	qulonglong getToa();
+	void setToa(qulonglong temp);
+	/******************************************************************/
+	quint32 getDoa();
+	void setDoa(quint32 temp);
+	/******************************************************************/
+	quint32 getPa1();
+	void setPa1(quint32 temp);
+	/******************************************************************/
+	quint32 getPa2();
+	void setPa2(quint32 temp);
+	/******************************************************************/
+	quint32 getPa3();
+	void setPa3(quint32 temp);
+	/******************************************************************/
+	quint32 getPa4();
+	void setPa4(quint32 temp);
+	/******************************************************************/
+	quint32 getCode();
+	void setCode(quint32 temp);
+	/******************************************************************/
+	quint32 getCodeL();
+	void setCodeL(quint32 temp);
+	/******************************************************************/
+	quint32 getCodeM();
+	void setCodeM(quint32 temp);
+	/******************************************************************/
+};
+
+#endif //HONAPACKET_H
diff --git a/Plx/include/LowLevel/Utils/Utils.h b/Plx/include/LowLevel/Utils/Utils.h
index 2eb3411..8617982 100644
--- a/Plx/include/LowLevel/Utils/Utils.h
+++ b/Plx/include/LowLevel/Utils/Utils.h
@@ -2,64 +2,65 @@
 #define UTILS_H
 
 #include <QtCore>
+
 /*************************************************************************************************/
 enum apiResult : quint8
 {
-    success,
-    alreadyStarted,
-    busy,
-    error
+	success,
+	alreadyStarted,
+	busy,
+	error
 };
+
 /*************************************************************************************************/
 enum drxDeviceIfChannel : quint8
 {
-    ifChannel11,
-    ifChannel12
-
+	ifChannel11,
+	ifChannel12
 };
+
 /*************************************************************************************************/
 enum honaReceivers : quint8
 {
-    int123C,
-    intS,
-    resS,
-    int4,           //Mode 4
-    res4,           //Mode 4
-    signalPulse     //Mode 4
+	int123C,
+	res123C,
+	intS,
+	resS,
+	int4,           //Mode 4
+	res4,           //Mode 4
+	singlePulse     //Mode 4
 };
+
 /*************************************************************************************************/
 enum recorderMode : quint8
 {
-    signalChannel,
-    dualChannel
-
+	signalChannel,
+	dualChannel
 };
+
 /*************************************************************************************************/
 enum  recorderStart : quint8
 {
-    selfTestCounter= 1,
-    freeRunRecording = 2
+	selfTestCounter = 1,
+	freeRunRecording = 2
 };
+
 /*************************************************************************************************/
 enum honaPacketType : quint8
 {
-    interrogationMode123C,
-    interrogationModeS56,
-    interrogationModeS112,
-    interrogationMode4,
-
-    responseMode123C,
-    responseModeS56,
-    responseModeS112,
+	interrogationMode123C,
+	interrogationModeS56,
+	interrogationModeS112,
+	interrogationMode4,
 
-    responseMode4,
-    signalPulseMode4
+	responseMode123C,
+	responseModeS56,
+	responseModeS112,
 
+	responseMode4,
+	singlePulseMode4
 };
-/*************************************************************************************************/
-
-
-
 
+/*************************************************************************************************/
 
-#endif // UTILS_H
+#endif //UTILS_H
diff --git a/Plx/src/LowLevel/HonaLowLevelAPI.cpp b/Plx/src/LowLevel/HonaLowLevelAPI.cpp
index a176796..e31da29 100644
--- a/Plx/src/LowLevel/HonaLowLevelAPI.cpp
+++ b/Plx/src/LowLevel/HonaLowLevelAPI.cpp
@@ -1,11 +1,9 @@
 #include <include/LowLevel/Utils/Utils.h>
 #include "include/LowLevel/HonaLowLevelAPI.h"
 #include "include/Wrapper/PlxWrapper.h"
-
 #include "qdebug.h"
 #include "QTime"
 #include "QtConcurrent/QtConcurrent"
-PlxWrapper plx;
 
 bool HonaLowLevelAPI::getHsruIsStarted() const
 {
@@ -33,6 +31,13 @@ void HonaLowLevelAPI::setHiruIsStarted(bool hiruIsStarted)
 /*************************************************************************************************/
 HonaLowLevelAPI::HonaLowLevelAPI(QObject* parent) : QObject(parent)
 {
+	packetLenInt4 = 7;
+	packetLenRes4 = 5;
+	packetLenSinglePulse = 5;
+	packetLenInt123C = 6;
+	packetLenRes123C = 6;
+	packetLenIntS = 7;
+	packetLenResS = 7;
 }
 
 /*************************************************************************************************/
@@ -50,72 +55,55 @@ bool HonaLowLevelAPI::isHiruStarted()
 /*************************************************************************************************/
 void HonaLowLevelAPI::deviceReset()
 {
-	//ApiResult status;
-	//if(ApiResult::success)
-	//{
-	//}
-	/*
-	   QTime t;
-	   t.elapsed()
-
-	   PLX_STATUS status = base.DeviceReset();
-	   qDebug() << "Board Reseted, status: " + status.ToString());
-
-	   if (status == PLX_STATUS.ApiSuccess)
-	   {
-		toaStartBoard = (ulong) (DateTime.Now.Ticks);
-		return ApiResult.Success;
-	   }
-	   else
-		return ApiResult.Error; */
+	if(!plxWrapper.deviceReset())
+		throw HonaAlreadyStartedException("reset Doesnt Occur");
 }
 
 /*************************************************************************************************/
-void HonaLowLevelAPI::setConfig(HonaSettings* honaSetting)
+void HonaLowLevelAPI::setConfig(HonaSettings& settings)
 {
-	//Initial State Checking
-	/*
-	   HonaRegisterBuffer = new uint[8];  // Mode4 :: changed from 5 to 8 by H.H
-	   DeviceReadRegisters(0x10000000, ref HonaRegisterBuffer);
-
-	   _honaSetting = Settings;
-	   HonaFillRegisters(Settings);
-	   DeviceWriteRegisters(0x10000000, HonaRegisterBuffer);
-
-	   HonaRegisterBuffer = new uint[8];  // Mode4 :: changed from 5 to 8 by H.H
-	   DeviceReadRegisters(0x10000000, ref HonaRegisterBuffer);
-
-	   return ApiResult.Success; */
+	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())
-		//exceptiom
-
-		QtConcurrent::run(this, &HonaLowLevelAPI::hsruMainThread);
+	if(!isHiruStarted())
+		throw HonaAlreadyStartedException("HiruStarted doesn't started ");
+	QtConcurrent::run(this, &HonaLowLevelAPI::hiruMainThread);
+	setHiruIsStarted(true);
 }
 
 /*************************************************************************************************/
@@ -126,62 +114,100 @@ void HonaLowLevelAPI::init()
 /*************************************************************************************************/
 void HonaLowLevelAPI::writeSettingToRegisters(HonaSettings& settings)
 {
-	honaRegisterBuffer[0] = 0x00000000;
+	honaRegisterBuffer.clear();
+	honaRegisterBuffer.insert(0, 0x00000000);
 	/************************************************************************/
 	if(settings.hiruSettings.recordStard == recorderStart::selfTestCounter)
-		honaRegisterBuffer[0] = 0x80000000;
+		honaRegisterBuffer.insert(0, 0x80000000);
 	else
-		honaRegisterBuffer[0] = 0x7FFFFFFF;
+		honaRegisterBuffer.insert(0, 0x7FFFFFFF);
 	/************************************************************************/
 	if(settings.hiruSettings.recordChannel == drxDeviceIfChannel::ifChannel12)
-		honaRegisterBuffer[0] = 0x20000000;
+		honaRegisterBuffer.insert(0, 0x20000000);
 	else
-		honaRegisterBuffer[0] = 0xDFFFFFFF;
+		honaRegisterBuffer.insert(0, 0xDFFFFFFF);
 	/************************************************************************/
 	if(settings.hiruSettings.recordMode == recorderMode::dualChannel)
-		honaRegisterBuffer[0] = 0x10000000;
+		honaRegisterBuffer.insert(0, 0x10000000);
 	else
-		honaRegisterBuffer[0] = 0xEFFFFFFF;
+		honaRegisterBuffer.insert(0, 0xEFFFFFFF);
 	/************************************************************************/
 
-	honaRegisterBuffer[0] += (settings.hiruSettings.threshold & 0x00000FFF);
-
-	honaRegisterBuffer[1] = settings.hsruSettings.honaInt123CTHR;
-	honaRegisterBuffer[2] = settings.hsruSettings.honaRes123CTHR;
-	honaRegisterBuffer[3] = settings.hsruSettings.honaIntSTHR;
-	honaRegisterBuffer[4] = settings.hsruSettings.honaResSTHR;
-	honaRegisterBuffer[5] = settings.hsruSettings.honaSPTHR;
-	honaRegisterBuffer[6] = settings.hsruSettings.intM4_THR;
-	honaRegisterBuffer[7] = settings.hsruSettings.resM4_THR;
+	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()
 {
-	QtConcurrent::run(this, &HonaLowLevelAPI::hsruReadThread);
-	QtConcurrent::run(this, &HonaLowLevelAPI::hsruUpdateThread);
+	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;
 
-	_isReaderThreadFree = true;
-	_isUpdateThreadFree = true;
+	plxWrapper.deviceDisableInterrupt();
 }
 
 /*************************************************************************************************/
 void HonaLowLevelAPI::hsruReadThread()
 {
+	_hsruLoss = 0;
 	while(true)
 	{
-		if(_isReaderThreadFree)
+		if(_isHsruReaderThreadFree)
 			break;
-		//dosth
+
+		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);
@@ -197,16 +223,707 @@ void HonaLowLevelAPI::hsruUpdateThread()
 		_mutex.lock();
 		_hsruReadDone.wait(&_mutex);
 		_mutex.unlock();
-		if(_isUpdateThreadFree)
+		if(_isHsruUpdateThreadFree)
 			break;
-		//dosth
+		quint32 Doa = 0;
+		Doa = hiruGetDOA();
+		emit signalToTop(honaPacketList, _hsruLoss, Doa);
 		_hsruUpdateAck.wakeAll();
 	}
 }
 
 /*************************************************************************************************/
-int HonaLowLevelAPI::hiruGetDOA()
+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;
 }
 
 /*************************************************************************************************/
diff --git a/Plx/src/LowLevel/HonaPacket.cpp b/Plx/src/LowLevel/HonaPacket.cpp
index 084f80b..25322f6 100644
--- a/Plx/src/LowLevel/HonaPacket.cpp
+++ b/Plx/src/LowLevel/HonaPacket.cpp
@@ -2,105 +2,127 @@
 
 HonaPacket::HonaPacket()
 {
-
 }
+
 /*************************************************************************************************/
-honaPacketType HonaPacket::getPacketType(void)
+honaPacketType HonaPacket::getPacketType()
 {
-    return m_PacketType;
+	return m_PacketType;
 }
- void HonaPacket::setPacketType(honaPacketType &temp)
+
+void HonaPacket::setPacketType(honaPacketType temp)
 {
-    m_PacketType = temp;
+	m_PacketType = temp;
 }
+
 /*************************************************************************************************/
- quint32 HonaPacket::getPacketNumber(void)
- {
-     return m_PacketNumber;
- }
-  void HonaPacket::setPacketNumber(quint32 temp)
- {
-     m_PacketNumber = temp;
- }
+quint32 HonaPacket::getPacketNumber()
+{
+	return m_PacketNumber;
+}
+
+void HonaPacket::setPacketNumber(quint32 temp)
+{
+	m_PacketNumber = temp;
+}
+
 /*************************************************************************************************/
-  qulonglong HonaPacket::getToa(void)
-  {
-      return m_Toa;
-  }
-  void HonaPacket::setToa(qulonglong temp)
-  {
-       m_Toa = temp;
-  }
+qulonglong HonaPacket::getToa()
+{
+	return m_Toa;
+}
+
+void HonaPacket::setToa(qulonglong temp)
+{
+	m_Toa = temp;
+}
+
 /*************************************************************************************************/
-  quint32 HonaPacket::getDoa(void)
-  {
-      return m_Doa;
-  }
-  void HonaPacket::setDoa(quint32 temp)
-  {
-       m_Doa = temp;
-  }
+quint32 HonaPacket::getDoa()
+{
+	return m_Doa;
+}
+
+void HonaPacket::setDoa(quint32 temp)
+{
+	m_Doa = temp;
+}
+
 /*************************************************************************************************/
-  quint32 HonaPacket::getPa1(void)
-  {
-      return m_Pa1;
-  }
-  void HonaPacket::setPa1(quint32 temp)
-  {
-       m_Pa1 = temp;
-  }
+quint32 HonaPacket::getPa1()
+{
+	return m_Pa1;
+}
+
+void HonaPacket::setPa1(quint32 temp)
+{
+	m_Pa1 = temp;
+}
+
 /*************************************************************************************************/
-  quint32 HonaPacket::getPa2(void)
-  {
-      return m_Pa2;
-  }
-  void HonaPacket::setPa2(quint32 temp)
-  {
-       m_Pa2 = temp;
-  }
+quint32 HonaPacket::getPa2()
+{
+	return m_Pa2;
+}
+
+void HonaPacket::setPa2(quint32 temp)
+{
+	m_Pa2 = temp;
+}
+
 /*************************************************************************************************/
-  quint32 HonaPacket::getPa3(void)
-  {
-      return m_Pa3;
-  }
-  void HonaPacket::setPa3(quint32 temp)
-  {
-       m_Pa3= temp;
-  }
+quint32 HonaPacket::getPa3()
+{
+	return m_Pa3;
+}
+
+void HonaPacket::setPa3(quint32 temp)
+{
+	m_Pa3 = temp;
+}
+
 /*************************************************************************************************/
-  quint32 HonaPacket::getPa4(void)
-  {
-      return m_Pa4;
-  }
-  void HonaPacket::setPa4(quint32 temp)
-  {
-       m_Pa4= temp;
-  }
+quint32 HonaPacket::getPa4()
+{
+	return m_Pa4;
+}
+
+void HonaPacket::setPa4(quint32 temp)
+{
+	m_Pa4 = temp;
+}
+
 /*************************************************************************************************/
-  quint32 HonaPacket::getCode(void)
-  {
-      return m_Code;
-  }
-  void HonaPacket::setCode(quint32 temp)
-  {
-       m_Code = temp;
-  }
+quint32 HonaPacket::getCode()
+{
+	return m_Code;
+}
+
+void HonaPacket::setCode(quint32 temp)
+{
+	m_Code = temp;
+}
+
 /*************************************************************************************************/
-  quint32 HonaPacket::getCodeL(void)
-  {
-      return m_CodeL;
-  }
-  void HonaPacket::setCodeL(quint32 temp)
-  {
-       m_CodeL = temp;
-  }
+quint32 HonaPacket::getCodeL()
+{
+	return m_CodeL;
+}
+
+void HonaPacket::setCodeL(quint32 temp)
+{
+	m_CodeL = temp;
+}
+
 /*************************************************************************************************/
-  quint32 HonaPacket::getCodeM(void)
-  {
-      return m_CodeM;
-  }
-  void HonaPacket::setCodeM(quint32 temp)
-  {
-       m_CodeM= temp;
-  }
+quint32 HonaPacket::getCodeM()
+{
+	return m_CodeM;
+}
+
+void HonaPacket::setCodeM(quint32 temp)
+{
+	m_CodeM = temp;
+}
+
 /*************************************************************************************************/

From e806f5dca5339e55bffa51b321269edfe1ffd9d8 Mon Sep 17 00:00:00 2001
From: Alireza <nikolateslasoul@gmail.com>
Date: Wed, 15 Dec 2021 11:00:07 +0330
Subject: [PATCH 2/3] work on honaapilowlevel honaapi

---
 Plx/Plx.pro                                |  13 +-
 Plx/include/API/HonaAPI.h                  |  40 +++++
 Plx/include/LowLevel/HonaLowLevelAPI.h     |   1 +
 Plx/include/LowLevel/HonaPacket.h          |   6 +-
 Plx/include/LowLevel/HonaPacket.h.autosave |  62 -------
 Plx/include/LowLevel/Utils/Utils.h         |   2 +-
 Plx/src/API/HonaAPI.cpp                    | 183 +++++++++++++++++++++
 Plx/src/LowLevel/HonaLowLevelAPI.cpp       | 165 ++++++++++++-------
 PlxBoard.pro                               |   2 +-
 Test/MainWindow.cpp                        |  13 +-
 Test/MainWindow.h                          |  18 +-
 Test/MainWindow.ui                         |  44 ++++-
 Test/Test.pro                              |   5 -
 Test/main.cpp                              |   8 +-
 14 files changed, 409 insertions(+), 153 deletions(-)
 create mode 100644 Plx/include/API/HonaAPI.h
 delete mode 100644 Plx/include/LowLevel/HonaPacket.h.autosave
 create mode 100644 Plx/src/API/HonaAPI.cpp

diff --git a/Plx/Plx.pro b/Plx/Plx.pro
index 82f08e8..a9ec7ed 100644
--- a/Plx/Plx.pro
+++ b/Plx/Plx.pro
@@ -17,12 +17,15 @@ DEFINES += QT_DEPRECATED_WARNINGS
 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
 
 SOURCES += \
-    $$files(*.cpp, true) \ \
-    src/Wrapper/PlxWrapper.cpp
+    $$files(*.cpp, true) \ \ \
+
+
 
 
 HEADERS += \
-    $$files(*.h, true) \
+    $$files(*.h, true) \ \ \
+
+
 
 INCLUDEPATH += $$PWD/include
 
@@ -32,3 +35,7 @@ unix {
     target.path = $$[QT_INSTALL_PLUGINS]/generic
 }
 !isEmpty(target.path): INSTALLS += target
+
+
+
+
diff --git a/Plx/include/API/HonaAPI.h b/Plx/include/API/HonaAPI.h
new file mode 100644
index 0000000..1a7d61c
--- /dev/null
+++ b/Plx/include/API/HonaAPI.h
@@ -0,0 +1,40 @@
+#ifndef HONAAPI_H
+#define HONAAPI_H
+
+#include <QObject>
+
+#include "LowLevel/Setting/Setting.h"
+#include "include/LowLevel/Exception/HonaAlreadyStartedException.h"
+#include "include/LowLevel/Exception/HonaException.h"
+#include "include/LowLevel/Utils/Utils.h"
+#include "include/LowLevel/HonaLowLevelAPI.h"
+
+class HonaAPI : public QObject
+{
+	Q_OBJECT
+
+private:
+	HonaLowLevelAPI _honaLowLevelAPI;
+
+public:
+	explicit HonaAPI(QObject* parent = nullptr);
+	ApiResult isHsruStarted();
+	ApiResult isHiruStarted();
+	ApiResult deviceReset();
+
+	ApiResult setConfig(HonaSettings& settings);
+	ApiResult getConfig(HonaSettings& settings);
+	ApiResult getSwVersion(QString& swVerion);
+	ApiResult getDeviceId(QString& deviceId);
+	ApiResult hsruStart();
+	ApiResult hiruStart();
+	ApiResult hsruStop();
+	ApiResult init();
+
+signals:
+	//uncrustify off
+	public	slots:
+	//uncrustify on
+};
+
+#endif //HONAAPI_H
diff --git a/Plx/include/LowLevel/HonaLowLevelAPI.h b/Plx/include/LowLevel/HonaLowLevelAPI.h
index 8fcc097..052b7e8 100644
--- a/Plx/include/LowLevel/HonaLowLevelAPI.h
+++ b/Plx/include/LowLevel/HonaLowLevelAPI.h
@@ -89,6 +89,7 @@ public:
 	QString getDeviceId();
 	void hsruStart();
 	void hiruStart();
+	void hsruStop();
 	void init();
 
 	bool getHsruIsStarted() const;
diff --git a/Plx/include/LowLevel/HonaPacket.h b/Plx/include/LowLevel/HonaPacket.h
index 505a033..65381c6 100644
--- a/Plx/include/LowLevel/HonaPacket.h
+++ b/Plx/include/LowLevel/HonaPacket.h
@@ -20,12 +20,13 @@ private:
 	quint32 m_Code;
 	quint32 m_CodeL;
 	quint32 m_CodeM;
+	quint8 m4Status;
 
 public:
 	HonaPacket();
 	/******************************************************************/
 	honaPacketType getPacketType();
-	void setPacketType(honaPacketType& temp);
+	void setPacketType(honaPacketType temp);
 	/******************************************************************/
 	quint32 getPacketNumber();
 	void setPacketNumber(quint32 temp);
@@ -57,6 +58,9 @@ public:
 	quint32 getCodeM();
 	void setCodeM(quint32 temp);
 	/******************************************************************/
+	quint8 getm4Status();
+	void setm4Status(quint8 temp);
+	/******************************************************************/
 };
 
 #endif //HONAPACKET_H
diff --git a/Plx/include/LowLevel/HonaPacket.h.autosave b/Plx/include/LowLevel/HonaPacket.h.autosave
deleted file mode 100644
index 7860765..0000000
--- a/Plx/include/LowLevel/HonaPacket.h.autosave
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef HONAPACKET_H
-#define HONAPACKET_H
-
-#include <QtGlobal>
-
-#include "include/LowLevel/Utils/Utils.h"
-
-class HonaPacket
-{
-private:
-	qreal toaClock;
-	honaPacketType m_PacketType;
-	quint32 m_PacketNumber;
-	qulonglong m_Toa;
-	quint32 m_Doa;
-	quint32 m_Pa1;
-	quint32 m_Pa2;
-	quint32 m_Pa3;
-	quint32 m_Pa4;
-	quint32 m_Code;
-	quint32 m_CodeL;
-	quint32 m_CodeM;
-
-public:
-	HonaPacket();
-	/******************************************************************/
-	honaPacketType getPacketType();
-	void setPacketType(honaPacketType temp);
-	/******************************************************************/
-	quint32 getPacketNumber();
-	void setPacketNumber(quint32 temp);
-	/******************************************************************/
-	qulonglong getToa();
-	void setToa(qulonglong temp);
-	/******************************************************************/
-	quint32 getDoa();
-	void setDoa(quint32 temp);
-	/******************************************************************/
-	quint32 getPa1();
-	void setPa1(quint32 temp);
-	/******************************************************************/
-	quint32 getPa2();
-	void setPa2(quint32 temp);
-	/******************************************************************/
-	quint32 getPa3();
-	void setPa3(quint32 temp);
-	/******************************************************************/
-	quint32 getPa4();
-	void setPa4(quint32 temp);
-	/******************************************************************/
-	quint32 getCode();
-	void setCode(quint32 temp);
-	/******************************************************************/
-	quint32 getCodeL();
-	void setCodeL(quint32 temp);
-	/******************************************************************/
-	quint32 getCodeM();
-	void setCodeM(quint32 temp);
-	/******************************************************************/
-};
-
-#endif //HONAPACKET_H
diff --git a/Plx/include/LowLevel/Utils/Utils.h b/Plx/include/LowLevel/Utils/Utils.h
index 8617982..1e9a4c6 100644
--- a/Plx/include/LowLevel/Utils/Utils.h
+++ b/Plx/include/LowLevel/Utils/Utils.h
@@ -4,7 +4,7 @@
 #include <QtCore>
 
 /*************************************************************************************************/
-enum apiResult : quint8
+enum ApiResult : quint8
 {
 	success,
 	alreadyStarted,
diff --git a/Plx/src/API/HonaAPI.cpp b/Plx/src/API/HonaAPI.cpp
new file mode 100644
index 0000000..9ea7226
--- /dev/null
+++ b/Plx/src/API/HonaAPI.cpp
@@ -0,0 +1,183 @@
+#include "include/API/HonaAPI.h"
+
+HonaAPI::HonaAPI(QObject* parent) : QObject(parent)
+{
+}
+
+/*************************************************************************************************/
+ApiResult HonaAPI::isHsruStarted()
+{
+	try {
+		if(_honaLowLevelAPI.isHsruStarted())
+			return ApiResult::success;
+	}
+	catch(HonaException ex)
+	{
+		return ApiResult::error;
+	}
+}
+
+/*************************************************************************************************/
+ApiResult HonaAPI::isHiruStarted()
+{
+	try {
+		if(_honaLowLevelAPI.isHiruStarted())
+			return ApiResult::success;
+	}
+	catch(HonaException ex)
+	{
+		return ApiResult::error;
+	}
+}
+
+/*************************************************************************************************/
+ApiResult HonaAPI::deviceReset()
+{
+	try {
+		_honaLowLevelAPI.deviceReset();
+	}
+	catch(HonaException ex)
+	{
+		return ApiResult::error;
+	}
+	catch(HonaAlreadyStartedException ex)
+	{
+		return ApiResult::error;
+	}
+
+	return ApiResult::success;
+}
+
+/*************************************************************************************************/
+ApiResult HonaAPI::setConfig(HonaSettings& settings)
+{
+	try {
+		_honaLowLevelAPI.setConfig(settings);
+	}
+	catch(HonaException ex)
+	{
+		return ApiResult::error;
+	}
+	catch(HonaAlreadyStartedException ex)
+	{
+		return ApiResult::error;
+	}
+
+	return ApiResult::success;
+}
+
+/*************************************************************************************************/
+ApiResult HonaAPI::getConfig(HonaSettings& settings)
+{
+	try {
+		settings = _honaLowLevelAPI.getConfig();
+	}
+	catch(HonaException ex)
+	{
+		return ApiResult::error;
+	}
+
+	return ApiResult::success;
+}
+
+/*************************************************************************************************/
+ApiResult HonaAPI::getSwVersion(QString& swVerion)
+{
+	try {
+		swVerion = _honaLowLevelAPI.getSwVersion();
+	}
+	catch(HonaException ex)
+	{
+		return ApiResult::error;
+	}
+
+	return ApiResult::success;
+}
+
+/*************************************************************************************************/
+ApiResult HonaAPI::getDeviceId(QString& deviceId)
+{
+	try {
+		deviceId = _honaLowLevelAPI.getDeviceId();
+	}
+	catch(HonaException ex)
+	{
+		return ApiResult::error;
+	}
+
+	return ApiResult::success;
+}
+
+/*************************************************************************************************/
+ApiResult HonaAPI::hsruStart()
+{
+	try {
+		_honaLowLevelAPI.hsruStart();
+	}
+	catch(HonaException ex)
+	{
+		return ApiResult::error;
+	}
+	catch(HonaAlreadyStartedException ex)
+	{
+		return ApiResult::error;
+	}
+
+	return ApiResult::success;
+}
+
+/*************************************************************************************************/
+ApiResult HonaAPI::hiruStart()
+{
+	try {
+		_honaLowLevelAPI.hiruStart();
+	}
+	catch(HonaException ex)
+	{
+		return ApiResult::error;
+	}
+	catch(HonaAlreadyStartedException ex)
+	{
+		return ApiResult::error;
+	}
+
+	return ApiResult::success;
+}
+
+/*************************************************************************************************/
+ApiResult HonaAPI::hsruStop()
+{
+	try {
+		_honaLowLevelAPI.hsruStop();
+	}
+	catch(HonaException ex)
+	{
+		return ApiResult::error;
+	}
+	catch(HonaAlreadyStartedException ex)
+	{
+		return ApiResult::error;
+	}
+
+	return ApiResult::success;
+}
+
+/*************************************************************************************************/
+ApiResult HonaAPI::init()
+{
+	try {
+		_honaLowLevelAPI.init();
+	}
+	catch(HonaException ex)
+	{
+		return ApiResult::error;
+	}
+	catch(HonaAlreadyStartedException ex)
+	{
+		return ApiResult::error;
+	}
+
+	return ApiResult::success;
+}
+
+/*************************************************************************************************/
diff --git a/Plx/src/LowLevel/HonaLowLevelAPI.cpp b/Plx/src/LowLevel/HonaLowLevelAPI.cpp
index e31da29..97804b7 100644
--- a/Plx/src/LowLevel/HonaLowLevelAPI.cpp
+++ b/Plx/src/LowLevel/HonaLowLevelAPI.cpp
@@ -56,17 +56,27 @@ bool HonaLowLevelAPI::isHiruStarted()
 void HonaLowLevelAPI::deviceReset()
 {
 	if(!plxWrapper.deviceReset())
-		throw HonaAlreadyStartedException("reset Doesnt Occur");
+		throw HonaAlreadyStartedException("Reset Doesnt Occur");
 }
 
 /*************************************************************************************************/
 void HonaLowLevelAPI::setConfig(HonaSettings& settings)
 {
-	plxWrapper.deviceReadRegister(0x10000000, honaRegisterBuffer, 8);
+	if(!plxWrapper.deviceReadRegister(0x10000000, honaRegisterBuffer, 8))
+	{
+		throw HonaAlreadyStartedException("DeviceReadRegister Doesnt Occur");
+	}
 	_honaSetting = settings;
 	writeSettingToRegisters(settings);
-	plxWrapper.deviceWriteRegister(0x10000000, honaRegisterBuffer);
-	plxWrapper.deviceReadRegister(0x10000000, honaRegisterBuffer, 8);
+	if(!plxWrapper.deviceWriteRegister(0x10000000, honaRegisterBuffer))
+	{
+		throw HonaAlreadyStartedException("DeviceWriteRegister Doesnt Occur");
+	}
+
+	if(!plxWrapper.deviceReadRegister(0x10000000, honaRegisterBuffer, 8))
+	{
+		throw HonaAlreadyStartedException("DeviceReadRegister Doesnt Occur");
+	}
 }
 
 /*************************************************************************************************/
@@ -92,7 +102,7 @@ QString HonaLowLevelAPI::getDeviceId()
 void HonaLowLevelAPI::hsruStart()
 {
 	if(!isHsruStarted())
-		throw HonaAlreadyStartedException("HsruStarted doesn't started ");
+		throw HonaException("HsruStarted doesn't started ");
 	QtConcurrent::run(this, &HonaLowLevelAPI::hsruMainThread);
 	setHsruIsStarted(true);
 }
@@ -101,14 +111,26 @@ void HonaLowLevelAPI::hsruStart()
 void HonaLowLevelAPI::hiruStart()
 {
 	if(!isHiruStarted())
-		throw HonaAlreadyStartedException("HiruStarted doesn't started ");
+		throw HonaException("HiruStarted doesn't started ");
 	QtConcurrent::run(this, &HonaLowLevelAPI::hiruMainThread);
 	setHiruIsStarted(true);
 }
 
+/*************************************************************************************************/
+void HonaLowLevelAPI::hsruStop()
+{
+	if(isHiruStarted())
+		setHsruIsStarted(false);
+	_hsruStopEvent.wakeAll();
+}
+
 /*************************************************************************************************/
 void HonaLowLevelAPI::init()
 {
+	if(!plxWrapper.deviceInit(0X9054))
+	{
+		throw HonaAlreadyStartedException("Init Doesnt Occur");
+	}
 }
 
 /*************************************************************************************************/
@@ -134,8 +156,8 @@ void HonaLowLevelAPI::writeSettingToRegisters(HonaSettings& settings)
 	/************************************************************************/
 
 	honaRegisterBuffer.insert(0,
-							  (honaRegisterBuffer.at(0) +
-							   (settings.hiruSettings.threshold & 0x00000FFF)));
+	                          (honaRegisterBuffer.at(0) +
+	                           (settings.hiruSettings.threshold & 0x00000FFF)));
 
 	honaRegisterBuffer.insert(1, settings.hsruSettings.honaInt123CTHR);
 	honaRegisterBuffer.insert(2, settings.hsruSettings.honaRes123CTHR);
@@ -160,7 +182,10 @@ void HonaLowLevelAPI::hsruMainThread()
 		deviceReset();
 		setConfig();
 		deviceReset();
-		plxWrapper.deviceEnableInterrupt();
+		if(!plxWrapper.deviceEnableInterrupt())
+		{
+			throw HonaAlreadyStartedException("DeviceEnableInterrupt Doesnt Occur");
+		}
 
 		QtConcurrent::run(this, &HonaLowLevelAPI::hsruReadThread);
 		QtConcurrent::run(this, &HonaLowLevelAPI::hsruUpdateThread);
@@ -169,7 +194,7 @@ void HonaLowLevelAPI::hsruMainThread()
 	{
 		_isHsruReaderThreadFree = true;
 		_isHsruUpdateThreadFree = true;
-		setHiruIsStarted(false);
+		hsruStop();
 	}
 
 	_mutex.lock();
@@ -178,7 +203,10 @@ void HonaLowLevelAPI::hsruMainThread()
 	_isHsruReaderThreadFree = true;
 	_isHsruUpdateThreadFree = true;
 
-	plxWrapper.deviceDisableInterrupt();
+	if(!plxWrapper.deviceDisableInterrupt())
+	{
+		throw HonaAlreadyStartedException("DeviceEnableInterrupt Doesnt Occur");
+	}
 }
 
 /*************************************************************************************************/
@@ -190,23 +218,35 @@ void HonaLowLevelAPI::hsruReadThread()
 		if(_isHsruReaderThreadFree)
 			break;
 
-		plxWrapper.deviceWaitForInterrupt(1000);
+		if(!plxWrapper.deviceWaitForInterrupt(1000))
+		{
+			throw HonaAlreadyStartedException("DeviceWaitForInterrupt Doesnt Occur");
+		}
 		honaPacketList.clear();
 		_hsruLoss = 0;
-		plxWrapper.deviceOpenPCIChannel();
+		if(!plxWrapper.deviceOpenPCIChannel())
+		{
+			throw HonaAlreadyStartedException("DeviceOpenPCIChannel Doesnt Occur");
+		}
 
 		_hsruLoss += hsruParserInt123C(hsruReadHonaBuffer(honaReceivers::int123C),
-									   honaPacketList);
+		                               honaPacketList);
 		_hsruLoss += hsruParserRes123C(hsruReadHonaBuffer(honaReceivers::res123C),
-									   honaPacketList);
+		                               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();
+		                                   honaPacketList);
+		if(!plxWrapper.deviceClosePCIChannel())
+		{
+			throw HonaAlreadyStartedException("DeviceClosePCIChannel Doesnt Occur");
+		}
+		if(!plxWrapper.deviceEnableInterrupt())
+		{
+			throw HonaAlreadyStartedException("DeviceEnableInterrupt Doesnt Occur");
+		}
 
 		_mutex.lock();
 		_hsruReadDone.wakeAll();
@@ -242,9 +282,6 @@ void HonaLowLevelAPI::hiruMainThread()
 		_mutex.lock();
 		_hsruStopEvent.wait(&_mutex);
 		_mutex.unlock();
-
-		//_isReaderThreadFree = true;
-		//_isUpdateThreadFree = true;
 	}
 }
 
@@ -262,7 +299,10 @@ void HonaLowLevelAPI::hiruUpdateThread()
 quint32 HonaLowLevelAPI::hiruGetDOA()
 {
 	quint32 Doa = 0;
-	plxWrapper.deviceReadRegister(0x30000004, Doa);
+	if(!plxWrapper.deviceReadRegister(0x30000004, Doa))
+	{
+		throw HonaAlreadyStartedException("DeviceReadRegister Doesnt Occur");
+	}
 	Doa = Doa & 0x0000FFFF;
 
 	return Doa;
@@ -270,7 +310,7 @@ quint32 HonaLowLevelAPI::hiruGetDOA()
 
 /*************************************************************************************************/
 quint32 HonaLowLevelAPI::hsruParserInt123C(const QVector<quint32>& honaData,
-										   QList<HonaPacket> honaPacketList)
+                                           QList<HonaPacket> honaPacketList)
 {
 	quint32 lossFound;
 	for(quint32 Ind = 0; Ind < honaData.length(); Ind++)
@@ -282,7 +322,7 @@ quint32 HonaLowLevelAPI::hsruParserInt123C(const QVector<quint32>& honaData,
 			packetLenInt123C = 6;
 			tempHonaPacketInt123C.setPacketNumber(honaData.at(Ind) & 0x0000FFFF);
 			if((tempHonaPacketInt123C.getPacketNumber() !=
-				(lastPNInt123C + 1)) & (lastPNInt123C > 0))
+			    (lastPNInt123C + 1)) & (lastPNInt123C > 0))
 			//& (LastPNInt123C != 65535))
 			{
 				lossFound +=
@@ -301,7 +341,7 @@ quint32 HonaLowLevelAPI::hsruParserInt123C(const QVector<quint32>& honaData,
 		else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextInt123C == 2))
 		{
 			tempHonaPacketInt123C.setToa(((tempHonaPacketInt123C.getToa()) +
-										  (qulonglong)((honaData.at(Ind) & 0x0000FFFF) << 28)));
+			                              (qulonglong)((honaData.at(Ind) & 0x0000FFFF) << 28)));
 
 			tempHonaPacketInt123C.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
 			nextInt123C = 3;
@@ -350,7 +390,7 @@ quint32 HonaLowLevelAPI::hsruParserInt123C(const QVector<quint32>& honaData,
 
 /*************************************************************************************************/
 quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector<quint32>& honaData,
-										   QList<HonaPacket> honaPacketList)
+                                           QList<HonaPacket> honaPacketList)
 {
 	quint32 lossFound = 0;
 	for(quint32 Ind = 0; Ind < honaData.length(); Ind++)
@@ -361,7 +401,7 @@ quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector<quint32>& honaData,
 			packetLenRes123C = 6;
 			tempHonaPacketRes123C.setPacketNumber(honaData.at(Ind) & 0x0000FFFF);
 			if((tempHonaPacketRes123C.getPacketNumber() !=
-				(lastPNRes123C + 1)) & (lastPNRes123C > 0))
+			    (lastPNRes123C + 1)) & (lastPNRes123C > 0))
 			//& (LastPNRes123C != 65535))
 			{
 				lossFound +=
@@ -380,7 +420,7 @@ quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector<quint32>& honaData,
 		else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextRes123C == 2))
 		{
 			tempHonaPacketRes123C.setToa(tempHonaPacketRes123C.getToa() +
-										 (((ulong)(honaData.at(Ind) & 0x0000FFFF)) << 28));
+			                             (((ulong)(honaData.at(Ind) & 0x0000FFFF)) << 28));
 			tempHonaPacketRes123C.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
 			nextRes123C = 3;
 		}
@@ -394,9 +434,9 @@ quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector<quint32>& honaData,
 		{
 			tempHonaPacketRes123C.setPa1(honaData.at(Ind) & 0x0000FFFF);
 			tempHonaPacketRes123C.setPa2(tempHonaPacketRes123C.getPa2() +
-										 ((honaData.at(Ind) & 0x000F0000) >> 4));
+			                             ((honaData.at(Ind) & 0x000F0000) >> 4));
 			tempHonaPacketRes123C.setPa3(tempHonaPacketRes123C.getPa3() +
-										 ((honaData.at(Ind) & 0x00F00000) >> 8));
+			                             ((honaData.at(Ind) & 0x00F00000) >> 8));
 			nextRes123C = 5;
 		}
 		else if(((honaData.at(Ind) & 0xF0000000) == 0x50000000) && (nextRes123C == 5))
@@ -430,7 +470,7 @@ quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector<quint32>& honaData,
 
 /*************************************************************************************************/
 quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
-										QList<HonaPacket> honaPacketList)
+                                        QList<HonaPacket> honaPacketList)
 {
 	uint lossFound = 0;
 	for(quint32 Ind = 0; Ind < honaData.length(); Ind++)
@@ -468,7 +508,7 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
 		else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextIntS == 2))
 		{
 			tempHonaPacketIntS.setToa(tempHonaPacketIntS.getToa() +
-									  (((ulong)(honaData.at(Ind) & 0x0000FFFF)) << 28));
+			                          (((ulong)(honaData.at(Ind) & 0x0000FFFF)) << 28));
 			tempHonaPacketIntS.setToa((honaData.at(Ind) & 0x0FFF0000) >> 16);
 			nextIntS = 3;
 		}
@@ -479,13 +519,13 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
 			nextIntS = 4;
 		}
 		else if(((honaData.at(static_cast<int>(Ind)) & 0xF0000000) == 0x40000000) &&
-				(nextIntS == 4))
+		        (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));
+			                          ((honaData.at(Ind) & 0x00F00000) >> 4));
 			nextIntS = 5;
 		}
 		else if(((honaData.at(Ind) & 0xF0000000) == 0x50000000) && (nextIntS == 5))
@@ -497,7 +537,7 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
 		else if(((honaData.at(Ind) & 0xF0000000) == 0x60000000) && (nextIntS == 6))
 		{
 			tempHonaPacketIntS.setCodeM(tempHonaPacketIntS.getCodeM() +
-										((ulong)(honaData.at(Ind) & 0x0FFFFFFF)) << 36);
+			                            ((ulong)(honaData.at(Ind) & 0x0FFFFFFF)) << 36);
 			tempHonaPacketIntS.setCodeL(0);
 			nextIntS = 7;
 		}
@@ -510,7 +550,7 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
 		else if(((honaData.at(Ind) & 0xF0000000) == 0x80000000) && (nextIntS == 8))
 		{
 			tempHonaPacketIntS.setCodeM(tempHonaPacketIntS.getCodeM() +
-										((ulong)(honaData.at(Ind) & 0x0FFFFFFF)) << 36);
+			                            ((ulong)(honaData.at(Ind) & 0x0FFFFFFF)) << 36);
 			nextIntS = 9;
 		}
 		else if(honaData.at(Ind) == 0xEEEEEEEE)
@@ -538,7 +578,7 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
 
 /*************************************************************************************************/
 quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
-										QList<HonaPacket> honaPacketList)
+                                        QList<HonaPacket> honaPacketList)
 {
 	uint lossFound = 0;
 	for(quint32 Ind = 0; Ind < honaData.length(); Ind++)
@@ -576,8 +616,8 @@ quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
 		else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextResS == 2))
 		{
 			tempHonaPacketResS.setDoa(tempHonaPacketResS.getDoa() +
-									  ((static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF)) <<
-									   28));
+			                          ((static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF)) <<
+			                           28));
 			tempHonaPacketResS.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
 			nextResS = 3;
 		}
@@ -593,7 +633,7 @@ quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
 			tempHonaPacketResS.setPa2(tempHonaPacketResS.getPa2() + ((honaData.at(
 																		  Ind) & 0x000F0000)));
 			tempHonaPacketResS.setPa3(tempHonaPacketResS.getPa3() +
-									  ((honaData.at(Ind) & 0x00F00000) >> 4));
+			                          ((honaData.at(Ind) & 0x00F00000) >> 4));
 			nextResS = 5;
 		}
 		else if(((honaData.at(Ind) & 0xF0000000) == 0x50000000) && (nextResS == 5))
@@ -606,7 +646,7 @@ quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
 		else if(((honaData.at(Ind) & 0xF0000000) == 0x60000000) && (nextResS == 6))
 		{
 			tempHonaPacketResS.setCodeM(tempHonaPacketResS.getCodeM() +
-										(static_cast<qulonglong>(honaData.at(
+			                            (static_cast<qulonglong>(honaData.at(
 																	 Ind) & 0x0FFFFFFF)) << 36);
 			tempHonaPacketResS.setCodeL(0);
 			nextResS = 7;
@@ -621,7 +661,7 @@ quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
 		else if(((honaData.at(Ind) & 0xF0000000) == 0x80000000) && (nextResS == 8))
 		{
 			tempHonaPacketResS.setCodeM(tempHonaPacketResS.getCodeM() +
-										(static_cast<qulonglong>(honaData.at(
+			                            (static_cast<qulonglong>(honaData.at(
 																	 Ind) & 0x0FFFFFFF)) << 36);
 			nextResS = 9;
 		}
@@ -650,7 +690,7 @@ quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
 
 /*************************************************************************************************/
 quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData,
-										QList<HonaPacket> honaPacketList)
+                                        QList<HonaPacket> honaPacketList)
 {
 	uint lossFound = 0;
 
@@ -679,8 +719,8 @@ quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData,
 		else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextInt4 == 2))
 		{
 			tempHonaPacketInt4.setToa(tempHonaPacketInt4.getToa() +
-									  ((static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF)) <<
-									   28));
+			                          ((static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF)) <<
+			                           28));
 			tempHonaPacketInt4.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
 			nextInt4 = 3;
 		}
@@ -694,9 +734,9 @@ quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData,
 		{
 			tempHonaPacketInt4.setPa1(honaData.at(Ind) & 0x0000FFFF);
 			tempHonaPacketInt4.setPa2(tempHonaPacketInt4.getPa2() +
-									  ((honaData.at(Ind) & 0x000F0000) >> 4));
+			                          ((honaData.at(Ind) & 0x000F0000) >> 4));
 			tempHonaPacketInt4.setPa3(tempHonaPacketInt4.getPa3() +
-									  ((honaData.at(Ind) & 0x00F00000) >> 8));
+			                          ((honaData.at(Ind) & 0x00F00000) >> 8));
 			nextInt4 = 5;
 		}
 		else if(((honaData.at(Ind) & 0xF0000000) == 0x50000000) && (nextInt4 == 5))
@@ -709,9 +749,9 @@ quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData,
 		{
 			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));
+			                            ((static_cast<qulonglong>(honaData.at(Ind) & 0x000F0000)) <<
+			                             12));
+			tempHonaPacketInt4.setm4Status((quint8)((honaData.at(Ind) & 0x0F000000) >> 20));
 			nextInt4 = 7;
 		}
 		else if(honaData.at(Ind) == 0xEEEEEEEE)
@@ -738,7 +778,7 @@ quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData,
 }
 
 quint32 HonaLowLevelAPI::hsruParserRes4(const QVector<quint32>& honaData,
-										QList<HonaPacket> honaPacketList)
+                                        QList<HonaPacket> honaPacketList)
 {
 	uint lossFound = 0;
 	for(quint32 Ind = 0; Ind < honaData.length(); Ind++)
@@ -766,8 +806,8 @@ quint32 HonaLowLevelAPI::hsruParserRes4(const QVector<quint32>& honaData,
 		else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextRes4 == 2))
 		{
 			tempHonaPacketRes4.setToa(tempHonaPacketRes4.getToa() +
-									  (static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF) <<
-									   28));
+			                          (static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF) <<
+			                           28));
 			tempHonaPacketRes4.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
 			nextRes4 = 3;
 		}
@@ -811,7 +851,7 @@ quint32 HonaLowLevelAPI::hsruParserRes4(const QVector<quint32>& honaData,
 
 /*************************************************************************************************/
 quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector<quint32>& honaData,
-											   QList<HonaPacket> honaPacketList)
+                                               QList<HonaPacket> honaPacketList)
 {
 	uint lossFound = 0;
 	for(quint32 Ind = 0; Ind < honaData.length(); Ind++)
@@ -822,7 +862,7 @@ quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector<quint32>& honaData,
 			packetLenSinglePulse = 5;
 			tempHonaPacketSinglePulse.setPacketNumber(honaData.at(Ind) & 0x0000FFFF);
 			if((tempHonaPacketSinglePulse.getPacketNumber() !=
-				(lastPNSinglePulse + 1)) & (lastPNSinglePulse > 0))
+			    (lastPNSinglePulse + 1)) & (lastPNSinglePulse > 0))
 				;
 			{
 				lossFound +=
@@ -838,14 +878,14 @@ quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector<quint32>& honaData,
 		else if(((honaData.at(Ind) & 0xF0000000) == 0x10000000) && (nextSinglePulse == 1))
 		{
 			tempHonaPacketSinglePulse.setToa(static_cast<qulonglong>(honaData.at(Ind) &
-																	 0x0FFFFFFF));
+			                                                         0x0FFFFFFF));
 			nextSinglePulse = 2;
 		}
 		else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextSinglePulse == 2))
 		{
 			tempHonaPacketSinglePulse.setToa(tempHonaPacketSinglePulse.getToa() +
-											 ((static_cast<qulonglong>(honaData.at(Ind) &
-																	   0x0000FFFF)) << 28));
+			                                 ((static_cast<qulonglong>(honaData.at(Ind) &
+			                                                           0x0000FFFF)) << 28));
 			tempHonaPacketSinglePulse.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
 			nextSinglePulse = 3;
 		}
@@ -859,9 +899,9 @@ quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector<quint32>& honaData,
 		{
 			tempHonaPacketSinglePulse.setPa1(honaData.at(Ind) & 0x0000FFFF);
 			tempHonaPacketSinglePulse.setPa2(tempHonaPacketSinglePulse.getPa2() +
-											 ((honaData.at(Ind) & 0x000F0000) >> 4));                                     //NOTE: shifted by 4
+			                                 ((honaData.at(Ind) & 0x000F0000) >> 4));                                     //NOTE: shifted by 4
 			tempHonaPacketSinglePulse.setPa3(tempHonaPacketSinglePulse.getPa3() +
-											 ((honaData.at(Ind) & 0x00F00000) >> 8));                                     //NOTE: shifted by 8
+			                                 ((honaData.at(Ind) & 0x00F00000) >> 8));                                     //NOTE: shifted by 8
 			nextSinglePulse = 5;
 		}
 		else if(honaData.at(Ind) == 0xEEEEEEEE)
@@ -912,7 +952,10 @@ QVector<quint32> HonaLowLevelAPI::hsruReadHonaBuffer(honaReceivers receiver)
 	else
 		throw HonaException("honaReceivers is Not Valid");
 
-	plxWrapper.deviceReadMemory(address, honaData, honaData.size());
+	if(!plxWrapper.deviceReadMemory(address, honaData, honaData.size()))
+	{
+		throw HonaAlreadyStartedException("DeviceReadMemory Doesnt Occur");
+	}
 
 	return honaData;
 }
diff --git a/PlxBoard.pro b/PlxBoard.pro
index 24a39c2..e511f93 100644
--- a/PlxBoard.pro
+++ b/PlxBoard.pro
@@ -1,7 +1,7 @@
 TEMPLATE = subdirs
 
 SUBDIRS += \
-    Plx\
+    Plx \
     Test
 Test.depends += Plx
 
diff --git a/Test/MainWindow.cpp b/Test/MainWindow.cpp
index ff126e8..060284c 100644
--- a/Test/MainWindow.cpp
+++ b/Test/MainWindow.cpp
@@ -1,15 +1,18 @@
 #include "MainWindow.h"
 #include "ui_MainWindow.h"
 
-MainWindow::MainWindow(QWidget *parent)
-    : QMainWindow(parent)
-    , ui(new Ui::MainWindow)
+MainWindow::MainWindow(QWidget* parent)
+	: QMainWindow(parent)
+	, ui(new Ui::MainWindow)
 {
-    ui->setupUi(this);
+	ui->setupUi(this);
 }
 
 MainWindow::~MainWindow()
 {
-    delete ui;
+	delete ui;
 }
 
+void MainWindow::on_testPLX_clicked()
+{
+}
diff --git a/Test/MainWindow.h b/Test/MainWindow.h
index 4643e32..4c11b82 100644
--- a/Test/MainWindow.h
+++ b/Test/MainWindow.h
@@ -4,18 +4,24 @@
 #include <QMainWindow>
 
 QT_BEGIN_NAMESPACE
-namespace Ui { class MainWindow; }
+namespace Ui { class MainWindow;
+}
 QT_END_NAMESPACE
 
 class MainWindow : public QMainWindow
 {
-    Q_OBJECT
+	Q_OBJECT
 
 public:
-    MainWindow(QWidget *parent = nullptr);
-    ~MainWindow();
+	MainWindow(QWidget* parent = nullptr);
+	~MainWindow();
 
+	//uncrustify off
+private	slots:
+		void on_testPLX_clicked();
+	//uncrustify on
 private:
-    Ui::MainWindow *ui;
+	Ui::MainWindow* ui;
 };
-#endif // MAINWINDOW_H
+
+#endif //MAINWINDOW_H
diff --git a/Test/MainWindow.ui b/Test/MainWindow.ui
index b232854..d768678 100644
--- a/Test/MainWindow.ui
+++ b/Test/MainWindow.ui
@@ -6,15 +6,51 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>800</width>
-    <height>600</height>
+    <width>311</width>
+    <height>281</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>MainWindow</string>
   </property>
-  <widget class="QWidget" name="centralwidget"/>
-  <widget class="QMenuBar" name="menubar"/>
+  <widget class="QWidget" name="centralwidget">
+   <widget class="QPushButton" name="testPLX">
+    <property name="geometry">
+     <rect>
+      <x>100</x>
+      <y>120</y>
+      <width>89</width>
+      <height>25</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Test PLX</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label">
+    <property name="geometry">
+     <rect>
+      <x>60</x>
+      <y>30</y>
+      <width>171</width>
+      <height>51</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:20pt;&quot;&gt;Test PLX&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+    </property>
+   </widget>
+  </widget>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>311</width>
+     <height>22</height>
+    </rect>
+   </property>
+  </widget>
   <widget class="QStatusBar" name="statusbar"/>
  </widget>
  <resources/>
diff --git a/Test/Test.pro b/Test/Test.pro
index 17267a1..b6fdfca 100644
--- a/Test/Test.pro
+++ b/Test/Test.pro
@@ -22,14 +22,9 @@ SOURCES += \
 HEADERS += \
     MainWindow.h
 
-INCLUDEPATH += $$PWD/../Plx/include
-
 FORMS += \
     MainWindow.ui
 
-LIBS += -L$$OUT_PWD/../Plx/ -lPlx
-PRE_TARGETDEPS += $$OUT_PWD/../Plx/libPlx.a
-
 # Default rules for deployment.
 qnx: target.path = /tmp/$${TARGET}/bin
 else: unix:!android: target.path = /opt/$${TARGET}/bin
diff --git a/Test/main.cpp b/Test/main.cpp
index 0a0916f..723a9ab 100644
--- a/Test/main.cpp
+++ b/Test/main.cpp
@@ -4,8 +4,8 @@
 
 int main(int argc, char *argv[])
 {
-    QApplication a(argc, argv);
-    MainWindow w;
-    w.show();
-    return a.exec();
+	QApplication a(argc, argv);
+	MainWindow w;
+	w.show();
+	return a.exec();
 }

From 64f6e7f618eb5a6f1f63a4c5f377b46f1e7bc126 Mon Sep 17 00:00:00 2001
From: Alireza <nikolateslasoul@gmail.com>
Date: Thu, 16 Dec 2021 14:31:06 +0330
Subject: [PATCH 3/3] Update LAst Change after crash Computer

---
 Plx/Plx.pro                                   |  19 +-
 Plx/include/API/HonaAPI.h                     |  13 +-
 .../Exception/HonaAlreadyStartedException.h   |   3 +
 .../LowLevel/Exception/HonaBusyException.h    |  24 -
 Plx/include/LowLevel/HonaLowLevelAPI.h        |  43 +-
 Plx/include/LowLevel/HonaPacket.h             |   6 +-
 Plx/include/LowLevel/Setting/Setting.h        |   7 +-
 Plx/include/Wrapper/PlxWrapper.h              |  43 +-
 Plx/src/API/HonaAPI.cpp                       |  11 +-
 Plx/src/LowLevel/HonaLowLevelAPI.cpp          | 549 +++++++++---------
 Plx/src/LowLevel/HonaPacket.cpp               |  13 +-
 Plx/src/Wrapper/PlxWrapper.cpp                | 146 +++--
 Test/MainWindow.cpp                           |  54 ++
 Test/MainWindow.h                             |  17 +-
 Test/MainWindow.ui                            |  46 +-
 Test/Test.pro                                 |  15 +
 Test2/MainWindow.cpp                          |  15 +
 Test2/MainWindow.h                            |  21 +
 Test2/MainWindow.ui                           |  22 +
 Test2/Test2.pro                               |  31 +
 Test2/main.cpp                                |  11 +
 21 files changed, 662 insertions(+), 447 deletions(-)
 delete mode 100644 Plx/include/LowLevel/Exception/HonaBusyException.h
 create mode 100644 Test2/MainWindow.cpp
 create mode 100644 Test2/MainWindow.h
 create mode 100644 Test2/MainWindow.ui
 create mode 100644 Test2/Test2.pro
 create mode 100644 Test2/main.cpp

diff --git a/Plx/Plx.pro b/Plx/Plx.pro
index a9ec7ed..bceed92 100644
--- a/Plx/Plx.pro
+++ b/Plx/Plx.pro
@@ -17,19 +17,13 @@ DEFINES += QT_DEPRECATED_WARNINGS
 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
 
 SOURCES += \
-    $$files(*.cpp, true) \ \ \
-
-
-
+    $$files(*.cpp, true)
 
 HEADERS += \
-    $$files(*.h, true) \ \ \
-
-
+    $$files(*.h, true)
 
 INCLUDEPATH += $$PWD/include
 
-
 # Default rules for deployment.
 unix {
     target.path = $$[QT_INSTALL_PLUGINS]/generic
@@ -38,4 +32,13 @@ unix {
 
 
 
+unix:!macx: LIBS += -L$$PWD/../../Plxlibrary/Library/ -lPlxApi
+
+INCLUDEPATH += $$PWD/../../Plxlibrary/Library
+DEPENDPATH += $$PWD/../../Plxlibrary/Library
+
+INCLUDEPATH += $$PWD/../../Plxlibrary
+DEPENDPATH += $$PWD/../../Plxlibrary
+
+unix:!macx: PRE_TARGETDEPS += $$PWD/../../Plxlibrary/Library/libPlxApi.a
 
diff --git a/Plx/include/API/HonaAPI.h b/Plx/include/API/HonaAPI.h
index 1a7d61c..8f49e89 100644
--- a/Plx/include/API/HonaAPI.h
+++ b/Plx/include/API/HonaAPI.h
@@ -17,7 +17,14 @@ private:
 	HonaLowLevelAPI _honaLowLevelAPI;
 
 public:
-	explicit HonaAPI(QObject* parent = nullptr);
+	HonaAPI()
+	{
+	}
+
+	~HonaAPI()
+	{
+	}
+
 	ApiResult isHsruStarted();
 	ApiResult isHiruStarted();
 	ApiResult deviceReset();
@@ -32,9 +39,7 @@ public:
 	ApiResult init();
 
 signals:
-	//uncrustify off
-	public	slots:
-	//uncrustify on
+	void honaDataResult(QList<HonaPacket> honaPacketList, quint32 hsruLoss, quint32 Doa);
 };
 
 #endif //HONAAPI_H
diff --git a/Plx/include/LowLevel/Exception/HonaAlreadyStartedException.h b/Plx/include/LowLevel/Exception/HonaAlreadyStartedException.h
index eaf159e..c8352b2 100644
--- a/Plx/include/LowLevel/Exception/HonaAlreadyStartedException.h
+++ b/Plx/include/LowLevel/Exception/HonaAlreadyStartedException.h
@@ -13,10 +13,13 @@ public:
 	HonaAlreadyStartedException(QString str)
 	{
 		_str = str;
+		qDebug() << "HonaAlreadyStartedException " << str;
 	}
 
 	virtual const char* what() const throw()
 	{
+		qDebug() << "HonaAlreadyStartedException return   " << _str;
+
 		return _str.toStdString().c_str();
 	}
 };
diff --git a/Plx/include/LowLevel/Exception/HonaBusyException.h b/Plx/include/LowLevel/Exception/HonaBusyException.h
deleted file mode 100644
index d466099..0000000
--- a/Plx/include/LowLevel/Exception/HonaBusyException.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef HONABUSYEXCEPTION_H
-#define HONABUSYEXCEPTION_H
-
-#include <QDebug>
-#include <QString>
-
-class HonaBusyException : public std::exception
-{
-private:
-	QString _str;
-
-public:
-	HonaBusyException(QString str)
-	{
-		_str = str;
-	}
-
-	virtual const char* what() const throw()
-	{
-		return _str.toStdString().c_str();
-	}
-};
-
-#endif //HONABUSYEXCEPTION_H
diff --git a/Plx/include/LowLevel/HonaLowLevelAPI.h b/Plx/include/LowLevel/HonaLowLevelAPI.h
index 052b7e8..bb6b32a 100644
--- a/Plx/include/LowLevel/HonaLowLevelAPI.h
+++ b/Plx/include/LowLevel/HonaLowLevelAPI.h
@@ -1,26 +1,24 @@
 #ifndef HONALOWLEVELAPI_H
 #define HONALOWLEVELAPI_H
-
 #include <QObject>
-#include "include/LowLevel/Setting/Setting.h"
-#include "include/LowLevel/HonaPacket.h"
-
+#include "LowLevel/Setting/Setting.h"
+#include "LowLevel/HonaPacket.h"
 #include "LowLevel/Setting/Setting.h"
 #include "HonaPacket.h"
 #include "QWaitCondition"
 #include "QMutex"
-#include "include/LowLevel/Exception/HonaAlreadyStartedException.h"
-#include "include/LowLevel/Exception/HonaException.h"
-#include "include/Wrapper/PlxWrapper.h"
-#include "include/LowLevel/Utils/Utils.h"
+#include "LowLevel/Exception/HonaAlreadyStartedException.h"
+#include "LowLevel/Exception/HonaException.h"
+#include "Wrapper/PlxWrapper.h"
+#include "LowLevel/Utils/Utils.h"
 
 class HonaLowLevelAPI : public QObject
 {
 	Q_OBJECT
 
 private:
-	bool _hsruIsStarted;
-	bool _hiruIsStarted;
+	bool _hsruIsStarted = false;
+	bool _hiruIsStarted = false;
 	quint32 _hsruLoss;
 	HonaSettings _honaSetting;
 	QWaitCondition _hsruReadDone, _hsruUpdateAck, _hsruStopEvent, _hiruReadDone0, _hiruCountDone,
@@ -77,8 +75,11 @@ private:
 public:
 	qulonglong toaStartBoard = 0;
 
-public:
-	explicit HonaLowLevelAPI(QObject* parent = nullptr);
+	HonaLowLevelAPI(QObject* parent = nullptr);
+	~HonaLowLevelAPI()
+	{
+	}
+
 	bool isHsruStarted();
 	bool isHiruStarted();
 	void deviceReset();
@@ -109,21 +110,23 @@ private:
 	void hiruUpdateThread();
 	quint32 hiruGetDOA();
 
-	quint32 hsruParserInt123C(const QVector<quint32>& honaData, QList<HonaPacket> honaPacketList);
-	quint32 hsruParserRes123C(const QVector<quint32>& honaData, QList<HonaPacket> honaPacketList);
-	quint32 hsruParserIntS(const QVector<quint32>& honaData, QList<HonaPacket> honaPacketList);
-	quint32 hsruParserResS(const QVector<quint32>& honaData, QList<HonaPacket> honaPacketList);
-	quint32 hsruParserInt4(const QVector<quint32>& honaData, QList<HonaPacket> honaPacketList);
-	quint32 hsruParserRes4(const QVector<quint32>& honaData, QList<HonaPacket> honaPacketList);
+	quint32 hsruParserInt123C(const QVector<quint32>& honaData, QList<HonaPacket>& honaPacketList);
+	quint32 hsruParserRes123C(const QVector<quint32>& honaData, QList<HonaPacket>& honaPacketList);
+	quint32 hsruParserIntS(const QVector<quint32>& honaData, QList<HonaPacket>& honaPacketList);
+	quint32 hsruParserResS(const QVector<quint32>& honaData, QList<HonaPacket>& honaPacketList);
+	quint32 hsruParserInt4(const QVector<quint32>& honaData, QList<HonaPacket>& honaPacketList);
+	quint32 hsruParserRes4(const QVector<quint32>& honaData, QList<HonaPacket>& honaPacketList);
 	quint32 hsruParserSinglePulse(const QVector<quint32>& honaData,
-								  QList<HonaPacket> honaPacketList);
+								  QList<HonaPacket>& honaPacketList);
 
 	QVector<quint32> hsruReadHonaBuffer(honaReceivers receiver);
 
 	bool isValid(HonaPacket hp);
 
+public:
+
 signals:
-	void signalToTop(QList<HonaPacket> honaPacketList, quint32 i, quint32 j);
+	void lowLevelHonaData(QList<HonaPacket> honaPacketList, quint32 hsruLoss, quint32 Doa);
 
 	//uncrustify off
 public	slots:
diff --git a/Plx/include/LowLevel/HonaPacket.h b/Plx/include/LowLevel/HonaPacket.h
index 65381c6..534369f 100644
--- a/Plx/include/LowLevel/HonaPacket.h
+++ b/Plx/include/LowLevel/HonaPacket.h
@@ -3,7 +3,7 @@
 
 #include <QtGlobal>
 
-#include "include/LowLevel/Utils/Utils.h"
+#include "LowLevel/Utils/Utils.h"
 
 class HonaPacket
 {
@@ -18,8 +18,8 @@ private:
 	quint32 m_Pa3;
 	quint32 m_Pa4;
 	quint32 m_Code;
-	quint32 m_CodeL;
-	quint32 m_CodeM;
+	qulonglong m_CodeL;
+	qulonglong m_CodeM;
 	quint8 m4Status;
 
 public:
diff --git a/Plx/include/LowLevel/Setting/Setting.h b/Plx/include/LowLevel/Setting/Setting.h
index 3c2932f..ac07087 100644
--- a/Plx/include/LowLevel/Setting/Setting.h
+++ b/Plx/include/LowLevel/Setting/Setting.h
@@ -3,10 +3,9 @@
 
 #include <QtGlobal>
 #include <QList>
-#include "include/LowLevel/Utils/Utils.h"
-#include <QtGlobal>
-#include <QList>
-#include "include/LowLevel/Utils/Utils.h"
+
+#include "LowLevel/Utils/Utils.h"
+
 /***********************************************************************************************/
 struct hiruSettings_t
 {
diff --git a/Plx/include/Wrapper/PlxWrapper.h b/Plx/include/Wrapper/PlxWrapper.h
index 9286ead..4453da5 100755
--- a/Plx/include/Wrapper/PlxWrapper.h
+++ b/Plx/include/Wrapper/PlxWrapper.h
@@ -2,33 +2,34 @@
 #define PLXWRAPPER_H
 
 #include <QtGlobal>
-#include "../../plxlib/plxinc/PlxPci_9054_Func.h"
+#include "PlxPci_9054_Func.h"
 
 class PlxWrapper
 {
 public:
-    PlxWrapper();
+	PlxWrapper();
 
-    bool deviceInit(quint32 devicekey);
-    bool deviceOpen(void);
-    bool deviceClose(void);
-    bool deviceReset(void);
-    bool deviceLoadE2pToFPGA(void);
+	bool deviceInit(quint32 devicekey);
+	bool deviceOpen(void);
+	bool deviceClose(void);
+	bool deviceReset(void);
+	bool deviceLoadE2pToFPGA(void);
 
-    bool deviceReadEeprom(quint16 offset,quint32 length, QVector<quint32> &data);
-    bool deviceWriteEeprom(quint16 offset, quint32 data);
+	bool deviceReadEeprom(quint16 offset, quint32 length, QVector<quint32>& data);
+	bool deviceWriteEeprom(quint16 offset, quint32 data);
 
-    bool deviceReadRegister(quint32 address,QVector<quint32> &data,quint32 length);
-    bool deviceReadRegister(quint32 address,quint32 &data);
-    bool deviceWriteRegister(quint32 address,QVector<quint32> &data);
-    bool deviceWriteRegister(quint32 address,quint32 data);
+	bool deviceReadRegister(quint32 address, QVector<quint32>& data, quint32 length);
+	bool deviceReadRegister(quint32 address, quint32& data);
+	bool deviceWriteRegister(quint32 address, QVector<quint32>& data);
+	bool deviceWriteRegister(quint32 address, quint32 data);
 
-    bool deviceReadMemory(quint32 localAddress ,QVector<quint32> &data,quint32 length);
-    bool deviceOpenPCIChannel(void);
-    bool deviceClosePCIChannel(void);
-    bool deviceEnableInterrupt(void);
-    bool deviceDisableInterrupt(void);
-    bool deviceWaitForInterrupt(quint32 timeout);
-    bool deviceGetChipType(quint8 revision,quint16 chipType);
+	bool deviceReadMemory(quint32 localAddress, QVector<quint32>& data, quint32 length);
+	bool deviceOpenPCIChannel(void);
+	bool deviceClosePCIChannel(void);
+	bool deviceEnableInterrupt(void);
+	bool deviceDisableInterrupt(void);
+	bool deviceWaitForInterrupt(quint32 timeout);
+	bool deviceGetChipType(quint8 revision, quint16 chipType);
 };
-#endif // PLXWRAPPER_H
+
+#endif //PLXWRAPPER_H
diff --git a/Plx/src/API/HonaAPI.cpp b/Plx/src/API/HonaAPI.cpp
index 9ea7226..77fcc23 100644
--- a/Plx/src/API/HonaAPI.cpp
+++ b/Plx/src/API/HonaAPI.cpp
@@ -1,10 +1,7 @@
 #include "include/API/HonaAPI.h"
 
-HonaAPI::HonaAPI(QObject* parent) : QObject(parent)
-{
-}
-
 /*************************************************************************************************/
+
 ApiResult HonaAPI::isHsruStarted()
 {
 	try {
@@ -15,6 +12,8 @@ ApiResult HonaAPI::isHsruStarted()
 	{
 		return ApiResult::error;
 	}
+
+	return ApiResult::success;
 }
 
 /*************************************************************************************************/
@@ -28,6 +27,8 @@ ApiResult HonaAPI::isHiruStarted()
 	{
 		return ApiResult::error;
 	}
+
+	return ApiResult::success;
 }
 
 /*************************************************************************************************/
@@ -165,6 +166,8 @@ ApiResult HonaAPI::hsruStop()
 /*************************************************************************************************/
 ApiResult HonaAPI::init()
 {
+	connect(&_honaLowLevelAPI, &HonaLowLevelAPI::lowLevelHonaData, this, &HonaAPI::honaDataResult);
+
 	try {
 		_honaLowLevelAPI.init();
 	}
diff --git a/Plx/src/LowLevel/HonaLowLevelAPI.cpp b/Plx/src/LowLevel/HonaLowLevelAPI.cpp
index 97804b7..a2b7ff5 100644
--- a/Plx/src/LowLevel/HonaLowLevelAPI.cpp
+++ b/Plx/src/LowLevel/HonaLowLevelAPI.cpp
@@ -1,9 +1,28 @@
+#include <QtConcurrent/QtConcurrent>
+
 #include <include/LowLevel/Utils/Utils.h>
 #include "include/LowLevel/HonaLowLevelAPI.h"
 #include "include/Wrapper/PlxWrapper.h"
-#include "qdebug.h"
-#include "QTime"
-#include "QtConcurrent/QtConcurrent"
+
+#include <QDebug>
+
+quint32 HonaLowLevelAPI::packetLenInt4;
+quint32 HonaLowLevelAPI::packetLenRes4;
+quint32 HonaLowLevelAPI::packetLenSinglePulse;
+
+quint32 HonaLowLevelAPI::packetLenInt123C;
+quint32 HonaLowLevelAPI::packetLenRes123C;
+quint32 HonaLowLevelAPI::packetLenIntS;
+quint32 HonaLowLevelAPI::packetLenResS;
+
+quint32 HonaLowLevelAPI::nextInt4;
+quint32 HonaLowLevelAPI::nextRes4;
+quint32 HonaLowLevelAPI::nextSinglePulse;
+
+quint32 HonaLowLevelAPI::nextResS;
+quint32 HonaLowLevelAPI::nextInt123C;
+quint32 HonaLowLevelAPI::nextRes123C;
+quint32 HonaLowLevelAPI::nextIntS;
 
 bool HonaLowLevelAPI::getHsruIsStarted() const
 {
@@ -56,7 +75,7 @@ bool HonaLowLevelAPI::isHiruStarted()
 void HonaLowLevelAPI::deviceReset()
 {
 	if(!plxWrapper.deviceReset())
-		throw HonaAlreadyStartedException("Reset Doesnt Occur");
+		throw HonaException("Reset Doesnt Occur");
 }
 
 /*************************************************************************************************/
@@ -64,18 +83,18 @@ void HonaLowLevelAPI::setConfig(HonaSettings& settings)
 {
 	if(!plxWrapper.deviceReadRegister(0x10000000, honaRegisterBuffer, 8))
 	{
-		throw HonaAlreadyStartedException("DeviceReadRegister Doesnt Occur");
+		throw HonaException("DeviceReadRegister Doesnt Occur");
 	}
 	_honaSetting = settings;
 	writeSettingToRegisters(settings);
 	if(!plxWrapper.deviceWriteRegister(0x10000000, honaRegisterBuffer))
 	{
-		throw HonaAlreadyStartedException("DeviceWriteRegister Doesnt Occur");
+		throw HonaException("DeviceWriteRegister Doesnt Occur");
 	}
 
 	if(!plxWrapper.deviceReadRegister(0x10000000, honaRegisterBuffer, 8))
 	{
-		throw HonaAlreadyStartedException("DeviceReadRegister Doesnt Occur");
+		throw HonaException("DeviceReadRegister Doesnt Occur");
 	}
 }
 
@@ -101,10 +120,15 @@ QString HonaLowLevelAPI::getDeviceId()
 /*************************************************************************************************/
 void HonaLowLevelAPI::hsruStart()
 {
-	if(!isHsruStarted())
-		throw HonaException("HsruStarted doesn't started ");
-	QtConcurrent::run(this, &HonaLowLevelAPI::hsruMainThread);
-	setHsruIsStarted(true);
+	if(HonaLowLevelAPI::isHsruStarted())
+	{
+		throw HonaAlreadyStartedException(" alreadyStarted");
+	}
+	else
+	{
+		setHsruIsStarted(true);
+		QtConcurrent::run(this, &HonaLowLevelAPI::hsruMainThread);
+	}
 }
 
 /*************************************************************************************************/
@@ -129,7 +153,12 @@ void HonaLowLevelAPI::init()
 {
 	if(!plxWrapper.deviceInit(0X9054))
 	{
-		throw HonaAlreadyStartedException("Init Doesnt Occur");
+		throw HonaException("Init Doesn't Occur");
+	}
+
+	if(!plxWrapper.deviceOpen())
+	{
+		throw HonaException("deviceOpen Doesn't Occur");
 	}
 }
 
@@ -156,8 +185,8 @@ void HonaLowLevelAPI::writeSettingToRegisters(HonaSettings& settings)
 	/************************************************************************/
 
 	honaRegisterBuffer.insert(0,
-	                          (honaRegisterBuffer.at(0) +
-	                           (settings.hiruSettings.threshold & 0x00000FFF)));
+							  (honaRegisterBuffer.at(0) +
+							   (settings.hiruSettings.threshold & 0x00000FFF)));
 
 	honaRegisterBuffer.insert(1, settings.hsruSettings.honaInt123CTHR);
 	honaRegisterBuffer.insert(2, settings.hsruSettings.honaRes123CTHR);
@@ -177,26 +206,26 @@ void HonaLowLevelAPI::setConfig()
 /*************************************************************************************************/
 void HonaLowLevelAPI::hsruMainThread()
 {
-	try
-	{
-		deviceReset();
-		setConfig();
-		deviceReset();
-		if(!plxWrapper.deviceEnableInterrupt())
-		{
-			throw HonaAlreadyStartedException("DeviceEnableInterrupt Doesnt Occur");
-		}
-
-		QtConcurrent::run(this, &HonaLowLevelAPI::hsruReadThread);
-		QtConcurrent::run(this, &HonaLowLevelAPI::hsruUpdateThread);
-	}
-	catch(...)
+	//try
+	//{
+	deviceReset();
+	setConfig();
+	deviceReset();
+	if(!plxWrapper.deviceEnableInterrupt())
 	{
-		_isHsruReaderThreadFree = true;
-		_isHsruUpdateThreadFree = true;
-		hsruStop();
+		throw HonaException("DeviceEnableInterrupt Doesnt Occur");
 	}
 
+	QtConcurrent::run(this, &HonaLowLevelAPI::hsruReadThread);
+	QtConcurrent::run(this, &HonaLowLevelAPI::hsruUpdateThread);
+	//}
+	//catch(...)
+	//{
+	//_isHsruReaderThreadFree = true;
+	//_isHsruUpdateThreadFree = true;
+	//hsruStop();
+	//}
+
 	_mutex.lock();
 	_hsruStopEvent.wait(&_mutex);
 	_mutex.unlock();
@@ -205,7 +234,7 @@ void HonaLowLevelAPI::hsruMainThread()
 
 	if(!plxWrapper.deviceDisableInterrupt())
 	{
-		throw HonaAlreadyStartedException("DeviceEnableInterrupt Doesnt Occur");
+		throw HonaException("DeviceEnableInterrupt Doesnt Occur");
 	}
 }
 
@@ -220,34 +249,33 @@ void HonaLowLevelAPI::hsruReadThread()
 
 		if(!plxWrapper.deviceWaitForInterrupt(1000))
 		{
-			throw HonaAlreadyStartedException("DeviceWaitForInterrupt Doesnt Occur");
+			throw HonaException("DeviceWaitForInterrupt Doesnt Occur");
 		}
 		honaPacketList.clear();
 		_hsruLoss = 0;
 		if(!plxWrapper.deviceOpenPCIChannel())
 		{
-			throw HonaAlreadyStartedException("DeviceOpenPCIChannel Doesnt Occur");
+			throw HonaException("DeviceOpenPCIChannel Doesnt Occur");
 		}
 
 		_hsruLoss += hsruParserInt123C(hsruReadHonaBuffer(honaReceivers::int123C),
-		                               honaPacketList);
+									   honaPacketList);
 		_hsruLoss += hsruParserRes123C(hsruReadHonaBuffer(honaReceivers::res123C),
-		                               honaPacketList);
+									   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);
+										   honaPacketList);
 		if(!plxWrapper.deviceClosePCIChannel())
 		{
-			throw HonaAlreadyStartedException("DeviceClosePCIChannel Doesnt Occur");
+			throw HonaException("DeviceClosePCIChannel Doesnt Occur");
 		}
 		if(!plxWrapper.deviceEnableInterrupt())
 		{
-			throw HonaAlreadyStartedException("DeviceEnableInterrupt Doesnt Occur");
+			throw HonaException("DeviceEnableInterrupt Doesnt Occur");
 		}
-
 		_mutex.lock();
 		_hsruReadDone.wakeAll();
 		_hsruUpdateAck.wait(&_mutex);
@@ -267,7 +295,7 @@ void HonaLowLevelAPI::hsruUpdateThread()
 			break;
 		quint32 Doa = 0;
 		Doa = hiruGetDOA();
-		emit signalToTop(honaPacketList, _hsruLoss, Doa);
+		emit lowLevelHonaData(honaPacketList, _hsruLoss, Doa);
 		_hsruUpdateAck.wakeAll();
 	}
 }
@@ -301,7 +329,7 @@ quint32 HonaLowLevelAPI::hiruGetDOA()
 	quint32 Doa = 0;
 	if(!plxWrapper.deviceReadRegister(0x30000004, Doa))
 	{
-		throw HonaAlreadyStartedException("DeviceReadRegister Doesnt Occur");
+		throw HonaException("DeviceReadRegister Doesnt Occur");
 	}
 	Doa = Doa & 0x0000FFFF;
 
@@ -310,20 +338,19 @@ quint32 HonaLowLevelAPI::hiruGetDOA()
 
 /*************************************************************************************************/
 quint32 HonaLowLevelAPI::hsruParserInt123C(const QVector<quint32>& honaData,
-                                           QList<HonaPacket> honaPacketList)
+										   QList<HonaPacket>& honaPacketList)
 {
-	quint32 lossFound;
-	for(quint32 Ind = 0; Ind < honaData.length(); Ind++)
+	quint32 lossFound = 0;
+	for(qint32 Ind = 0; Ind < honaData.length(); Ind++)
 	{
-		if((honaData.at(Ind) & 0xFF000000) == 0x0F000000)
+		if((honaData[Ind] & 0xFF000000) == 0x0F000000)
 		{
 			HonaPacket tempHonaPacketInt123C;
-			tempHonaPacketInt123C.setPacketType(honaPacketType::responseMode123C);
+			tempHonaPacketInt123C.setPacketType(honaPacketType::interrogationMode123C);
 			packetLenInt123C = 6;
-			tempHonaPacketInt123C.setPacketNumber(honaData.at(Ind) & 0x0000FFFF);
+			tempHonaPacketInt123C.setPacketNumber(honaData[Ind] & 0x0000FFFF);
 			if((tempHonaPacketInt123C.getPacketNumber() !=
-			    (lastPNInt123C + 1)) & (lastPNInt123C > 0))
-			//& (LastPNInt123C != 65535))
+				(lastPNInt123C + 1)) & (lastPNInt123C > 0))
 			{
 				lossFound +=
 					((tempHonaPacketInt123C.getPacketNumber() - lastPNInt123C + 65536) % 65536 - 1);
@@ -333,53 +360,49 @@ quint32 HonaLowLevelAPI::hsruParserInt123C(const QVector<quint32>& honaData,
 				lossFound++;
 			nextInt123C = 1;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x10000000) && (nextInt123C == 1))
+		else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextInt123C == 1))
 		{
-			tempHonaPacketInt123C.setToa((qulonglong)(honaData.at(Ind) & 0x0FFFFFFF));
+			tempHonaPacketInt123C.setToa(static_cast<qulonglong>(honaData[Ind] & 0x0FFFFFFF));
 			nextInt123C = 2;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextInt123C == 2))
+		else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextInt123C == 2))
 		{
-			tempHonaPacketInt123C.setToa(((tempHonaPacketInt123C.getToa()) +
-			                              (qulonglong)((honaData.at(Ind) & 0x0000FFFF) << 28)));
+			tempHonaPacketInt123C.setToa((tempHonaPacketInt123C.getToa()) +
+										 (static_cast<qulonglong>(honaData[Ind] & 0x0000FFFF) <<
+										  28));
 
-			tempHonaPacketInt123C.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
+			tempHonaPacketInt123C.setPa2((honaData[Ind] & 0x0FFF0000) >> 16);
 			nextInt123C = 3;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x30000000) && (nextInt123C == 3))
+		else if(((honaData[Ind] & 0xF0000000) == 0x30000000) && (nextInt123C == 3))
 		{
-			tempHonaPacketInt123C.setDoa(honaData.at(Ind) & 0x0000FFFF);
-			tempHonaPacketInt123C.setPa3((honaData.at(Ind) & 0x0FFF0000) >> 16);
+			tempHonaPacketInt123C.setDoa(honaData[Ind] & 0x0000FFFF);
+			tempHonaPacketInt123C.setPa3((honaData[Ind] & 0x0FFF0000) >> 16);
 			nextInt123C = 4;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x40000000) && (nextInt123C == 4))
+		else if(((honaData[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);
+			tempHonaPacketInt123C.setPa1(honaData[Ind] & 0x0000FFFF);
+			tempHonaPacketInt123C.setPa2(tempHonaPacketInt123C.getPa2() +
+										 ((honaData[Ind] & 0x000F0000) >> 4));
+			tempHonaPacketInt123C.setPa3(tempHonaPacketInt123C.getPa3() +
+										 ((honaData[Ind] & 0x00F00000) >> 8));
 			nextInt123C = 5;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x50000000) && (nextInt123C == 5))
+		else if(((honaData[Ind] & 0xF0000000) == 0x50000000) && (nextInt123C == 5))
 		{
-			tempHonaPacketInt123C.setCodeM(((ulong)(honaData.at(Ind) & 0x0000001F)) << 59);
+			tempHonaPacketInt123C.setCodeM(
+				(static_cast<qulonglong>(honaData[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);
+				tempHonaPacketInt123C.setToa((tempHonaPacketInt123C.getToa() / 8) + toaStartBoard);
+				honaPacketList.append(tempHonaPacketInt123C);
 			}
 			nextInt123C = 0;
 		}
@@ -390,19 +413,18 @@ quint32 HonaLowLevelAPI::hsruParserInt123C(const QVector<quint32>& honaData,
 
 /*************************************************************************************************/
 quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector<quint32>& honaData,
-                                           QList<HonaPacket> honaPacketList)
+										   QList<HonaPacket>& honaPacketList)
 {
 	quint32 lossFound = 0;
-	for(quint32 Ind = 0; Ind < honaData.length(); Ind++)
+	for(qint32 Ind = 0; Ind < honaData.length(); Ind++)
 	{
-		if((honaData.at(Ind) & 0xFF000000) == 0x0F000000)
+		if((honaData[Ind] & 0xFF000000) == 0x0F000000)
 		{
-			tempHonaPacketRes123C.setPacketNumber(honaPacketType::responseMode123C);
+			tempHonaPacketRes123C.setPacketType(honaPacketType::responseMode123C);
 			packetLenRes123C = 6;
-			tempHonaPacketRes123C.setPacketNumber(honaData.at(Ind) & 0x0000FFFF);
+			tempHonaPacketRes123C.setPacketNumber(honaData[Ind] & 0x0000FFFF);
 			if((tempHonaPacketRes123C.getPacketNumber() !=
-			    (lastPNRes123C + 1)) & (lastPNRes123C > 0))
-			//& (LastPNRes123C != 65535))
+				(lastPNRes123C + 1)) & (lastPNRes123C > 0))
 			{
 				lossFound +=
 					((tempHonaPacketRes123C.getPacketNumber() - lastPNRes123C + 65536) % 65536 - 1);
@@ -412,54 +434,48 @@ quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector<quint32>& honaData,
 				lossFound++;
 			nextRes123C = 1;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x10000000) && (nextRes123C == 1))
+		else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextRes123C == 1))
 		{
-			tempHonaPacketRes123C.setToa((qulonglong)(honaData.at(Ind) & 0x0FFFFFFF));
+			tempHonaPacketRes123C.setToa(static_cast<qulonglong>(honaData[Ind] & 0x0FFFFFFF));
 			nextRes123C = 2;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextRes123C == 2))
+		else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextRes123C == 2))
 		{
 			tempHonaPacketRes123C.setToa(tempHonaPacketRes123C.getToa() +
-			                             (((ulong)(honaData.at(Ind) & 0x0000FFFF)) << 28));
-			tempHonaPacketRes123C.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
+										 ((static_cast<qulonglong>(honaData[Ind] & 0x0000FFFF)) <<
+										  28));
+			tempHonaPacketRes123C.setPa2((honaData[Ind] & 0x0FFF0000) >> 16);
 			nextRes123C = 3;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x30000000) && (nextRes123C == 3))
+		else if(((honaData[Ind] & 0xF0000000) == 0x30000000) && (nextRes123C == 3))
 		{
-			tempHonaPacketRes123C.setDoa(honaData.at(Ind) & 0x0000FFFF);
-			tempHonaPacketRes123C.setPa3((honaData.at(Ind) & 0x0FFF0000) >> 16);
+			tempHonaPacketRes123C.setDoa(honaData[Ind] & 0x0000FFFF);
+			tempHonaPacketRes123C.setPa3((honaData[Ind] & 0x0FFF0000) >> 16);
 			nextRes123C = 4;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x40000000) && (nextRes123C == 4))
+		else if(((honaData[Ind] & 0xF0000000) == 0x40000000) && (nextRes123C == 4))
 		{
-			tempHonaPacketRes123C.setPa1(honaData.at(Ind) & 0x0000FFFF);
+			tempHonaPacketRes123C.setPa1(honaData[Ind] & 0x0000FFFF);
 			tempHonaPacketRes123C.setPa2(tempHonaPacketRes123C.getPa2() +
-			                             ((honaData.at(Ind) & 0x000F0000) >> 4));
+										 ((honaData[Ind] & 0x000F0000) >> 4));
 			tempHonaPacketRes123C.setPa3(tempHonaPacketRes123C.getPa3() +
-			                             ((honaData.at(Ind) & 0x00F00000) >> 8));
+										 ((honaData[Ind] & 0x00F00000) >> 8));
 			nextRes123C = 5;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x50000000) && (nextRes123C == 5))
+		else if(((honaData[Ind] & 0xF0000000) == 0x50000000) && (nextRes123C == 5))
 		{
-			tempHonaPacketRes123C.setCodeM(((ulong)(honaData.at(Ind) & 0x00001FFF)) << 51);
+			tempHonaPacketRes123C.setCodeM(
+				(static_cast<qulonglong>(honaData[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);
+				tempHonaPacketRes123C.setToa((tempHonaPacketRes123C.getToa() / 8) + toaStartBoard);
+				honaPacketList.append(tempHonaPacketRes123C);
 			}
 			nextRes123C = 0;
 		}
@@ -470,14 +486,14 @@ quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector<quint32>& honaData,
 
 /*************************************************************************************************/
 quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
-                                        QList<HonaPacket> honaPacketList)
+										QList<HonaPacket>& honaPacketList)
 {
 	uint lossFound = 0;
-	for(quint32 Ind = 0; Ind < honaData.length(); Ind++)
+	for(qint32 Ind = 0; Ind < honaData.length(); Ind++)
 	{
-		if((honaData.at(Ind) & 0xFF000000) == 0x0F000000)
+		if((honaData[Ind] & 0xFF000000) == 0x0F000000)
 		{
-			uint TypeVal = (honaData.at(Ind) & 0x00F00000) >> 20;
+			qint32 TypeVal = (honaData[Ind] & 0x00F00000) >> 20;
 			if(TypeVal == 2)
 			{
 				tempHonaPacketIntS.setPacketType(honaPacketType::interrogationModeS56);
@@ -488,9 +504,8 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
 				tempHonaPacketIntS.setPacketType(honaPacketType::interrogationModeS112);
 				packetLenIntS = 9;
 			}
-			tempHonaPacketIntS.setPacketNumber(honaData.at(Ind) & 0x0000FFFF);
+			tempHonaPacketIntS.setPacketNumber(honaData[Ind] & 0x0000FFFF);
 			if((tempHonaPacketIntS.getPacketNumber() != (lastPNIntS + 1)) & (lastPNIntS > 0))
-			//& (LastPNIntS != 65535))
 			{
 				lossFound +=
 					((tempHonaPacketIntS.getPacketNumber() - lastPNIntS + 65536) % 65536 - 1);
@@ -500,74 +515,67 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
 				lossFound++;
 			nextIntS = 1;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x10000000) && (nextIntS == 1))
+		else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextIntS == 1))
 		{
-			tempHonaPacketIntS.setToa((qulonglong)(honaData.at(Ind) & 0x0FFFFFFF));
+			tempHonaPacketIntS.setToa(static_cast<qulonglong>(honaData[Ind] & 0x0FFFFFFF));
 			nextIntS = 2;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextIntS == 2))
+		else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextIntS == 2))
 		{
 			tempHonaPacketIntS.setToa(tempHonaPacketIntS.getToa() +
-			                          (((ulong)(honaData.at(Ind) & 0x0000FFFF)) << 28));
-			tempHonaPacketIntS.setToa((honaData.at(Ind) & 0x0FFF0000) >> 16);
+									  ((static_cast<qulonglong>(honaData[Ind] & 0x0000FFFF)) <<
+									   28));
+			tempHonaPacketIntS.setPa2((honaData[Ind] & 0x0FFF0000) >> 16);
 			nextIntS = 3;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x30000000) && (nextIntS == 3))
+		else if(((honaData[Ind] & 0xF0000000) == 0x30000000) && (nextIntS == 3))
 		{
-			tempHonaPacketIntS.setDoa(honaData.at(Ind) & 0x0000FFFF);
-			tempHonaPacketIntS.setPa3((honaData.at(Ind) & 0x0FFF0000) >> 16);
+			tempHonaPacketIntS.setDoa(honaData[Ind] & 0x0000FFFF);
+			tempHonaPacketIntS.setPa3((honaData[Ind] & 0x0FFF0000) >> 16);
 			nextIntS = 4;
 		}
-		else if(((honaData.at(static_cast<int>(Ind)) & 0xF0000000) == 0x40000000) &&
-		        (nextIntS == 4))
+		else if(((honaData[Ind] & 0xF0000000) == 0x40000000) && (nextIntS == 4))
 		{
-			tempHonaPacketIntS.setPa1(honaData.at(Ind) & 0x0000FFFF);
-			tempHonaPacketIntS.setPa2(tempHonaPacketIntS.getPa2() + ((honaData.at(
-																		  Ind) & 0x000F0000)));
+			tempHonaPacketIntS.setPa1(honaData[Ind] & 0x0000FFFF);
+			tempHonaPacketIntS.setPa2(tempHonaPacketIntS.getPa2() + ((honaData[Ind] & 0x000F0000)));
 			tempHonaPacketIntS.setPa3(tempHonaPacketIntS.getPa3() +
-			                          ((honaData.at(Ind) & 0x00F00000) >> 4));
+									  ((honaData[Ind] & 0x00F00000) >> 4));
 			nextIntS = 5;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x50000000) && (nextIntS == 5))
+		else if(((honaData[Ind] & 0xF0000000) == 0x50000000) && (nextIntS == 5))
 		{
-			tempHonaPacketIntS.setCodeM(((ulong)(honaData.at(Ind) & 0x0FFFFFFF)) << 8);
+			tempHonaPacketIntS.setCodeM((static_cast<qulonglong>(honaData[Ind] & 0x0FFFFFFF)) << 8);
 			tempHonaPacketIntS.setCodeL(0);
 			nextIntS = 6;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x60000000) && (nextIntS == 6))
+		else if(((honaData[Ind] & 0xF0000000) == 0x60000000) && (nextIntS == 6))
 		{
 			tempHonaPacketIntS.setCodeM(tempHonaPacketIntS.getCodeM() +
-			                            ((ulong)(honaData.at(Ind) & 0x0FFFFFFF)) << 36);
+										(static_cast<qulonglong>(honaData[Ind] & 0x0FFFFFFF)) <<
+										36);
 			tempHonaPacketIntS.setCodeL(0);
 			nextIntS = 7;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x70000000) && (nextIntS == 7))
+		else if(((honaData[Ind] & 0xF0000000) == 0x70000000) && (nextIntS == 7))
 		{
 			tempHonaPacketIntS.setCodeL(tempHonaPacketIntS.getCodeM());
-			tempHonaPacketIntS.setCodeM(((ulong)(honaData.at(Ind) & 0x0FFFFFFF)) << 8);
+			tempHonaPacketIntS.setCodeM((static_cast<qulonglong>(honaData[Ind] & 0x0FFFFFFF)) << 8);
 			nextIntS = 8;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x80000000) && (nextIntS == 8))
+		else if(((honaData[Ind] & 0xF0000000) == 0x80000000) && (nextIntS == 8))
 		{
 			tempHonaPacketIntS.setCodeM(tempHonaPacketIntS.getCodeM() +
-			                            ((ulong)(honaData.at(Ind) & 0x0FFFFFFF)) << 36);
+										(static_cast<qulonglong>(honaData[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);
+				tempHonaPacketIntS.setToa((tempHonaPacketIntS.getToa() / 8) + toaStartBoard);
+				honaPacketList.append(tempHonaPacketIntS);
 			}
 			nextIntS = 0;
 		}
@@ -578,14 +586,14 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
 
 /*************************************************************************************************/
 quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
-                                        QList<HonaPacket> honaPacketList)
+										QList<HonaPacket>& honaPacketList)
 {
 	uint lossFound = 0;
-	for(quint32 Ind = 0; Ind < honaData.length(); Ind++)
+	for(qint32 Ind = 0; Ind < honaData.length(); Ind++)
 	{
-		if((honaData.at(Ind) & 0xFF000000) == 0x0F000000)
+		if((honaData[Ind] & 0xFF000000) == 0x0F000000)
 		{
-			uint TypeVal = (honaData.at(Ind) & 0x00F00000) >> 20;
+			qint32 TypeVal = (honaData[Ind] & 0x00F00000) >> 20;
 			if(TypeVal == 4)
 			{
 				tempHonaPacketResS.setPacketType(honaPacketType::responseModeS56);
@@ -596,9 +604,8 @@ quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
 				tempHonaPacketResS.setPacketType(honaPacketType::responseModeS112);
 				packetLenResS = 9;
 			}
-			tempHonaPacketResS.setPacketNumber(honaData.at(Ind) & 0x0000FFFF);
+			tempHonaPacketResS.setPacketNumber(honaData[Ind] & 0x0000FFFF);
 			if((tempHonaPacketResS.getPacketNumber() != (lastPNResS + 1)) & (lastPNResS > 0))
-			//& (LastPNResS != 65535))
 			{
 				lossFound +=
 					((tempHonaPacketResS.getPacketNumber() - lastPNResS + 65536) % 65536 - 1);
@@ -608,78 +615,66 @@ quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
 				lossFound++;
 			nextResS = 1;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x10000000) && (nextResS == 1))
+		else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextResS == 1))
 		{
-			tempHonaPacketResS.setToa(static_cast<qulonglong>(honaData.at(Ind) & 0x0FFFFFFF));
+			tempHonaPacketResS.setToa(static_cast<qulonglong>(honaData[Ind] & 0x0FFFFFFF));
 			nextResS = 2;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextResS == 2))
+		else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextResS == 2))
 		{
-			tempHonaPacketResS.setDoa(tempHonaPacketResS.getDoa() +
-			                          ((static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF)) <<
-			                           28));
-			tempHonaPacketResS.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
+			tempHonaPacketResS.setToa(tempHonaPacketResS.getToa() +
+									  ((static_cast<qulonglong>(honaData[Ind] & 0x0000FFFF)) <<
+									   28));
+			tempHonaPacketResS.setPa2((honaData[Ind] & 0x0FFF0000) >> 16);
 			nextResS = 3;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x30000000) && (nextResS == 3))
+		else if(((honaData[Ind] & 0xF0000000) == 0x30000000) && (nextResS == 3))
 		{
-			tempHonaPacketResS.setDoa(honaData.at(Ind) & 0x0000FFFF);
-			tempHonaPacketResS.setPa3((honaData.at(Ind) & 0x0FFF0000) >> 16);
+			tempHonaPacketResS.setDoa(honaData[Ind] & 0x0000FFFF);
+			tempHonaPacketResS.setPa3((honaData[Ind] & 0x0FFF0000) >> 16);
 			nextResS = 4;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x40000000) && (nextResS == 4))
+		else if(((honaData[Ind] & 0xF0000000) == 0x40000000) && (nextResS == 4))
 		{
-			tempHonaPacketResS.setPa1(honaData.at(Ind) & 0x0000FFFF);
-			tempHonaPacketResS.setPa2(tempHonaPacketResS.getPa2() + ((honaData.at(
-																		  Ind) & 0x000F0000)));
+			tempHonaPacketResS.setPa1(honaData[Ind] & 0x0000FFFF);
+			tempHonaPacketResS.setPa2(tempHonaPacketResS.getPa2() + ((honaData[Ind] & 0x000F0000)));
 			tempHonaPacketResS.setPa3(tempHonaPacketResS.getPa3() +
-			                          ((honaData.at(Ind) & 0x00F00000) >> 4));
+									  ((honaData[Ind] & 0x00F00000) >> 4));
 			nextResS = 5;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x50000000) && (nextResS == 5))
+		else if(((honaData[Ind] & 0xF0000000) == 0x50000000) && (nextResS == 5))
 		{
-			tempHonaPacketResS.setCodeM((static_cast<qulonglong>(honaData.at(
-																	 Ind) & 0x0FFFFFFF)) << 8);
+			tempHonaPacketResS.setCodeM((static_cast<qulonglong>(honaData[Ind] & 0x0FFFFFFF)) << 8);
 			tempHonaPacketResS.setCodeL(0);
 			nextResS = 6;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x60000000) && (nextResS == 6))
+		else if(((honaData[Ind] & 0xF0000000) == 0x60000000) && (nextResS == 6))
 		{
 			tempHonaPacketResS.setCodeM(tempHonaPacketResS.getCodeM() +
-			                            (static_cast<qulonglong>(honaData.at(
-																	 Ind) & 0x0FFFFFFF)) << 36);
+										(static_cast<qulonglong>(honaData[Ind] & 0x0FFFFFFF)) <<
+										36);
 			tempHonaPacketResS.setCodeL(0);
 			nextResS = 7;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x70000000) && (nextResS == 7))
+		else if(((honaData[Ind] & 0xF0000000) == 0x70000000) && (nextResS == 7))
 		{
 			tempHonaPacketResS.setCodeL(tempHonaPacketResS.getCodeM());
-			tempHonaPacketResS.setCodeM((static_cast<qulonglong>(honaData.at(
-																	 Ind) & 0x0FFFFFFF)) << 8);
+			tempHonaPacketResS.setCodeM((static_cast<qulonglong>(honaData[Ind] & 0x0FFFFFFF)) << 8);
 			nextResS = 8;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x80000000) && (nextResS == 8))
+		else if(((honaData[Ind] & 0xF0000000) == 0x80000000) && (nextResS == 8))
 		{
 			tempHonaPacketResS.setCodeM(tempHonaPacketResS.getCodeM() +
-			                            (static_cast<qulonglong>(honaData.at(
-																	 Ind) & 0x0FFFFFFF)) << 36);
+										(static_cast<qulonglong>(honaData[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);
+				tempHonaPacketResS.setToa((tempHonaPacketResS.getToa() / 8) + toaStartBoard);
+				honaPacketList.append(tempHonaPacketResS);
 			}
 			nextResS = 0;
 		}
@@ -690,18 +685,18 @@ quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
 
 /*************************************************************************************************/
 quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData,
-                                        QList<HonaPacket> honaPacketList)
+										QList<HonaPacket>& honaPacketList)
 {
 	uint lossFound = 0;
 
-	for(quint32 Ind = 0; Ind < honaData.length(); Ind++)
+	for(qint32 Ind = 0; Ind < honaData.length(); Ind++)
 	{
-		if((honaData.at(Ind) & 0xFF000000) == 0x0F000000)
+		if((honaData[Ind] & 0xFF000000) == 0x0F000000)
 		{
 			tempHonaPacketInt4.setPacketType(honaPacketType::interrogationMode4);
 			packetLenInt4 = 7;
-			tempHonaPacketInt4.setPacketNumber(honaData.at(Ind) & 0x0000FFFF);
-			if((tempHonaPacketInt4.getPacketNumber() != (lastPNInt4 + 1)) & (lastPNInt4 > 0)) //& (LastPNInt123C != 65535))
+			tempHonaPacketInt4.setPacketNumber(honaData[Ind] & 0x0000FFFF);
+			if((tempHonaPacketInt4.getPacketNumber() != (lastPNInt4 + 1)) & (lastPNInt4 > 0))
 			{
 				lossFound +=
 					((tempHonaPacketInt4.getPacketNumber() - lastPNInt4 + 65536) % 65536 - 1);
@@ -711,64 +706,56 @@ quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData,
 				lossFound++;
 			nextInt4 = 1;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x10000000) && (nextInt4 == 1))
+		else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextInt4 == 1))
 		{
-			tempHonaPacketInt4.setToa(static_cast<qulonglong>(honaData.at(Ind) & 0x0FFFFFFF));
+			tempHonaPacketInt4.setToa(static_cast<qulonglong>(honaData[Ind] & 0x0FFFFFFF));
 			nextInt4 = 2;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextInt4 == 2))
+		else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextInt4 == 2))
 		{
 			tempHonaPacketInt4.setToa(tempHonaPacketInt4.getToa() +
-			                          ((static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF)) <<
-			                           28));
-			tempHonaPacketInt4.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
+									  ((static_cast<qulonglong>(honaData[Ind] & 0x0000FFFF)) <<
+									   28));
+			tempHonaPacketInt4.setPa2((honaData[Ind] & 0x0FFF0000) >> 16);
 			nextInt4 = 3;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x30000000) && (nextInt4 == 3))
+		else if(((honaData[Ind] & 0xF0000000) == 0x30000000) && (nextInt4 == 3))
 		{
-			tempHonaPacketInt4.setDoa(honaData.at(Ind) & 0x0000FFFF);
-			tempHonaPacketInt4.setPa3((honaData.at(Ind) & 0x0FFF0000) >> 16);
+			tempHonaPacketInt4.setDoa(honaData[Ind] & 0x0000FFFF);
+			tempHonaPacketInt4.setPa3((honaData[Ind] & 0x0FFF0000) >> 16);
 			nextInt4 = 4;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x40000000) && (nextInt4 == 4))
+		else if(((honaData[Ind] & 0xF0000000) == 0x40000000) && (nextInt4 == 4))
 		{
-			tempHonaPacketInt4.setPa1(honaData.at(Ind) & 0x0000FFFF);
+			tempHonaPacketInt4.setPa1(honaData[Ind] & 0x0000FFFF);
 			tempHonaPacketInt4.setPa2(tempHonaPacketInt4.getPa2() +
-			                          ((honaData.at(Ind) & 0x000F0000) >> 4));
+									  ((honaData[Ind] & 0x000F0000) >> 4));
 			tempHonaPacketInt4.setPa3(tempHonaPacketInt4.getPa3() +
-			                          ((honaData.at(Ind) & 0x00F00000) >> 8));
+									  ((honaData[Ind] & 0x00F00000) >> 8));
 			nextInt4 = 5;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x50000000) && (nextInt4 == 5))
+		else if(((honaData[Ind] & 0xF0000000) == 0x50000000) && (nextInt4 == 5))
 		{
 			tempHonaPacketInt4.setCodeM(0);
-			tempHonaPacketInt4.setCodeL(static_cast<qulonglong>(honaData.at(Ind) & 0x0FFFFFFF));
+			tempHonaPacketInt4.setCodeL(static_cast<qulonglong>(honaData[Ind] & 0x0FFFFFFF));
 			nextInt4 = 6;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x60000000) && (nextInt4 == 6))
+		else if(((honaData[Ind] & 0xF0000000) == 0x60000000) && (nextInt4 == 6))
 		{
-			tempHonaPacketInt4.setPa4(honaData.at(Ind) & 0x0000FFFF);
+			tempHonaPacketInt4.setPa4(honaData[Ind] & 0x0000FFFF);
 			tempHonaPacketInt4.setCodeL(tempHonaPacketInt4.getCodeL() +
-			                            ((static_cast<qulonglong>(honaData.at(Ind) & 0x000F0000)) <<
-			                             12));
-			tempHonaPacketInt4.setm4Status((quint8)((honaData.at(Ind) & 0x0F000000) >> 20));
+										((static_cast<qulonglong>(honaData[Ind] & 0x000F0000)) <<
+										 12));
+			tempHonaPacketInt4.setm4Status(static_cast<quint8>((honaData[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);
+				tempHonaPacketInt4.setToa((tempHonaPacketInt4.getToa() / 6) + toaStartBoard);
+				honaPacketList.append(tempHonaPacketInt4);
 			}
 			nextInt4 = 0;
 		}
@@ -778,17 +765,17 @@ quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData,
 }
 
 quint32 HonaLowLevelAPI::hsruParserRes4(const QVector<quint32>& honaData,
-                                        QList<HonaPacket> honaPacketList)
+										QList<HonaPacket>& honaPacketList)
 {
 	uint lossFound = 0;
-	for(quint32 Ind = 0; Ind < honaData.length(); Ind++)
+	for(qint32 Ind = 0; Ind < honaData.length(); Ind++)
 	{
-		if((honaData.at(Ind) & 0xFF000000) == 0x0F000000)
+		if((honaData[Ind] & 0xFF000000) == 0x0F000000)
 		{
 			tempHonaPacketRes4.setPacketType(honaPacketType::responseMode4);
 			packetLenRes4 = 5;
-			tempHonaPacketRes4.setPacketNumber(honaData.at(Ind) & 0x0000FFFF);
-			if((tempHonaPacketRes4.getPacketNumber() != (lastPNRes4 + 1)) & (lastPNRes4 > 0)) //& (LastPNRes123C != 65535))
+			tempHonaPacketRes4.setPacketNumber(honaData[Ind] & 0x0000FFFF);
+			if((tempHonaPacketRes4.getPacketNumber() != (lastPNRes4 + 1)) & (lastPNRes4 > 0))
 			{
 				lossFound +=
 					((tempHonaPacketRes4.getPacketNumber() - lastPNRes4 + 65536) % 65536 - 1);
@@ -798,49 +785,41 @@ quint32 HonaLowLevelAPI::hsruParserRes4(const QVector<quint32>& honaData,
 				lossFound++;
 			nextRes4 = 1;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x10000000) && (nextRes4 == 1))
+		else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextRes4 == 1))
 		{
-			tempHonaPacketRes4.setToa((static_cast<qulonglong>(honaData.at(Ind) & 0x0FFFFFFF)));
+			tempHonaPacketRes4.setToa((static_cast<qulonglong>(honaData[Ind] & 0x0FFFFFFF)));
 			nextRes4 = 2;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextRes4 == 2))
+		else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextRes4 == 2))
 		{
 			tempHonaPacketRes4.setToa(tempHonaPacketRes4.getToa() +
-			                          (static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF) <<
-			                           28));
-			tempHonaPacketRes4.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
+									  (static_cast<qulonglong>(honaData[Ind] & 0x0000FFFF) <<
+									   28));
+			tempHonaPacketRes4.setPa2((honaData[Ind] & 0x0FFF0000) >> 16);
 			nextRes4 = 3;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x30000000) && (nextRes4 == 3))
+		else if(((honaData[Ind] & 0xF0000000) == 0x30000000) && (nextRes4 == 3))
 		{
-			tempHonaPacketRes4.setDoa(honaData.at(Ind) & 0x0000FFFF);
-			tempHonaPacketRes4.setPa3((honaData.at(Ind) & 0x0FFF0000) >> 16);
+			tempHonaPacketRes4.setDoa(honaData[Ind] & 0x0000FFFF);
+			tempHonaPacketRes4.setPa3((honaData[Ind] & 0x0FFF0000) >> 16);
 			nextRes4 = 4;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x40000000) && (nextRes4 == 4))
+		else if(((honaData[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
+			tempHonaPacketRes4.setPa1(honaData[Ind] & 0x0000FFFF);
+			tempHonaPacketRes4.setPa2(tempHonaPacketRes4.getPa2() +
+									  ((honaData[Ind] & 0x000F0000) >> 4));
+			tempHonaPacketRes4.setPa3(tempHonaPacketRes4.getPa3() +
+									  ((honaData[Ind] & 0x00F00000) >> 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);
+				tempHonaPacketRes4.setToa((tempHonaPacketRes4.getToa() / 6) + toaStartBoard);
+				honaPacketList.append(tempHonaPacketRes4);
 			}
 			nextRes4 = 0;
 		}
@@ -851,19 +830,18 @@ quint32 HonaLowLevelAPI::hsruParserRes4(const QVector<quint32>& honaData,
 
 /*************************************************************************************************/
 quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector<quint32>& honaData,
-                                               QList<HonaPacket> honaPacketList)
+											   QList<HonaPacket>& honaPacketList)
 {
 	uint lossFound = 0;
-	for(quint32 Ind = 0; Ind < honaData.length(); Ind++)
+	for(qint32 Ind = 0; Ind < honaData.length(); Ind++)
 	{
-		if((honaData.at(Ind) & 0xFF000000) == 0x0F000000)
+		if((honaData[Ind] & 0xFF000000) == 0x0F000000)
 		{
 			tempHonaPacketSinglePulse.setPacketType(honaPacketType::singlePulseMode4);
 			packetLenSinglePulse = 5;
-			tempHonaPacketSinglePulse.setPacketNumber(honaData.at(Ind) & 0x0000FFFF);
+			tempHonaPacketSinglePulse.setPacketNumber(honaData[Ind] & 0x0000FFFF);
 			if((tempHonaPacketSinglePulse.getPacketNumber() !=
-			    (lastPNSinglePulse + 1)) & (lastPNSinglePulse > 0))
-				;
+				(lastPNSinglePulse + 1)) & (lastPNSinglePulse > 0))
 			{
 				lossFound +=
 					((tempHonaPacketSinglePulse.getPacketNumber() - lastPNSinglePulse + 65536) %
@@ -875,50 +853,43 @@ quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector<quint32>& honaData,
 				lossFound++;
 			nextSinglePulse = 1;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x10000000) && (nextSinglePulse == 1))
+		else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextSinglePulse == 1))
 		{
-			tempHonaPacketSinglePulse.setToa(static_cast<qulonglong>(honaData.at(Ind) &
-			                                                         0x0FFFFFFF));
+			tempHonaPacketSinglePulse.setToa(static_cast<qulonglong>(honaData[Ind] &
+																	 0x0FFFFFFF));
 			nextSinglePulse = 2;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextSinglePulse == 2))
+		else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextSinglePulse == 2))
 		{
 			tempHonaPacketSinglePulse.setToa(tempHonaPacketSinglePulse.getToa() +
-			                                 ((static_cast<qulonglong>(honaData.at(Ind) &
-			                                                           0x0000FFFF)) << 28));
-			tempHonaPacketSinglePulse.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
+											 ((static_cast<qulonglong>(honaData[Ind] &
+																	   0x0000FFFF)) << 28));
+			tempHonaPacketSinglePulse.setPa2((honaData[Ind] & 0x0FFF0000) >> 16);
 			nextSinglePulse = 3;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x30000000) && (nextSinglePulse == 3))
+		else if(((honaData[Ind] & 0xF0000000) == 0x30000000) && (nextSinglePulse == 3))
 		{
-			tempHonaPacketSinglePulse.setDoa(honaData.at(Ind) & 0x0000FFFF);
-			tempHonaPacketSinglePulse.setPa3((honaData.at(Ind) & 0x0FFF0000) >> 16);
+			tempHonaPacketSinglePulse.setDoa(honaData[Ind] & 0x0000FFFF);
+			tempHonaPacketSinglePulse.setPa3((honaData[Ind] & 0x0FFF0000) >> 16);
 			nextSinglePulse = 4;
 		}
-		else if(((honaData.at(Ind) & 0xF0000000) == 0x40000000) && (nextSinglePulse == 4))
+		else if(((honaData[Ind] & 0xF0000000) == 0x40000000) && (nextSinglePulse == 4))
 		{
-			tempHonaPacketSinglePulse.setPa1(honaData.at(Ind) & 0x0000FFFF);
+			tempHonaPacketSinglePulse.setPa1(honaData[Ind] & 0x0000FFFF);
 			tempHonaPacketSinglePulse.setPa2(tempHonaPacketSinglePulse.getPa2() +
-			                                 ((honaData.at(Ind) & 0x000F0000) >> 4));                                     //NOTE: shifted by 4
+											 ((honaData[Ind] & 0x000F0000) >> 4));
 			tempHonaPacketSinglePulse.setPa3(tempHonaPacketSinglePulse.getPa3() +
-			                                 ((honaData.at(Ind) & 0x00F00000) >> 8));                                     //NOTE: shifted by 8
+											 ((honaData[Ind] & 0x00F00000) >> 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);
+				tempHonaPacketSinglePulse.setToa(
+					(tempHonaPacketSinglePulse.getToa() / 6) + toaStartBoard);
+				honaPacketList.append(tempHonaPacketSinglePulse);
 			}
 			nextSinglePulse = 0;
 		}
@@ -942,11 +913,11 @@ QVector<quint32> HonaLowLevelAPI::hsruReadHonaBuffer(honaReceivers receiver)
 		address = 0X70000000;
 	else if(receiver == honaReceivers::resS)
 		address = 0X80000000;
-	else if(receiver == honaReceivers::int4) //Mode4 :: added by H.H
+	else if(receiver == honaReceivers::int4)
 		address = 0X90000000;
-	else if(receiver == honaReceivers::res4) //Mode4 :: added by H.H
+	else if(receiver == honaReceivers::res4)
 		address = 0XA0000000;
-	else if(receiver == honaReceivers::singlePulse) //Mode4 :: added by H.H
+	else if(receiver == honaReceivers::singlePulse)
 		address = 0XB0000000;
 
 	else
@@ -954,9 +925,13 @@ QVector<quint32> HonaLowLevelAPI::hsruReadHonaBuffer(honaReceivers receiver)
 
 	if(!plxWrapper.deviceReadMemory(address, honaData, honaData.size()))
 	{
-		throw HonaAlreadyStartedException("DeviceReadMemory Doesnt Occur");
+		throw HonaException("DeviceReadMemory Doesnt Occur");
 	}
 
+	//qDebug() << " hsruReadHonaBuffer  receiver "<< receiver;
+	//for(auto i = 0 ; i < 10; i++)
+	//qDebug() << "[" << i << "] " << "0x" << QString::number(honaData[i], 16);
+	//qDebug() << "------------------------------------------------------------";
 	return honaData;
 }
 
diff --git a/Plx/src/LowLevel/HonaPacket.cpp b/Plx/src/LowLevel/HonaPacket.cpp
index 25322f6..5f6b5a8 100644
--- a/Plx/src/LowLevel/HonaPacket.cpp
+++ b/Plx/src/LowLevel/HonaPacket.cpp
@@ -1,4 +1,4 @@
-#include "../../include/LowLevel/HonaPacket.h"
+#include "LowLevel/HonaPacket.h"
 
 HonaPacket::HonaPacket()
 {
@@ -126,3 +126,14 @@ void HonaPacket::setCodeM(quint32 temp)
 }
 
 /*************************************************************************************************/
+quint8 HonaPacket::getm4Status()
+{
+	return m4Status;
+}
+
+void HonaPacket::setm4Status(quint8 temp)
+{
+	m4Status = temp;
+}
+
+/*************************************************************************************************/
diff --git a/Plx/src/Wrapper/PlxWrapper.cpp b/Plx/src/Wrapper/PlxWrapper.cpp
index e77198a..ad98fb7 100644
--- a/Plx/src/Wrapper/PlxWrapper.cpp
+++ b/Plx/src/Wrapper/PlxWrapper.cpp
@@ -1,140 +1,160 @@
 #include <QDebug>
 #include <QVector>
+
 #include "include/Wrapper/PlxWrapper.h"
 
 PlxWrapper::PlxWrapper()
 {
-
 }
+
 /*************************************************************************************************/
 bool PlxWrapper::deviceInit(quint32 devicekey)
 {
-    return PlxPci_9054_SelDevice(devicekey);
+	return PlxPci_9054_SelDevice(devicekey);
 }
+
 /*************************************************************************************************/
-bool PlxWrapper::deviceOpen(void)
+bool PlxWrapper::deviceOpen()
 {
-    return  PlxPci_9054_Open();
+	return PlxPci_9054_Open();
 }
+
 /*************************************************************************************************/
 
-bool PlxWrapper::deviceClose(void)
+bool PlxWrapper::deviceClose()
 {
-    return PlxPci_9054_Close();
+	return PlxPci_9054_Close();
 }
+
 /*************************************************************************************************/
-bool PlxWrapper::deviceReset(void)
+bool PlxWrapper::deviceReset()
 {
-    return PlxPci_9054_Reset();
+	return PlxPci_9054_Reset();
 }
+
 /*************************************************************************************************/
-bool PlxWrapper::deviceLoadE2pToFPGA(void)
+bool PlxWrapper::deviceLoadE2pToFPGA()
 {
-    return PlxPci_9054_LoadE2pToFPGA();
+	return PlxPci_9054_LoadE2pToFPGA();
 }
+
 /*************************************************************************************************/
-bool PlxWrapper::deviceReadEeprom(quint16 offset,quint32 length, QVector<quint32> &data)
+bool PlxWrapper::deviceReadEeprom(quint16 offset, quint32 length, QVector<quint32>& data)
 {
-    bool ret = true;
-    data.clear();
+	bool ret = true;
+	data.clear();
+
+	for(auto i = 0U; i < (length - 1) * 4; i += 4)
+	{
+		quint32 temp;
+		ret &= PlxPci_9054_ReadEep(offset + i, &temp);
+		data.append(temp);
+	}
 
-    for(auto i = 0U; i < (length-1)*4; i+=4)
-    {
-        quint32 temp;
-        ret &= PlxPci_9054_ReadEep(offset+i, &temp);
-        data.append(temp);
-    }
-    return ret;
+	return ret;
 }
+
 /*************************************************************************************************/
-bool PlxWrapper::deviceWriteEeprom(quint16 offset,quint32 data)
+bool PlxWrapper::deviceWriteEeprom(quint16 offset, quint32 data)
 {
-    return PlxPci_9054_WriteEep(offset,data);
+	return PlxPci_9054_WriteEep(offset, data);
 }
+
 /*************************************************************************************************/
-bool PlxWrapper::deviceReadRegister(quint32 address,QVector<quint32> &data,quint32 length)
+bool PlxWrapper::deviceReadRegister(quint32 address, QVector<quint32>& data, quint32 length)
 {
-    bool ret = true;
-    data.clear();
+	bool ret = true;
+	data.clear();
 
-    quint32 temp[length];
-    ret &= PlxPci_9054_ReadBar(address,&temp,length * 4);
-    if(ret == true)
-    {
-        for(auto i = 0U; i <length; i++)
-        {
-           data.append(temp[i]);
-            qDebug()<<hex<<temp[i];
-        }
-    }
-    return ret;
+	quint32 temp[length];
+	ret &= PlxPci_9054_ReadBar(address, &temp, length * 4);
+	if(ret == true)
+	{
+		for(auto i = 0U; i < length; i++)
+		{
+			data.append(temp[i]);
+			qDebug() << hex << temp[i];
+		}
+	}
+
+	return ret;
 }
+
 /*************************************************************************************************/
-bool PlxWrapper::deviceReadRegister(quint32 address,quint32 &data)
+bool PlxWrapper::deviceReadRegister(quint32 address, quint32& data)
 {
-    return PlxPci_9054_ReadBar(address,&data,4);
+	return PlxPci_9054_ReadBar(address, &data, 4);
 }
+
 /*************************************************************************************************/
-bool PlxWrapper::deviceWriteRegister(quint32 address,QVector<quint32> &data)
+bool PlxWrapper::deviceWriteRegister(quint32 address, QVector<quint32>& data)
 {
-    bool ret = true;
-    auto length = data.length();
-    quint32 temp[length];
+	bool ret = true;
+	auto length = data.length();
+	quint32 temp[length];
 
-    for(auto i = 0U; i <length; i++)
-       temp[i] = data.at(i);
+	for(auto i = 0U; i < length; i++)
+		temp[i] = data.at(i);
 
-    ret &= PlxPci_9054_WriteBar(address,&temp,length * 4);
+	ret &= PlxPci_9054_WriteBar(address, &temp, length * 4);
 
-    return ret;
+	return ret;
 }
+
 /*************************************************************************************************/
-bool PlxWrapper::deviceWriteRegister(quint32 address,quint32 data)
+bool PlxWrapper::deviceWriteRegister(quint32 address, quint32 data)
 {
-    return PlxPci_9054_WriteBar(address,&data,4);
+	return PlxPci_9054_WriteBar(address, &data, 4);
 }
+
 /*************************************************************************************************/
-bool PlxWrapper::deviceReadMemory(quint32 localAddress ,QVector<quint32> &data,quint32 length)
+bool PlxWrapper::deviceReadMemory(quint32 localAddress, QVector<quint32>& data, quint32 length)
 {
-    bool ret = true;
-    data.clear();
+	bool ret = true;
+	data.clear();
 
-    quint32 temp[length];
-    ret &= PlxPci_9054_DMATransfer(localAddress,&temp,(quint32)(length*4));
+	quint32 temp[length];
+	ret &= PlxPci_9054_DMATransfer(localAddress, &temp, (quint32)(length * 4));
 
-    for(auto i = 0U; i <length; i++)
-       data.append(temp[i]);
+	for(auto i = 0U; i < length; i++)
+		data.append(temp[i]);
 
-      return  ret;
+	return ret;
 }
+
 /*************************************************************************************************/
 bool PlxWrapper::deviceOpenPCIChannel(void)
 {
-    return PlxPci_9054_DMAChannelOpen();
+	return PlxPci_9054_DMAChannelOpen();
 }
+
 /*************************************************************************************************/
 bool PlxWrapper::deviceClosePCIChannel(void)
 {
-    return PlxPci_9054_DMAChannelClose();
+	return PlxPci_9054_DMAChannelClose();
 }
+
 /*************************************************************************************************/
 
 bool PlxWrapper::deviceEnableInterrupt(void)
 {
-    return PlxPci_9054_EnableInterrupt();
+	return PlxPci_9054_EnableInterrupt();
 }
+
 /*************************************************************************************************/
 bool PlxWrapper::deviceDisableInterrupt(void)
 {
-    return PlxPci_9054_DisableInterrupt();
+	return PlxPci_9054_DisableInterrupt();
 }
+
 /*************************************************************************************************/
 bool PlxWrapper::deviceWaitForInterrupt(quint32 timeout)
 {
-    return PlxPci_9054_WaitForInterrupt(timeout);
+	return PlxPci_9054_WaitForInterrupt(timeout);
 }
+
 /*************************************************************************************************/
-bool PlxWrapper::deviceGetChipType(quint8 revision,quint16 chipType)
+bool PlxWrapper::deviceGetChipType(quint8 revision, quint16 chipType)
 {
-    return PlxPci_9054_ChipTypeGet(revision,chipType);
+	return PlxPci_9054_ChipTypeGet(revision, chipType);
 }
diff --git a/Test/MainWindow.cpp b/Test/MainWindow.cpp
index 060284c..54f24b5 100644
--- a/Test/MainWindow.cpp
+++ b/Test/MainWindow.cpp
@@ -1,11 +1,13 @@
 #include "MainWindow.h"
 #include "ui_MainWindow.h"
+HonaAPI _honaAPI;
 
 MainWindow::MainWindow(QWidget* parent)
 	: QMainWindow(parent)
 	, ui(new Ui::MainWindow)
 {
 	ui->setupUi(this);
+	connect(&_honaAPI, &HonaAPI::honaDataResult, this, &MainWindow::honaDataResultUi);
 }
 
 MainWindow::~MainWindow()
@@ -13,6 +15,58 @@ MainWindow::~MainWindow()
 	delete ui;
 }
 
+/*************************************************************************************************/
+void MainWindow::honaDataResultUi(QList<HonaPacket> honaPacketList, quint32 hsruLoss, quint32 Doa)
+{
+	qDebug() << "honaDataResultUi inside " << honaPacketList.length();
+	QString _str;
+	for(auto i = 0; i < honaPacketList.length(); i++)
+	{
+		_str = "[" + QString::number(i) + "] " + "0x hsruLoss" + QString::number(hsruLoss);
+		_str += "\n *********************************************";
+	}
+
+	ui->dataFromMemory->setText(_str);
+}
+
 void MainWindow::on_testPLX_clicked()
 {
+	ApiResult _resultInit = _honaAPI.init();
+	//ApiResult _deviceReset = _honaAPI.deviceReset();
+	//HonaSettings settings;
+	//ApiResult _configResult = _honaAPI.setConfig(settings);
+	//ApiResult isHsruStarted = _honaAPI.isHsruStarted();
+	ApiResult _hsruStartResult = _honaAPI.hsruStart();
+
+	//********************************************************
+	QString temp = ui->errorMonitoring->text();
+	if(_resultInit == ApiResult::error)
+	{
+		ui->errorMonitoring->setText(temp + "\n" + " Error _resultInit");
+	}
+	else if(_resultInit == ApiResult::success)
+	{
+		ui->errorMonitoring->setText(temp + "\n" + "success _resultInit");
+	}
+	//********************************************************
+
+	if(_hsruStartResult == ApiResult::error)
+	{
+		ui->errorMonitoring->setText(temp + "\n" + " Error _hsruStartResult");
+	}
+	else if(_hsruStartResult == ApiResult::success)
+	{
+		ui->errorMonitoring->setText(temp + "\n" + " success _hsruStartResult");
+	}
+	//********************************************************
+}
+
+void MainWindow::on_stopHsru_clicked()
+{
+	QString temp = ui->errorMonitoring->text();
+	ApiResult _hsruStop = _honaAPI.hsruStop();
+	if(_hsruStop == ApiResult::error)
+	{
+		ui->errorMonitoring->setText(temp + "\n" + " success _hsruStartResult");
+	}
 }
diff --git a/Test/MainWindow.h b/Test/MainWindow.h
index 4c11b82..9e218f4 100644
--- a/Test/MainWindow.h
+++ b/Test/MainWindow.h
@@ -3,6 +3,11 @@
 
 #include <QMainWindow>
 
+#include "API/HonaAPI.h"
+#include "LowLevel/Setting/Setting.h"
+#include "LowLevel/Utils/Utils.h"
+#include "LowLevel/HonaPacket.h"
+
 QT_BEGIN_NAMESPACE
 namespace Ui { class MainWindow;
 }
@@ -12,16 +17,22 @@ class MainWindow : public QMainWindow
 {
 	Q_OBJECT
 
+private:
+	Ui::MainWindow* ui;
+	int a;
+
 public:
 	MainWindow(QWidget* parent = nullptr);
 	~MainWindow();
 
 	//uncrustify off
 private	slots:
-		void on_testPLX_clicked();
-	//uncrustify on
+	void honaDataResultUi(QList<HonaPacket> honaPacketList, quint32 hsruLoss, quint32 Doa);
+	void on_testPLX_clicked();
+	void on_stopHsru_clicked();
+	//uncrustify on:
 private:
-	Ui::MainWindow* ui;
+	//HonaAPI _honaAPI;
 };
 
 #endif //MAINWINDOW_H
diff --git a/Test/MainWindow.ui b/Test/MainWindow.ui
index d768678..a9148d8 100644
--- a/Test/MainWindow.ui
+++ b/Test/MainWindow.ui
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>311</width>
-    <height>281</height>
+    <width>543</width>
+    <height>475</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -17,8 +17,8 @@
    <widget class="QPushButton" name="testPLX">
     <property name="geometry">
      <rect>
-      <x>100</x>
-      <y>120</y>
+      <x>250</x>
+      <y>40</y>
       <width>89</width>
       <height>25</height>
      </rect>
@@ -40,13 +40,49 @@
      <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:20pt;&quot;&gt;Test PLX&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
     </property>
    </widget>
+   <widget class="QLabel" name="errorMonitoring">
+    <property name="geometry">
+     <rect>
+      <x>50</x>
+      <y>90</y>
+      <width>411</width>
+      <height>61</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>TextLabel</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="stopHsru">
+    <property name="geometry">
+     <rect>
+      <x>390</x>
+      <y>40</y>
+      <width>89</width>
+      <height>25</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>stopHsru</string>
+    </property>
+   </widget>
+   <widget class="QTextEdit" name="dataFromMemory">
+    <property name="geometry">
+     <rect>
+      <x>50</x>
+      <y>160</y>
+      <width>451</width>
+      <height>261</height>
+     </rect>
+    </property>
+   </widget>
   </widget>
   <widget class="QMenuBar" name="menubar">
    <property name="geometry">
     <rect>
      <x>0</x>
      <y>0</y>
-     <width>311</width>
+     <width>543</width>
      <height>22</height>
     </rect>
    </property>
diff --git a/Test/Test.pro b/Test/Test.pro
index b6fdfca..b5c986c 100644
--- a/Test/Test.pro
+++ b/Test/Test.pro
@@ -22,10 +22,25 @@ SOURCES += \
 HEADERS += \
     MainWindow.h
 
+INCLUDEPATH += $$PWD/../Plx/include
+
 FORMS += \
     MainWindow.ui
 
+LIBS += -L$$OUT_PWD/../Plx/ -lPlx
+PRE_TARGETDEPS += $$OUT_PWD/../Plx/libPlx.a
+
 # Default rules for deployment.
 qnx: target.path = /tmp/$${TARGET}/bin
 else: unix:!android: target.path = /opt/$${TARGET}/bin
 !isEmpty(target.path): INSTALLS += target
+
+unix:!macx: LIBS += -L$$PWD/../../Plxlibrary/Library/ -lPlxApi
+
+INCLUDEPATH += $$PWD/../../Plxlibrary/Library
+DEPENDPATH += $$PWD/../../Plxlibrary/Library
+
+INCLUDEPATH += $$PWD/../../Plxlibrary
+DEPENDPATH += $$PWD/../../Plxlibrary
+
+unix:!macx: PRE_TARGETDEPS += $$PWD/../../Plxlibrary/Library/libPlxApi.a
diff --git a/Test2/MainWindow.cpp b/Test2/MainWindow.cpp
new file mode 100644
index 0000000..ec12972
--- /dev/null
+++ b/Test2/MainWindow.cpp
@@ -0,0 +1,15 @@
+#include "MainWindow.h"
+#include "ui_MainWindow.h"
+
+MainWindow::MainWindow(QWidget *parent)
+	: QMainWindow(parent)
+	, ui(new Ui::MainWindow)
+{
+	ui->setupUi(this);
+}
+
+MainWindow::~MainWindow()
+{
+	delete ui;
+}
+
diff --git a/Test2/MainWindow.h b/Test2/MainWindow.h
new file mode 100644
index 0000000..274dd1b
--- /dev/null
+++ b/Test2/MainWindow.h
@@ -0,0 +1,21 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+QT_BEGIN_NAMESPACE
+namespace Ui { class MainWindow; }
+QT_END_NAMESPACE
+
+class MainWindow : public QMainWindow
+{
+	Q_OBJECT
+
+public:
+	MainWindow(QWidget *parent = nullptr);
+	~MainWindow();
+
+private:
+	Ui::MainWindow *ui;
+};
+#endif // MAINWINDOW_H
diff --git a/Test2/MainWindow.ui b/Test2/MainWindow.ui
new file mode 100644
index 0000000..b232854
--- /dev/null
+++ b/Test2/MainWindow.ui
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>800</width>
+    <height>600</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralwidget"/>
+  <widget class="QMenuBar" name="menubar"/>
+  <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Test2/Test2.pro b/Test2/Test2.pro
new file mode 100644
index 0000000..b6fdfca
--- /dev/null
+++ b/Test2/Test2.pro
@@ -0,0 +1,31 @@
+QT       += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+CONFIG += c++11
+
+# The following define makes your compiler emit warnings if you use
+# any Qt feature that has been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+    main.cpp \
+    MainWindow.cpp
+
+HEADERS += \
+    MainWindow.h
+
+FORMS += \
+    MainWindow.ui
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
diff --git a/Test2/main.cpp b/Test2/main.cpp
new file mode 100644
index 0000000..723a9ab
--- /dev/null
+++ b/Test2/main.cpp
@@ -0,0 +1,11 @@
+#include "MainWindow.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+	QApplication a(argc, argv);
+	MainWindow w;
+	w.show();
+	return a.exec();
+}