From 9397d5310701739336ce024b558cfbe07b516fbd Mon Sep 17 00:00:00 2001 From: jxjajs Date: Mon, 7 Apr 2025 19:34:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=8A=A8=E6=8B=8D?= =?UTF-8?q?=E7=85=A7=E7=AD=89=E5=BE=85=E6=97=B6=E9=97=B4=EF=BC=8C=E9=98=B2?= =?UTF-8?q?=E6=AD=A2=E5=90=8C=E4=B8=80=E6=97=B6=E9=97=B4ptz=E6=8B=8D?= =?UTF-8?q?=E5=A4=9A=E5=BC=A0=E5=9B=BE=E7=89=87=E6=97=B6=EF=BC=8C=E4=B8=AD?= =?UTF-8?q?=E9=97=B4=E4=BC=9A=E5=85=B3=E7=94=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/PtzController.cpp | 34 ++++++++++++++++++++++++++++-- app/src/main/cpp/PtzController.h | 4 +++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/app/src/main/cpp/PtzController.cpp b/app/src/main/cpp/PtzController.cpp index 0b16984e..b013fe7d 100644 --- a/app/src/main/cpp/PtzController.cpp +++ b/app/src/main/cpp/PtzController.cpp @@ -123,7 +123,10 @@ void PtzController::PtzProc() time_t PTZ_preset_wait_time = 0; time_t close_delay_time = CAMERA_CLOSE_DELAYTIME; time_t start_delay_time = 0; + time_t auto_delay_time = 0; + time_t auto_wait_time = WAIT_TIME_AUTO_CLOSE; time_t photo_move_preset_time = 0; + int iwaitime = 0; while(true) { @@ -197,7 +200,30 @@ void PtzController::PtzProc() } if(0 == start_delay_time) { - ; + if(0 == iwaitime) + { + auto_delay_time = time(NULL); + iwaitime += 1; + m_sem.release(); + continue; + } + else + { + if(time(NULL) - auto_delay_time < 0) + { + auto_delay_time = time(NULL); + } + if(time(NULL) - auto_delay_time >= auto_wait_time) + { + iwaitime = 0; + XYLOG(XYLOG_SEVERITY_INFO, "摄像机自动上电延时时间超过%u秒!准备关闭摄像机!", (uint32_t)auto_wait_time); + } + else + { + m_sem.release(); + continue; + } + } } else { @@ -207,7 +233,7 @@ void PtzController::PtzProc() } if(time(NULL) - start_delay_time >= close_delay_time) { - XYLOG(XYLOG_SEVERITY_INFO, "摄像机空闲时间超过%u秒!关闭摄像机!", (uint32_t)close_delay_time); + XYLOG(XYLOG_SEVERITY_INFO, "摄像机空闲时间超过%u秒!准备关闭摄像机!", (uint32_t)close_delay_time); } else { @@ -284,6 +310,10 @@ void PtzController::PtzProc() break; } } + if(time(NULL) - PTZ_preset_start_time < 0) + {/* 防止等待关机期间,其他线程发生对时,改变了系统时间,导致长时间等待摄像机到达预置点*/ + PTZ_preset_start_time = time(NULL); + } if(time(NULL) - PTZ_preset_start_time >= PTZ_preset_wait_time) { XYLOG(XYLOG_SEVERITY_INFO, "摄像机拍照前调用预置点%u,摄像机在%u秒内未收到调用预置点结束应答!state=%d", (uint32_t)cmd.preset, (uint32_t)PTZ_preset_wait_time, state); diff --git a/app/src/main/cpp/PtzController.h b/app/src/main/cpp/PtzController.h index badd3ed6..75c65053 100644 --- a/app/src/main/cpp/PtzController.h +++ b/app/src/main/cpp/PtzController.h @@ -26,8 +26,10 @@ enum PROC_PTZ_STATE #define CAMERA_SELF_TEST_TIME 60 /* Camera self-test time (excluding PTZ self-test)*/ #define MOVE_PRESET_WAIT_TIME 20 /* Waiting for the maximum time for the PTZ to move to the preset position*/ -#define CAMERA_CLOSE_DELAYTIME 120 /* Auto Power-Off Timer Setting After Manual Power-On (for Camera)*/ +#define CAMERA_CLOSE_DELAYTIME 150 /* Auto Power-Off Timer Setting After Manual Power-On (for Camera)*/ #define PHOTO_OPEN_POWER 16000 +#define WAIT_TIME_AUTO_CLOSE 2 /* In order to automatically capture multiple preset point images at the same time and prevent the camera from self checking every time it takes a picture.*/ + class PtzPhotoParams { public: