Browse Source

thread edit for start/stop change with H.H

mehrabi
mehrabi 3 years ago
parent
commit
0a43a11850
  1. 7
      Plx/include/LowLevel/HonaLowLevelAPI.h
  2. 10
      Plx/src/API/HonaAPI.cpp
  3. 130
      Plx/src/LowLevel/HonaLowLevelAPI.cpp
  4. 13
      Test/MainWindow.cpp

7
Plx/include/LowLevel/HonaLowLevelAPI.h

@ -20,13 +20,17 @@ class HonaLowLevelAPI : public QObject
private: private:
bool _hsruIsStarted = false; bool _hsruIsStarted = false;
bool _hiruIsStarted = false; bool _hiruIsStarted = false;
bool _hsruFirstStarted = false;
quint32 _hsruLoss; quint32 _hsruLoss;
HonaSettings _honaSetting; HonaSettings _honaSetting;
QWaitCondition _hsruReadDone, _hsruUpdateAck, _hsruStopEvent, _hiruReadDone0, _hiruCountDone, QWaitCondition _hsruReadDone, _hsruUpdateAck, _hsruStopEvent, _hiruReadDone0, _hiruCountDone,
_hiruUpdateAck1; _hiruUpdateAck1;
QList<HonaPacket> honaPacketList; QList<HonaPacket> honaPacketList;
QMutex _mutex; QMutex _readMutex;
QMutex _updateMutex;
QMutex _mainMutex;
int _threadSforValue = 0; int _threadSforValue = 0;
bool _isHsruMainThreadFree = false; bool _isHsruMainThreadFree = false;
bool _isHsruReaderThreadFree = false; bool _isHsruReaderThreadFree = false;
@ -93,6 +97,7 @@ public:
void hiruStart(); void hiruStart();
void hsruStop(); void hsruStop();
void init(); void init();
bool isHsruStarted();
private: private:
void writeSettingToRegisters(HonaSettings& settings); void writeSettingToRegisters(HonaSettings& settings);

10
Plx/src/API/HonaAPI.cpp

