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.

64 lines
1.7 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "rgooseIPCamera.h"
  2. #define LOG( X ) m_pLog->Log( "ARGUS_CAM", this, X )
  3. #define LOG_ERROR( X ) m_pLog->Log( "ARGUS_CAM", this, _LOG_ERROR, X )
  4. ARGUS_Camera::ARGUS_Camera():basicEventHandler(),basicThread(){
  5. m_pLog = basicLogCollection::getInstance();
  6. m_pOnVif = NULL;
  7. m_pPos = NULL;
  8. m_bOnline = false;
  9. };
  10. ARGUS_Camera::~ARGUS_Camera(){
  11. waitThreadEnd( true );
  12. if(m_pOnVif != NULL) delete(m_pOnVif);
  13. if(m_pPos != NULL ) delete(m_pPos);
  14. };
  15. bool ARGUS_Camera::create( CSTR ip, CSTR username, CSTR password ){
  16. m_pOnVif = new pOnvif();
  17. if(m_pOnVif != NULL) {
  18. m_pOnVif->setIPAddress( ip );
  19. m_pOnVif->setUsername( username );
  20. m_pOnVif->setPassword( password );
  21. if(m_pOnVif->create()){
  22. videoSourceProfile *tPtr;
  23. tPtr = m_pOnVif->getProfiles()->at(0);
  24. sprintf( m_pProfileToken, "%s", tPtr->profiletoken );
  25. LOG( m_pProfileToken );
  26. sprintf( m_pDevToken, "%s", tPtr->sourcetoken );
  27. LOG( m_pDevToken );
  28. m_bOnline = basicThread::init();
  29. return m_bOnline;
  30. };
  31. };
  32. return false;
  33. };
  34. void ARGUS_Camera::m_fThreadProc( void ){
  35. m_bThreadStatus = TH_WORKING;
  36. float Direction = 1.f;
  37. while( m_bThreadStatus < TH_ENDED ){
  38. m_tTimeTSeconds = time( NULL );
  39. if( ( m_tTimeTSeconds % 30 ) == 0 ) {
  40. m_pOnVif->ptz_AbsoluteMove( m_pProfileToken, 0, -1, 0 );
  41. SLEEP(1000);
  42. }
  43. if( ( ( m_tTimeTSeconds - 15 ) % 30 ) == 0 ) {
  44. m_pOnVif->ptz_AbsoluteMove( m_pProfileToken, Direction, -1, 0 );
  45. Direction *= -1.f;
  46. SLEEP(1000);
  47. }
  48. SLEEP( 100 );
  49. };
  50. };
  51. void ARGUS_Camera::dispatchEvent( basicEvent *Evt ){
  52. if( m_bOnline ) {
  53. LOG("EVENT!");
  54. };
  55. };
  56. #undef LOG
  57. #undef LOG_ERROR