2 changed files with 185 additions and 0 deletions
@ -0,0 +1,57 @@ |
|||
#ifndef __KERNEL_KAFKA_MODULE_HEADERS__ |
|||
#define __KERNEL_KAFKA_MODULE_HEADERS__ |
|||
|
|||
|
|||
#include "kernelModule.h" |
|||
#include "../components/base/basicThread.h" |
|||
#include "../components/base/basicEventHeap.h" |
|||
#include "../data/protocol/protocolREST.h" |
|||
|
|||
class kernelModuleRemoteServer: public kernelModule, public basicThread { |
|||
private: |
|||
//KAFKA_SETTINGS *m_pSettings; |
|||
protocolREST *m_pProtocol; |
|||
bool m_bConsumerEnabled; |
|||
basicEventHeap *m_pEventHeap; |
|||
//KAFKA_TEMPLATE ***m_pEvtTemplates; |
|||
|
|||
int32_t partition; |
|||
int64_t start_offset; |
|||
char m_sServerIP[48]; |
|||
char m_sServerName[48]; |
|||
unsigned long long m_llTicks; |
|||
CSTR buildTemplate( CSTR tpl, |
|||
uint32_t source_id, |
|||
CSTR ts, |
|||
CSTR uuid = NULL, |
|||
CSTR az = NULL, |
|||
CSTR range = NULL, |
|||
CSTR width = NULL, |
|||
CSTR el = NULL, |
|||
CSTR lat = NULL, |
|||
CSTR lon = NULL, |
|||
CSTR alt = NULL, |
|||
CSTR extID = NULL, |
|||
CSTR src_Name = NULL, |
|||
CSTR src_IP = NULL, |
|||
CSTR src_lat = NULL, |
|||
CSTR src_lon = NULL, |
|||
CSTR src_alt = NULL, |
|||
CSTR src_rot_x = NULL, |
|||
CSTR src_rot_y = NULL, |
|||
CSTR src_rot_z = NULL |
|||
); |
|||
protected: |
|||
virtual void m_fThreadProc( void ); |
|||
public: |
|||
explicit kernelModuleKafka( uint32_t ModuleID ); |
|||
virtual ~kernelModuleKafka(); |
|||
|
|||
virtual bool reloadSettings(); |
|||
virtual bool startService(); |
|||
virtual bool stopService( bool force = false ); |
|||
virtual void dispatchEvent(EVENT_CONTAINER *Evt); |
|||
}; |
|||
|
|||
|
|||
#endif |
|||
@ -0,0 +1,128 @@ |
|||
#ifndef __PROTOCOL_RESTAPI_HEADER__ |
|||
#define __PROTOCOL_RESTAPI_HEADER__ |
|||
|
|||
#ifdef __linux__ |
|||
#include <features.h> |
|||
#endif |
|||
|
|||
#include "protocolHTTP.h" |
|||
|
|||
#include <time.h> |
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include <sys/types.h> |
|||
#include <sys/timeb.h> |
|||
#include <string> |
|||
|
|||
#include "../../components/base/basicFunctionality.h" |
|||
#include "../../components/base/basicLogCollection.h" |
|||
#include "../../components/base/basicSettingsProvider.h" |
|||
|
|||
#include "xmlParser.h" |
|||
|
|||
#define PROTOCOL_TYPE_3D true |
|||
#define PROTOCOL_TYPE_2D false |
|||
|
|||
#define SERVICE_URL_TEMPLATE_STATUS "/sensors/lidar%dd/%s/status" |
|||
#define SERVICE_URL_TEMPLATE_FAULT "/sensors/lidar%dd/%s/fault" |
|||
#define SERVICE_URL_TEMPLATE_EVENT "/sensors/lidar%dd/%s/event" |
|||
#define SERVICE_URL_TEMPLATE_CALLBACK "/sensors/lidar%dd/%s/httpcallback" |
|||
#define SERVICE_URL_TEMPLATE_CLOCKSYNC "/sensors/lidar%dd/%s/clocksync" |
|||
|
|||
|
|||
#define PACKAGE_ENVELOPE_TEMPLATE_STATUS "<lcu:SystemStatus xmlns:lcu=\"http://www.safeshore.eu/lcu/schema\">" \ |
|||
"<lcu:Mode>%s</lcu:Mode>" \ |
|||
"<lcu:Timestamp>%s</lcu:Timestamp>" \ |
|||
"</lcu:SystemStatus>" |
|||
|
|||
#define PACKAGE_ENVELOPE_TEMPLATE_FAULT "<lcu:FaultDescription xmlns:lcu=\"http://www.safeshore.eu/lcu/schema\">" \ |
|||
"<lcu:Level>%s</lcu:Level>" \ |
|||
"<lcu:Timestamp>%s</lcu:Timestamp>" \ |
|||
"<lcu:Description>%s</lcu:Description>" \ |
|||
"</lcu:FaultDescription>" |
|||
|
|||
#define PACKAGE_ENVELOPE_TEMPLATE_EVT2D "<lcu:EventLidar2D xmlns:lcu=\"http://www.safeshore.eu/lcu/schema\">" \ |
|||
"<lcu:UniqueId>%s</lcu:UniqueId>" \ |
|||
"<lcu:Timestamp>%s</lcu:Timestamp>" \ |
|||
"<lcu:Target><lcu:Id>%d</lcu:Id>" \ |
|||
"<lcu:Coordinates><lcu:Azimuth>%d</lcu:Azimuth><lcu:Distance>%d</lcu:Distance></lcu:Coordinates>" \ |
|||
"<lcu:Width>%d</lcu:Width></lcu:Target>" \ |
|||
"</lcu:EventLidar2D>" |
|||
|
|||
#define PACKAGE_ENVELOPE_TEMPLATE_EVT3D "<lcu:EventLidar3D xmlns:lcu=\"http://www.safeshore.eu/lcu/schema\">" \ |
|||
"<lcu:UniqueId>%s</lcu:UniqueId>" \ |
|||
"<lcu:Timestamp>%s</lcu:Timestamp>" \ |
|||
"<lcu:Target><lcu:Id>%d</lcu:Id>" \ |
|||
"<lcu:Coordinates><lcu:Azimuth>%d</lcu:Azimuth><lcu:Elevation>%d</lcu:Elevation><lcu:Distance>%d</lcu:Distance></lcu:Coordinates>" \ |
|||
"</lcu:Target>" \ |
|||
"</lcu:EventLidar3D>" |
|||
|
|||
#define PACKAGE_ENVELOPE_TEMPLATE_REG_CALL "<lcu:Callback xmlns:lcu=\"http://www.safeshore.eu/lcu/schema\">" \ |
|||
"<lcu:XAddr>%s</lcu:XAddr>" \ |
|||
"</lcu:Callback>" |
|||
|
|||
#define PACKAGE_ENVELOPE_TEMPLATE_CLOCKSYNC "<lcu:ClockSyncQuery xmlns:lcu=\"http://www.safeshore.eu/lcu/schema\">" \ |
|||
"<lcu:t0>%s</lcu:t0>" \ |
|||
"</lcu:ClockSyncQuery>" |
|||
|
|||
#define OS_SCANNER_NAME_SIZE 128 |
|||
#define OS_LCU_ADDRESS_SIZE 16 |
|||
|
|||
/** |
|||
* TODO: Add class description |
|||
* |
|||
* @author gagua |
|||
*/ |
|||
class protocolREST : public protocolHTTP { |
|||
private: |
|||
basicLogCollection * m_pLog; |
|||
config_setting_t * m_pSettings; |
|||
bool m_bEnabled; |
|||
int m_nScannerDimentions; |
|||
CSTR m_pScannerName; |
|||
CSTR m_pServerIP; |
|||
int m_nServerPort; |
|||
bool m_bCurrentStatus; |
|||
CSTR buildURL( CSTR templ, int dim, CSTR devID ); |
|||
CSTR buildUniqID( void ); |
|||
bool buildClockSyncPackage( unsigned char *Buffer, int &BufferSize ); |
|||
bool buildCallBackPackage( unsigned char *Buffer, int &BufferSize, CSTR CallBackPath ); |
|||
bool buildStatusPackage( unsigned char *Buffer, int &BufferSize, bool Status ); |
|||
bool buildFaultPackage( unsigned char *Buffer, int &BufferSize, unsigned char Type, CSTR Description ); |
|||
bool buildEvent2DPackage( unsigned char *Buffer, int &BufferSize, CSTR msgUID, int targetID, int Angle, int Range, int Width ); |
|||
bool buildEvent3DPackage( unsigned char *Buffer, int &BufferSize, CSTR msgUID, int targetID, int Angle1, int Angle2, int Range ); |
|||
|
|||
protected: |
|||
virtual bool packetHandler( protocolPackage *Package ); |
|||
public: |
|||
// Constructor |
|||
explicit protocolREST( config_setting_t *Settings = NULL ); |
|||
//ToDo: change Serial to BaseClass of some kind of socket |
|||
//protocolREST( clientPort *SocketTransport, config_setting_t *Settings = NULL ); |
|||
// Destructor |
|||
virtual ~protocolREST(); |
|||
virtual bool init(){ return true; }; |
|||
bool Alarm2D( int Angle, int Range, int Width, int ID=0 ); |
|||
bool Alarm3D( int Angle1, int Angle2, int Range, int ID=0 ); |
|||
bool VisibilityChanged( bool Worsened ); |
|||
bool StatusUpdate( void ); |
|||
void SetStatus( bool A ){ m_bCurrentStatus = A; }; |
|||
bool ErrorReporting( int lvl, CSTR Descr ); |
|||
bool StartTimeSynch( void ); |
|||
#ifdef __linux__ |
|||
//bool FinishTimeSynch( unsigned long long *tVals ); |
|||
#else |
|||
//bool FinishTimeSynch( unsigned __int64 *tVals ); |
|||
#endif |
|||
bool SetupCallBack( CSTR CallBackPath ); |
|||
void setProtocolType( bool DeviceIs3D ); |
|||
void setScannerName( CSTR Name ); |
|||
}; |
|||
|
|||
#ifdef __linux__ |
|||
unsigned long long getSHTimeValue( void ); |
|||
#else |
|||
unsigned __int64 getSHTimeValue( void ); |
|||
#endif |
|||
|
|||
#endif |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue