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.
 
 
 
 
 
 

79 lines
3.1 KiB

#ifndef __ARGUS_DATABASE_CONNECTOR_HEADER__
#define __ARGUS_DATABASE_CONNECTOR_HEADER__
#include "../components/base/basicSettingsProvider.h"
#include "../data/mysql/database_class.h"
#include "../data/protocol/onvifMediaObserver.h"
#include "../alg/generic/md5.h"
#define ONE_DAY_HISTORY 86400
#define ONE_HOUR_HISTORY 3600
#define ONE_SECOND_HISTORY 1
typedef struct S_CamRecordDBC{
int id;
bool online;
char uuid[CLOG];
char ip[16];
char username[CLOG];
char password[CLOG];
}CamRecordDBC;
typedef struct S_EventRecordDBC{
int ts_s;
int ts_ms;
int type;
}EventRecordDBC;
typedef struct S_DBC_NODE_DATA{
uint32_t node_id;
uint32_t aux_id;
uint32_t type;
bool online;
uint32_t tss;
uint32_t tsm;
char name[128];
}DBC_NODE_DATA;
typedef std::vector<int> DBC_INT_LIST;
typedef std::vector<CamRecordDBC*> vectorCamRecords;
typedef std::vector<EventRecordDBC*> vectorEventRecords;
class ARGUS_DBC{
private:
basicLogCollection * m_pLog;
config_setting_t * m_pSettings;
MySQL_Connector * m_pDatabase;
bool m_bIsConnected;
char m_pDbHost[CLOG];
char m_pDbUsername[CLOG];
char m_pDbPassword[CLOG];
char m_pDbDatabase[CLOG];
public:
explicit ARGUS_DBC( config_setting_t * Settings );
~ARGUS_DBC();
/* Functionality */
bool connect( void );
bool getConnectionStatus(void){return m_bIsConnected;};
bool setOnlineStatus( bool Status );
int getIPCamCount( uint32_t SiteID );
bool getIPCamRecords( uint32_t SiteID, vectorCamRecords &VR );
bool updateIPCam( uint32_t SiteID, CSTR uuid, CSTR Addr );
bool updateIPCam( uint32_t SiteID, resultWoWo *tPtr );
bool updateNetworkNode( bool OnlineStatus );
bool getLastEvents( vectorEventRecords &VR, uint32_t tss, uint32_t tsms );
bool transferEvtToArchive( uint32_t SECONDS = ONE_DAY_HISTORY );
DBC_INT_LIST * listNodes( uint32_t SiteID );
DBC_NODE_DATA * getNodeData( uint32_t ID );
void registerServer(uint32_t SiteID, CSTR identity );
void unregisterServer(uint32_t ServerID, uint32_t NodeID );
uint32_t getServerID( CSTR identity );
uint32_t getServerNode( uint32_t SID );
void addNodeSocket( uint32_t NodeID, uint8_t SocketType, CSTR path, CSTR name );
void setNodeOnline( uint32_t NodeID );
void setNodeOffline( uint32_t NodeID );
};
#endif