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.

108 lines
3.1 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __PROTOCOL_DEFENDER_HEADER__
  2. #define __PROTOCOL_DEFENDER_HEADER__
  3. #ifdef __linux__
  4. #include <features.h>
  5. #endif
  6. #include "../../components/base/basicFunctionality.h"
  7. #include "../../components/base/basicLogCollection.h"
  8. #include "../../components/base/basicSettingsProvider.h"
  9. #include "protocolEuropeanGeneral.h"
  10. #include "protocolHTTP.h"
  11. #include "xmlParser.h"
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <string>
  15. #include <sys/timeb.h>
  16. #include <sys/types.h>
  17. #include <time.h>
  18. /**
  19. * TODO: Add class description
  20. *
  21. * @author gagua
  22. */
  23. class protocolDefender : public protocolHTTP
  24. {
  25. private:
  26. basicLogCollection * m_pLog;
  27. config_setting_t * m_pSettings;
  28. int m_nScannerDimentions;
  29. CSTR m_pScannerName;
  30. CSTR m_pServerIP;
  31. CSTR m_pAccessURL;
  32. bool m_bEnabled;
  33. bool m_bUseSSL;
  34. bool m_bMitigationStatus;
  35. float m_fLon;
  36. float m_fLat;
  37. int m_nServerPort;
  38. bool m_bCurrentStatus;
  39. CSTR buildURL(CSTR templ, int dim, CSTR devID);
  40. bool buildClockSyncPackage(unsigned char * Buffer, int & BufferSize);
  41. bool buildCallBackPackage(unsigned char * Buffer, int & BufferSize, CSTR CallBackPath);
  42. bool buildStatusPackage(unsigned char * Buffer, int & BufferSize, bool Status);
  43. bool buildFaultPackage(unsigned char * Buffer, int & BufferSize, unsigned char Type, CSTR Description);
  44. bool buildEvent2DPackage(unsigned char * Buffer, int & BufferSize, CSTR msgUID, int targetID, float Angle, float Range, float Width);
  45. bool buildEvent3DPackage(unsigned char * Buffer, int & BufferSize, CSTR msgUID, int targetID, float Angle1, float Angle2, float Range);
  46. CSTR assembleStatusData(bool StatusOK);
  47. CSTR assembleFaultData(uint8_t Code, CSTR Desc);
  48. CSTR assembleTargetData(int targetID, int Range, int Width, int Azimuth, int Elevation = 0);
  49. size_t assembleDefenderJSON(CSTR Buffer, defenderCategoryTypes Type, uint8_t Severity, CSTR Location, CSTR Data);
  50. protected:
  51. virtual bool packetHandler(protocolPackage * Package);
  52. public:
  53. // Constructor
  54. explicit protocolDefender(config_setting_t * Settings = NULL);
  55. // ToDo: change Serial to BaseClass of some kind of socket
  56. // protocolSafeShore( clientPort *SocketTransport, config_setting_t *Settings = NULL );
  57. // Destructor
  58. virtual ~protocolDefender();
  59. virtual bool init()
  60. {
  61. return true;
  62. }
  63. bool Alarm2D(float Angle, float Range, float Width, int ID = 0);
  64. bool Alarm3D(float Angle1, float Angle2, float Range, int ID = 0);
  65. bool VisibilityChanged(bool Worsened);
  66. bool StatusUpdate(void);
  67. void SetStatus(bool A)
  68. {
  69. m_bCurrentStatus = A;
  70. }
  71. bool ErrorReporting(int lvl, CSTR Descr);
  72. bool StartTimeSynch(void);
  73. #ifdef __linux__
  74. // bool FinishTimeSynch( unsigned long long *tVals );
  75. #else
  76. // bool FinishTimeSynch( unsigned __int64 *tVals );
  77. #endif
  78. bool SetupCallBack(CSTR CallBackPath);
  79. void setProtocolType(bool DeviceIs3D);
  80. void setScannerName(CSTR Name);
  81. void setScannerPosition(float Lat, float Lon)
  82. {
  83. m_fLon = Lon;
  84. m_fLat = Lat;
  85. }
  86. bool getMitigationStatus(void)
  87. {
  88. return m_bMitigationStatus;
  89. }
  90. };
  91. #endif