From b5969dee83d35fa254eaf3c40e8a3b875ad5090e Mon Sep 17 00:00:00 2001 From: lidg Date: Thu, 12 Nov 2026 14:39:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=81=BF=E9=9A=9C=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/visiondllworker.cpp | 17 +++++++++++++++-- services/visionservice.cpp | 4 +++- ssp.pro.user | 2 +- tools/Deploy-Bin.ps1 | 9 +++++++-- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/services/visiondllworker.cpp b/services/visiondllworker.cpp index d7bfb53..b70394a 100644 --- a/services/visiondllworker.cpp +++ b/services/visiondllworker.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -34,7 +35,17 @@ QJsonObject readObject(const QString &path, QString *error) QString operationMessage(const QJsonObject &result) { - const QString message = result.value("message").toString(); + QString message = result.value("message").toString(); + for (const QJsonValue &value : result.value("cameras").toArray()) { + const QJsonObject camera = value.toObject(); + const QString error = camera.value("error").toString(); + if (error.isEmpty()) continue; + const QString side = camera.value("camera").toString(); + message += QString(";%1(%2):%3") + .arg(side == "left" ? QStringLiteral("左相机") + : side == "right" ? QStringLiteral("右相机") : QStringLiteral("相机")) + .arg(camera.value("serial").toString()).arg(error); + } return message.isEmpty() ? QStringLiteral("DLL 未返回详细原因") : message; } } @@ -181,11 +192,13 @@ void VisionDllWorker::initializeDevices(int initializeTimeoutMs) }; HikVisionGuidanceQt::Reply reply = timedCall("InitializeCamera", {{"camera", "both"}}); + // A failed initialization can still leave partially opened or stale camera handles. + m_cameraConnected = true; if (!reply.ok()) { + rollbackDevices(); emit devicesInitialized(false, reply.json, replyError("初始化相机", reply)); return; } - m_cameraConnected = true; reply = timedCall("InitializeLight"); if (!reply.ok()) { diff --git a/services/visionservice.cpp b/services/visionservice.cpp index 2cd5c27..1e28d9e 100644 --- a/services/visionservice.cpp +++ b/services/visionservice.cpp @@ -247,7 +247,9 @@ void VisionService::finishAvoidance(int code, const QJsonObject &result) if (!m_avoidanceDiscarded && m_avoidanceEnabled && !m_shuttingDown && !m_releasing) { const double distance = result.value("distance_mm").toDouble(); const bool warning = distance < m_config.warningDistanceMm; - if (code != HVG_OK) { + if (code == HVG_DISTANCE_UNKNOWN) { + m_avoidanceLogKey.clear(); + } else if (code != HVG_OK) { logAvoidance("ERROR", QString("避障检测失败(code=%1):%2") .arg(code).arg(result.value("message").toString())); if (code == HVG_NOT_READY || code == HVG_DEVICE_ERROR || code == HVG_CONFIG_ERROR) diff --git a/ssp.pro.user b/ssp.pro.user index 6b2f803..f10f3a3 100644 --- a/ssp.pro.user +++ b/ssp.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/tools/Deploy-Bin.ps1 b/tools/Deploy-Bin.ps1 index bf17c09..69ab623 100644 --- a/tools/Deploy-Bin.ps1 +++ b/tools/Deploy-Bin.ps1 @@ -84,9 +84,13 @@ Copy-FileIfChanged (Join-Path $qt 'plugins/sqldrivers/qsqlpsql.dll') ` (Join-Path $output 'sqldrivers/qsqlpsql.dll') foreach ($name in @('libpq.dll', 'libssl-3-x64.dll', 'libcrypto-3-x64.dll', - 'libintl-9.dll', 'libiconv-2.dll', 'libwinpthread-1.dll')) { + 'libintl-9.dll', 'libiconv-2.dll')) { Copy-FileIfChanged (Join-Path $postgres $name) (Join-Path $output $name) } +# PostgreSQL loads libwinpthread first. Use the SDK version for both consumers: +# the older PostgreSQL copy lacks clock_gettime64/nanosleep64 required by MVS FFmpeg. +Copy-FileIfChanged (Join-Path $sdkBin 'ThirdParty/libwinpthread-1.dll') ` + (Join-Path $output 'libwinpthread-1.dll') if (-not $RuntimeOnly) { Copy-FileIfChanged (Join-Path $project 'config.ini') (Join-Path $output 'config.ini') @@ -99,7 +103,8 @@ $requiredRuntime = @( 'VisionGuide.dll', 'VisionGuide_cpp.dll', 'MvCameraControl.dll', 'Qt5Core.dll', 'Qt5Gui.dll', 'Qt5Widgets.dll', 'Qt5Network.dll', 'Qt5SerialPort.dll', 'Qt5SerialBus.dll', 'Qt5Sql.dll', - 'platforms/qwindows.dll', 'sqldrivers/qsqlpsql.dll', 'libpq.dll' + 'platforms/qwindows.dll', 'sqldrivers/qsqlpsql.dll', 'libpq.dll', + 'libwinpthread-1.dll', 'ThirdParty/libwinpthread-1.dll' ) foreach ($relative in $requiredRuntime) { if (-not (Test-Path -LiteralPath (Join-Path $output $relative) -PathType Leaf)) {