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.

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