@ -97,17 +97,21 @@ ApiResult HonaAPI::hsruStop()
{ {
_honaLowLevelAPI.hsruStop(); _honaLowLevelAPI.hsruStop();
disconnect(&_honaLowLevelAPI, &HonaLowLevelAPI::lowLevelHonaData, this, &HonaAPI::honaDataResult);
return ApiResult::success; return ApiResult::success;
} }
/*************************************************************************************************/ /*************************************************************************************************/
ApiResult HonaAPI::init() ApiResult HonaAPI::init()
{ {
connect(&_honaLowLevelAPI, &HonaLowLevelAPI::lowLevelHonaData, this, &HonaAPI::honaDataResult);
try try
{ {
_honaLowLevelAPI.init(); if(!_honaLowLevelAPI.isHsruStarted())
{
connect(&_honaLowLevelAPI, &HonaLowLevelAPI::lowLevelHonaData, this, &HonaAPI::honaDataResult);
_honaLowLevelAPI.init();
}
} }
catch(HonaException ex) catch(HonaException ex)
{ {

130
Plx/src/LowLevel/HonaLowLevelAPI.cpp

@ -138,9 +138,6 @@ void HonaLowLevelAPI::hiruStart()
/*************************************************************************************************/ /*************************************************************************************************/
void HonaLowLevelAPI::hsruStop() void HonaLowLevelAPI::hsruStop()
{ {
if(_hsruIsStarted)
_hsruIsStarted = false;
_hsruStopEvent.wakeAll(); _hsruStopEvent.wakeAll();
} }
@ -158,6 +155,11 @@ void HonaLowLevelAPI::init()
} }
} }
bool HonaLowLevelAPI::isHsruStarted()
{
return _hsruIsStarted;
}
/*************************************************************************************************/ /*************************************************************************************************/
void HonaLowLevelAPI::writeSettingToRegisters(HonaSettings& settings) void HonaLowLevelAPI::writeSettingToRegisters(HonaSettings& settings)
{ {
@ -181,7 +183,7 @@ void HonaLowLevelAPI::writeSettingToRegisters(HonaSettings& settings)
/************************************************************************/ /************************************************************************/
honaRegisterBuffer.insert(0,(honaRegisterBuffer.at(0) + honaRegisterBuffer.insert(0,(honaRegisterBuffer.at(0) +
(settings.hiruSettings.threshold & 0x00000FFF))); (settings.hiruSettings.threshold & 0x00000FFF)));
honaRegisterBuffer.insert(1, settings.hsruSettings.honaInt123CTHR); honaRegisterBuffer.insert(1, settings.hsruSettings.honaInt123CTHR);
honaRegisterBuffer.insert(2, settings.hsruSettings.honaRes123CTHR); honaRegisterBuffer.insert(2, settings.hsruSettings.honaRes123CTHR);
@ -204,6 +206,7 @@ void HonaLowLevelAPI::hsruMainThread()
deviceReset(); deviceReset();
setConfig(); setConfig();
deviceReset(); deviceReset();
if(!plxWrapper.deviceEnableInterrupt()) if(!plxWrapper.deviceEnableInterrupt())
{ {
throw HonaException(); throw HonaException();
@ -215,13 +218,18 @@ void HonaLowLevelAPI::hsruMainThread()
QtConcurrent::run(this, &HonaLowLevelAPI::hsruReadThread); QtConcurrent::run(this, &HonaLowLevelAPI::hsruReadThread);
QtConcurrent::run(this, &HonaLowLevelAPI::hsruUpdateThread); QtConcurrent::run(this, &HonaLowLevelAPI::hsruUpdateThread);
_mutex.lock(); _mainMutex.lock();
_hsruStopEvent.wait(&_mutex); _hsruStopEvent.wait(&_mainMutex);
_mutex.unlock(); _mainMutex.unlock();
_isHsruReaderThreadFree = true; _isHsruReaderThreadFree = true;
_isHsruUpdateThreadFree = true; _isHsruUpdateThreadFree = true;
_hsruReadDone.wakeAll();
_hsruUpdateAck.wakeAll();
_hsruIsStarted = false;
if(!plxWrapper.deviceDisableInterrupt()) if(!plxWrapper.deviceDisableInterrupt())
{ {
throw HonaException(); throw HonaException();
@ -241,8 +249,8 @@ void HonaLowLevelAPI::hsruReadThread()
{ {
throw HonaException(); throw HonaException();
} }
honaPacketList.clear();
_hsruLoss = 0;
if(!plxWrapper.deviceOpenPCIChannel()) if(!plxWrapper.deviceOpenPCIChannel())
{ {
throw HonaException(); throw HonaException();
@ -250,11 +258,11 @@ void HonaLowLevelAPI::hsruReadThread()
_hsruLoss += hsruParserInt123C(hsruReadHonaBuffer(honaReceivers::int123C), honaPacketList); _hsruLoss += hsruParserInt123C(hsruReadHonaBuffer(honaReceivers::int123C), honaPacketList);
_hsruLoss += hsruParserRes123C(hsruReadHonaBuffer(honaReceivers::res123C), honaPacketList); _hsruLoss += hsruParserRes123C(hsruReadHonaBuffer(honaReceivers::res123C), honaPacketList);
_hsruLoss += hsruParserIntS(hsruReadHonaBuffer(honaReceivers::intS), honaPacketList); // _hsruLoss += hsruParserIntS(hsruReadHonaBuffer(honaReceivers::intS), honaPacketList);
_hsruLoss += hsruParserResS(hsruReadHonaBuffer(honaReceivers::resS), honaPacketList); _hsruLoss += hsruParserResS(hsruReadHonaBuffer(honaReceivers::resS), honaPacketList);
_hsruLoss += hsruParserInt4(hsruReadHonaBuffer(honaReceivers::int4), honaPacketList); // _hsruLoss += hsruParserInt4(hsruReadHonaBuffer(honaReceivers::int4), honaPacketList);
_hsruLoss += hsruParserRes4(hsruReadHonaBuffer(honaReceivers::res4), honaPacketList); // _hsruLoss += hsruParserRes4(hsruReadHonaBuffer(honaReceivers::res4), honaPacketList);
_hsruLoss += hsruParserSinglePulse(hsruReadHonaBuffer(honaReceivers::singlePulse),honaPacketList); // _hsruLoss += hsruParserSinglePulse(hsruReadHonaBuffer(honaReceivers::singlePulse),honaPacketList);
if(!plxWrapper.deviceClosePCIChannel()) if(!plxWrapper.deviceClosePCIChannel())
{ {
@ -264,11 +272,11 @@ void HonaLowLevelAPI::hsruReadThread()
{ {
throw HonaException(); throw HonaException();
} }
QThread::usleep(200000);
_mutex.lock(); _readMutex.lock();
_hsruReadDone.wakeAll(); _hsruReadDone.wakeAll();
_hsruUpdateAck.wait(&_mutex); _hsruUpdateAck.wait(&_readMutex);
_mutex.unlock(); _readMutex.unlock();
} }
} }
@ -277,14 +285,19 @@ void HonaLowLevelAPI::hsruUpdateThread()
{ {
while(true) while(true)
{ {
_mutex.lock();
_hsruReadDone.wait(&_mutex);
_mutex.unlock();
if(_isHsruUpdateThreadFree) if(_isHsruUpdateThreadFree)
break; break;
_updateMutex.lock();
_hsruReadDone.wait(&_updateMutex);
_updateMutex.unlock();
quint32 Doa = 0; quint32 Doa = 0;
Doa = hiruGetDOA(); Doa = hiruGetDOA();
emit lowLevelHonaData(honaPacketList, _hsruLoss, Doa); emit lowLevelHonaData(honaPacketList, _hsruLoss, Doa);
_hsruLoss = 0;
honaPacketList.clear();
QThread::usleep(200000);
_hsruUpdateAck.wakeAll(); _hsruUpdateAck.wakeAll();
} }
} }
@ -292,14 +305,7 @@ void HonaLowLevelAPI::hsruUpdateThread()
/*************************************************************************************************/ /*************************************************************************************************/
void HonaLowLevelAPI::hiruMainThread() void HonaLowLevelAPI::hiruMainThread()
{ {
QtConcurrent::run(this, &HonaLowLevelAPI::hiruReadThread);
QtConcurrent::run(this, &HonaLowLevelAPI::hiruUpdateThread);
while(true)
{
_mutex.lock();
_hsruStopEvent.wait(&_mutex);
_mutex.unlock();
}
} }
/*************************************************************************************************/ /*************************************************************************************************/
@ -341,7 +347,7 @@ quint32 HonaLowLevelAPI::hsruParserInt123C(const QVector<quint32>& honaData,
(lastPNInt123C + 1)) & (lastPNInt123C > 0)) (lastPNInt123C + 1)) & (lastPNInt123C > 0))
{ {
lossFound += lossFound +=
((tempHonaPacketInt123C.getPacketNumber() - lastPNInt123C + 65536) % 65536 - 1); ((tempHonaPacketInt123C.getPacketNumber() - lastPNInt123C + 65536) % 65536 - 1);
} }
lastPNInt123C = tempHonaPacketInt123C.getPacketNumber(); lastPNInt123C = tempHonaPacketInt123C.getPacketNumber();
if(nextInt123C > 0) if(nextInt123C > 0)
@ -356,7 +362,7 @@ quint32 HonaLowLevelAPI::hsruParserInt123C(const QVector<quint32>& honaData,
else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextInt123C == 2)) else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextInt123C == 2))
{ {
tempHonaPacketInt123C.setToa((tempHonaPacketInt123C.getToa()) + tempHonaPacketInt123C.setToa((tempHonaPacketInt123C.getToa()) +
(static_cast<quint64>(honaData[Ind] & 0x0000FFFF) <<28)); (static_cast<quint64>(honaData[Ind] & 0x0000FFFF) <<28));
tempHonaPacketInt123C.setPa2((honaData[Ind] & 0x0FFF0000) >> 16); tempHonaPacketInt123C.setPa2((honaData[Ind] & 0x0FFF0000) >> 16);
nextInt123C = 3; nextInt123C = 3;
@ -415,7 +421,7 @@ quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector<quint32>& honaData,
(lastPNRes123C + 1)) & (lastPNRes123C > 0)) (lastPNRes123C + 1)) & (lastPNRes123C > 0))
{ {
lossFound += lossFound +=
((tempHonaPacketRes123C.getPacketNumber() - lastPNRes123C + 65536) % 65536 - 1); ((tempHonaPacketRes123C.getPacketNumber() - lastPNRes123C + 65536) % 65536 - 1);
} }
lastPNRes123C = tempHonaPacketRes123C.getPacketNumber(); lastPNRes123C = tempHonaPacketRes123C.getPacketNumber();
if(nextRes123C > 0) if(nextRes123C > 0)
@ -430,7 +436,7 @@ quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector<quint32>& honaData,
else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextRes123C == 2)) else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextRes123C == 2))
{ {
tempHonaPacketRes123C.setToa(tempHonaPacketRes123C.getToa() + tempHonaPacketRes123C.setToa(tempHonaPacketRes123C.getToa() +
((static_cast<quint64>(honaData[Ind] & 0x0000FFFF)) << 28)); ((static_cast<quint64>(honaData[Ind] & 0x0000FFFF)) << 28));
tempHonaPacketRes123C.setPa2((honaData[Ind] & 0x0FFF0000) >> 16); tempHonaPacketRes123C.setPa2((honaData[Ind] & 0x0FFF0000) >> 16);
nextRes123C = 3; nextRes123C = 3;
} }
@ -445,15 +451,15 @@ quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector<quint32>& honaData,
tempHonaPacketRes123C.setPa1(honaData[Ind] & 0x0000FFFF); tempHonaPacketRes123C.setPa1(honaData[Ind] & 0x0000FFFF);
tempHonaPacketRes123C.setPa2(tempHonaPacketRes123C.getPa2() + tempHonaPacketRes123C.setPa2(tempHonaPacketRes123C.getPa2() +
((honaData[Ind] & 0x000F0000) >> 4)); ((honaData[Ind] & 0x000F0000) >> 4));
tempHonaPacketRes123C.setPa3(tempHonaPacketRes123C.getPa3() + tempHonaPacketRes123C.setPa3(tempHonaPacketRes123C.getPa3() +
((honaData[Ind] & 0x00F00000) >> 8)); ((honaData[Ind] & 0x00F00000) >> 8));
nextRes123C = 5; nextRes123C = 5;
} }
else if(((honaData[Ind] & 0xF0000000) == 0x50000000) && (nextRes123C == 5)) else if(((honaData[Ind] & 0xF0000000) == 0x50000000) && (nextRes123C == 5))
{ {
tempHonaPacketRes123C.setCodeM( tempHonaPacketRes123C.setCodeM(
(static_cast<quint64>(honaData[Ind] & 0x00001FFF)) << 51); (static_cast<quint64>(honaData[Ind] & 0x00001FFF)) << 51);
tempHonaPacketRes123C.setCodeL(0); tempHonaPacketRes123C.setCodeL(0);
nextRes123C = 6; nextRes123C = 6;
@ -500,7 +506,7 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
if((tempHonaPacketIntS.getPacketNumber() != (lastPNIntS + 1)) & (lastPNIntS > 0)) if((tempHonaPacketIntS.getPacketNumber() != (lastPNIntS + 1)) & (lastPNIntS > 0))
{ {
lossFound += lossFound +=
((tempHonaPacketIntS.getPacketNumber() - lastPNIntS + 65536) % 65536 - 1); ((tempHonaPacketIntS.getPacketNumber() - lastPNIntS + 65536) % 65536 - 1);
} }
lastPNIntS = tempHonaPacketIntS.getPacketNumber(); lastPNIntS = tempHonaPacketIntS.getPacketNumber();
if(nextIntS > 0) if(nextIntS > 0)
@ -515,7 +521,7 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextIntS == 2)) else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextIntS == 2))
{ {
tempHonaPacketIntS.setToa(tempHonaPacketIntS.getToa() + tempHonaPacketIntS.setToa(tempHonaPacketIntS.getToa() +
((static_cast<quint64>(honaData[Ind] & 0x0000FFFF)) << 28)); ((static_cast<quint64>(honaData[Ind] & 0x0000FFFF)) << 28));
tempHonaPacketIntS.setPa2((honaData[Ind] & 0x0FFF0000) >> 16); tempHonaPacketIntS.setPa2((honaData[Ind] & 0x0FFF0000) >> 16);
nextIntS = 3; nextIntS = 3;
} }
@ -530,7 +536,7 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
tempHonaPacketIntS.setPa1(honaData[Ind] & 0x0000FFFF); tempHonaPacketIntS.setPa1(honaData[Ind] & 0x0000FFFF);
tempHonaPacketIntS.setPa2(tempHonaPacketIntS.getPa2() + ((honaData[Ind] & 0x000F0000))); tempHonaPacketIntS.setPa2(tempHonaPacketIntS.getPa2() + ((honaData[Ind] & 0x000F0000)));
tempHonaPacketIntS.setPa3(tempHonaPacketIntS.getPa3() + tempHonaPacketIntS.setPa3(tempHonaPacketIntS.getPa3() +
((honaData[Ind] & 0x00F00000) >> 4)); ((honaData[Ind] & 0x00F00000) >> 4));
nextIntS = 5; nextIntS = 5;
} }
else if(((honaData[Ind] & 0xF0000000) == 0x50000000) && (nextIntS == 5)) else if(((honaData[Ind] & 0xF0000000) == 0x50000000) && (nextIntS == 5))
@ -542,7 +548,7 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
else if(((honaData[Ind] & 0xF0000000) == 0x60000000) && (nextIntS == 6)) else if(((honaData[Ind] & 0xF0000000) == 0x60000000) && (nextIntS == 6))
{ {
tempHonaPacketIntS.setCodeM(tempHonaPacketIntS.getCodeM() + tempHonaPacketIntS.setCodeM(tempHonaPacketIntS.getCodeM() +
((static_cast<quint64>(honaData[Ind] & 0x0FFFFFFF)) << 36)); ((static_cast<quint64>(honaData[Ind] & 0x0FFFFFFF)) << 36));
tempHonaPacketIntS.setCodeL(0); tempHonaPacketIntS.setCodeL(0);
nextIntS = 7; nextIntS = 7;
} }
@ -555,7 +561,7 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
else if(((honaData[Ind] & 0xF0000000) == 0x80000000) && (nextIntS == 8)) else if(((honaData[Ind] & 0xF0000000) == 0x80000000) && (nextIntS == 8))
{ {
tempHonaPacketIntS.setCodeM(tempHonaPacketIntS.getCodeM() + tempHonaPacketIntS.setCodeM(tempHonaPacketIntS.getCodeM() +
((static_cast<quint64>(honaData[Ind] & 0x0FFFFFFF)) << 36)); ((static_cast<quint64>(honaData[Ind] & 0x0FFFFFFF)) << 36));
nextIntS = 9; nextIntS = 9;
} }
@ -601,7 +607,7 @@ quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
if((tempHonaPacketResS.getPacketNumber() != (lastPNResS + 1)) & (lastPNResS > 0)) if((tempHonaPacketResS.getPacketNumber() != (lastPNResS + 1)) & (lastPNResS > 0))
{ {
lossFound += lossFound +=
((tempHonaPacketResS.getPacketNumber() - lastPNResS + 65536) % 65536 - 1); ((tempHonaPacketResS.getPacketNumber() - lastPNResS + 65536) % 65536 - 1);
} }
lastPNResS = tempHonaPacketResS.getPacketNumber(); lastPNResS = tempHonaPacketResS.getPacketNumber();
if(nextResS > 0) if(nextResS > 0)
@ -616,7 +622,7 @@ quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextResS == 2)) else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextResS == 2))
{ {
tempHonaPacketResS.setToa(tempHonaPacketResS.getToa() + tempHonaPacketResS.setToa(tempHonaPacketResS.getToa() +
((static_cast<quint64>(honaData[Ind] & 0x0000FFFF)) << 28)); ((static_cast<quint64>(honaData[Ind] & 0x0000FFFF)) << 28));
tempHonaPacketResS.setPa2((honaData[Ind] & 0x0FFF0000) >> 16); tempHonaPacketResS.setPa2((honaData[Ind] & 0x0FFF0000) >> 16);
nextResS = 3; nextResS = 3;
} }
@ -642,7 +648,7 @@ quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
else if(((honaData[Ind] & 0xF0000000) == 0x60000000) && (nextResS == 6)) else if(((honaData[Ind] & 0xF0000000) == 0x60000000) && (nextResS == 6))
{ {
tempHonaPacketResS.setCodeM(tempHonaPacketResS.getCodeM() + tempHonaPacketResS.setCodeM(tempHonaPacketResS.getCodeM() +
((static_cast<quint64>(honaData[Ind] & 0x0FFFFFFF)) << 36)); ((static_cast<quint64>(honaData[Ind] & 0x0FFFFFFF)) << 36));
tempHonaPacketResS.setCodeL(0); tempHonaPacketResS.setCodeL(0);
nextResS = 7; nextResS = 7;
} }
@ -655,7 +661,7 @@ quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
else if(((honaData[Ind] & 0xF0000000) == 0x80000000) && (nextResS == 8)) else if(((honaData[Ind] & 0xF0000000) == 0x80000000) && (nextResS == 8))
{ {
tempHonaPacketResS.setCodeM(tempHonaPacketResS.getCodeM() + tempHonaPacketResS.setCodeM(tempHonaPacketResS.getCodeM() +
((static_cast<quint64>(honaData[Ind] & 0x0FFFFFFF)) << 36)); ((static_cast<quint64>(honaData[Ind] & 0x0FFFFFFF)) << 36));
nextResS = 9; nextResS = 9;
} }
if(nextResS == packetLenResS) if(nextResS == packetLenResS)
@ -692,7 +698,7 @@ quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData,
if((tempHonaPacketInt4.getPacketNumber() != (lastPNInt4 + 1)) & (lastPNInt4 > 0)) if((tempHonaPacketInt4.getPacketNumber() != (lastPNInt4 + 1)) & (lastPNInt4 > 0))
{ {
lossFound += lossFound +=
((tempHonaPacketInt4.getPacketNumber() - lastPNInt4 + 65536) % 65536 - 1); ((tempHonaPacketInt4.getPacketNumber() - lastPNInt4 + 65536) % 65536 - 1);
} }
lastPNInt4 = tempHonaPacketInt4.getPacketNumber(); lastPNInt4 = tempHonaPacketInt4.getPacketNumber();
if(nextInt4 > 0) if(nextInt4 > 0)
@ -707,7 +713,7 @@ quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData,
else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextInt4 == 2)) else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextInt4 == 2))
{ {
tempHonaPacketInt4.setToa(tempHonaPacketInt4.getToa() + tempHonaPacketInt4.setToa(tempHonaPacketInt4.getToa() +
((static_cast<quint64>(honaData[Ind] & 0x0000FFFF)) << 28)); ((static_cast<quint64>(honaData[Ind] & 0x0000FFFF)) << 28));
tempHonaPacketInt4.setPa2((honaData[Ind] & 0x0FFF0000) >> 16); tempHonaPacketInt4.setPa2((honaData[Ind] & 0x0FFF0000) >> 16);
nextInt4 = 3; nextInt4 = 3;
} }
@ -721,9 +727,9 @@ quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData,
{ {
tempHonaPacketInt4.setPa1(honaData[Ind] & 0x0000FFFF); tempHonaPacketInt4.setPa1(honaData[Ind] & 0x0000FFFF);
tempHonaPacketInt4.setPa2(tempHonaPacketInt4.getPa2() + tempHonaPacketInt4.setPa2(tempHonaPacketInt4.getPa2() +
((honaData[Ind] & 0x000F0000) >> 4)); ((honaData[Ind] & 0x000F0000) >> 4));
tempHonaPacketInt4.setPa3(tempHonaPacketInt4.getPa3() + tempHonaPacketInt4.setPa3(tempHonaPacketInt4.getPa3() +
((honaData[Ind] & 0x00F00000) >> 8)); ((honaData[Ind] & 0x00F00000) >> 8));
nextInt4 = 5; nextInt4 = 5;
} }
else if(((honaData[Ind] & 0xF0000000) == 0x50000000) && (nextInt4 == 5)) else if(((honaData[Ind] & 0xF0000000) == 0x50000000) && (nextInt4 == 5))
@ -736,7 +742,7 @@ quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData,
{ {
tempHonaPacketInt4.setPa4(honaData[Ind] & 0x0000FFFF); tempHonaPacketInt4.setPa4(honaData[Ind] & 0x0000FFFF);
tempHonaPacketInt4.setCodeL(tempHonaPacketInt4.getCodeL() + tempHonaPacketInt4.setCodeL(tempHonaPacketInt4.getCodeL() +
(static_cast<quint64>(honaData[Ind] & 0x000F0000) << 12)); (static_cast<quint64>(honaData[Ind] & 0x000F0000) << 12));
tempHonaPacketInt4.setm4Status(static_cast<quint8>((honaData[Ind] & 0x0F000000) >> 20)); tempHonaPacketInt4.setm4Status(static_cast<quint8>((honaData[Ind] & 0x0F000000) >> 20));
nextInt4 = 7; nextInt4 = 7;
} }
@ -774,7 +780,7 @@ quint32 HonaLowLevelAPI::hsruParserRes4(const QVector<quint32>& honaData,
if((tempHonaPacketRes4.getPacketNumber() != (lastPNRes4 + 1)) & (lastPNRes4 > 0)) if((tempHonaPacketRes4.getPacketNumber() != (lastPNRes4 + 1)) & (lastPNRes4 > 0))
{ {
lossFound += lossFound +=
((tempHonaPacketRes4.getPacketNumber() - lastPNRes4 + 65536) % 65536 - 1); ((tempHonaPacketRes4.getPacketNumber() - lastPNRes4 + 65536) % 65536 - 1);
} }
lastPNRes4 = tempHonaPacketRes4.getPacketNumber(); lastPNRes4 = tempHonaPacketRes4.getPacketNumber();
if(nextRes4 > 0) if(nextRes4 > 0)
@ -789,7 +795,7 @@ quint32 HonaLowLevelAPI::hsruParserRes4(const QVector<quint32>& honaData,
else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextRes4 == 2)) else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextRes4 == 2))
{ {
tempHonaPacketRes4.setToa(tempHonaPacketRes4.getToa() + tempHonaPacketRes4.setToa(tempHonaPacketRes4.getToa() +
(static_cast<quint64>(honaData[Ind] & 0x0000FFFF) << 28)); (static_cast<quint64>(honaData[Ind] & 0x0000FFFF) << 28));
tempHonaPacketRes4.setPa2((honaData[Ind] & 0x0FFF0000) >> 16); tempHonaPacketRes4.setPa2((honaData[Ind] & 0x0FFF0000) >> 16);
nextRes4 = 3; nextRes4 = 3;
} }
@ -803,9 +809,9 @@ quint32 HonaLowLevelAPI::hsruParserRes4(const QVector<quint32>& honaData,
{ {
tempHonaPacketRes4.setPa1(honaData[Ind] & 0x0000FFFF); tempHonaPacketRes4.setPa1(honaData[Ind] & 0x0000FFFF);
tempHonaPacketRes4.setPa2(tempHonaPacketRes4.getPa2() + tempHonaPacketRes4.setPa2(tempHonaPacketRes4.getPa2() +
((honaData[Ind] & 0x000F0000) >> 4)); ((honaData[Ind] & 0x000F0000) >> 4));
tempHonaPacketRes4.setPa3(tempHonaPacketRes4.getPa3() + tempHonaPacketRes4.setPa3(tempHonaPacketRes4.getPa3() +
((honaData[Ind] & 0x00F00000) >> 8)); ((honaData[Ind] & 0x00F00000) >> 8));
nextRes4 = 5; nextRes4 = 5;
} }
@ -843,9 +849,9 @@ quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector<quint32>& honaData,
(lastPNSinglePulse + 1)) & (lastPNSinglePulse > 0)) (lastPNSinglePulse + 1)) & (lastPNSinglePulse > 0))
{ {
lossFound += lossFound +=
((tempHonaPacketSinglePulse.getPacketNumber() - lastPNSinglePulse + 65536) % ((tempHonaPacketSinglePulse.getPacketNumber() - lastPNSinglePulse + 65536) %
65536 - 65536 -
1); 1);
} }
lastPNSinglePulse = tempHonaPacketSinglePulse.getPacketNumber(); lastPNSinglePulse = tempHonaPacketSinglePulse.getPacketNumber();
if(nextSinglePulse > 0) if(nextSinglePulse > 0)
@ -855,14 +861,14 @@ quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector<quint32>& honaData,
else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextSinglePulse == 1)) else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextSinglePulse == 1))
{ {
tempHonaPacketSinglePulse.setToa(static_cast<quint64>(honaData[Ind] & tempHonaPacketSinglePulse.setToa(static_cast<quint64>(honaData[Ind] &
0x0FFFFFFF)); 0x0FFFFFFF));
nextSinglePulse = 2; nextSinglePulse = 2;
} }
else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextSinglePulse == 2)) else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextSinglePulse == 2))
{ {
tempHonaPacketSinglePulse.setToa(tempHonaPacketSinglePulse.getToa() + tempHonaPacketSinglePulse.setToa(tempHonaPacketSinglePulse.getToa() +
((static_cast<quint64>(honaData[Ind] & ((static_cast<quint64>(honaData[Ind] &
0x0000FFFF)) << 28)); 0x0000FFFF)) << 28));
tempHonaPacketSinglePulse.setPa2((honaData[Ind] & 0x0FFF0000) >> 16); tempHonaPacketSinglePulse.setPa2((honaData[Ind] & 0x0FFF0000) >> 16);
nextSinglePulse = 3; nextSinglePulse = 3;
} }
@ -876,9 +882,9 @@ quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector<quint32>& honaData,
{ {
tempHonaPacketSinglePulse.setPa1(honaData[Ind] & 0x0000FFFF); tempHonaPacketSinglePulse.setPa1(honaData[Ind] & 0x0000FFFF);
tempHonaPacketSinglePulse.setPa2(tempHonaPacketSinglePulse.getPa2() + tempHonaPacketSinglePulse.setPa2(tempHonaPacketSinglePulse.getPa2() +
((honaData[Ind] & 0x000F0000) >> 4)); ((honaData[Ind] & 0x000F0000) >> 4));
tempHonaPacketSinglePulse.setPa3(tempHonaPacketSinglePulse.getPa3() + tempHonaPacketSinglePulse.setPa3(tempHonaPacketSinglePulse.getPa3() +
((honaData[Ind] & 0x00F00000) >> 8)); ((honaData[Ind] & 0x00F00000) >> 8));
nextSinglePulse = 5; nextSinglePulse = 5;
} }
@ -887,7 +893,7 @@ quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector<quint32>& honaData,
if(isValid(tempHonaPacketSinglePulse)) if(isValid(tempHonaPacketSinglePulse))
{ {
tempHonaPacketSinglePulse.setToa( tempHonaPacketSinglePulse.setToa(
(tempHonaPacketSinglePulse.getToa() / 6) + toaStartBoard); (tempHonaPacketSinglePulse.getToa() / 6) + toaStartBoard);
honaPacketList.append(tempHonaPacketSinglePulse); honaPacketList.append(tempHonaPacketSinglePulse);
} }
nextSinglePulse = 0; nextSinglePulse = 0;

13
Test/MainWindow.cpp

@ -60,7 +60,6 @@ QString resultString(ApiResult res){
return ""; return "";
}; };
void MainWindow::on_startHsru_clicked() void MainWindow::on_startHsru_clicked()
{ {
//******************************************************** //********************************************************
@ -77,8 +76,16 @@ void MainWindow::on_startHsru_clicked()
void MainWindow::on_resetDevice_clicked() void MainWindow::on_resetDevice_clicked()
{ {
ApiResult _hsruStop = _honaAPI.deviceReset(); ApiResult _hsruStop = _honaAPI.hsruStop();
ui->errorMonitoring->setText("deviceReset: " + resultString(_hsruStop)); ui->errorMonitoring->setText("hsruStop: " + resultString(_hsruStop));
ApiResult _resultInit = _honaAPI.init();
ui->errorMonitoring->setText("_resultInit: " + resultString(_resultInit));
ApiResult _hsruStartResult = _honaAPI.hsruStart();
QString temp = ui->errorMonitoring->text();
ui->errorMonitoring->setText(temp + "\n _hsruStartResult: " + resultString(_hsruStartResult));
} }
void MainWindow::on_stopHsru_clicked() void MainWindow::on_stopHsru_clicked()

Loading…
Cancel
Save