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.
 
 
 
 
 
 

144 lines
10 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"
#include "rgooseTypes.h"
class argusDBC{
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];
uint32_t m_nSiteID;
public:
static argusDBC * getInstance( config_setting_t * Settings = NULL );
virtual ~argusDBC();
/* Functionality */
bool connect( void );
bool addDraw( uint32_t DBID, uint16_t SIZE, CSTR ID );
uint32_t addEvent( uint32_t SRC, CSTR UUID, uint32_t tss, uint32_t tsms, uint8_t evt_type, uint16_t dig_r=0, float AZ=.0f, float EL=.0f, float RANGE=.0f, float AREA=.0f, float lat=.0f, float lon=.0f, float alt=.0f, uint32_t RefID=0, CSTR RefUUID=NULL );
//bool addIPCam( uint32_t SiteID, resultWoWo *tPtr );
bool addIPCam( uint32_t SiteID, OBSERVER_RESULT *tPtr );
uint32_t addLocalMediaSource( uint32_t SiteID, CSTR path, uint32_t width, uint32_t height );
uint32_t addLocalDCB( uint32_t SiteID, CSTR PATH, CSTR SERIAL, uint8_t CNT, uint32_t status );
uint32_t addLocalUART( uint32_t NodeID, uint8_t utype, uint32_t speed, uint8_t bit, char parity, float stop_bit, CSTR PATH, uint8_t mode=0, uint16_t port=0 );
uint32_t addLocalNIF( CSTR device, CSTR mac, ARGUS_NIF_TYPE dtype, ARGUS_NIF_MODE dmode, uint32_t aux_id = 0 );
uint32_t addLocalNetwork( uint32_t NIF_ID, ARGUS_NETWORK_TYPE net_type, CSTR address, CSTR mask, CSTR gateway, CSTR broadcast );
uint32_t addLocalNetworkInfrastructure( uint32_t NIF_ID, uint32_t OUTBOUND_NIF, bool ena_dhcp=false, CSTR BRANG=NULL, CSTR ERANG=NULL, CSTR MASK=NULL, CSTR LEASE_TIME=NULL );
uint32_t addLocalWiFi( uint32_t NIF_ID, ARGUS_WIFI_MODE mode, CSTR SSID, CSTR password, ARGUS_WIFI_ENCRIPTION encryption, uint32_t router_id=0 );
bool addNotification( uint32_t MSG_ID, uint8_t DIS_LVL = 0, uint32_t OBJ_ID=0 );
uint32_t addPicture( uint32_t streamID, CSTR md5, CSTR ext );
bool addPictureEvent( uint32_t evtID, uint32_t pictureoID );
uint32_t addResource( uint32_t NodeID, uint8_t type, CSTR devName, uint32_t auxID = 0 );
uint32_t addUploadFile( uint32_t NodeID, CSTR uid, CSTR fileName );
bool addVideoEvent( uint32_t evtID, uint32_t videoID );
uint32_t addVideoRecord( uint32_t streamID, CSTR md5, uint32_t partID );
bool cleanResources( uint32_t ServerNodeID, bool all = false );
void lazyEventArchiver( uint32_t DalayTime = 10 );
DBC_INT_LIST * listCamMediaStreams( uint32_t CAMID );
DBC_INT_LIST * listDetectionProfileIDs( uint32_t nodeID );
DBC_INT_LIST * listDetectionProfiles( uint32_t nodeID );
DBC_INT_LIST * listFilters( uint32_t m_nServerID );
DBC_INT_LIST * listMediaServerStreams( uint32_t SiteId, uint32_t MediaServerID, uint8_t listingType = LIST_ALL_RECORDS );
DBC_INT_LIST * listMediaStreams( uint32_t SiteId, uint8_t listingType = LIST_ALL_RECORDS );
DBC_INT_LIST * listModules( uint32_t SiteID );
DBC_INT_LIST * listNetworks( uint32_t nif_id );
DBC_INT_LIST * listNewModules( uint32_t SiteID, DBC_INT_LIST * old_ids );
DBC_INT_LIST * listNewNodes( uint32_t SiteID, DBC_INT_LIST * old_ids );
DBC_INT_LIST * listNodes( uint32_t SiteID );
//DBC_INT_LIST * listSockets( uint32_t NodeID );
DBC_INT_LIST * listResources( uint32_t NodeID = 0 );
bool getAllCamRecords( uint32_t SiteID, vectorCamRecords &VR );
DBC_APF_DATA * getAPFData( uint32_t APFID );
DBC_CAM_DATA * getCamData( uint32_t CamID );
uint32_t getCamId( CSTR UUID );
bool getConnectionStatus(void){return m_bIsConnected;};
DBC_EVT_DATA * getEventByUUID( CSTR UUID );
DBC_MODULE_EMBED_VIDEO_DATA * getEmbedVideoData( uint32_t ID );
DBC_FH_DATA * getFlyHunterData( uint32_t ID );
int getIPCamCount( uint32_t SiteID );
KAFKA_TEMPLATE * getKafkaTemplateForEvent( uint32_t ModuleID, uint32_t ClassID, uint32_t EventID );
bool getLastEvents( vectorEventRecords &VR, uint32_t tss, uint32_t tsms );
DBC_LRF_DATA * getLRFData( uint32_t ID );
uint8_t getLRFDataStatus( uint32_t ID );
DBC_MEDIA_STREAM_DATA * getMediaStreamData( uint32_t ID );
DBC_MEDIA_SERVER_DATA * getMediaServerData( uint32_t ID );
DBC_MEDIA_SERVER_STREAM_DATA * getMediaServerStreamData( uint32_t ID );
DBC_MEDIA_SERVER_STREAM_DATA * getMediaServerStreamDataBySource( uint32_t ID );
DBC_MODULE_DATA * getModuleData( uint32_t ID );
DBC_NETWORK_DATA * getNetworkData( uint32_t net_id );
uint32_t getNetworkInfrastructureID( uint32_t nif_id );
DBC_NET_IF_DATA * getNIF_Data( uint32_t ID );
uint32_t getNIF_ID( CSTR key );
uint32_t getNIF_IDbyDevice( CSTR device );
DBC_NODE_DATA * getNodeData( uint32_t ID );
DBC_PUSHED_CMD * getNodePushedCMD( uint32_t NodeID );
//uint32_t getNodeSocketID( uint32_t NodeID, uint32_t auxID, uint8_t SocketType, CSTR path );
DBC_RESOURCE_DATA * getResourceData( uint32_t ResourceID );
uint32_t getResourceID( uint32_t NodeID, uint8_t type, uint32_t auxID );
uint32_t getServerID( CSTR identity );
uint32_t getServerNode( uint32_t SID );
KAFKA_SETTINGS * getSettingsKAFKA( uint32_t NodeID );
DBC_SITE_DATA * getSiteData( uint32_t ID );
//DBC_SOCKET_DATA * getSocketData( uint32_t ID );
DBC_TARGET_FLITER_DATA * getTargetFilterData( uint32_t ID );
DBC_UART_DATA * getUartData( uint32_t UartID );
uint32_t getUartID( uint32_t NodeID, uint8_t Type, CSTR path );
uint32_t getWiFi_ID( uint32_t nif_id );
void registerServer(uint32_t SiteID, CSTR identity, int PID );
void unregisterServer(uint32_t ServerID, uint32_t NodeID );
bool transferEvtToArchive( uint32_t SECONDS = ONE_DAY_HISTORY );
bool setNodeOnline( uint32_t NodeID, uint8_t status=ARGUS_NODE_STATUS_WORK );
bool setNodeOffline( uint32_t NodeID );
bool setOnlineStatus( bool Status );
bool setLRFDetectionProfile( uint32_t lrfID, uint8_t profileID );
bool setLRFDataStatus( uint32_t lrfID, uint8_t ST );
bool setLRFAltSerial( uint32_t lrfID, CSTR Serial );
bool setLRFAltVerison( uint32_t lrfID, CSTR version );
bool setStreamValid( uint32_t streamID );
bool updateAFPBox( uint32_t filterID, CSTR Tag, float x, float y, float z );
bool updateIPCam( uint32_t SiteID, CSTR uuid, CSTR Addr );
bool updateIPCam( uint32_t SiteID, uint32_t CamID, CSTR Addr );
bool updateLRFSerial( uint32_t lrfID, CSTR Serial );
bool updateLRFVerison( uint32_t lrfID, CSTR version );
bool updateLRFDetectionProfile( uint32_t lrfID, uint8_t profileID, bool master, uint16_t nOrder, uint16_t nOffset, uint16_t nDelta, uint16_t nWidth, uint16_t nFlip, uint16_t nSun, uint8_t bSST, uint32_t GP=0, uint32_t spikes=0 );
bool updateMediaServerStream( uint32_t id, CSTR mrl=NULL, CSTR key = NULL );
bool updateNetworkNode( bool OnlineStatus );
bool updateResourceAUX( uint32_t ResID, uint32_t AUX );
bool updateServerUtilisation( uint32_t ServerID, uint32_t nCores, float cpu1, float cpu5, float cpu15, float mem, float disk, uint64_t dtsize, uint64_t dcsize, uint64_t mtsize, uint64_t mcsize );
private:
static argusDBC * _instance;
explicit argusDBC( config_setting_t * Settings = NULL );
};
#endif