未开启电源时,控制云台不会打开电源

N938
XI.CHEN 6 months ago
parent 92781524d7
commit e0d926efb1

@ -27,6 +27,7 @@ CSemaphore GpioControl::m_semaphore;
std::vector<GpioControl::ITEM> 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<int>& 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<std::pair<int, uint32_t> >& 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<std::pair<int, uint32_t> >& 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
{

@ -164,6 +164,7 @@ private:
static std::vector<ITEM> 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<int>& cmds, uint32_t delayedCloseTime = 0);
static size_t TurnOff(const std::vector<std::pair<int, uint32_t> >& cmds);
static size_t TurnOffImmediately(int cmd);
static bool SetCamerastatus(int cmd, bool status);
static bool GetCamerastatus();
static void PowerControlThreadProc();

@ -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,

Loading…
Cancel
Save