#ifndef __PROTOCOL_SAFESHORE_HEADER__ #define __PROTOCOL_SAFESHORE_HEADER__ #ifdef __linux__ #include #endif #include "protocolHTTP.h" #include #include #include #include #include #include #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 "" \ "%s" \ "%s" \ "" #define PACKAGE_ENVELOPE_TEMPLATE_FAULT "" \ "%s" \ "%s" \ "%s" \ "" #define PACKAGE_ENVELOPE_TEMPLATE_EVT2D "" \ "%s" \ "%s" \ "%d" \ "%d%d" \ "%d" \ "" #define PACKAGE_ENVELOPE_TEMPLATE_EVT3D "" \ "%s" \ "%s" \ "%d" \ "%d%d%d" \ "" \ "" #define PACKAGE_ENVELOPE_TEMPLATE_REG_CALL "" \ "%s" \ "" #define PACKAGE_ENVELOPE_TEMPLATE_CLOCKSYNC "" \ "%s" \ "" #define OS_SCANNER_NAME_SIZE 128 #define OS_LCU_ADDRESS_SIZE 16 /** * TODO: Add class description * * @author gagua */ class protocolSafeShore : public protocolHTTP { private: basicLogCollection *m_pLog; config_setting_t *m_pSettings; 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 protocolSafeShore( 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 ~protocolSafeShore(); 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