diff --git a/app/HxDataBase.cpp b/app/HxDataBase.cpp index 87167c4..c08bd19 100644 --- a/app/HxDataBase.cpp +++ b/app/HxDataBase.cpp @@ -142,9 +142,9 @@ void DataBase::initialization() /* 创建 程序配置信息 表 */ if (!query.exec("CREATE TABLE IF NOT EXISTS [Setting] (" - " [name] TEXT NOT NULL PRIMARY KEY," - " [value] TEXT" - ");")) + " [name] TEXT NOT NULL PRIMARY KEY," + " [value] TEXT" + ");")) { qDebug("配置表创建失败"); return; @@ -175,14 +175,14 @@ void DataBase::initialization() bsd_video_input_source = read_setting("bsd_video_input_source", QString(";;;;;;")).split(";"); bsd_warn_regions = read_setting( - "bsd_warn_regions", - QString("0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0*" - "0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0*" - "0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0*" - "0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0*" - "0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0*" - "0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0")) - .split("*"); + "bsd_warn_regions", + QString("0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0*" + "0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0*" + "0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0*" + "0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0*" + "0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0*" + "0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0$0,0 0,0 0,0 0,0")) + .split("*"); } bool DataBase::save_setting() diff --git a/app/HxTaskDispatch.h b/app/HxTaskDispatch.h index bde63ef..b00ce84 100644 --- a/app/HxTaskDispatch.h +++ b/app/HxTaskDispatch.h @@ -36,7 +36,7 @@ public: static DataBase database(void); - static CarInfoInput *get_car_info(void); + static CarInfoInput* get_car_info(void); static QString get_video_frame_data(int type, int channel, int id); @@ -83,10 +83,10 @@ private: QDateTime vehicle_status_update_time; /* 边缘云 Socket (客户端) */ - HxSocketUtils *platform; + HxSocketUtils* platform; /* DebugTool Socket (服务端) */ - HxSocketUtils *debug_tool; + HxSocketUtils* debug_tool; /* 车辆状态信息 */ CarInfoInput car_info; diff --git a/app/HxUtils.h b/app/HxUtils.h index 73ef705..988339b 100644 --- a/app/HxUtils.h +++ b/app/HxUtils.h @@ -90,6 +90,9 @@ public slots: } } + /** + * @brief 重连 + */ void reconnection() { /* 取消已有的连接 */ @@ -127,12 +130,15 @@ private: QString address; bool is_reconnect = false; QTcpServer server; - QTcpSocket *socket = nullptr; + QTcpSocket* socket = nullptr; }; class HxProcessUtils { public: + /** + * + */ static int execute(QString command) { auto array = command.split(" "); diff --git a/app/HxVideoDevice.cpp b/app/HxVideoDevice.cpp index 6ee53b4..908b870 100644 --- a/app/HxVideoDevice.cpp +++ b/app/HxVideoDevice.cpp @@ -1,7 +1,7 @@ #include "HxVideoDevice.h" /* bsd算法结果处理函数 */ -void algorithm_alarm_callback(int nDataChannel, ObjectTrackEventResult *pObjectTrackEventResult, void *pPrivData) +void algorithm_alarm_callback(int nDataChannel, ObjectTrackEventResult* pObjectTrackEventResult, void* pPrivData) { Q_UNUSED(nDataChannel); Q_UNUSED(pPrivData); @@ -36,11 +36,11 @@ void algorithm_alarm_callback(int nDataChannel, ObjectTrackEventResult *pObjectT TaskDispatch::algorithm_alarm_event(1, 0, pObjectTrackEventResult->nEventType, 0, 0, 0, 0, 0, 0, 0, base64_string, filename); } else if (nDataChannel == 1 || /* BSD-右前 */ - nDataChannel == 3 || /* BSD-右后 */ - nDataChannel == 4 || /* BSD-左前 */ - nDataChannel == 5 || /* BSD-左后 */ - nDataChannel == 6 || /* BSD-前 */ - nDataChannel == 7) /* BSD-后 */ + nDataChannel == 3 || /* BSD-右后 */ + nDataChannel == 4 || /* BSD-左前 */ + nDataChannel == 5 || /* BSD-左后 */ + nDataChannel == 6 || /* BSD-前 */ + nDataChannel == 7) /* BSD-后 */ { int channel = 0; @@ -85,17 +85,17 @@ void algorithm_alarm_callback(int nDataChannel, ObjectTrackEventResult *pObjectT /* 上传 */ TaskDispatch::algorithm_alarm_event(channel, - pObjectTrackEventResult->nDangerLevel, - pObjectTrackEventResult->nEventType, - pObjectTrackEventResult->objInfo[i].nDetectType, - pObjectTrackEventResult->objInfo[i].nLeft, - pObjectTrackEventResult->objInfo[i].nTop, - pObjectTrackEventResult->objInfo[i].nRight, - pObjectTrackEventResult->objInfo[i].nBottom, - pObjectTrackEventResult->objInfo[i].fDist, - pObjectTrackEventResult->objInfo[i].fVelo, - base64_string, - filename); + pObjectTrackEventResult->nDangerLevel, + pObjectTrackEventResult->nEventType, + pObjectTrackEventResult->objInfo[i].nDetectType, + pObjectTrackEventResult->objInfo[i].nLeft, + pObjectTrackEventResult->objInfo[i].nTop, + pObjectTrackEventResult->objInfo[i].nRight, + pObjectTrackEventResult->objInfo[i].nBottom, + pObjectTrackEventResult->objInfo[i].fDist, + pObjectTrackEventResult->objInfo[i].fVelo, + base64_string, + filename); } } } @@ -160,73 +160,72 @@ QString VideoDevice::build_video(int id) QString url = QString("ftp://%3/%4/%5/alarm/").arg(DataBase::ftp_address, QDateTime::currentDateTime().toString("yyyyMMdd"), DataBase::device_id); QString filename = QString("%1.mp4").arg(QDateTime::currentDateTime().toString("yyyyMMddHHmmsszzz")); - QtConcurrent::run([=]() - { - if(video_frames_string.contains(id)) - { - frame_mutex.lock(); - auto first_key = video_frames_string.firstKey(); - frame_mutex.unlock(); + QtConcurrent::run([=]() { + if (video_frames_string.contains(id)) + { + frame_mutex.lock(); + auto first_key = video_frames_string.firstKey(); + frame_mutex.unlock(); - auto start_id = id - frame_fps * 10, end_id = id + frame_fps * 10; + auto start_id = id - frame_fps * 10, end_id = id + frame_fps * 10; - start_id = start_id < first_key ? first_key : start_id; + start_id = start_id < first_key ? first_key : start_id; - qDebug() << "build video; start id = "< buffer) { - QByteArray byteArray = QByteArray::fromRawData((const char *)buffer.data(), buffer.size()); + QByteArray byteArray = QByteArray::fromRawData((const char*)buffer.data(), buffer.size()); return QString(byteArray.toBase64()); } @@ -338,7 +337,7 @@ void VideoDevice::run() } } -int VideoDevice::MvGetFrameBlkInfo(VideoFrameDataInfo *pImageDataInfo) +int VideoDevice::MvGetFrameBlkInfo(VideoFrameDataInfo* pImageDataInfo) { Q_UNUSED(pImageDataInfo); @@ -346,14 +345,14 @@ int VideoDevice::MvGetFrameBlkInfo(VideoFrameDataInfo *pImageDataInfo) if (pImageDataInfo == NULL) return -1; - pImageDataInfo->pu8VirAddr = (unsigned char *)calloc(pImageDataInfo->u32Width * pImageDataInfo->u32Height * 3, sizeof(unsigned char)); + pImageDataInfo->pu8VirAddr = (unsigned char*)calloc(pImageDataInfo->u32Width * pImageDataInfo->u32Height * 3, sizeof(unsigned char)); if (pImageDataInfo->pu8VirAddr == NULL) return -1; #endif return 0; } -int VideoDevice::MvReleaseFrameBlkInfo(VideoFrameDataInfo *pImageDataInfo) +int VideoDevice::MvReleaseFrameBlkInfo(VideoFrameDataInfo* pImageDataInfo) { Q_UNUSED(pImageDataInfo); @@ -370,7 +369,7 @@ int VideoDevice::MvReleaseFrameBlkInfo(VideoFrameDataInfo *pImageDataInfo) return 0; } -int VideoDevice::MvConvertImage(VideoFrameDataInfo *pSrcImageDataInfo, VideoFrameDataInfo *pDstImageDataInfo) +int VideoDevice::MvConvertImage(VideoFrameDataInfo* pSrcImageDataInfo, VideoFrameDataInfo* pDstImageDataInfo) { Q_UNUSED(pSrcImageDataInfo); Q_UNUSED(pDstImageDataInfo); diff --git a/app/HxVideoDevice.h b/app/HxVideoDevice.h index 670f41f..b03d124 100644 --- a/app/HxVideoDevice.h +++ b/app/HxVideoDevice.h @@ -45,9 +45,9 @@ protected: void run() override; private: - int MvGetFrameBlkInfo(VideoFrameDataInfo *pImageDataInfo); - int MvReleaseFrameBlkInfo(VideoFrameDataInfo *pImageDataInfo); - int MvConvertImage(VideoFrameDataInfo *pSrcImageDataInfo, VideoFrameDataInfo *pDstImageDataInfo); + int MvGetFrameBlkInfo(VideoFrameDataInfo* pImageDataInfo); + int MvReleaseFrameBlkInfo(VideoFrameDataInfo* pImageDataInfo); + int MvConvertImage(VideoFrameDataInfo* pSrcImageDataInfo, VideoFrameDataInfo* pDstImageDataInfo); private: int type;