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.

172 lines
4.0 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 years ago
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 years ago
​
​
  1. #include "deviceNodePresetCamControl.h"
  2. #include "../mojo/mojoKernel.h"
  3. #define LOG(X) deviceNode::m_pLog->Log("PRST_CAM", this, X)
  4. #define LOG_ERROR(X) deviceNode::m_pLog->Log("PRST_CAM", this, _LOG_ERROR, X)
  5. deviceNodePresetCamControl::deviceNodePresetCamControl(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. deviceNodePresetCamControl::deviceNodePresetCamControl(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. deviceNodePresetCamControl::~deviceNodePresetCamControl()
  24. {
  25. detachEvents(); // stop event delivery before the members are destroyed (see basicEventHandler.h)
  26. stopService();
  27. }
  28. bool deviceNodePresetCamControl::startService()
  29. {
  30. return create();
  31. }
  32. bool deviceNodePresetCamControl::stopService()
  33. {
  34. return true;
  35. }
  36. bool deviceNodePresetCamControl::dispatchEvent(EVENT_CONTAINER * E)
  37. {
  38. if (E == NULL)
  39. {
  40. return false;
  41. }
  42. // if( !m_sCamData.online ) return;
  43. // if( m_bBusy ) return;
  44. if (m_sCamData.prefered_events_only)
  45. {
  46. // Check if we eligable dest of event
  47. if (E->m_nDestinationNodeID != m_sNodeData.node_id)
  48. {
  49. return true;
  50. }
  51. };
  52. switch (E->m_eClass)
  53. {
  54. case EVT_CLASS_SYSTEM:
  55. {
  56. // Map ROI (kernel): the cameras that can see the point
  57. TARGET_DATA * tDATA = (TARGET_DATA *) E->m_pEvtData;
  58. if (E->m_eType == EVT_ROI_ACTIVE && tDATA != NULL && testFOV(tDATA->system_target))
  59. {
  60. lookAt(E->m_db_id, tDATA->system_target);
  61. };
  62. break;
  63. };
  64. case EVT_CLASS_SENSOR_CLD:
  65. case EVT_CLASS_SENSOR_LGS:
  66. case EVT_CLASS_SENSOR_LFS:
  67. case EVT_CLASS_SENSOR_MND:
  68. case EVT_CLASS_SENSOR_PLS_210:
  69. case EVT_CLASS_SENSOR_PLS_360:
  70. case EVT_CLASS_SENSOR_ALS:
  71. case EVT_CLASS_SENSOR_3D:
  72. case EVT_CLASS_SENSOR_ACC:
  73. {
  74. switch (E->m_eType)
  75. {
  76. case EVT_ROI_ACTIVE:
  77. {
  78. TARGET_DATA * tDATA;
  79. tDATA = (TARGET_DATA *) E->m_pEvtData;
  80. if (tDATA)
  81. {
  82. lookAt(E->m_db_id, tDATA->system_target);
  83. };
  84. break;
  85. };
  86. case EVT_TARGET_1D:
  87. case EVT_TARGET_2D_BLACK:
  88. case EVT_TARGET_2D_WHITE:
  89. case EVT_TARGET_3D_BLACK:
  90. case EVT_TARGET_3D_WHITE:
  91. {
  92. TARGET_DATA * tDATA;
  93. tDATA = (TARGET_DATA *) E->m_pEvtData;
  94. if (tDATA)
  95. {
  96. #ifdef DEBUG_EXTRA
  97. LOG("CHECK CAMERA FOV");
  98. #endif
  99. if (testFOV(tDATA->system_target))
  100. {
  101. #ifdef DEBUG_EXTRA
  102. LOG("TARGET IN CAMERA FOV");
  103. #endif
  104. lookAt(E->m_db_id, tDATA->system_target);
  105. };
  106. };
  107. break;
  108. };
  109. default: break;
  110. };
  111. break;
  112. };
  113. default: break;
  114. };
  115. return true; // Propogate Event
  116. }
  117. bool deviceNodePresetCamControl::validate()
  118. {
  119. #ifdef DEBUG_EXTRA
  120. LOG("VALIDATE");
  121. #endif
  122. if (CAM_WS_END == getWM())
  123. {
  124. return false;
  125. }
  126. // Validate Camera Settings
  127. /*{
  128. DBC_CAM_DATA *tDATA = argusNetNode::m_pDBC->getCamData( m_sNodeData.aux_id );
  129. if( tDATA ) {
  130. if( memcmp( &m_sCamData, tDATA, sizeof(DBC_CAM_DATA)) != 0 ){
  131. free( tDATA );
  132. LOG("Cam Settings Changed!");
  133. return false;
  134. };
  135. free( tDATA );
  136. } else{
  137. LOG("Cam Deleted!");
  138. return false;
  139. };
  140. }*/
  141. // Validate Stream - > moved to Video Encoder!
  142. /*
  143. {
  144. if( m_sNodeData.aux_parameter ) {
  145. #ifdef DEBUG_EXTRA
  146. LOG("VALIDATE Stream");
  147. #endif
  148. if( !m_bSourceConnected ) {
  149. if( connectToStream( m_sNodeData.aux_parameter ) ) {
  150. argusNetNode::m_pDBC->setStreamValid( m_sNodeData.aux_parameter );
  151. } else {
  152. argusNetNode::m_pDBC->setStreamValid( m_sNodeData.aux_parameter, false );
  153. };
  154. } else {
  155. validateStream();
  156. };
  157. };
  158. }
  159. */
  160. return deviceNodeCamera::validate();
  161. }
  162. #undef LOG
  163. #undef LOG_ERROR