123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- #ifndef _OneOscilloscopeData_H_
- #define _OneOscilloscopeData_H_
- #include <QObject>
- #include <QMap>
- #include "USBInterFace.h"
- #include "spdlog/spdlog.h"
- #include "GlobalInfo.h"
- #include "OscDataInfo.h"
- #include "RingQueue/RingQueue.hpp"
- #define OneOscData OneOscilloscopeData::getInstance()
- class OneOscilloscopeData : public QObject
- {
- Q_OBJECT
- const uint32_t BUFFER_SIZE = 1024 * 128 ;
- private:
-
- OneOscilloscopeData(const OneOscilloscopeData&) = delete;
- OneOscilloscopeData& operator=(const OneOscilloscopeData&) = delete;
- public:
- OneOscilloscopeData();
- ~OneOscilloscopeData();
- static OneOscilloscopeData& getInstance()
- {
- static OneOscilloscopeData instance;
- return instance;
- }
-
- void initOsc();
-
- bool openOSC();
-
- void closeOSC();
-
- bool isOpen() { return m_isOpen; }
-
- bool startCapture();
-
- void stopCapture();
-
-
- void setSampleRate(OscSampleRate rate);
-
- void setChannelMerge(bool merge);
-
- void setChannelARange(OscVoltageRange range);
-
- void setChannelBRange(OscVoltageRange range);
-
- void setChannelCoupling(OscChannel channel, OscChannelCoupling coupling);
-
- void setChannelATrigger(bool enable);
-
- void setExternalTrigger(bool enable);
-
- void setTriggerMode(OscTriggerMode mode);
-
- void setTriggerLevel(unsigned char level);
-
- void setTriggerSensitivity(OscTriggerSensitivity sensitivity);
-
- void setTriggerPosition(unsigned char lowByte, unsigned char highByte);
-
- void getZeroVoltage();
-
- void printZeroVoltage(OscChannel channel);
-
- void getVoltageCalibration();
-
- void printVoltageCalibration(OscChannel channel);
- public:
-
- void threadCaptureData();
-
- void threadSeparateData();
-
- void threadProcessData_A();
-
- void threadProcessData_B();
-
- void parseEyeMapData(OscChannel chn, unsigned char* buffer, unsigned int size);
-
- void setZeroVoltageAndCalibration(OscChannel chn, OscVoltageRange range);
-
- inline double calibrationVoltageA(uint8_t& data);
- inline double calibrationVoltageB(uint8_t& data);
- private:
- std::shared_ptr<spdlog::logger> m_logger = nullptr;
- std::shared_ptr<USBInterface> m_usbInterface = nullptr;
- std::atomic_bool m_isOpen = false;
- std::atomic_bool m_runCapture = false;
- std::atomic_bool m_isRunCapture = false;
- std::atomic_bool m_isCapturedData = false;
- std::condition_variable m_condCapture;
- std::condition_variable m_condBuffer_A;
- std::condition_variable m_condBuffer_B;
- std::mutex m_mutexBuffer;
- std::mutex m_mutexBuffer_A;
- std::mutex m_mutexBuffer_B;
- unsigned char* m_devBuffer = nullptr;
- unsigned char* m_buffer = nullptr;
- unsigned char* m_bufferChnA = nullptr;
- unsigned char* m_bufferChnB = nullptr;
- RingQueue<unsigned char*> m_ringQueue;
- unsigned char m_ctrlByte0 = 0;
- unsigned char m_ctrlByte1 = 0;
- QMap<OscVoltageRange, unsigned char> m_mapChAZeroVoltage;
- QMap<OscVoltageRange, unsigned char> m_mapChBZeroVoltage;
- QMap<OscVoltageRange, unsigned char> m_mapChAVoltageAmplitudeRatio;
- QMap<OscVoltageRange, unsigned char> m_mapChBVoltageAmplitudeRatio;
- unsigned char m_zeroVoltageA = 0;
- unsigned char m_zeroVoltageB = 0;
- char m_diffVoltageA = 0;
- char m_diffVoltageB = 0;
- double m_voltageCalibrationA = 0;
- double m_voltageCalibrationB = 0;
- double m_rangeRatioA = 0.0;
- double m_rangeRatioB = 0.0;
-
- EyeDataMatrix* m_eyeDataMatrix_A = nullptr;
- EyeDataMatrix* m_eyeDataMatrix_B = nullptr;
- EyeMapMatrix* m_eyeMapMatrix_A = nullptr;
- EyeMapMatrix* m_eyeMapMatrix_B = nullptr;
- };
- #endif
|