增加电源延时

N938
XI.CHEN 6 months ago
parent 821dd34c18
commit 30a1706af5

@ -337,6 +337,7 @@ void GpioControl::PowerControlThreadProc()
if (it->references == 0) if (it->references == 0)
{ {
// Should turn off the power // Should turn off the power
time_t tt = it->closeTime;
if ((it->closeTime == 0) || (it->closeTime <= ts)) if ((it->closeTime == 0) || (it->closeTime <= ts))
{ {
// close it directly // close it directly

@ -185,6 +185,11 @@ public:
#endif #endif
} }
static void setCam3V3Enable(bool enabled, uint32_t delayedCloseTime)
{
enabled ? TurnOn(CMD_SET_CAM_3V3_EN_STATE) : TurnOff(CMD_SET_CAM_3V3_EN_STATE, delayedCloseTime);
}
static void setCam3V3Enable(bool enabled) static void setCam3V3Enable(bool enabled)
{ {
enabled ? TurnOn(CMD_SET_CAM_3V3_EN_STATE) : TurnOff(CMD_SET_CAM_3V3_EN_STATE); enabled ? TurnOn(CMD_SET_CAM_3V3_EN_STATE) : TurnOff(CMD_SET_CAM_3V3_EN_STATE);
@ -212,6 +217,20 @@ public:
} }
} }
static void setRS485Enable(bool z, uint32_t delayedCloseTime)
{
#ifndef USING_N938
z ? TurnOn(CMD_SET_485_EN_STATE) : TurnOff(CMD_SET_485_EN_STATE, delayedCloseTime);
#endif
}
static void set12VEnable(bool z, uint32_t delayedCloseTime)
{
#ifndef USING_N938
z ? TurnOn(CMD_SET_12V_EN_STATE) : TurnOff(CMD_SET_12V_EN_STATE, delayedCloseTime);
#endif
}
static void setRS485Enable(bool z) static void setRS485Enable(bool z)
{ {
#ifndef USING_N938 #ifndef USING_N938

@ -1852,8 +1852,8 @@ bool CPhoneDevice::OpenPTZSensors(int sec)
{ {
if (m_shouldStopWaiting.load()) if (m_shouldStopWaiting.load())
{ {
CloseSensors(CAMERA_SENSOR_OPEN); CloseSensors(CAMERA_SENSOR_OPEN, 0);
CloseSensors(MAIN_POWER_OPEN); CloseSensors(MAIN_POWER_OPEN, 0);
m_cameraStatus = false; m_cameraStatus = false;
m_sensorsStatus = false; m_sensorsStatus = false;
m_shouldStopWaiting.store(false); m_shouldStopWaiting.store(false);
@ -1880,7 +1880,7 @@ bool CPhoneDevice::OpenPTZSensors(int sec)
} }
bool CPhoneDevice::ClosePTZSensors() bool CPhoneDevice::ClosePTZSensors(uint32_t delayedCloseTime)
{ {
if(m_sensorsStatus && !m_cameraStatus) if(m_sensorsStatus && !m_cameraStatus)
{ {
@ -1890,8 +1890,8 @@ bool CPhoneDevice::ClosePTZSensors()
{ {
std::lock_guard<std::mutex> lock(m_cameraLocker); std::lock_guard<std::mutex> lock(m_cameraLocker);
// std::unique_lock<std::mutex> lock(m_cameraLocker); // std::unique_lock<std::mutex> lock(m_cameraLocker);
CloseSensors(CAMERA_SENSOR_OPEN); CloseSensors(CAMERA_SENSOR_OPEN, delayedCloseTime);
CloseSensors(MAIN_POWER_OPEN); CloseSensors(MAIN_POWER_OPEN, delayedCloseTime);
m_cameraStatus = false; m_cameraStatus = false;
m_sensorsStatus = false; m_sensorsStatus = false;
} }
@ -3917,32 +3917,32 @@ bool CPhoneDevice::OpenSensors(int sensortype)
return 0; return 0;
} }
bool CPhoneDevice::CloseSensors(int sensortype) bool CPhoneDevice::CloseSensors(int sensortype, uint32_t delayedCloseTime)
{ {
if(sensortype == MAIN_POWER_OPEN) if(sensortype == MAIN_POWER_OPEN)
{ {
GpioControl::set12VEnable(false); GpioControl::set12VEnable(false, delayedCloseTime);
GpioControl::setRS485Enable(false); GpioControl::setRS485Enable(false, delayedCloseTime);
GpioControl::setCam3V3Enable(false); GpioControl::setCam3V3Enable(false, delayedCloseTime);
GpioControl::TurnOff(CMD_SET_SPI_POWER); GpioControl::TurnOff(CMD_SET_SPI_POWER, delayedCloseTime);
// GpioControl::TurnOff(CMD_SET_485_EN_STATE); // GpioControl::TurnOff(CMD_SET_485_EN_STATE);
#ifndef USING_N938 #ifndef USING_N938
#ifndef USING_PLZ #ifndef USING_PLZ
GpioControl::TurnOff(CMD_SET_485_EN_STATE); GpioControl::TurnOff(CMD_SET_485_EN_STATE, delayedCloseTime);
#else #else
GpioControl::TurnOff(CMD_SET_485_ENABLE); GpioControl::TurnOff(CMD_SET_485_ENABLE, delayedCloseTime);
#endif #endif
#else #else
GpioControl::TurnOff(CMD_SPI2SERIAL_POWER_EN); GpioControl::TurnOff(CMD_SPI2SERIAL_POWER_EN, delayedCloseTime);
GpioControl::TurnOff(CMD_RS485_3V3_EN); GpioControl::TurnOff(CMD_RS485_3V3_EN, delayedCloseTime);
#endif #endif
} }
if(sensortype == CAMERA_SENSOR_OPEN) if(sensortype == CAMERA_SENSOR_OPEN)
{ {
#ifdef USING_N938 #ifdef USING_N938
GpioControl::TurnOff(CMD_SET_PIC1_POWER); GpioControl::TurnOff(CMD_SET_PIC1_POWER, delayedCloseTime);
GpioControl::TurnOff(CMD_SET_485_EN4); GpioControl::TurnOff(CMD_SET_485_EN4, delayedCloseTime);
// GpioControl::TurnOff(CMD_SET_CAM_3V3_EN_STATE); // GpioControl::TurnOff(CMD_SET_CAM_3V3_EN_STATE);
#endif #endif
@ -3950,7 +3950,7 @@ bool CPhoneDevice::CloseSensors(int sensortype)
// GpioControl::TurnOff(CMD_SET_3V3_PWR_ENABLE); // GpioControl::TurnOff(CMD_SET_3V3_PWR_ENABLE);
#ifndef USING_PLZ #ifndef USING_PLZ
#else #else
GpioControl::TurnOff(CMD_SET_PTZ_PWR_ENABLE); GpioControl::TurnOff(CMD_SET_PTZ_PWR_ENABLE, delayedCloseTime);
#endif #endif
#endif #endif
} }
@ -3958,26 +3958,26 @@ bool CPhoneDevice::CloseSensors(int sensortype)
{ {
#ifndef USING_N938 #ifndef USING_N938
#else #else
GpioControl::TurnOff(CMD_SET_WTH_POWER); GpioControl::TurnOff(CMD_SET_WTH_POWER, delayedCloseTime);
GpioControl::TurnOff(CMD_SET_485_EN3); GpioControl::TurnOff(CMD_SET_485_EN3, delayedCloseTime);
#endif #endif
} }
if(sensortype == ICETHICK_SENSOR_OPEN) if(sensortype == ICETHICK_SENSOR_OPEN)
{ {
#ifndef USING_N938 #ifndef USING_N938
#else #else
GpioControl::TurnOff(CMD_SET_PULL_POWER); GpioControl::TurnOff(CMD_SET_PULL_POWER, delayedCloseTime);
GpioControl::TurnOff(CMD_SET_ANGLE_POWER); GpioControl::TurnOff(CMD_SET_ANGLE_POWER, delayedCloseTime);
GpioControl::TurnOff(CMD_SET_485_EN1); GpioControl::TurnOff(CMD_SET_485_EN1, delayedCloseTime);
GpioControl::TurnOff(CMD_SET_485_EN0); GpioControl::TurnOff(CMD_SET_485_EN0, delayedCloseTime);
#endif #endif
} }
if(sensortype == OTHER_SENSOR) if(sensortype == OTHER_SENSOR)
{ {
#ifndef USING_N938 #ifndef USING_N938
#else #else
GpioControl::TurnOff(CMD_SET_OTHER_POWER); GpioControl::TurnOff(CMD_SET_OTHER_POWER, delayedCloseTime);
GpioControl::TurnOff(CMD_SET_485_EN2); GpioControl::TurnOff(CMD_SET_485_EN2, delayedCloseTime);
#endif #endif
} }
return 0; return 0;

@ -230,9 +230,9 @@ public:
virtual int GetWData(WEATHER_INFO *weatherInfo); virtual int GetWData(WEATHER_INFO *weatherInfo);
virtual int GetIceData(ICE_INFO *iceInfo, ICE_TAIL *icetail, SENSOR_PARAM *sensorParam); virtual int GetIceData(ICE_INFO *iceInfo, ICE_TAIL *icetail, SENSOR_PARAM *sensorParam);
virtual bool OpenSensors(int sensortype); virtual bool OpenSensors(int sensortype);
virtual bool CloseSensors(int sensortype); virtual bool CloseSensors(int sensortype, uint32_t delayedCloseTime);
virtual bool OpenPTZSensors(int sec); virtual bool OpenPTZSensors(int sec);
virtual bool ClosePTZSensors(); virtual bool ClosePTZSensors(uint32_t delayedCloseTime);
virtual bool GetPTZSensorsStatus(); virtual bool GetPTZSensorsStatus();
virtual bool GetCameraStatus(); virtual bool GetCameraStatus();

Loading…
Cancel
Save