Browse Source

Fixed Report Removal by Factory Reset, Camera Enumeration is Delayed more then prev. commit, Testing For New Database to perform HW Detection Automatically

pull/7/head
Evgeny Gagua 8 months ago
parent
commit
a2caf18f98
  1. 8
      Distro/database/db_tools.php
  2. 16
      Distro/tmp/after.php
  3. 10258
      lib/App/common/SQLite_dataBinder.cpp
  4. 1
      lib/App/common/SQLite_dataBinder.h
  5. 2
      lib/App/common/dataBinder.h
  6. 2
      lib/App/common/deviceNodeFactory.h
  7. 8
      lib/App/mojo/mojoBackend.cpp
  8. 13
      lib/App/mojo/mojoKernel.cpp
  9. 1
      lib/App/mojo/mojoKernel.h

8
Distro/database/db_tools.php

@ -48,7 +48,7 @@ CREATE TABLE "cameras" (
"uuid" TEXT UNIQUE,
"mac" TEXT,
"ip" TEXT,
"port" INTEGER,
"port" INTEGER DEFAULT 0,
"onvif_access" TEXT,
"onvif_ctrl" TEXT,
"ptz_token" TEXT,
@ -552,10 +552,10 @@ CREATE TABLE "system_props" (
"hemisphere" TEXT DEFAULT 'N',
"map_id" INTEGER DEFAULT 0,
"local_binding" INTEGER DEFAULT 1,
"oem_logo" TEXT,
"oem_logo" TEXT DEFAULT '',
"work_mode" INTEGER DEFAULT 1,
"os_info" TEXT,
"hw_info" TEXT,
"os_info" TEXT DEFAULT '',
"hw_info" TEXT DEFAULT '',
"report_cleanup" INTEGER DEFAULT 600,
"preserve_empty" INTEGER DEFAULT 10,
"app_layout" INTEGER DEFAULT 3,

16
Distro/tmp/after.php

@ -72,6 +72,18 @@
};
};
};
function add_whole_line( $A, $B , $C ){
$POPIN = array();
foreach( $C as $Key=>$Value ){
if( $Key != 'id' ){
$POPIN[]=$Value;
$POLE[]=$Key;
};
};
$QS = "INSERT INTO `{$B}`(`".implode("`,`",$POLE )."`) VALUES('". implode("','",$POPIN )."')";
out_log( $QS );
$A->Query( $QS );
;
if( file_exists('/srv/www/web/lib/controller/data/mysqlitedb.db') ){
if( !class_exists( 'SQLite_DB' ) ){
require_once( $WDIR . '/SQLite_Class.php');
@ -87,8 +99,8 @@
if( isset( $SENSOR_SETTINGS ) ) foreach( $SENSOR_SETTINGS as $SS ) restore_line( $INS_TIME_DB, 'lrf_sensors', $SS );
if( isset( $TRAIN_FILTER_SETTINGS ) ) foreach( $TRAIN_FILTER_SETTINGS as $FS ) restore_line( $INS_TIME_DB, 'target_filter_train', $FS );
if( isset( $BUBBLE_FILTER_SETTINGS ) ) foreach( $BUBBLE_FILTER_SETTINGS as $FS ) restore_line( $INS_TIME_DB, 'target_filter_bubble', $FS );
if( isset( $FROZEN_BUBBLES ) ) foreach( $FROZEN_BUBBLES as $FS ) restore_line( $INS_TIME_DB, 'target_bubbles', $FS );
if( isset( $DRAW_SETTINGS ) ) foreach( $DRAW_SETTINGS as $DS ) restore_line( $INS_TIME_DB, 'lrf_draw', $DS );
if( isset( $FROZEN_BUBBLES ) ) foreach( $FROZEN_BUBBLES as $FS ) add_whole_line( $INS_TIME_DB, 'target_bubbles', $FS );
if( isset( $DRAW_SETTINGS ) ) foreach( $DRAW_SETTINGS as $DS ) add_whole_line( $INS_TIME_DB, 'lrf_draw', $DS );
unset( $INS_TIME_DB );
copy( '/srv/www/web/lib/controller/data/mysqlitedb.db', '/srv/www/distro/lib/data/mysqlitedb.db' );
} else out_log("New Database Not exists!");

10258
lib/App/common/SQLite_dataBinder.cpp
File diff suppressed because it is too large
View File

1
lib/App/common/SQLite_dataBinder.h

@ -156,6 +156,7 @@ class sqliteDBC: public dataBinder {
virtual DBC_UART_DATA * getUartData( uint32_t UartID );
virtual uint32_t getUartID( uint32_t NodeID, uint8_t Type, CSTR path );
virtual uint32_t getWiFi_ID( uint32_t nif_id );
virtual bool isDatabaseNew();
virtual DBC_INT_LIST * listCameras();
virtual DBC_INT_LIST * listCamPresets( uint32_t SETID );
virtual DBC_INT_LIST * listFilters( uint32_t ServerID );

2
lib/App/common/dataBinder.h

@ -57,7 +57,7 @@ class dataBinder{
virtual bool deleteReportStat( uint32_t id ){};
//virtual void fillRDF( uint32_t ts, REPORT_DIRINFO &RDF ){};
virtual bool isDatabaseNew(){ return true; };
virtual void lazyEventArchiver( uint32_t DalayTime = 10 ){};
virtual DBC_INT_LIST * listCameras(){ return NULL;};
virtual DBC_INT_LIST * listCamMediaStreams( uint32_t CAMID ){ return NULL;};

2
lib/App/common/deviceNodeFactory.h

@ -25,7 +25,7 @@ class deviceNodeFactory: public basicThread{
deviceNode * getNode( uint32_t id );
uint32_t getNodesCount( ARGUS_NODE_TYPE type );
bool loadNodes();
bool nodesAreLoaded(){ return m_vDeviceNodes.size()>0; };
bool nodesAreLoaded(){ return m_vDeviceNodes.size()>2; };
bool unloadNodes( void );
bool reloadNodes( );
bool reloadNode( uint32_t NodeID );

8
lib/App/mojo/mojoBackend.cpp

@ -520,6 +520,8 @@ int main( int argc, char *argv[] ){
delete( DBC );
DBC = NULL;
if ( tNAME != NULL ) {
//ToDo: Must be Deleted Database Object before replacing Database!!
// Or to move this functionality to CRON Job??
LOG("FACTORY RESET ISSUED!");
if( !fileExist( "data/factory.db" ) ){
LOG_ERROR( "++++ No Factory Backup ++++" );
@ -533,9 +535,9 @@ int main( int argc, char *argv[] ){
fileCopy( "data/factory.db", tNAME );
ch_chown( tNAME, tUSER, tGROUP );
// delete reports cleanup
system("rm -R -f data/reports");
mkdir( "data/reports", 0755 );
ch_chown( "data/reports", tUSER, tGROUP );
//system("rm -R -f data/reports");
//mkdir( "data/reports", 0755 );
//ch_chown( "data/reports", tUSER, tGROUP );
};
free( tNAME );
free( tUSER );

13
lib/App/mojo/mojoKernel.cpp

@ -66,6 +66,7 @@ mojoKernel::mojoKernel( config_setting_t *ptr ):kernelPrototype( ptr ){
m_bWorkWithRemoteServer = false;
m_bKeepLocalReport = true;
m_bMediaMode = 0;
m_bApplicationFirstRun = false;
m_pRPC = NULL;
#ifdef EMBED_AUTORESET
m_bEnableAutoReset = false;
@ -289,6 +290,9 @@ bool mojoKernel::create(){
return false;
};
if ( m_bApplicationFirstRun = m_pDBC->isDatabaseNew() ) {
LOG("DATABASE IS NEW - Will Detect Hardware!");
} else LOG("DATABASE IS OLD - Will SKIP Detection of Hardware!");
// Must Be moved elsewhere To be connected after all Nodes are Loadded ?? at Node's Validation ??
/*
if ( m_bWorkWithRemoteServer ) {
@ -515,6 +519,15 @@ void mojoKernel::m_fThreadProc( void ){
//Each Second
if( m_tTimeTSeconds != tTimeTSeconds ){
tTimeTSeconds = m_tTimeTSeconds;
if ( m_bApplicationFirstRun ) {
if( m_pHardwareManager!= NULL ) {
LOG_ERROR( "Restart and Detect HardWare!" );
// Must be shutdowned all service that uses hardware prior to detection!
m_bThreadStatus = TH_ENDED;
setExitCause( EXIT_CODE_DETECT_HARDWARE ); // Go -> Detect Hardware in BACKEND
continue;
};
};
#ifdef LINUX_KERNEL_WATCHDOG
if( m_iWatchdogFd > -1 ) {
char tB[64];

1
lib/App/mojo/mojoKernel.h

@ -64,6 +64,7 @@ class mojoKernel: public kernelPrototype{
basicEventHeap * m_pEventHeap;
ShadowMask * m_pShadow;
time_t m_tTimeTSeconds;
bool m_bApplicationFirstRun;
DBC_SYS_LOAD_INFO m_sSysInfo;
DBC_SITE_DATA m_sSiteData;
char m_sIdentity[128];

Loading…
Cancel
Save