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.
171 lines
5.1 KiB
171 lines
5.1 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
|
|
// At each local hour change an open session is closed in the old hour's report. If a video segment
|
|
// with events is still being recorded, wait for it (so it is stored with its events) at most this long.
|
|
#define REPORT_SWITCH_MAX_VIDEO_WAIT 90 // sec
|
|
|
|
#define EMBED_AUTORESET 300 //sec
|
|
#define PEREODIC_SENSORS_RESET
|
|
|
|
#include "../../alg/generic/md5.h"
|
|
#include "../../alg/lgs/detector.h"
|
|
#include "../../alg/lgs/detectorStructures.h"
|
|
#include "../../alg/lgs/mask.h"
|
|
#include "../../components/base/basicEvent.h"
|
|
#include "../../components/base/basicEventHeap.h"
|
|
#include "../../components/base/basicSettingsProvider.h"
|
|
#include "../../components/base/basicThread.h"
|
|
#include "../../components/object/objectSystemAnchor.h"
|
|
#include "../common/kernelPrototype.h"
|
|
#include "mojoRemoteClient.h"
|
|
#include "../common/kernelHelperMediaMTX.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;
|
|
bool m_bApplicationFirstRun;
|
|
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;
|
|
#ifndef LRF_PROXY_ONLY
|
|
kernelHelperMediaMTX * m_pMediaHelper;
|
|
#endif
|
|
basicMutex m_mSysInfoProtector;
|
|
unsigned long long m_mDateOfToday;
|
|
bool m_bForceCloseSessionOnEndOfTheDay;
|
|
int m_nReportPeriod; // local day*100+hour of the open report
|
|
bool m_bReportSwitchPending; // local hour changed, report not switched yet
|
|
time_t m_tReportSwitchDetected; // when the hour change was detected
|
|
int m_nSessionPeriod; // local day*100+hour the current session was started in
|
|
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 PEREODIC_SENSORS_RESET
|
|
bool m_bEnablePereodicReset;
|
|
uint32_t m_nPereodicResetTime;
|
|
uint32_t m_nPereodicResetCounter;
|
|
#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);
|
|
void handleReportPeriodChange(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;
|
|
}
|
|
|
|
bool getTrainPresence();
|
|
|
|
inline uint8_t getMediaMode()
|
|
{
|
|
return m_bMediaMode;
|
|
}
|
|
#ifdef __MOJO_REMOTE_CLIENT_HEADER__
|
|
bool fillMojoInfo(ARGUS_DATA_MOJO_INFO * ptr);
|
|
#endif
|
|
virtual void requestExplicitChannel( uint32_t node_id, uint32_t channel_id, uint8_t seconds_to );
|
|
virtual void releaseExplicitChannel( uint32_t node_id, uint32_t channel_id );
|
|
friend class mojoRemoteClient;
|
|
};
|
|
|
|
#endif // __MOJJO_KERNEL_H_INCL__
|