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.
 
 
 
 
 
 

130 lines
5.0 KiB

//----------------------------------------------------------------------------
// Dr.Frucht Systems Ltd.
// Copyright © 2000-2022. All Rights Reserved.
// Version 1.0 11/19/2022
// Last modification: 11/19/2022
// PROJECT:
// SUBSYSTEM:
// FILE: mojoKernel.h
// AUTHOR: gagua
// OVERVIEW
// ~~~~~~~~
// Header file of mojoKernel.cpp
//----------------------------------------------------------------------------
//
#ifndef __MOJO_KERNEL_H_INCL__
#define __MOJO_KERNEL_H_INCL__
#define LA_METRO 1
#define MER_INC 2
#define NOTARGET_SESSION_CLOSE 120 //sec
//#define EMBED_AUTORESET 300 //sec
#include "../../components/base/basicThread.h"
#include "../../components/base/basicSettingsProvider.h"
#include "../../components/base/basicEventHeap.h"
#include "../../components/base/basicEvent.h"
#include "../../components/object/objectSystemAnchor.h"
#include "../../alg/lgs/detectorStructures.h"
#include "../../alg/lgs/detector.h"
#include "../../alg/lgs/mask.h"
#include "../../alg/generic/md5.h"
#include "../common/kernelPrototype.h"
#include "mojoRemoteClient.h"
#define MAX_CYCLE_COUNTER_VALUE 0xFFFFFFFF;
#define SLEEP_KERNEL_INTERVAL 10 // 10 millisecond
#define TIME_SYNC_INTERVAL 900000 // 15 minute(s) in 1 millisecond units
#define STATUS_OK_INTERVAL 2000 // 2 Sec in 1 millisecond units
#define KNL_SETTINGS_DETECTOR_WIDTH "DETECTOR_WIDTH"
#define KNL_SETTINGS_FILTER_KERNELS "ENABLED_LRF"
#define KNL_SETTINGS_DETECTOR_SST "DETECTOR_SST"
//#define KNL_SETTINGS_V_MOTOR_SETPOINT "VERTICAL_ENC_FREQ"
#define MOJO_KERNEL_TAG_SITE_ID "SITE_ID"
#define MOJO_KERNEL_TAG_SERVER_IDENTITY "IDENTITY"
#define CRON_JOB_CREATE_BACKUP 20
/**
* LRF_Kernel class - manages communication between client
* handlers and PRU cores bseide of Event management.
*
*
* @author gagua
*/
class mojoKernel: public kernelPrototype{
private:
basicEventHeap * m_pEventHeap;
ShadowMask * m_pShadow;
time_t m_tTimeTSeconds;
DBC_SYS_LOAD_INFO m_sSysInfo;
DBC_SITE_DATA m_sSiteData;
char m_sIdentity[128];
uint32_t m_nInstanceID;
uint32_t m_nServerID;
uint32_t m_nServerNodeID;
systemAnchor * m_pSystemAnchor;
mojoRemoteClient * m_pRPC;
basicMutex m_mSysInfoProtector;
bool m_bDebugMode;
bool m_bKeepLocalReport;
bool m_bWorkWithRemoteServer;
bool m_bSessionStarted;
bool m_bSessionMustPreserve;
bool m_bFirstSession;
uint8_t m_bMediaMode;
uint32_t m_nNoAlarmCounter;
#ifdef EMBED_AUTORESET
bool m_bEnableAutoReset;
uint32_t m_nAutoResetTime;
uint32_t m_nSessionCounter;
#endif
#ifdef LA_METRO
#endif
void loadFilters();
void unloadFilters();
void validateFilters();
void validateSession();
basicMutex m_mSessionProtector;
void stopSession( bool forced = true );
void preserveSession(){ m_bSessionMustPreserve = true; };
static mojoKernel * _instance;
void handleVideo( VIDEO_SEGMENT_INFO *ptr );
bool validateReports( void );
bool createCronJob( uint8_t job, CSTR param_str = NULL, int param_int = 0 );
void cleanUpReportDir( uint32_t days );
void backupReports( uint32_t days );
void getSystemUtilization( DBC_SYS_LOAD_INFO *ptr );
protected:
virtual void m_fThreadProc( void );
// Constructor
explicit mojoKernel( config_setting_t *ptr );
public:
static mojoKernel * getInstance( config_setting_t *ptr = NULL );
// Destructor
virtual ~mojoKernel();
virtual bool create();
virtual bool dispatchEvent( EVENT_CONTAINER *Evt );
virtual void startSession();
inline bool getDebugMode(){ return m_bDebugMode; };
inline uint8_t getMediaMode(){ return m_bMediaMode; };
#ifdef __MOJO_REMOTE_CLIENT_HEADER__
bool fillMojoInfo( ARGUS_DATA_MOJO_INFO* ptr );
#endif
friend class mojoRemoteClient;
};
#endif // __MOJJO_KERNEL_H_INCL__