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.

155 lines
4.2 KiB

2 years ago
​
​
​
2 years ago
​
​
2 years ago
​
​
​
​
​
​
2 years ago
​
​
2 years ago
​
​
​
2 years ago
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
2 hours ago
​
​
​
​
2 hours ago
​
​
​
​
​
​
​
2 hours ago
​
​
​
​
​
​
​
2 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
  1. #include "deviceNodePTZCamControl.h"
  2. #include "../mojo/mojoKernel.h"
  3. #define LOG(X) deviceNode::m_pLog->Log("PTZ_CAM", this, X)
  4. #define LOG_ERROR(X) deviceNode::m_pLog->Log("PTZ_CAM", this, _LOG_ERROR, X)
  5. deviceNodePTZCamControl::deviceNodePTZCamControl(DBC_NODE_DATA * Data) :
  6. deviceNodeCamera(Data),
  7. basicEventHandler(false) // registered at the end of the constructor
  8. {
  9. // Receive events only now that the object is completely constructed
  10. attachEvents();
  11. }
  12. deviceNodePTZCamControl::deviceNodePTZCamControl(uint32_t id) :
  13. deviceNodeCamera(id),
  14. basicEventHandler(false) // registered at the end of the constructor
  15. {
  16. m_sMediaSource.mediaSourceId = m_sNodeData.aux_id;
  17. strncpy(m_sMediaSource.mediaName, m_sNodeData.name, 128);
  18. m_sMediaSource.mediaName[127] = (char) 0;
  19. memset(&m_sCtrlData, 0, sizeof(CAMERA_CTRL_DATA));
  20. // Receive events only now that the object is completely constructed
  21. attachEvents();
  22. }
  23. deviceNodePTZCamControl::~deviceNodePTZCamControl()
  24. {
  25. detachEvents(); // stop event delivery before the members are destroyed (see basicEventHandler.h)
  26. stopService();
  27. }
  28. bool deviceNodePTZCamControl::startService()
  29. {
  30. return create();
  31. }
  32. bool deviceNodePTZCamControl::stopService()
  33. {
  34. return true;
  35. }
  36. bool deviceNodePTZCamControl::dispatchEvent(EVENT_CONTAINER * E)
  37. {
  38. if (E == NULL) return false;
  39. // if( !m_sCamData.online ) return true;
  40. // if( m_bBusy ) return true;
  41. if (m_sCamData.prefered_events_only){
  42. #ifdef DEBUG_EXTRA
  43. char tB[200];
  44. sprintf( tB, "comp Evt Dest %ld %ld", E->m_nDestinationNodeID, m_sNodeData.node_id );
  45. LOG( tB );
  46. #endif
  47. // Check if we are eligable dest of event
  48. if( E->m_nDestinationNodeID != m_sNodeData.node_id ) return true;
  49. };
  50. switch (E->m_eType){
  51. case EVT_ROI_ACTIVE:{
  52. if ( !m_bCameraAIControled ) {
  53. TARGET_DATA *tDATA = (TARGET_DATA *)E->m_pEvtData;
  54. if( tDATA ) lookAt(E->m_db_id, tDATA->system_target);
  55. }
  56. break;
  57. };
  58. case EVT_CAMERA_AI_MODE_ON:{
  59. if( E->m_nDestinationNodeID == m_sNodeData.node_id ) m_bCameraAIControled = true;
  60. break;
  61. };
  62. case EVT_CAMERA_AI_MODE_OFF:{
  63. if( E->m_nDestinationNodeID == m_sNodeData.node_id ) m_bCameraAIControled = false;
  64. break;
  65. };
  66. case EVT_CAMERA_MOVE_TO:{
  67. //Event used by AI Analytics to move camera
  68. TARGET_DATA *tDATA = (TARGET_DATA *)E->m_pEvtData;
  69. if (tDATA) {
  70. lookAt( E->m_db_id, tDATA->system_target );
  71. };
  72. break;
  73. };
  74. case EVT_TARGET_1D:
  75. case EVT_TARGET_2D_BLACK:
  76. case EVT_TARGET_2D_WHITE:
  77. case EVT_TARGET_3D_BLACK:
  78. case EVT_TARGET_3D_WHITE:{
  79. if ( !m_bCameraAIControled ) {
  80. TARGET_DATA *tDATA = (TARGET_DATA *)E->m_pEvtData;
  81. if (tDATA){
  82. #ifdef DEBUG_EXTRA
  83. LOG("CHECK CAMERA FOV");
  84. #endif
  85. if (testFOV(tDATA->system_target)){
  86. #ifdef DEBUG_EXTRA
  87. LOG("TARGET IN CAMERA FOV");
  88. #endif
  89. lookAt(E->m_db_id, tDATA->system_target);
  90. };
  91. };
  92. }
  93. break;
  94. };
  95. default: break;
  96. };
  97. return true;
  98. }
  99. bool deviceNodePTZCamControl::validate()
  100. {
  101. #ifdef DEBUG_EXTRA
  102. LOG("VALIDATE");
  103. #endif
  104. if (CAM_WS_END == getWM())
  105. {
  106. return false;
  107. }
  108. // Validate Camera Settings
  109. /*{
  110. DBC_CAM_DATA *tDATA = argusNetNode::m_pDBC->getCamData( m_sNodeData.aux_id );
  111. if( tDATA ) {
  112. if( memcmp( &m_sCamData, tDATA, sizeof(DBC_CAM_DATA)) != 0 ){
  113. free( tDATA );
  114. LOG("Cam Settings Changed!");
  115. return false;
  116. };
  117. free( tDATA );
  118. } else{
  119. LOG("Cam Deleted!");
  120. return false;
  121. };
  122. }*/
  123. // Validate Stream - > moved to Video Encoder!
  124. /*
  125. {
  126. if( m_sNodeData.aux_parameter ) {
  127. #ifdef DEBUG_EXTRA
  128. LOG("VALIDATE Stream");
  129. #endif
  130. if( !m_bSourceConnected ) {
  131. if( connectToStream( m_sNodeData.aux_parameter ) ) {
  132. argusNetNode::m_pDBC->setStreamValid( m_sNodeData.aux_parameter );
  133. } else {
  134. argusNetNode::m_pDBC->setStreamValid( m_sNodeData.aux_parameter, false );
  135. };
  136. } else {
  137. validateStream();
  138. };
  139. };
  140. }
  141. */
  142. return deviceNodeCamera::validate();
  143. }
  144. #undef LOG
  145. #undef LOG_ERROR