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.

157 lines
5.1 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*******************************************************************
  2. *
  3. * DESCRIPTION: Pathfinder Kernel Header File
  4. *
  5. * AUTHOR: gagua
  6. *
  7. * HISTORY:
  8. *
  9. * DATE:1/20/2020
  10. *
  11. *******************************************************************/
  12. #ifndef __ARGUS_KERNEL_HEADER__
  13. #define __ARGUS_KERNEL_HEADER__
  14. #include <sys/types.h>
  15. #include <dirent.h>
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #include <assert.h>
  20. #include <getopt.h> /* getopt_long() */
  21. #include <fcntl.h> /* low-level i/o */
  22. #include <unistd.h>
  23. #include <errno.h>
  24. #include <sys/stat.h>
  25. #include <sys/types.h>
  26. #include <sys/time.h>
  27. #include <sys/mman.h>
  28. #include <sys/ioctl.h>
  29. #include <linux/videodev2.h>
  30. #include <linux/types.h>
  31. struct serial_struct {
  32. int type;
  33. int line;
  34. unsigned int port;
  35. int irq;
  36. int flags;
  37. int xmit_fifo_size;
  38. int custom_divisor;
  39. int baud_base;
  40. unsigned short close_delay;
  41. char io_type;
  42. char reserved_char[1];
  43. int hub6;
  44. unsigned short closing_wait; /* time to wait before closing */
  45. unsigned short closing_wait2; /* no longer used... */
  46. unsigned char * iomem_base;
  47. unsigned short iomem_reg_shift;
  48. unsigned int port_high;
  49. unsigned long iomap_base; /* cookie passed into ioremap */
  50. };
  51. #include "../../alg/generic/md5.h"
  52. #include "../../components/base/basicThread.h"
  53. #include "../../components/base/basicEngine.h"
  54. #include "../../components/base/basicSettingsProvider.h"
  55. #include "../../components/object/objectPathfinderBinaryLog.h"
  56. #include "../../data/ponvif/ponvif.h"
  57. #include "../../data/protocol/onvifMediaObserver.h"
  58. #include "../../data/ssdp/ssdpAnnouncer.h"
  59. #include "../../components/base/basicEventHeap.h"
  60. #include "../../data/net/netServer.h"
  61. #include "../../pathfinder/pathfinderDBConnector.h"
  62. #include "../../hardware/sensors/9dof/BNO055.h"
  63. #include "../../hardware/sensors/gps/XA1110_I2C.h"
  64. #include "../../hardware/sensors/gphoto/gPhotoCamera.h"
  65. #include "../../hardware/sensors/optic_flow/adns3080/opticFlowADNS.h"
  66. #include "../../hardware/sensors/lrf/lrfScanner.h"
  67. #include <wiringPi.h>
  68. #define SLEEP_KERNEL_INTERVAL 10
  69. #define ONVIF_DISCOVERY_INTERVAL 300 // 5 min
  70. #define ONVIF_DISCOVERY_RESULT_TIME 5
  71. typedef enum E_PF_COMMANDS{
  72. PF_CMD_ARM_APPLICATION = 1,
  73. PF_CMD_DISARM_APPLICATION = 2,
  74. PF_CMD_OFSENSOR_SET_CAM = 3,
  75. PF_CMD_OFSENSOR_SET_OF = 4,
  76. PF_CMD_START_SCANER = 10,
  77. PF_CMD_RESET_SCANER = 13,
  78. PF_CMD_STOP_SCANER = 15,
  79. PF_CMD_SHOT_CAMERA = 22,
  80. PF_CMD_START_BURST_CAMERA = 23,
  81. PF_CMD_STOP_BURST_CAMERA = 24,
  82. PF_CMD_SWITCH_CAMERA = 25,
  83. PF_CMD_SWITCH_STORAGE = 26,
  84. PF_CMD_PREV_CAMERA = 27,
  85. PF_CMD_UPDATE_IMU = 28,
  86. PF_CMD_START_PROCESS = 29,
  87. PF_CMD_STOP_PROCESS = 30,
  88. PF_CMD_SET_CURRENT_ALT = 31,
  89. PF_CMD_DELETE_CAM_PHOTOS = 32,
  90. PF_CMD_DELETE_DATA_FILE = 33
  91. } PF_COMMANDS;
  92. #define PF_HW_NONE 0
  93. #define PF_HW_GPS 1
  94. #define PF_HW_BNO 2
  95. #define PF_HW_OPF 4
  96. #define PF_HW_LRF 8
  97. #define PF_HW_PHO 16
  98. #define PF_HW_ALL 31
  99. class PF_Kernel: public basicThread {
  100. private:
  101. time_t m_tTimeTSeconds;
  102. basicLogCollection * m_pLog;
  103. config_setting_t * m_pSettings;
  104. ssdpAnnouncer * m_pServiceAnnouncer;
  105. uint8_t m_bExitCause;
  106. bool m_bCreatedDBC;
  107. uint8_t m_bStartMode;
  108. uint8_t m_bHWFlags;
  109. float m_fStartAlt;
  110. float m_fGSAlt;
  111. bool m_bGPSis3D;
  112. PATHFINDER_DBC * m_pDBC;
  113. objectPathfinderBinaryLog * m_pBLOG;
  114. /* Sensors and Devices */
  115. sensorBNO * m_pBNO;
  116. sensorXA1110 * m_pGPS;
  117. LRF_techScanner * m_pScanner;
  118. gPhotoCamera * m_pCamera;
  119. opticFlow * m_pFlow;
  120. /* Flags */
  121. bool m_bArmed;
  122. bool m_bForced;
  123. bool m_bActive;
  124. protected:
  125. void m_fThreadProc( void );
  126. void startDataAsqusition( void );
  127. void stopDataAsqusition( void );
  128. public:
  129. // Constructor
  130. explicit PF_Kernel( config_setting_t *Settings = NULL );
  131. // Destructor
  132. virtual ~PF_Kernel();
  133. bool create( void );
  134. bool signalEvent( void );
  135. void WaitFinish( bool Force = false );
  136. bool setStatus( int );
  137. uint8_t getExitCause( void ){ return m_bExitCause;};
  138. void armStatusChanged(void);
  139. };
  140. #endif