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.

96 lines
4.4 KiB

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