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.

119 lines
3.7 KiB

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