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.
199 lines
3.8 KiB
199 lines
3.8 KiB
#include "objectCamera_VISCA_PTZ.h"
|
|
|
|
#define LOG(X) m_pLog->Log("objectCamera_VISCA_PTZ", this, X)
|
|
#define LOG_ERROR(X) m_pLog->Log("objectCamera_VISCA_PTZ", this, _LOG_ERROR, X)
|
|
|
|
objectCamera_VISCA_PTZ::objectCamera_VISCA_PTZ(config_setting_t * Settings) :
|
|
basicCameraPTZ(Settings)
|
|
{
|
|
m_pLog = basicLogCollection::getInstance();
|
|
m_pProtocol = NULL;
|
|
m_pTransport = NULL;
|
|
m_sSourcePort = -1;
|
|
m_eControllProtocolType = PTZ_PROTO_VISCA;
|
|
}
|
|
|
|
objectCamera_VISCA_PTZ::~objectCamera_VISCA_PTZ()
|
|
{
|
|
// Delete Video Source
|
|
if (m_pVideoSource != NULL)
|
|
{
|
|
delete((videoAVLIBSource *) m_pVideoSource);
|
|
};
|
|
if (m_pProtocol != NULL)
|
|
{
|
|
delete(m_pProtocol);
|
|
};
|
|
if (m_pTransport != NULL)
|
|
{
|
|
delete(m_pTransport);
|
|
};
|
|
}
|
|
|
|
bool objectCamera_VISCA_PTZ::create(void)
|
|
{
|
|
config_setting_t * pSetting;
|
|
|
|
if (m_pSettings == NULL)
|
|
{
|
|
return false;
|
|
}
|
|
/* Load Srom Settings */
|
|
if (! basicCameraPTZ::create())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, "COM_PORT");
|
|
if (pSetting == NULL)
|
|
{
|
|
return false;
|
|
}
|
|
m_sSourcePort = config_setting_get_int(pSetting);
|
|
|
|
if (m_sSourcePort < 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
char cPortStr[8];
|
|
sprintf(cPortStr, "com%d", m_sSourcePort);
|
|
m_pTransport = new serialPort(cPortStr, 9600);
|
|
if (m_pTransport != NULL)
|
|
{
|
|
m_pProtocol = new protocolPTZ_VISCA(m_pTransport);
|
|
m_pProtocol->init();
|
|
};
|
|
// init video
|
|
videoAVLIBSource * tSource;
|
|
tSource = new videoAVLIBSource();
|
|
if (tSource->open((CSTR) m_sCameraInfo.m_pSourcePath, false, 25, m_sCameraInfo.m_iSourcePort, m_sCameraInfo.m_iWidth, m_sCameraInfo.m_iHeight))
|
|
{
|
|
// tNode->setTimeLapse(3000);
|
|
tSource->attachDestination(m_pVideoNode);
|
|
tSource->setStreaming(true);
|
|
m_pVideoSource = (basicMediaSource *) tSource;
|
|
}
|
|
else
|
|
{
|
|
delete tSource;
|
|
return false;
|
|
};
|
|
return true;
|
|
}
|
|
|
|
/* èóøå üøûðçôå 500 .... 10.
|
|
|
|
7:30 mispar tik 123760118
|
|
*/
|
|
|
|
bool objectCamera_VISCA_PTZ::create(mediaSourceInfo * SI)
|
|
{
|
|
config_setting_t * pSetting;
|
|
|
|
if (m_pSettings == NULL)
|
|
{
|
|
return false;
|
|
}
|
|
if (SI == NULL)
|
|
{
|
|
return false;
|
|
}
|
|
if (! basicCameraPTZ::create(SI))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, "COM_PORT");
|
|
m_sSourcePort = SI->comTransportType;
|
|
if (pSetting == NULL)
|
|
{
|
|
pSetting = config_setting_add(m_pSettings, "COM_PORT", CONFIG_TYPE_INT);
|
|
};
|
|
config_setting_set_int(pSetting, m_sSourcePort);
|
|
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
return create();
|
|
}
|
|
|
|
void objectCamera_VISCA_PTZ::dispatch(basicEvent * Evt)
|
|
{
|
|
if (Evt->m_eClass == EVT_CLASS_SENSOR)
|
|
{
|
|
switch (Evt->m_eType)
|
|
{
|
|
case EVT_ALARM:
|
|
// Basic Camera Reaction
|
|
break;
|
|
default: break;
|
|
};
|
|
}
|
|
else if (Evt->m_eClass == EVT_CLASS_IMAGE)
|
|
{
|
|
switch (Evt->m_eType)
|
|
{
|
|
case EVT_COMMAND:
|
|
basicCameraCommand * pData;
|
|
pData = (basicCameraCommand *) Evt->m_pEvtData;
|
|
// Basic Camera Commands
|
|
switch (pData->m_cCode)
|
|
{
|
|
case CMD_CAMERA_INIT: m_pProtocol->init(); break;
|
|
case CMD_CAMERA_SET_PTZ:
|
|
// m_pProtocol->goAbsolute( cP, cT, cZ );
|
|
break;
|
|
default: break;
|
|
};
|
|
break;
|
|
default: break;
|
|
};
|
|
};
|
|
}
|
|
|
|
void objectCamera_VISCA_PTZ::cmdBeginPanLeft(void)
|
|
{
|
|
m_pProtocol->goLeft();
|
|
}
|
|
|
|
void objectCamera_VISCA_PTZ::cmdBeginPanRight(void)
|
|
{
|
|
m_pProtocol->goRight();
|
|
}
|
|
|
|
void objectCamera_VISCA_PTZ::cmdEndManualPan(void)
|
|
{
|
|
m_pProtocol->goStop();
|
|
}
|
|
|
|
void objectCamera_VISCA_PTZ::cmdBeginTiltUp(void)
|
|
{
|
|
m_pProtocol->goUp();
|
|
}
|
|
|
|
void objectCamera_VISCA_PTZ::cmdBeginTiltDown(void)
|
|
{
|
|
m_pProtocol->goDown();
|
|
}
|
|
|
|
void objectCamera_VISCA_PTZ::cmdEndManualTilt(void)
|
|
{
|
|
m_pProtocol->goStop();
|
|
}
|
|
|
|
void objectCamera_VISCA_PTZ::cmdBeginZoomWide(void)
|
|
{
|
|
m_pProtocol->startZoomWide();
|
|
}
|
|
|
|
void objectCamera_VISCA_PTZ::cmdBeginZoomTele(void)
|
|
{
|
|
m_pProtocol->startZoomTele();
|
|
}
|
|
|
|
void objectCamera_VISCA_PTZ::cmdEndManualZoom(void)
|
|
{
|
|
m_pProtocol->stopZoom();
|
|
}
|
|
|
|
#undef LOG
|
|
#undef LOG_ERROR
|