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.

92 lines
3.3 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
  1. #ifndef __PROTOCOL_DEFENDER_HEADER__
  2. #define __PROTOCOL_DEFENDER_HEADER__
  3. #ifdef __linux__
  4. #include <features.h>
  5. #endif
  6. #include "protocolHTTP.h"
  7. #include <time.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <sys/types.h>
  11. #include <sys/timeb.h>
  12. #include <string>
  13. #include "../../components/base/basicFunctionality.h"
  14. #include "../../components/base/basicLogCollection.h"
  15. #include "../../components/base/basicSettingsProvider.h"
  16. #include "xmlParser.h"
  17. #include "protocolEuropeanGeneral.h"
  18. /**
  19. * TODO: Add class description
  20. *
  21. * @author gagua
  22. */
  23. class protocolDefender : public protocolHTTP {
  24. private:
  25. basicLogCollection *m_pLog;
  26. config_setting_t *m_pSettings;
  27. int m_nScannerDimentions;
  28. CSTR m_pScannerName;
  29. CSTR m_pServerIP;
  30. CSTR m_pAccessURL;
  31. bool m_bEnabled;
  32. bool m_bUseSSL;
  33. bool m_bMitigationStatus;
  34. float m_fLon;
  35. float m_fLat;
  36. int m_nServerPort;
  37. bool m_bCurrentStatus;
  38. CSTR buildURL( CSTR templ, int dim, CSTR devID );
  39. CSTR buildUniqID( void );
  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(){ return true; };
  60. bool Alarm2D( float Angle, float Range, float Width, int ID=0 );
  61. bool Alarm3D( float Angle1, float Angle2, float Range, int ID=0 );
  62. bool VisibilityChanged( bool Worsened );
  63. bool StatusUpdate( void );
  64. void SetStatus( bool A ){ m_bCurrentStatus = A; };
  65. bool ErrorReporting( int lvl, CSTR Descr );
  66. bool StartTimeSynch( void );
  67. #ifdef __linux__
  68. //bool FinishTimeSynch( unsigned long long *tVals );
  69. #else
  70. //bool FinishTimeSynch( unsigned __int64 *tVals );
  71. #endif
  72. bool SetupCallBack( CSTR CallBackPath );
  73. void setProtocolType( bool DeviceIs3D );
  74. void setScannerName( CSTR Name );
  75. void setScannerPosition( float Lat, float Lon ){ m_fLon = Lon; m_fLat = Lat; };
  76. bool getMitigationStatus(void) { return m_bMitigationStatus; };
  77. };
  78. #ifdef __linux__
  79. unsigned long long getSHTimeValue( void );
  80. #else
  81. unsigned __int64 getSHTimeValue( void );
  82. #endif
  83. #endif