|
|
#ifndef __PROTOCOL_DEFENDER_HEADER__
#define __PROTOCOL_DEFENDER_HEADER__
#ifdef __linux__
#include <features.h>
#endif
#include "../../components/base/basicFunctionality.h"
#include "../../components/base/basicLogCollection.h"
#include "../../components/base/basicSettingsProvider.h"
#include "protocolEuropeanGeneral.h"
#include "protocolHTTP.h"
#include "xmlParser.h"
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <sys/timeb.h>
#include <sys/types.h>
#include <time.h>
/**
* TODO: Add class description * * @author gagua */class protocolDefender : public protocolHTTP{ private:
basicLogCollection * m_pLog; config_setting_t * m_pSettings; int m_nScannerDimentions; CSTR m_pScannerName; CSTR m_pServerIP; CSTR m_pAccessURL; bool m_bEnabled; bool m_bUseSSL; bool m_bMitigationStatus; float m_fLon; float m_fLat; int m_nServerPort; bool m_bCurrentStatus; CSTR buildURL(CSTR templ, int dim, CSTR devID); 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, float Angle, float Range, float Width); bool buildEvent3DPackage(unsigned char * Buffer, int & BufferSize, CSTR msgUID, int targetID, float Angle1, float Angle2, float Range);
CSTR assembleStatusData(bool StatusOK); CSTR assembleFaultData(uint8_t Code, CSTR Desc); CSTR assembleTargetData(int targetID, int Range, int Width, int Azimuth, int Elevation = 0); size_t assembleDefenderJSON(CSTR Buffer, defenderCategoryTypes Type, uint8_t Severity, CSTR Location, CSTR Data);
protected:
virtual bool packetHandler(protocolPackage * Package);
public:
// Constructor
explicit protocolDefender(config_setting_t * Settings = NULL); // ToDo: change Serial to BaseClass of some kind of socket
// protocolSafeShore( clientPort *SocketTransport, config_setting_t *Settings = NULL );
// Destructor
virtual ~protocolDefender();
virtual bool init() { return true; }
bool Alarm2D(float Angle, float Range, float Width, int ID = 0); bool Alarm3D(float Angle1, float Angle2, float 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);
void setScannerPosition(float Lat, float Lon) { m_fLon = Lon; m_fLat = Lat; }
bool getMitigationStatus(void) { return m_bMitigationStatus; }};
#endif
|