添加项目文件。

This commit is contained in:
ldh
2026-11-06 14:45:09 +08:00
parent fb76f2ed7d
commit 24cbecc2cc
3437 changed files with 895900 additions and 0 deletions
+431
View File
@@ -0,0 +1,431 @@
// ===========================================================================
// ARIS 兼容桩(aris_stub.dll)
//
// 作用:
// 本机只有 64 位版 libaris(G:/qt/Qt/mylib/aris_0411,闭源,无源码),
// 在 32 位(MinGW 32-bit)目标下无法使用。为了让工程在 32 位套件下也能
// 正常编译、启动和调试界面/算法,这里用**真实的 ARIS 头文件**编译一个
// 接口完全一致的空实现 DLL:
//
// * 所有函数签名、类布局与正式 SDK 完全相同(直接编译厂商头文件);
// * 连接/采集等操作均为空实现,设备数量恒为 0;
// * 拿到 32 位版 ARIS SDK 后,把它放到 third_party/aris-mingw32/
// 或配置时传 -DARIS_ROOT=<目录>,CMake 会自动改用真实 SDK,
// 本文件不会被编译。
//
// 注意:此 DLL 只能用于界面/算法调试,无法驱动光谱仪硬件。
// ===========================================================================
#include <cstdio>
#include <utility>
#include "aris.h"
#include "libusbinterface.h"
#include "spectrometerdevice.h"
#include "ziolinkprotocol.h"
namespace {
void warnStubOnce()
{
static bool warned = false;
if (!warned) {
warned = true;
// 走 stdout:main.cpp 会把 libaris 的 UTF-8 输出转成本地代码页,中文不会乱码
std::fprintf(stdout,
"[ARIS-STUB] 当前使用的是 ARIS 兼容桩(无光谱仪硬件功能)。\n"
"[ARIS-STUB] 如需驱动硬件,请提供与程序位数一致的 ARIS SDK。\n");
}
}
} // namespace
// ---------------------------------------------------------------------------
// Aris
// ---------------------------------------------------------------------------
Aris::Aris() = default;
// ---------------------------------------------------------------------------
// LibusbInterface
// ---------------------------------------------------------------------------
libusb_context *LibusbInterface::sUsbContext = nullptr;
int LibusbInterface::sInstanceCount = 0;
LibusbInterface::LibusbInterface(uint16_t vendorId, uint16_t productId,
uint8_t busNumber, uint8_t deviceAddress)
: mDevHandle(nullptr)
, mVendorId(vendorId)
, mProductId(productId)
, mBusNumber(busNumber)
, mDeviceAddress(deviceAddress)
, mOpenFlag(false)
, mEndpointOut(0)
, mEndpointIn(0)
{
}
LibusbInterface::~LibusbInterface() = default;
void LibusbInterface::open()
{
}
void LibusbInterface::close()
{
}
bool LibusbInterface::isOpen() const
{
return false;
}
void LibusbInterface::write(const std::vector<unsigned char> &)
{
}
std::vector<unsigned char> LibusbInterface::read(int)
{
return {};
}
std::vector<std::tuple<uint8_t, uint8_t>>
LibusbInterface::findDevices(uint16_t, uint16_t)
{
return {};
}
void LibusbInterface::initUsbContext()
{
}
void LibusbInterface::cleanupUsbContext()
{
}
void LibusbInterface::setupEndpoints(libusb_device *)
{
}
void LibusbInterface::configureDevice()
{
}
// ---------------------------------------------------------------------------
// SpectrometerDevice
// ---------------------------------------------------------------------------
SpectrometerDevice::SpectrometerDevice()
: m_startPixel(0)
, m_endPixel(0)
, m_pixelCount(0)
, m_device(nullptr)
, m_deviceIndex(0)
, m_subtractDark(false)
, m_hasDarkSpectrum(false)
{
}
SpectrometerDevice::SpectrometerDevice(std::unique_ptr<LibusbInterface> device)
: m_startPixel(0)
, m_endPixel(0)
, m_pixelCount(0)
, m_device(std::move(device))
, m_deviceIndex(0)
, m_subtractDark(false)
, m_hasDarkSpectrum(false)
{
}
SpectrometerParameters SpectrometerDevice::getParameters() const
{
SpectrometerParameters parameters;
parameters.serialNumber = m_serialNumber;
parameters.startPixel = 0;
parameters.endPixel = 0;
parameters.pixelCount = 0;
parameters.wavelengths.clear();
return parameters;
}
void SpectrometerDevice::disconnect()
{
}
void SpectrometerDevice::setExposureParams(int, int)
{
}
void SpectrometerDevice::setTriggerMode(TriggerMode)
{
}
TriggerConfig SpectrometerDevice::getTriggerMode()
{
return TriggerConfig{};
}
void SpectrometerDevice::startMeasure()
{
}
void SpectrometerDevice::startMeasure(int)
{
}
void SpectrometerDevice::standBy()
{
}
SpectrStatus SpectrometerDevice::getStatus()
{
return SpectrStatus::NotConnected;
}
StatusInfo SpectrometerDevice::getStatusInfo()
{
StatusInfo info;
info.status = SpectrStatus::NotConnected;
info.availableSpectra = 0;
return info;
}
std::vector<float> SpectrometerDevice::getSpectrum()
{
return {};
}
std::vector<float> SpectrometerDevice::getSpectrum(uint32_t &time01ms, uint32_t &dateDays)
{
time01ms = 0;
dateDays = 0;
return {};
}
std::vector<float> SpectrometerDevice::getSpectrum(uint32_t &time01ms, uint32_t &dateDays,
uint32_t &exposureTimeUs, uint32_t &averaging)
{
time01ms = 0;
dateDays = 0;
exposureTimeUs = 0;
averaging = 0;
return {};
}
std::vector<std::vector<float>> SpectrometerDevice::getAllSpectrumData()
{
return {};
}
void SpectrometerDevice::discardSpectrum()
{
}
std::vector<float> SpectrometerDevice::getWavelength()
{
return m_wavelengths;
}
void SpectrometerDevice::stopMeasure()
{
}
void SpectrometerDevice::takeDarkSpectrum()
{
}
void SpectrometerDevice::setSubtractDark(bool)
{
}
void SpectrometerDevice::setGain(int)
{
}
void SpectrometerDevice::setDelayParams(int)
{
}
void SpectrometerDevice::cancelExposure()
{
}
void SpectrometerDevice::initialize()
{
}
std::string SpectrometerDevice::getSerialNumber()
{
return m_serialNumber;
}
int SpectrometerDevice::getStartPixel()
{
return 0;
}
int SpectrometerDevice::getEndPixel()
{
return 0;
}
int SpectrometerDevice::getPixelCount()
{
return 0;
}
std::vector<float> SpectrometerDevice::readWavelengthsFromDevice()
{
return {};
}
std::vector<unsigned char>
SpectrometerDevice::sendBulkReceiveMessage(const std::vector<unsigned char> &)
{
return {};
}
std::vector<uint8_t> SpectrometerDevice::sendReceiveMessage(uint32_t)
{
return {};
}
std::vector<uint8_t> SpectrometerDevice::sendReceiveMessage(uint32_t, uint32_t)
{
return {};
}
std::vector<uint8_t> SpectrometerDevice::sendReceiveMessage(uint32_t,
const std::vector<uint8_t> &)
{
return {};
}
std::vector<uint8_t> SpectrometerDevice::readBulkData(size_t)
{
return {};
}
void SpectrometerDevice::setFreeRunningTrigger()
{
}
void SpectrometerDevice::setHardwareRisingEdgeTrigger()
{
}
void SpectrometerDevice::saveSpectrumWithDarkSubtractionCSV(const std::vector<float> &)
{
}
std::string SpectrometerDevice::generateRandomFilename(const std::string &prefix,
const std::string &ext)
{
return prefix + ext;
}
FirmwareVersion SpectrometerDevice::readSoftwareVersion()
{
return FirmwareVersion{};
}
void SpectrometerDevice::updateTimeInDevice()
{
}
void SpectrometerDevice::ensureIdleForConfiguration()
{
}
// ---------------------------------------------------------------------------
// ZioLinkProtocol
// ---------------------------------------------------------------------------
ZioLinkProtocol::ZioLinkProtocol()
: mCurrentDeviceIndex(0)
, isStop(true)
{
warnStubOnce();
// 预置一个空设备,保证 getDevice() 返回有效引用
mDevicePool.emplace_back(std::unique_ptr<SpectrometerDevice>(new SpectrometerDevice()));
}
ZioLinkProtocol::~ZioLinkProtocol() = default;
void ZioLinkProtocol::connectDevice()
{
}
void ZioLinkProtocol::disconnectDevice()
{
}
size_t ZioLinkProtocol::getConnectedDeviceCount() const
{
return 0;
}
void ZioLinkProtocol::setTriggerMode(TriggerMode)
{
}
TriggerConfig ZioLinkProtocol::getTriggerMode(int)
{
return TriggerConfig{};
}
void ZioLinkProtocol::startMeasurement(SpectrometerCallback *, int, int, int, int)
{
}
void ZioLinkProtocol::startBatchMeasurement(SpectrometerCallback *, int, int, int, int)
{
}
void ZioLinkProtocol::stopMeasurement()
{
}
std::unique_ptr<SpectrometerDevice> &ZioLinkProtocol::getDevice(int deviceKey)
{
if (deviceKey < 0 || static_cast<size_t>(deviceKey) >= mDevicePool.size()) {
return mDevicePool.front();
}
return mDevicePool[static_cast<size_t>(deviceKey)];
}
void ZioLinkProtocol::takeDarkSpectrum(int, int, int)
{
}
void ZioLinkProtocol::setSubtractDark(bool, int)
{
}
void ZioLinkProtocol::setFreeRunningTrigger(int)
{
}
void ZioLinkProtocol::setHardwareRisingEdgeTrigger(int)
{
}
void ZioLinkProtocol::checkStatusAndNotify(SpectrometerCallback *, int,
std::chrono::steady_clock::time_point,
std::chrono::system_clock::time_point,
int, int)
{
}
void ZioLinkProtocol::getSpectrometerStatus(int)
{
}
void ZioLinkProtocol::setExposureParams(int, int, int)
{
}
void ZioLinkProtocol::stopDeviceMeasurement(int)
{
}
void ZioLinkProtocol::disconnectCurrentDevice(int)
{
}