Browse Source

nothing

heydari
Alireza 3 years ago
parent
commit
07a5f24ece
  1. 74
      Plx/include/LowLevel/HonaLowLevelAPI.h
  2. 43
      Plx/include/LowLevel/Setting/Setting.h
  3. 186
      Plx/src/LowLevel/HonaLowLevelAPI.cpp

74
Plx/include/LowLevel/HonaLowLevelAPI.h

@ -5,7 +5,6 @@
#include "include/LowLevel/Setting/Setting.h" #include "include/LowLevel/Setting/Setting.h"
#include "include/LowLevel/HonaPacket.h" #include "include/LowLevel/HonaPacket.h"
#include "LowLevel/Setting/Setting.h" #include "LowLevel/Setting/Setting.h"
#include "HonaPacket.h" #include "HonaPacket.h"
#include "QWaitCondition" #include "QWaitCondition"
@ -14,58 +13,53 @@
class HonaLowLevelAPI : public QObject class HonaLowLevelAPI : public QObject
{ {
Q_OBJECT Q_OBJECT
private: private:
bool _hsruIsStarted;
bool _hsruIsStarted; bool _hiruIsStarted;
bool _hiruIsStarted; HonaSetting _honaSetting;
HonaSetting _honaSetting; QWaitCondition _hsruReadDone, _hsruUpdateAck, _hsruStopEvent;
QWaitCondition HsruReadDone, HsruUpdateAck, HsruStopEvent; QMutex _mutex;
QMutex _mutex; int _threadSforValue = 0;
int _threadSforValue = 0; bool _isReaderThreadFree = false;
bool _isReaderThreadFree = false; bool _isUpdateThreadFree = false;
bool _isUpdateThreadFree = false; quint32 honaRegisterBuffer[8];
quint32 honaRegisterBuffer[8];
public: public:
explicit HonaLowLevelAPI(QObject* parent = nullptr); explicit HonaLowLevelAPI(QObject* parent = nullptr);
bool isHsruStarted(); bool isHsruStarted();
bool isHiruStarted(); bool isHiruStarted();
void deviceReset(); void deviceReset();
void setConfig(HonaSetting* honaSetting); void setConfig(HonaSetting* honaSetting);
HonaSetting getConfig(); HonaSetting getConfig();
QString getSwVersion(); QString getSwVersion();
QString getDeviceId(); QString getDeviceId();
void hsruStart(); void hsruStart();
void hiruStart(); void hiruStart();
void init(); void init();
bool getHsruIsStarted() const; bool getHsruIsStarted() const;
void setHsruIsStarted(bool hsruIsStarted); void setHsruIsStarted(bool hsruIsStarted);
bool getHiruIsStarted() const; bool getHiruIsStarted() const;
void setHiruIsStarted(bool hiruIsStarted); void setHiruIsStarted(bool hiruIsStarted);
private: private:
void writeSettingToRegisters(honaSettings& settings); void writeSettingToRegisters(HonaSetting& settings);
void setConfig(); void setConfig();
void hsruMainThread(); void hsruMainThread();
void hsruReadThread(); void hsruReadThread();
void hsruUpdateThread(); void hsruUpdateThread();
int hiruGetDOA(); int hiruGetDOA();
signals: signals:
void signalToTop(QList<HonaPacket*> honaPacketList, int i, int j); void signalToTop(QList<HonaPacket*> honaPacketList, int i, int j);
//uncrustify off //uncrustify off
public slots: public slots:
//uncrustify on //uncrustify on
}; };
#endif //HONALOWLEVELAPI_H #endif //HONALOWLEVELAPI_H

43
Plx/include/LowLevel/Setting/Setting.h

@ -8,35 +8,36 @@
#include <QList> #include <QList>
#include "include/LowLevel/Utils/Utils.h" #include "include/LowLevel/Utils/Utils.h"
/***********************************************************************************************/ /***********************************************************************************************/
struct hiruSettings_t struct hiruSettings_t
{ {
recorderStart recordStard; recorderStart recordStard;
recorderMode recordMode; recorderMode recordMode;
quint32 recordChannel; quint32 recordChannel;
quint32 threshold = 0; quint32 threshold = 0;
quint32 timeout = 1000; quint32 timeout = 1000;
quint32 count = 5; quint32 count = 5;
}; };
/***********************************************************************************************/ /***********************************************************************************************/
struct hsruSettings_t struct hsruSettings_t
{ {
bool isReal = true; bool isReal = true;
quint32 honaInt123CTHR = 128; quint32 honaInt123CTHR = 128;
quint32 honaRes123CTHR = 128; quint32 honaRes123CTHR = 128;
quint32 honaIntSTHR = 20; quint32 honaIntSTHR = 20;
quint32 honaResSTHR = 20; quint32 honaResSTHR = 20;
quint32 honaSPTHR = 20; //mode4 quint32 honaSPTHR = 20; //mode4
quint32 intM4_THR = 20; //mode4 quint32 intM4_THR = 20; //mode4
quint32 resM4_THR = 20; //mode4 quint32 resM4_THR = 20; //mode4
}; };
/***********************************************************************************************/ /***********************************************************************************************/
struct honaSettings struct HonaSetting
{ {
hiruSettings_t hiruSettings; hiruSettings_t hiruSettings;
hsruSettings_t hsruSettings; hsruSettings_t hsruSettings;
}; };
/***********************************************************************************************/ /***********************************************************************************************/
#endif //SETTING_H #endif //SETTING_H

186
Plx/src/LowLevel/HonaLowLevelAPI.cpp

@ -1,5 +1,3 @@
<<<<<<< HEAD
#include <include/LowLevel/Utils/Utils.h> #include <include/LowLevel/Utils/Utils.h>
#include "include/LowLevel/HonaLowLevelAPI.h" #include "include/LowLevel/HonaLowLevelAPI.h"
#include "include/Wrapper/PlxWrapper.h" #include "include/Wrapper/PlxWrapper.h"
@ -11,25 +9,25 @@ PlxWrapper plx;
bool HonaLowLevelAPI::getHsruIsStarted() const bool HonaLowLevelAPI::getHsruIsStarted() const
{ {
return _hsruIsStarted; return _hsruIsStarted;
} }
/*************************************************************************************************/ /*************************************************************************************************/
void HonaLowLevelAPI::setHsruIsStarted(bool hsruIsStarted) void HonaLowLevelAPI::setHsruIsStarted(bool hsruIsStarted)
{ {
_hsruIsStarted = hsruIsStarted; _hsruIsStarted = hsruIsStarted;
} }
/*************************************************************************************************/ /*************************************************************************************************/
bool HonaLowLevelAPI::getHiruIsStarted() const bool HonaLowLevelAPI::getHiruIsStarted() const
{ {
return _hiruIsStarted; return _hiruIsStarted;
} }
/*************************************************************************************************/ /*************************************************************************************************/
void HonaLowLevelAPI::setHiruIsStarted(bool hiruIsStarted) void HonaLowLevelAPI::setHiruIsStarted(bool hiruIsStarted)
{ {
_hiruIsStarted = hiruIsStarted; _hiruIsStarted = hiruIsStarted;
} }
/*************************************************************************************************/ /*************************************************************************************************/
@ -40,55 +38,54 @@ HonaLowLevelAPI::HonaLowLevelAPI(QObject* parent) : QObject(parent)
/*************************************************************************************************/ /*************************************************************************************************/
bool HonaLowLevelAPI::isHsruStarted() bool HonaLowLevelAPI::isHsruStarted()
{ {
return getHsruIsStarted(); return getHsruIsStarted();
} }
/*************************************************************************************************/ /*************************************************************************************************/
bool HonaLowLevelAPI::isHiruStarted() bool HonaLowLevelAPI::isHiruStarted()
{ {
return getHiruIsStarted(); return getHiruIsStarted();
} }
/*************************************************************************************************/ /*************************************************************************************************/
void HonaLowLevelAPI::deviceReset() void HonaLowLevelAPI::deviceReset()
{ {
ApiResult status; //ApiResult status;
if(ApiResult::success) //if(ApiResult::success)
{ //{
//}
} /*
/* QTime t;
QTime t; t.elapsed()
t.elapsed()
PLX_STATUS status = base.DeviceReset(); PLX_STATUS status = base.DeviceReset();
qDebug() << "Board Reseted, status: " + status.ToString()); qDebug() << "Board Reseted, status: " + status.ToString());
if (status == PLX_STATUS.ApiSuccess) if (status == PLX_STATUS.ApiSuccess)
{ {
toaStartBoard = (ulong) (DateTime.Now.Ticks); toaStartBoard = (ulong) (DateTime.Now.Ticks);
return ApiResult.Success; return ApiResult.Success;
} }
else else
return ApiResult.Error; */ return ApiResult.Error; */
} }
/*************************************************************************************************/ /*************************************************************************************************/
void HonaLowLevelAPI::setConfig(HonaSetting* honaSetting) void HonaLowLevelAPI::setConfig(HonaSetting* honaSetting)
{ {
//Initial State Checking //Initial State Checking
/* /*
HonaRegisterBuffer = new uint[8]; // Mode4 :: changed from 5 to 8 by H.H HonaRegisterBuffer = new uint[8]; // Mode4 :: changed from 5 to 8 by H.H
DeviceReadRegisters(0x10000000, ref HonaRegisterBuffer); DeviceReadRegisters(0x10000000, ref HonaRegisterBuffer);
_honaSetting = Settings; _honaSetting = Settings;
HonaFillRegisters(Settings); HonaFillRegisters(Settings);
DeviceWriteRegisters(0x10000000, HonaRegisterBuffer); DeviceWriteRegisters(0x10000000, HonaRegisterBuffer);
HonaRegisterBuffer = new uint[8]; // Mode4 :: changed from 5 to 8 by H.H HonaRegisterBuffer = new uint[8]; // Mode4 :: changed from 5 to 8 by H.H
DeviceReadRegisters(0x10000000, ref HonaRegisterBuffer); DeviceReadRegisters(0x10000000, ref HonaRegisterBuffer);
return ApiResult.Success; */ return ApiResult.Success; */
} }
/*************************************************************************************************/ /*************************************************************************************************/
@ -105,24 +102,20 @@ QString HonaLowLevelAPI::getSwVersion()
/*************************************************************************************************/ /*************************************************************************************************/
QString HonaLowLevelAPI::getDeviceId() QString HonaLowLevelAPI::getDeviceId()
{ {
} }
/*************************************************************************************************/ /*************************************************************************************************/
void HonaLowLevelAPI::hsruStart() void HonaLowLevelAPI::hsruStart()
{ {
} }
/*************************************************************************************************/ /*************************************************************************************************/
void HonaLowLevelAPI::hiruStart() void HonaLowLevelAPI::hiruStart()
{ {
if(isHiruStarted())
//exceptiom
if (isHiruStarted()) QtConcurrent::run(this, &HonaLowLevelAPI::hsruMainThread);
//exceptiom
QtConcurrent::run(this,&HonaLowLevelAPI::hsruMainThread);
} }
/*************************************************************************************************/ /*************************************************************************************************/
@ -131,36 +124,35 @@ void HonaLowLevelAPI::init()
} }
/*************************************************************************************************/ /*************************************************************************************************/
void HonaLowLevelAPI::writeSettingToRegisters(honaSettings& settings) void HonaLowLevelAPI::writeSettingToRegisters(HonaSetting& settings)
{ {
honaRegisterBuffer[0] = 0x00000000; honaRegisterBuffer[0] = 0x00000000;
/************************************************************************/ /************************************************************************/
if(settings.hiruSettings.recordStard == recorderStart::selfTestCounter) if(settings.hiruSettings.recordStard == recorderStart::selfTestCounter)
honaRegisterBuffer[0] = 0x80000000; honaRegisterBuffer[0] = 0x80000000;
else else
honaRegisterBuffer[0] = 0x7FFFFFFF; honaRegisterBuffer[0] = 0x7FFFFFFF;
/************************************************************************/ /************************************************************************/
if(settings.hiruSettings.recordChannel == drxDeviceIfChannel::ifChannel12) if(settings.hiruSettings.recordChannel == drxDeviceIfChannel::ifChannel12)
honaRegisterBuffer[0] = 0x20000000; honaRegisterBuffer[0] = 0x20000000;
else else
honaRegisterBuffer[0] = 0xDFFFFFFF; honaRegisterBuffer[0] = 0xDFFFFFFF;
/************************************************************************/ /************************************************************************/
if(settings.hiruSettings.recordMode == recorderMode::dualChannel) if(settings.hiruSettings.recordMode == recorderMode::dualChannel)
honaRegisterBuffer[0] = 0x10000000; honaRegisterBuffer[0] = 0x10000000;
else else
honaRegisterBuffer[0] = 0xEFFFFFFF; honaRegisterBuffer[0] = 0xEFFFFFFF;
/************************************************************************/ /************************************************************************/
honaRegisterBuffer[0] += (settings.hiruSettings.threshold & 0x00000FFF);
honaRegisterBuffer[1] = settings.hsruSettings.honaInt123CTHR; honaRegisterBuffer[0] += (settings.hiruSettings.threshold & 0x00000FFF);
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[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;
} }
/*************************************************************************************************/ /*************************************************************************************************/
@ -171,47 +163,45 @@ void HonaLowLevelAPI::setConfig()
/*************************************************************************************************/ /*************************************************************************************************/
void HonaLowLevelAPI::hsruMainThread() 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(); _mutex.lock();
HsruStopEvent.wait(&_mutex); _hsruStopEvent.wait(&_mutex);
_mutex.unlock(); _mutex.unlock();
_isReaderThreadFree = true; _isReaderThreadFree = true;
_isUpdateThreadFree = true; _isUpdateThreadFree = true;
} }
/*************************************************************************************************/ /*************************************************************************************************/
void HonaLowLevelAPI::hsruReadThread() void HonaLowLevelAPI::hsruReadThread()
{ {
while (true) while(true)
{ {
if (_isReaderThreadFree) if(_isReaderThreadFree)
break; break;
//dosth //dosth
_mutex.lock(); _mutex.lock();
HsruReadDone.wakeAll(); _hsruReadDone.wakeAll();
HsruUpdateAck.wait(&_mutex); _hsruUpdateAck.wait(&_mutex);
_mutex.unlock(); _mutex.unlock();
} }
} }
/*************************************************************************************************/ /*************************************************************************************************/
void HonaLowLevelAPI::hsruUpdateThread() void HonaLowLevelAPI::hsruUpdateThread()
{ {
while (true) while(true)
{ {
_mutex.lock(); _mutex.lock();
HsruReadDone.wait(&_mutex); _hsruReadDone.wait(&_mutex);
_mutex.unlock(); _mutex.unlock();
if (_isUpdateThreadFree) if(_isUpdateThreadFree)
break; break;
//dosth //dosth
HsruUpdateAck.wakeAll(); _hsruUpdateAck.wakeAll();
}
}
} }
/*************************************************************************************************/ /*************************************************************************************************/

Loading…
Cancel
Save