添加项目文件。
This commit is contained in:
+122
@@ -0,0 +1,122 @@
|
||||
#ifndef ZIOLINK_PROTOCOL_H
|
||||
#define ZIOLINK_PROTOCOL_H
|
||||
|
||||
|
||||
#include "aris_global.h" // 在文件顶部添加
|
||||
#include "libusbinterface.h"
|
||||
#include <cstring>
|
||||
#include "spectrometercallback.h"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
#include "byteconverter.h"
|
||||
#include <unordered_map>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include <functional> // 用于回调函数
|
||||
#include <future>
|
||||
#include <deque>
|
||||
#include "spectrometerdevice.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class ARIS_EXPORT ZioLinkProtocol { // 添加导出宏
|
||||
public:
|
||||
ZioLinkProtocol();
|
||||
|
||||
~ZioLinkProtocol();
|
||||
|
||||
|
||||
|
||||
void connectDevice();
|
||||
|
||||
void disconnectDevice();
|
||||
|
||||
|
||||
// 获取已连接设备数量
|
||||
size_t getConnectedDeviceCount() const;
|
||||
|
||||
|
||||
// 设置触发模式
|
||||
void setTriggerMode(TriggerMode mode);
|
||||
|
||||
// 获取触发模式
|
||||
TriggerConfig getTriggerMode(int deviceIndex );
|
||||
|
||||
// 启动测量并传入回调函数
|
||||
void startMeasurement(SpectrometerCallback* callback, int exposureTime, int averaging = 1, int delayUs = 0, int measureCount = 1);
|
||||
void startBatchMeasurement(SpectrometerCallback* callback, int exposureTime, int collections, int averaging = 1, int delayUs = 0);
|
||||
// 停止测量
|
||||
void stopMeasurement();
|
||||
|
||||
std::unique_ptr<SpectrometerDevice>& getDevice(int deviceKey);
|
||||
|
||||
|
||||
|
||||
// 新增:暗背景管理方法
|
||||
void takeDarkSpectrum(int exposureTime, int averaging = 1, int deviceIndex = -1); // -1表示所有设备
|
||||
|
||||
void setSubtractDark(bool enable, int deviceIndex) ;
|
||||
private:
|
||||
static const uint16_t TARGET_VID ;
|
||||
static const uint16_t TARGET_PID;
|
||||
|
||||
|
||||
template<typename T>
|
||||
void pack_le(uint8_t* dest, T value) {
|
||||
for (size_t i = 0; i < sizeof(T); ++i) {
|
||||
dest[i] = (value >> (i * 8)) & 0xFF; // 将每一字节存储到数组中
|
||||
}
|
||||
}
|
||||
|
||||
// 设置触发模式为 Free-Running(曝光结束后触发)
|
||||
void setFreeRunningTrigger(int deviceIndex);
|
||||
|
||||
// 设置硬件上升沿触发模式
|
||||
void setHardwareRisingEdgeTrigger(int deviceIndex);
|
||||
|
||||
|
||||
void checkStatusAndNotify(SpectrometerCallback* callback,
|
||||
int deviceIndex,
|
||||
std::chrono::steady_clock::time_point startTime,
|
||||
std::chrono::system_clock::time_point startWallTime,
|
||||
int exposureTimeUs,
|
||||
int averaging);
|
||||
|
||||
std::vector<std::tuple<uint8_t, uint8_t>> mFoundDevices;
|
||||
|
||||
|
||||
int mCurrentDeviceIndex ;
|
||||
void getSpectrometerStatus( int deviceIndex);
|
||||
|
||||
// 设置测量参数
|
||||
void setExposureParams(int exposureTime = 30000, int averaging = 1, int deviceIndex=0);
|
||||
|
||||
|
||||
// 停止测量
|
||||
void stopDeviceMeasurement(int deviceIndex);
|
||||
|
||||
// 关闭当前设备
|
||||
void disconnectCurrentDevice( int deviceIndex);
|
||||
|
||||
// 线程安全状态管理
|
||||
std::mutex deviceMutex;
|
||||
|
||||
// 设备连接池,保存每个设备的独立连接
|
||||
std::vector<std::unique_ptr<SpectrometerDevice>> mDevicePool;
|
||||
|
||||
std::atomic<bool> isStop{true};
|
||||
|
||||
|
||||
|
||||
std::deque<std::unique_ptr<std::atomic<bool>>> deviceMeasurementStatus;
|
||||
|
||||
|
||||
std::vector<std::unique_ptr<std::mutex>> mDeviceMutexes;
|
||||
std::vector<std::thread> measurementThreads;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // ZIOLINK_PROTOCOL_H
|
||||
Reference in New Issue
Block a user