修改避障日志
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <QElapsedTimer>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonParseError>
|
||||
#include <QMutexLocker>
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user