From 7a5f33695706dfe936a8b057b089d9e71f19a954 Mon Sep 17 00:00:00 2001 From: Alireza Date: Wed, 8 Dec 2021 19:07:20 +0330 Subject: [PATCH] fix some code --- .../Exception/HonaAlreadyStartedException.h | 23 ++++--- .../LowLevel/Exception/HonaBusyException.h | 23 ++++--- Plx/include/LowLevel/HonaLowLevelAPI.h | 13 +++- .../Exception/HonaAlreadyStartedException.cpp | 6 -- .../LowLevel/Exception/HonaBusyException.cpp | 6 -- Plx/src/LowLevel/HonaLowLevelAPI.cpp | 61 ++++++++++++++++++- 6 files changed, 100 insertions(+), 32 deletions(-) delete mode 100644 Plx/src/LowLevel/Exception/HonaAlreadyStartedException.cpp delete mode 100644 Plx/src/LowLevel/Exception/HonaBusyException.cpp diff --git a/Plx/include/LowLevel/Exception/HonaAlreadyStartedException.h b/Plx/include/LowLevel/Exception/HonaAlreadyStartedException.h index e0a484a..eaf159e 100644 --- a/Plx/include/LowLevel/Exception/HonaAlreadyStartedException.h +++ b/Plx/include/LowLevel/Exception/HonaAlreadyStartedException.h @@ -1,17 +1,24 @@ #ifndef HONAALREADYSTARTEDEXCEPTION_H #define HONAALREADYSTARTEDEXCEPTION_H -#include +#include +#include -class HonaAlreadyStartedException : public QObject +class HonaAlreadyStartedException : public std::exception { - Q_OBJECT -public: - explicit HonaAlreadyStartedException(QObject *parent = nullptr); +private: + QString _str; -signals: +public: + HonaAlreadyStartedException(QString str) + { + _str = str; + } -public slots: + virtual const char* what() const throw() + { + return _str.toStdString().c_str(); + } }; -#endif // HONAALREADYSTARTEDEXCEPTION_H +#endif //HONAALREADYSTARTEDEXCEPTION_H diff --git a/Plx/include/LowLevel/Exception/HonaBusyException.h b/Plx/include/LowLevel/Exception/HonaBusyException.h index 4440628..d466099 100644 --- a/Plx/include/LowLevel/Exception/HonaBusyException.h +++ b/Plx/include/LowLevel/Exception/HonaBusyException.h @@ -1,17 +1,24 @@ #ifndef HONABUSYEXCEPTION_H #define HONABUSYEXCEPTION_H -#include +#include +#include -class HonaBusyException : public QObject +class HonaBusyException : public std::exception { - Q_OBJECT -public: - explicit HonaBusyException(QObject *parent = nullptr); +private: + QString _str; -signals: +public: + HonaBusyException(QString str) + { + _str = str; + } -public slots: + virtual const char* what() const throw() + { + return _str.toStdString().c_str(); + } }; -#endif // HONABUSYEXCEPTION_H +#endif //HONABUSYEXCEPTION_H diff --git a/Plx/include/LowLevel/HonaLowLevelAPI.h b/Plx/include/LowLevel/HonaLowLevelAPI.h index 972ea1b..77e9111 100644 --- a/Plx/include/LowLevel/HonaLowLevelAPI.h +++ b/Plx/include/LowLevel/HonaLowLevelAPI.h @@ -10,12 +10,17 @@ class HonaLowLevelAPI : public QObject { Q_OBJECT +private: + bool _hsruIsStarted; + bool _hiruIsStarted; + HonaSetting _honaSetting; + public: explicit HonaLowLevelAPI(QObject* parent = nullptr); bool isHsruStarted(); bool isHiruStarted(); void deviceReset(); - void setConfig(HonaSetting& honaSetting); + void setConfig(HonaSetting* honaSetting); HonaSetting getConfig(); QString getSwVersion(); QString getDeviceId(); @@ -23,6 +28,12 @@ public: void hiruStart(); void init(); + bool getHsruIsStarted() const; + void setHsruIsStarted(bool hsruIsStarted); + + bool getHiruIsStarted() const; + void setHiruIsStarted(bool hiruIsStarted); + private: void writeSettingToRegisters(HonaSetting& honaSetting); void setConfig(); diff --git a/Plx/src/LowLevel/Exception/HonaAlreadyStartedException.cpp b/Plx/src/LowLevel/Exception/HonaAlreadyStartedException.cpp deleted file mode 100644 index 9df262d..0000000 --- a/Plx/src/LowLevel/Exception/HonaAlreadyStartedException.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "../../../include/LowLevel/Exception/HonaAlreadyStartedException.h" - -HonaAlreadyStartedException::HonaAlreadyStartedException(QObject *parent) : QObject(parent) -{ - -} diff --git a/Plx/src/LowLevel/Exception/HonaBusyException.cpp b/Plx/src/LowLevel/Exception/HonaBusyException.cpp deleted file mode 100644 index 37f58f0..0000000 --- a/Plx/src/LowLevel/Exception/HonaBusyException.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "../../../include/LowLevel/Exception/HonaBusyException.h" - -HonaBusyException::HonaBusyException(QObject *parent) : QObject(parent) -{ - -} diff --git a/Plx/src/LowLevel/HonaLowLevelAPI.cpp b/Plx/src/LowLevel/HonaLowLevelAPI.cpp index 62509d5..74cd9ba 100644 --- a/Plx/src/LowLevel/HonaLowLevelAPI.cpp +++ b/Plx/src/LowLevel/HonaLowLevelAPI.cpp @@ -1,28 +1,83 @@ #include "../../include/LowLevel/HonaLowLevelAPI.h" +#include "qdebug.h" +#include "QTime" + +bool HonaLowLevelAPI::getHsruIsStarted() const +{ + return _hsruIsStarted; +} + +/*************************************************************************************************/ +void HonaLowLevelAPI::setHsruIsStarted(bool hsruIsStarted) +{ + _hsruIsStarted = hsruIsStarted; +} + +/*************************************************************************************************/ +bool HonaLowLevelAPI::getHiruIsStarted() const +{ + return _hiruIsStarted; +} + +/*************************************************************************************************/ +void HonaLowLevelAPI::setHiruIsStarted(bool hiruIsStarted) +{ + _hiruIsStarted = hiruIsStarted; +} + +/*************************************************************************************************/ HonaLowLevelAPI::HonaLowLevelAPI(QObject* parent) : QObject(parent) { } +/*************************************************************************************************/ bool HonaLowLevelAPI::isHsruStarted() { - return true; + return getHsruIsStarted(); } /*************************************************************************************************/ bool HonaLowLevelAPI::isHiruStarted() { - return true; + return getHiruIsStarted(); } /*************************************************************************************************/ void HonaLowLevelAPI::deviceReset() { + /* + 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; */ } /*************************************************************************************************/ -void HonaLowLevelAPI::setConfig(HonaSetting& honaSetting) +void HonaLowLevelAPI::setConfig(HonaSetting* honaSetting) { + //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; */ } /*************************************************************************************************/