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.

182 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 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): no preferred camera
  57. TARGET_DATA * tDATA = (TARGET_DATA *) E->m_pEvtData;
  58. if (E->m_eType == EVT_ROI_ACTIVE && tDATA != NULL)
  59. {
  60. if (1) // ToDo: camera setting - only when the point passes the camera's test (range, pan limits, FOV)
  61. {
  62. if (testFOV(tDATA->system_target))
  63. {
  64. lookAt(E->m_db_id, tDATA->system_target);
  65. };
  66. }
  67. else // every camera acts on it
  68. {
  69. lookAt(E->m_db_id, tDATA->system_target);
  70. };
  71. };
  72. break;
  73. };
  74. case EVT_CLASS_SENSOR_CLD:
  75. case EVT_CLASS_SENSOR_LGS:
  76. case EVT_CLASS_SENSOR_LFS:
  77. case EVT_CLASS_SENSOR_MND:
  78. case EVT_CLASS_SENSOR_PLS_210:
  79. case EVT_CLASS_SENSOR_PLS_360:
  80. case EVT_CLASS_SENSOR_ALS:
  81. case EVT_CLASS_SENSOR_3D:
  82. case EVT_CLASS_SENSOR_ACC:
  83. {
  84. switch (E->m_eType)
  85. {
  86. case EVT_ROI_ACTIVE:
  87. {
  88. TARGET_DATA * tDATA;
  89. tDATA = (TARGET_DATA *) E->m_pEvtData;
  90. if (tDATA)
  91. {
  92. lookAt(E->m_db_id, tDATA->system_target);
  93. };
  94. break;
  95. };
  96. case EVT_TARGET_1D:
  97. case EVT_TARGET_2D_BLACK:
  98. case EVT_TARGET_2D_WHITE:
  99. case EVT_TARGET_3D_BLACK:
  100. case EVT_TARGET_3D_WHITE:
  101. {
  102. TARGET_DATA * tDATA;
  103. tDATA = (TARGET_DATA *) E->m_pEvtData;
  104. if (tDATA)
  105. {
  106. #ifdef DEBUG_EXTRA
  107. LOG("CHECK CAMERA FOV");
  108. #endif
  109. if (testFOV(tDATA->system_target))
  110. {
  111. #ifdef DEBUG_EXTRA
  112. LOG("TARGET IN CAMERA FOV");
  113. #endif
  114. lookAt(E->m_db_id, tDATA->system_target);
  115. };
  116. };
  117. break;
  118. };
  119. default: break;
  120. };
  121. break;
  122. };
  123. default: break;
  124. };
  125. return true; // Propogate Event
  126. }
  127. bool deviceNodePresetCamControl::validate()
  128. {
  129. #ifdef DEBUG_EXTRA
  130. LOG("VALIDATE");
  131. #endif
  132. if (CAM_WS_END == getWM())
  133. {
  134. return false;
  135. }
  136. // Validate Camera Settings
  137. /*{
  138. DBC_CAM_DATA *tDATA = argusNetNode::m_pDBC->getCamData( m_sNodeData.aux_id );
  139. if( tDATA ) {
  140. if( memcmp( &m_sCamData, tDATA, sizeof(DBC_CAM_DATA)) != 0 ){
  141. free( tDATA );
  142. LOG("Cam Settings Changed!");
  143. return false;
  144. };
  145. free( tDATA );
  146. } else{
  147. LOG("Cam Deleted!");
  148. return false;
  149. };
  150. }*/
  151. // Validate Stream - > moved to Video Encoder!
  152. /*
  153. {
  154. if( m_sNodeData.aux_parameter ) {
  155. #ifdef DEBUG_EXTRA
  156. LOG("VALIDATE Stream");
  157. #endif
  158. if( !m_bSourceConnected ) {
  159. if( connectToStream( m_sNodeData.aux_parameter ) ) {
  160. argusNetNode::m_pDBC->setStreamValid( m_sNodeData.aux_parameter );
  161. } else {
  162. argusNetNode::m_pDBC->setStreamValid( m_sNodeData.aux_parameter, false );
  163. };
  164. } else {
  165. validateStream();
  166. };
  167. };
  168. }
  169. */
  170. return deviceNodeCamera::validate();
  171. }
  172. #undef LOG
  173. #undef LOG_ERROR