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.

80 lines
2.3 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "objectEventReport.h"
  2. #include "../base/basicEventHeap.h"
  3. #include "../../hardware/soc/general/3DLRF.h"
  4. objectEventReport *objectEventReport::_instance = NULL;
  5. /**
  6. * Returns the single instance of the object.
  7. */
  8. objectEventReport* objectEventReport::getInstance() {
  9. // check if the instance has been created yet
  10. if (0 == _instance) {
  11. // if not, then create it
  12. _instance = new objectEventReport();
  13. }
  14. // return the single instance
  15. return _instance;
  16. };
  17. // Constructor implementation
  18. objectEventReport::objectEventReport() : basicEventHandler(){
  19. m_pStorageProvider = storageProvider::getInstance();
  20. m_pStorageProvider->startNewSeries();
  21. sprintf( m_pReportFileName, "%s", m_pStorageProvider->getNewFileName());
  22. };
  23. // Destructor implementation
  24. objectEventReport::~objectEventReport(){
  25. };
  26. void objectEventReport::dispatchEvent( basicEvent *Evt ){
  27. if( Evt == NULL ) return;
  28. if (Evt->m_eClass == EVT_CLASS_SENSOR || Evt->m_eClass == EVT_CLASS_SYSTEM){
  29. addGenericEvent( Evt );
  30. };
  31. };
  32. bool objectEventReport::addGenericEvent( basicEvent *Evt ){
  33. FILE *FD;
  34. FD = fopen(m_pReportFileName, "a+");
  35. if( FD != NULL ){
  36. if( Evt->m_pEvtData == NULL ){
  37. fprintf( FD, "%d,\"%s\"\n", Evt->m_nSourceUID, Evt->m_pHumanReadableMsg );
  38. } else {
  39. CLIENT_EVENT *tData;
  40. float fRange, fAzimuth, fElevation;
  41. uint16_t cX, cY;
  42. bool lMaster;
  43. tData = (CLIENT_EVENT*)Evt->m_pEvtData;
  44. uint8_t kid;
  45. kid = tData->k_id & 0x07;
  46. lMaster = ((tData->k_id & 0x08) == 0x08 );
  47. fRange = 300.0 / 4095.0 * tData->range;
  48. //makeCds( tData->mStartID, sX, sY, m_bIsMaster );
  49. //makeCds( tData->mEndID, eX, eY, m_bIsMaster );
  50. //cX = ((sX+eX)>>1);
  51. //cY = ((sY+eY)>>1);
  52. makeXY( tData->th_id, cX, cY, lMaster );
  53. fAzimuth = 360.0 - (360.0 / TH_LINE_NODES )*cX;
  54. fElevation = 90.0 - (Q_DEGREE_FOV/Q_SCAN_COUNT )*cY + Q_SHIFT_DOWN_FOV;
  55. fprintf( FD, "%d,%d:%d,%c,%d,%c,%0.3f,%0.3f,%0.3f,%d\n",
  56. Evt->m_nSourceUID,
  57. tData->uts,
  58. tData->ums,
  59. (lMaster?'M':'S'),
  60. kid,
  61. ((tData->type == EVT_TARGET_WHITE )?'W':'B'),
  62. fRange,
  63. fAzimuth,
  64. fElevation,
  65. tData->w_cnt*tData->range
  66. );
  67. };
  68. fclose( FD );
  69. };
  70. return true;
  71. };
  72. bool objectEventReport::addVideoRecord( CSTR fileName ){
  73. return true;
  74. };