From e0d926efb129e659be81e4190aab1d7b59169a24 Mon Sep 17 00:00:00 2001 From: "XI.CHEN" <2311041011@qq.com> Date: Mon, 23 Dec 2024 16:14:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AA=E5=BC=80=E5=90=AF=E7=94=B5=E6=BA=90?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=8E=A7=E5=88=B6=E4=BA=91=E5=8F=B0=E4=B8=8D?= =?UTF-8?q?=E4=BC=9A=E6=89=93=E5=BC=80=E7=94=B5=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/GPIOControl.cpp | 33 ++++++++++++++++++++++++-------- app/src/main/cpp/GPIOControl.h | 3 +++ app/src/main/cpp/PhoneDevice.cpp | 2 +- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/app/src/main/cpp/GPIOControl.cpp b/app/src/main/cpp/GPIOControl.cpp index 0316084a..5e9f1893 100644 --- a/app/src/main/cpp/GPIOControl.cpp +++ b/app/src/main/cpp/GPIOControl.cpp @@ -27,6 +27,7 @@ CSemaphore GpioControl::m_semaphore; std::vector GpioControl::m_items; std::thread GpioControl::m_thread; bool GpioControl::m_exitSignal = false; +bool GpioControl::m_cameraPowerStatus = false; size_t GpioControl::turnOnImpl(const IOT_PARAM& param) { @@ -48,6 +49,7 @@ size_t GpioControl::turnOnImpl(const IOT_PARAM& param) it->references++; it->closeTime = 0; references = it->references; + SetCamerastatus(it->cmd, true); break; } } @@ -209,8 +211,7 @@ size_t GpioControl::TurnOffImmediately(int cmd) if (it->cmd == cmd) { ref = it->references; - if(it->closeCmds < it->references) - it->closeCmds++; + it->closeCmds++; it->closeTime = ts; break; } @@ -238,8 +239,7 @@ size_t GpioControl::TurnOff(int cmd, uint32_t delayedCloseTime/* = 0*/) if (it->cmd == cmd) { ref = it->references; - if(it->closeCmds < it->references) - it->closeCmds++; + it->closeCmds++; if (ts > it->closeTime) { it->closeTime = ts; @@ -272,8 +272,7 @@ size_t GpioControl::TurnOff(const std::vector& cmds, uint32_t delayedCloseT { if (it->cmd == *itCmd) { - if(it->closeCmds < it->references) - it->closeCmds++; + it->closeCmds++; if (ts > it->closeTime) { it->closeTime = ts; @@ -301,8 +300,8 @@ size_t GpioControl::TurnOff(const std::vector >& cmds) { if (it->cmd == itCmd->first) { - if(it->closeCmds < it->references) - it->closeCmds++; + + it->closeCmds++; if (itCmd->second != 0) { ts2 = itCmd->second + ts; @@ -320,6 +319,22 @@ size_t GpioControl::TurnOff(const std::vector >& cmds) return 0; } +bool GpioControl::SetCamerastatus(int cmd, bool status) +{ +#ifdef USING_N938 + if(cmd == CMD_SET_PIC1_POWER) + m_cameraPowerStatus = status; +#endif +#ifdef USING_PLZ + if(cmd == CMD_SET_PTZ_PWR_ENABLE) + m_cameraPowerStatus = status; +#endif + return true; +} +bool GpioControl::GetCamerastatus() +{ + return m_cameraPowerStatus; +} void GpioControl::PowerControlThreadProc() { @@ -330,6 +345,7 @@ void GpioControl::PowerControlThreadProc() time_t delayTime = 0; int fd = -1; int res = -1; + m_cameraPowerStatus = 0; while(1) { @@ -375,6 +391,7 @@ void GpioControl::PowerControlThreadProc() #ifdef _DEBUG ALOGI("PWR TH DO TurnOff cmd=%d", it->cmd); #endif + SetCamerastatus(it->cmd, false); } else { diff --git a/app/src/main/cpp/GPIOControl.h b/app/src/main/cpp/GPIOControl.h index 45363f28..49c9d5e9 100644 --- a/app/src/main/cpp/GPIOControl.h +++ b/app/src/main/cpp/GPIOControl.h @@ -164,6 +164,7 @@ private: static std::vector m_items; static bool m_exitSignal; static std::thread m_thread; + static bool m_cameraPowerStatus; protected: static size_t turnOnImpl(const IOT_PARAM& param); @@ -178,6 +179,8 @@ public: static size_t TurnOff(const std::vector& cmds, uint32_t delayedCloseTime = 0); static size_t TurnOff(const std::vector >& cmds); static size_t TurnOffImmediately(int cmd); + static bool SetCamerastatus(int cmd, bool status); + static bool GetCamerastatus(); static void PowerControlThreadProc(); diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index 21b0ae43..b21cdc18 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -3727,7 +3727,7 @@ void CPhoneDevice::ConvertDngToPng(const std::string& dngPath, const std::string void CPhoneDevice::CameraCtrl(unsigned short waitTime, unsigned short delayTime, unsigned char channel, int cmdidx, unsigned char preset, const char *serfile, unsigned int baud, int addr) { - if(!(m_sensorsStatus && !m_cameraStatus)) { + if(!(m_sensorsStatus && !m_cameraStatus) && GpioControl::GetCamerastatus()) { CPhoneDevice *pThis = this; string serfileStr(serfile); std::thread ctrlThread([pThis, waitTime, delayTime, cmdidx, channel, preset, serfileStr, baud,