主要新增功能: 1. 添加 Debian 打包脚本 (pack_deb.sh),支持一键打包部署 2. 新增机顶辐照度使用说明书 (README.md),记录系统配置和使用方法 3. 添加 SD 卡配置更新功能 (configdatairis 文件夹),便于现场配置 4. 新增光谱仪打开失败检测,两灯同时闪烁提示异常 5. 添加说明书自动拷贝到 SD 卡功能 详细修改: - main.cpp: * 添加 SD 卡 configdatairis 配置更新逻辑 * 添加说明书自动拷贝到 /home/data/ * 优化 stopwait.txt 判断逻辑 - Source/Capture/MainGrabber.cpp: * 添加光谱仪初始化失败检测,失败时两灯同时闪烁 - Source/Logger/Logger.h: * 添加日志功能支持 - pack_deb.sh: * 新增完整的 Debian 打包脚本 * 支持自动构建、复制文件、生成 postinst/prerm - root/start.sh: * 添加 mkdir 确保 /home/data 目录存在 - root/DCTable.txt: * 添加默认暗电流校准表文件 - README.md: * 编写完整的中文使用说明书 * 包含硬件连接、目录结构、配置说明、GPIO 指示灯含义等 依赖文件: - /root/DeviceSettings.ini (需另行配置) - /root/机顶辐照度使用说明书.md (打包时自动复制)
92 lines
2.3 KiB
C++
92 lines
2.3 KiB
C++
//
|
|
// Created by xin on 2021/8/17.
|
|
//edit by zz.
|
|
//fixed code page problem;added a new initialize function; --20211101
|
|
#pragma once
|
|
|
|
#include <QFile>
|
|
#include <QTextStream>
|
|
#include <QDateTime>
|
|
#include "qmutex.h"
|
|
#include "QtMsgHandler"
|
|
|
|
namespace QT_LOG
|
|
{
|
|
static int m_LogLevel = 1;
|
|
static QString m_LogFile = QString("%1.log").arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmss"));
|
|
QMutex m_LogMutex;
|
|
|
|
void customMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
|
{
|
|
if (type < m_LogLevel)
|
|
{
|
|
return;
|
|
}
|
|
|
|
QString log_info;
|
|
switch (type)
|
|
{
|
|
case QtDebugMsg:
|
|
log_info = QString("%1:%2").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"),msg);
|
|
break;
|
|
|
|
case QtWarningMsg:
|
|
log_info = QString("%1[Warning]:%2").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"),msg);
|
|
break;
|
|
|
|
case QtCriticalMsg:
|
|
log_info = QString("%1[Critical]:%2").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"),msg);
|
|
break;
|
|
|
|
case QtFatalMsg:
|
|
log_info = QString("%1[Fatal]:%2").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"),msg);
|
|
abort();
|
|
}
|
|
|
|
m_LogMutex.lock();
|
|
|
|
QFile outFile(m_LogFile);
|
|
outFile.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text);
|
|
QTextStream ts(&outFile);
|
|
ts << log_info << endl;
|
|
std::cout<< log_info.toStdString() << std::endl;
|
|
outFile.close();
|
|
|
|
m_LogMutex.unlock();
|
|
}
|
|
void logInit(QString logFile = "",int logLevel = 0)
|
|
{
|
|
|
|
#ifndef DEBUG
|
|
if ((logLevel < 0) || (logLevel > 3))
|
|
{
|
|
m_LogLevel = 1;
|
|
}
|
|
else
|
|
{
|
|
m_LogLevel = logLevel;
|
|
}
|
|
|
|
if (!logFile.isEmpty())
|
|
{
|
|
m_LogFile = logFile+"/"+m_LogFile;
|
|
}
|
|
|
|
qInstallMessageHandler(customMessageHandler);
|
|
//qInstallMsgHandler(customMessageHandler);
|
|
#endif
|
|
}
|
|
|
|
//added by IRIS_ZZ initialize from main
|
|
void ZZ_InitLogger(QString qstrDir)
|
|
{
|
|
QDir qdLogFolder;
|
|
qdLogFolder.mkdir(qstrDir);
|
|
qDebug() << QT_LOG::m_LogFile;
|
|
QT_LOG::logInit(qstrDir);
|
|
}
|
|
};
|
|
|
|
|
|
|