#ifndef DEVICEMANAGER_H #define DEVICEMANAGER_H #include #include #include "../Public/util.h" #include #include #include "../Spectrometer/spectrometer.h" #ifdef CAVITY_USE_ARIS_BRIDGE // MSVC 构建:通过 MinGW 编译的 aris_bridge.dll 驱动真实 ARIS SDK(纯 C 接口) #include "arisbridge.h" #else #include "spectrometercallback.h" #endif namespace std { //class vector; } #ifndef CAVITY_USE_ARIS_BRIDGE class ZioLinkProtocol; #endif // 两种后端: // * CAVITY_USE_ARIS_BRIDGE(MSVC + aris_bridge.dll):不继承 SDK 的回调类 // * 否则直接链接 ARIS SDK(MinGW)或兼容桩(aris_stub.dll) #ifdef CAVITY_USE_ARIS_BRIDGE class DeviceManager : public QObject #else class DeviceManager : public QObject, public SpectrometerCallback #endif { Q_OBJECT public: DeviceManager(QObject *parent = nullptr); ~DeviceManager(); std::vector readWavelengthCalibratedFile(const string &serialNumber); std::vector DetectDeviceLst(); //检测设备列表,并激活(打开设备) void CloseAllDevice(); //关闭所有的设备 std::vector GetDeviceList();//获取设备列表 static unsigned int m_nDeviceNum ; //实际已连接的设备数量 static std::vector m_pDeviceLst; int pixelCount; private: bool IsAllDevicesReady(); //检测所有设备是否都已准备就绪 void DeactivateDeviceLst(); //关闭所有设备 // 用波长校准文件覆盖设备的波长表;文件缺失/格式错误时退回设备自带波长 void loadDeviceWavelengths(Spectrometer *device, const std::vector &fallback); // 把光谱数据转成 Qt 信号发出去(可能来自设备的采集线程) void handleData(const std::string &serialNumber, const std::vector &wavelengthList, const std::vector &intensityList); bool bStartMeasure; bool stopscanning = true; int iRecvCnt; int iCurExecTimes; int iDataLen; #ifdef CAVITY_USE_ARIS_BRIDGE // 桥接 DLL 的数据回调(静态,转给当前实例) static void onBridgeData(const std::string &serialNumber, const std::vector &wavelengthList, const std::vector &intensityList); #else ZioLinkProtocol* m_pZio; #endif public slots: void onDetectDeviceLst(); #ifndef CAVITY_USE_ARIS_BRIDGE void onDataReceived(std::string deviceIndex,const std::vector &wavelength, const std::vector &spectrum) override; // 批量测量回调(ARIS 0411 版 SDK 新增的纯虚函数,必须实现,否则本类仍是抽象类) void onDataReceivedBanch(std::string deviceIndex,const std::vector &wavelength, const std::vector> &spectrum) override; // 回调函数,当发生错误时被调用 void onError(std::string, const std::string& error) override ; #endif int StartMeasure(int integrationTime, int nrAverages); void stopMeasure(); signals: void DetectDeviceFinish(std::vector m_pDeviceLst); void spectrumDataReady(QString deviceIndex, const QVector& wavelengthList, const QVector& spectrumList); }; #endif // DEVICEMANAGER_H