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.

86 lines
3.2 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. bool buildClockSyncPackage( unsigned char *Buffer, int &BufferSize );
  40. bool buildCallBackPackage( unsigned char *Buffer, int &BufferSize, CSTR CallBackPath );
  41. bool buildStatusPackage( unsigned char *Buffer, int &BufferSize, bool Status );
  42. bool buildFaultPackage( unsigned char *Buffer, int &BufferSize, unsigned char Type, CSTR Description );
  43. bool buildEvent2DPackage( unsigned char *Buffer, int &BufferSize, CSTR msgUID, int targetID, float Angle, float Range, float Width );
  44. bool buildEvent3DPackage( unsigned char *Buffer, int &BufferSize, CSTR msgUID, int targetID, float Angle1, float Angle2, float Range );
  45. CSTR assembleStatusData( bool StatusOK );
  46. CSTR assembleFaultData( uint8_t Code, CSTR Desc );
  47. CSTR assembleTargetData( int targetID, int Range, int Width, int Azimuth, int Elevation = 0 );
  48. size_t assembleDefenderJSON( CSTR Buffer, defenderCategoryTypes Type, uint8_t Severity, CSTR Location, CSTR Data );
  49. protected:
  50. virtual bool packetHandler( protocolPackage *Package );
  51. public:
  52. // Constructor
  53. explicit protocolDefender( config_setting_t *Settings = NULL );
  54. //ToDo: change Serial to BaseClass of some kind of socket
  55. //protocolSafeShore( clientPort *SocketTransport, config_setting_t *Settings = NULL );
  56. // Destructor
  57. virtual ~protocolDefender();
  58. virtual bool init(){ return true; };
  59. bool Alarm2D( float Angle, float Range, float Width, int ID=0 );
  60. bool Alarm3D( float Angle1, float Angle2, float Range, int ID=0 );
  61. bool VisibilityChanged( bool Worsened );
  62. bool StatusUpdate( void );
  63. void SetStatus( bool A ){ m_bCurrentStatus = A; };
  64. bool ErrorReporting( int lvl, CSTR Descr );
  65. bool StartTimeSynch( void );
  66. #ifdef __linux__
  67. //bool FinishTimeSynch( unsigned long long *tVals );
  68. #else
  69. //bool FinishTimeSynch( unsigned __int64 *tVals );
  70. #endif
  71. bool SetupCallBack( CSTR CallBackPath );
  72. void setProtocolType( bool DeviceIs3D );
  73. void setScannerName( CSTR Name );
  74. void setScannerPosition( float Lat, float Lon ){ m_fLon = Lon; m_fLat = Lat; };
  75. bool getMitigationStatus(void) { return m_bMitigationStatus; };
  76. };
  77. #endif