You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
226 lines
9.8 KiB
226 lines
9.8 KiB
#include "basicCameraPTZ.h"
|
|
|
|
// Constructor implementation
|
|
basicCameraPTZ::basicCameraPTZ(config_setting_t *Settings) : basicCamera(Settings){
|
|
m_eCaps = (objectCaps)( m_eCaps | OC_EVENT_HANDLER | OC_PAN_CONTROLL | OC_TILT_CONTROLL | OC_ZOOM_CONTROLL);
|
|
m_fPanShift = 0;
|
|
m_fTiltShift = 0;
|
|
m_bCtrlStage = 0;
|
|
m_pProtocol = NULL;
|
|
m_bDirectSpeedControl = false;
|
|
m_bEventTrackingEnabled = false;
|
|
//m_qCommandPipe clear
|
|
};
|
|
|
|
// Destructor implementation
|
|
basicCameraPTZ::~basicCameraPTZ(){
|
|
updateSettings();
|
|
};
|
|
|
|
bool basicCameraPTZ::create(void){
|
|
config_setting_t *pSetting;
|
|
if (m_pSettings == NULL) return false;
|
|
if (!basicCamera::create()) return false;
|
|
pSetting = config_setting_get_member(m_pSettings, BPTZCI_TAG_PROTO_TYPE);
|
|
if (pSetting == NULL) return false;
|
|
m_sSourceInfo.protocolId = config_setting_get_int(pSetting);
|
|
pSetting = config_setting_get_member(m_pSettings, BPTZCI_TAG_PAN_TOTTAL);
|
|
if (pSetting == NULL) return false;
|
|
m_sSourceInfo.fPanTotalDeg = config_setting_get_float(pSetting);
|
|
m_sSourceInfo.fPanTotalRad = m_sSourceInfo.fPanTotalDeg * 0.01745329251994329576923690768489f;
|
|
pSetting = config_setting_get_member(m_pSettings, BPTZCI_TAG_PAN_MIN);
|
|
if (pSetting == NULL) return false;
|
|
m_sSourceInfo.fPanMin = config_setting_get_float(pSetting);
|
|
pSetting = config_setting_get_member(m_pSettings, BPTZCI_TAG_PAN_MAX);
|
|
if (pSetting == NULL) return false;
|
|
m_sSourceInfo.fPanMax = config_setting_get_float(pSetting);
|
|
pSetting = config_setting_get_member(m_pSettings, BPTZCI_TAG_PAN_SPD_MIN);
|
|
if (pSetting == NULL) return false;
|
|
m_sSourceInfo.fPanSpeedMin = config_setting_get_float(pSetting);
|
|
pSetting = config_setting_get_member(m_pSettings, BPTZCI_TAG_PAN_SPD_MAX);
|
|
if (pSetting == NULL) return false;
|
|
m_sSourceInfo.fPanSpeedMax = config_setting_get_float(pSetting);
|
|
pSetting = config_setting_get_member(m_pSettings, BPTZCI_TAG_PAN_SPD_DYNAMIC);
|
|
if (pSetting == NULL) return false;
|
|
m_sSourceInfo.bPanSpeedDynamic = config_setting_get_bool(pSetting);
|
|
pSetting = config_setting_get_member(m_pSettings, BPTZCI_TAG_PAN_REVERSED);
|
|
if (pSetting == NULL) return false;
|
|
m_sSourceInfo.bPanReverse = config_setting_get_bool(pSetting);
|
|
pSetting = config_setting_get_member(m_pSettings, BPTZCI_TAG_TILT_TOTTAL);
|
|
if (pSetting == NULL) return false;
|
|
m_sSourceInfo.fTiltTotalDeg = config_setting_get_float(pSetting);
|
|
m_sSourceInfo.fTiltTotalRad = m_sSourceInfo.fPanTotalDeg * 0.01745329251994329576923690768489f;
|
|
pSetting = config_setting_get_member(m_pSettings, BPTZCI_TAG_TILT_MIN);
|
|
if (pSetting == NULL) return false;
|
|
m_sSourceInfo.fTiltMin = config_setting_get_float(pSetting);
|
|
pSetting = config_setting_get_member(m_pSettings, BPTZCI_TAG_TILT_MAX);
|
|
if (pSetting == NULL) return false;
|
|
m_sSourceInfo.fTiltMax = config_setting_get_float(pSetting);
|
|
pSetting = config_setting_get_member(m_pSettings, BPTZCI_TAG_TILT_SPD_MIN);
|
|
if (pSetting == NULL) return false;
|
|
m_sSourceInfo.fTiltSpeedMin = config_setting_get_float(pSetting);
|
|
pSetting = config_setting_get_member(m_pSettings, BPTZCI_TAG_TILT_SPD_MAX);
|
|
if (pSetting == NULL) return false;
|
|
m_sSourceInfo.fTiltSpeedMax = config_setting_get_float(pSetting);
|
|
pSetting = config_setting_get_member(m_pSettings, BPTZCI_TAG_TILT_SPD_DYNAMIC);
|
|
if (pSetting == NULL) return false;
|
|
m_sSourceInfo.bTiltSpeedDynamic = config_setting_get_bool(pSetting);
|
|
pSetting = config_setting_get_member(m_pSettings, BPTZCI_TAG_TILT_REVERSED);
|
|
if (pSetting == NULL) return false;
|
|
m_sSourceInfo.bTiltReverse = config_setting_get_bool(pSetting);
|
|
return basicThread::init();
|
|
};
|
|
|
|
bool basicCameraPTZ::create(SOURCE_INFO *SI){
|
|
config_setting_t *pSetting;
|
|
int tiVal;
|
|
float tfVal;
|
|
if (m_pSettings == NULL) return false;
|
|
if (SI == NULL) return false;
|
|
if (!basicCamera::create(SI)) return false;
|
|
|
|
pSetting = config_setting_add(m_pSettings, BPTZCI_TAG_PROTO_TYPE, CONFIG_TYPE_INT);
|
|
if( pSetting == NULL ) return false;
|
|
config_setting_set_int(pSetting, m_sSourceInfo.protocolId );
|
|
|
|
pSetting = config_setting_add(m_pSettings, BPTZCI_TAG_PAN_SPD_DYNAMIC, CONFIG_TYPE_BOOL);
|
|
if (pSetting == NULL) return false;
|
|
config_setting_set_int(pSetting, m_sSourceInfo.bPanSpeedDynamic);
|
|
|
|
pSetting = config_setting_add(m_pSettings, BPTZCI_TAG_PAN_TOTTAL, CONFIG_TYPE_FLOAT);
|
|
if (pSetting == NULL) return false;
|
|
m_sSourceInfo.fPanTotalDeg = m_sSourceInfo.fPanMax - m_sSourceInfo.fPanMin;
|
|
m_sSourceInfo.fPanTotalRad = m_sSourceInfo.fPanTotalDeg * 0.01745329251994329576923690768489f;
|
|
config_setting_set_float(pSetting, m_sSourceInfo.fPanTotalDeg );
|
|
|
|
pSetting = config_setting_add(m_pSettings, BPTZCI_TAG_PAN_MIN, CONFIG_TYPE_FLOAT);
|
|
if (pSetting == NULL) return false;
|
|
config_setting_set_float(pSetting, m_sSourceInfo.fPanMin);
|
|
|
|
pSetting = config_setting_add(m_pSettings, BPTZCI_TAG_PAN_MAX, CONFIG_TYPE_FLOAT);
|
|
if (pSetting == NULL) return false;
|
|
config_setting_set_float(pSetting, m_sSourceInfo.fPanMax);
|
|
|
|
pSetting = config_setting_add(m_pSettings, BPTZCI_TAG_PAN_SPD_MIN, CONFIG_TYPE_FLOAT);
|
|
if (pSetting == NULL) return false;
|
|
config_setting_set_float(pSetting, m_sSourceInfo.fPanSpeedMin);
|
|
|
|
pSetting = config_setting_add(m_pSettings, BPTZCI_TAG_PAN_SPD_MAX, CONFIG_TYPE_FLOAT);
|
|
if (pSetting == NULL) return false;
|
|
config_setting_set_float(pSetting, m_sSourceInfo.fPanSpeedMax);
|
|
|
|
pSetting = config_setting_add(m_pSettings, BPTZCI_TAG_PAN_REVERSED, CONFIG_TYPE_BOOL);
|
|
if (pSetting == NULL) return false;
|
|
config_setting_set_bool(pSetting, m_sSourceInfo.bPanReverse);
|
|
|
|
pSetting = config_setting_add(m_pSettings, BPTZCI_TAG_TILT_MIN, CONFIG_TYPE_FLOAT);
|
|
if (pSetting == NULL) return false;
|
|
config_setting_set_float(pSetting, m_sSourceInfo.fTiltMin);
|
|
|
|
pSetting = config_setting_add(m_pSettings, BPTZCI_TAG_TILT_MAX, CONFIG_TYPE_FLOAT);
|
|
if (pSetting == NULL) return false;
|
|
config_setting_set_float(pSetting, m_sSourceInfo.fTiltMax);
|
|
|
|
pSetting = config_setting_add(m_pSettings, BPTZCI_TAG_TILT_TOTTAL, CONFIG_TYPE_FLOAT);
|
|
if (pSetting == NULL) return false;
|
|
m_sSourceInfo.fTiltTotalDeg = m_sSourceInfo.fTiltMax - m_sSourceInfo.fTiltMin;
|
|
m_sSourceInfo.fTiltTotalRad = m_sSourceInfo.fTiltTotalDeg * 0.01745329251994329576923690768489f;
|
|
config_setting_set_float(pSetting, m_sSourceInfo.fTiltTotalDeg );
|
|
|
|
pSetting = config_setting_add(m_pSettings, BPTZCI_TAG_TILT_SPD_MIN, CONFIG_TYPE_FLOAT);
|
|
if (pSetting == NULL) return false;
|
|
config_setting_set_float(pSetting, m_sSourceInfo.fTiltSpeedMin);
|
|
|
|
pSetting = config_setting_add(m_pSettings, BPTZCI_TAG_TILT_SPD_MAX, CONFIG_TYPE_FLOAT);
|
|
if (pSetting == NULL) return false;
|
|
config_setting_set_float(pSetting, m_sSourceInfo.fTiltSpeedMax);
|
|
|
|
pSetting = config_setting_add(m_pSettings, BPTZCI_TAG_TILT_SPD_DYNAMIC, CONFIG_TYPE_BOOL);
|
|
if (pSetting == NULL) return false;
|
|
config_setting_set_bool(pSetting, m_sSourceInfo.bTiltSpeedDynamic);
|
|
|
|
pSetting = config_setting_add(m_pSettings, BPTZCI_TAG_TILT_REVERSED, CONFIG_TYPE_BOOL);
|
|
if (pSetting == NULL) return false;
|
|
config_setting_set_bool(pSetting, m_sSourceInfo.bTiltReverse);
|
|
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
return true;
|
|
};
|
|
|
|
void basicCameraPTZ::dispatchEvent( EVENT_CONTAINER *Evt ){
|
|
basicCamera::dispatchEvent( Evt );
|
|
};
|
|
|
|
void basicCameraPTZ::updateSettings(void){
|
|
if (!m_pSettings) return;
|
|
basicCamera::updateSettings();
|
|
config_setting_t *pSetting;
|
|
int tInt;
|
|
double tFloat;
|
|
CSTR tBuff;
|
|
/*
|
|
if (config_setting_lookup_float(m_pSettings, TAG_POSITION_LAT, &tFloat)){
|
|
if (tFloat != getLat()){
|
|
tFloat = getLat();
|
|
pSetting = config_setting_lookup(m_pSettings, TAG_POSITION_LAT);
|
|
config_setting_set_float(pSetting, tFloat);
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
};
|
|
};
|
|
if (config_setting_lookup_float(m_pSettings, TAG_POSITION_LON, &tFloat)){
|
|
if (tFloat != getLon()){
|
|
tFloat = getLon();
|
|
pSetting = config_setting_lookup(m_pSettings, TAG_POSITION_LON);
|
|
config_setting_set_float(pSetting, tFloat);
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
};
|
|
};
|
|
if (config_setting_lookup_float(m_pSettings, TAG_POSITION_ALT, &tFloat)){
|
|
if (tFloat != getAlt()){
|
|
tFloat = getAlt();
|
|
pSetting = config_setting_lookup(m_pSettings, TAG_POSITION_ALT);
|
|
config_setting_set_float(pSetting, tFloat);
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
};
|
|
};
|
|
if (config_setting_lookup_float(m_pSettings, TAG_POSITION_YAW, &tFloat)){
|
|
if (tFloat != getRotZ_deg()){
|
|
tFloat = getRotZ_deg();
|
|
pSetting = config_setting_lookup(m_pSettings, TAG_POSITION_YAW);
|
|
config_setting_set_float(pSetting, tFloat);
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
};
|
|
};
|
|
if (config_setting_lookup_float(m_pSettings, TAG_POSITION_ROLL, &tFloat)){
|
|
if (tFloat != getRotY_deg()){
|
|
tFloat = getRotY_deg();
|
|
pSetting = config_setting_lookup(m_pSettings, TAG_POSITION_ROLL);
|
|
config_setting_set_float(pSetting, tFloat);
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
};
|
|
};
|
|
if (config_setting_lookup_float(m_pSettings, TAG_POSITION_PITCH, &tFloat)){
|
|
if (tFloat != getRotX_deg()){
|
|
tFloat = getRotX_deg();
|
|
pSetting = config_setting_lookup(m_pSettings, TAG_POSITION_PITCH);
|
|
config_setting_set_float(pSetting, tFloat);
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
};
|
|
};
|
|
if (config_setting_lookup_string(m_pSettings, LGS_SET_ADDRESS, (const char**)&tBuff)){
|
|
if (strcmp(m_pHost, tBuff) != 0){
|
|
pSetting = config_setting_lookup(m_pSettings, LGS_SET_ADDRESS);
|
|
config_setting_set_string(pSetting, m_pHost);
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
};
|
|
};
|
|
if (config_setting_lookup_int(m_pSettings, LGS_SET_PORT, &tInt)){
|
|
if (m_nPort != tInt){
|
|
pSetting = config_setting_lookup(m_pSettings, LGS_SET_PORT);
|
|
config_setting_set_int(pSetting, m_nPort);
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
};
|
|
};
|
|
if (basicSettingsProvider::getInstance()->isCompromised()) basicSettingsProvider::getInstance()->validate();
|
|
*/
|
|
};
|