예제 #1
0
파일: DVR.cs 프로젝트: anndream/anpr-1
        void OnExternalDriveChange(string drive, string storagePath, DriveManager.DRIVE_CHANGE_EVENT dEvent)
        {
            PauseFlag.Pause = true;

            try
            {
                switch (dEvent)
                {
                    case DriveManager.DRIVE_CHANGE_EVENT.PAUSE:
                        PauseFlag.Pause = true;
                        Paths.Enabled = false;
                        break;

                    case DriveManager.DRIVE_CHANGE_EVENT.UNPAUSE:
                        PauseFlag.Pause = false;
                        Paths.Enabled = true;
                        break;

                    case DriveManager.DRIVE_CHANGE_EVENT.NEWDRIVE:

                        Paths.Drive = storagePath;

                        m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_Drive].StatString.SetValue = "Have drive " + Paths.Drive;

                        // start the accumulated file size at the intial value of the disk
                        bool driveReady=false;
                        string name=null;
                        double freeSpace=0.0;
                        double size=0.0;

                        m_DriveManager.GetDriveStatus (ref driveReady, ref name, ref freeSpace, ref size);
                        double initialUsedSpace = size - freeSpace;
                        Paths.AccumulatedSize = initialUsedSpace;

                        PauseFlag.DriveExists = true;
                        PauseFlag.OverridePause = true;
                        CreatePreMotionBufferDirectory();
                        PauseFlag.OverridePause = false;
                        PauseFlag.Pause = false;

                        m_Log.Log("Found new drive, unpausing DVR", ErrorLog.LOG_TYPE.INFORMATIONAL);
                        break;

                    case DriveManager.DRIVE_CHANGE_EVENT.LOST_PRIMARY_DRIVE:
                        PauseFlag.DriveExists = false;
                        PauseFlag.Pause = true;
                        Paths.Drive = null;

                        m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_Drive].StatString.SetValue = "No drive ";

                        m_Log.Log("DVR Lost primary drive", ErrorLog.LOG_TYPE.FATAL);
                        break;

                    case DriveManager.DRIVE_CHANGE_EVENT.TOO_MANY_DRIVES:
                        m_Log.Log("Too many external drives on start", ErrorLog.LOG_TYPE.FATAL);
                     //   m_MessageBoxMessage = "Too many external drives on start. Please connect only one external drive and re-start the LPR Service.";
                     //   RunMessageBoxDialog();
                        m_DVRReadyStatus = false;
                        break;

                }
            }
            catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); }
        }
예제 #2
0
파일: DVR.cs 프로젝트: anndream/anpr-1
        // constructor
        public DVR(APPLICATION_DATA appData)
        {
            try
            {
                m_AppData = appData;
                m_AppData.AddOnClosing(Stop, APPLICATION_DATA.CLOSE_ORDER.MIDDLE);
                m_Log = (ErrorLog)m_AppData.Logger;

                PauseFlag = new PAUSE_FLAG();

                PauseFlag.Pause = true;

                FileAccessControl = new FILE_SYSTEM_ACCESS(PauseFlag, m_AppData);

                try
                {
                    Paths = new PATHS(m_AppData.ThisComputerName, true, m_AppData);

                    m_AppData.PathManager = (object)Paths;
                }
                catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); }

                m_EventLogFile = new EventLogFiles.EventLogFiles(m_AppData);

                //   PRE MOTION BUFFER LENGHT

                m_NumberOfFramesToPrePostBuffer =    30;   // this many frames before and after moton event, if too small, files may be erased before motion is detected because of processing lag

                ////////

                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_DriveName].StatString.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_DriveReady].boolean.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_FreeSpace].SnapshotDouble.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_UsedSpace].SnapshotDouble.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_DriveHotSwap].StatString.RegisterForUse(true);

                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_Drive].StatString.SetValue = "No drive ";

                m_FrameGenerator = (FrameGenerator)m_AppData.FrameGenerator;

                m_DriveManager = new DriveManager(m_AppData, OnExternalDriveChange, Paths.StorageDir);

                // alway use external storage

                if ( m_AppData.RunninAsService)
                {

                    int count = 0;
                    Paths.Drive = m_DriveManager.GetDrive(ref count);
                    PauseFlag.DriveExists = true;
                    if (count > 1)
                    {
                        PauseFlag.Pause = true;
                        m_Log.Log("Too many external drives on start", ErrorLog.LOG_TYPE.FATAL);
                        //m_MessageBoxMessage = "Too many external drives on start. Please connect only one external drive and re-start the LPR Service.";
                        //RunMessageBoxDialog();

                    }
                    else if (Paths.Drive == null)
                    {
                        PauseFlag.Pause = true;

                        m_Log.Log("External Drive not found", ErrorLog.LOG_TYPE.FATAL);
                      //  m_MessageBoxMessage = "External drive not found. Please connect one external drive";
                        PauseFlag.DriveExists = false;
                       // RunMessageBoxDialog();
                    }

                }

                m_ConsumerID = m_FrameGenerator.GetNewConsumerID();

                m_NewFrameQ = new ThreadSafeQueue<FRAME>(240, "QueueOverruns_DVR_NewFrameQ", m_AppData);
                m_MotionDetectedQ = new ThreadSafeQueue<FRAME>(240, "QueueOverruns_DVR_MotionDetectedQ", m_AppData);
                m_DirectyToStorageQ = new ThreadSafeQueue<FRAME>(240, "QueueOverruns_DVR_DirectyToStorageQ", m_AppData);
                m_NewLPRRecordQ = new ThreadSafeQueue<FRAME>(m_LPRRecordQueLen, "QueueOverruns_DVR_NewLPRRecordQ", m_AppData);
                m_TempFileList = new ThreadSafeList<TEMPFILES>(120);

                m_NumSourceChannels = (m_AppData.RunninAsService) ? m_AppData.MAX_PHYSICAL_CHANNELS : m_AppData.MAX_VIRTUAL_CHANNELS;

                m_PreMotionRecords = new PRE_MOTION_RECORDS[m_NumSourceChannels];

                m_DVRLoopThread = new Thread(DVRLoop);

                m_ReportDVRStats = new Thread(ReportDVRStatusLoop);

                m_TempFileCleanUpThread = new Thread(TempFilesCleanUpLoop);

                m_MaintainFileSystemSizeLimit = new Thread(MaintainFileSystemSizeLimitLoop);

            }
            catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); }
        }
예제 #3
0
파일: DVR.cs 프로젝트: mutita/anpr
        // constructor
        public DVR(APPLICATION_DATA appData)
        {
            try
            {
                m_AppData = appData;
                m_AppData.AddOnClosing(Stop, APPLICATION_DATA.CLOSE_ORDER.MIDDLE);
                m_Log = (ErrorLog)m_AppData.Logger;

                PauseFlag = new PAUSE_FLAG();

                PauseFlag.Pause = true;

                FileAccessControl = new FILE_SYSTEM_ACCESS(PauseFlag, m_AppData);

                try
                {
                    Paths = new PATHS(m_AppData.ThisComputerName, true, m_AppData);

                    m_AppData.PathManager = (object)Paths;
                }
                catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); }

                m_EventLogFile = new EventLogFiles.EventLogFiles(m_AppData);

                //   PRE MOTION BUFFER LENGHT

                m_NumberOfFramesToPrePostBuffer = 30;      // this many frames before and after moton event, if too small, files may be erased before motion is detected because of processing lag

                ////////



                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_DriveName].StatString.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_DriveReady].boolean.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_FreeSpace].SnapshotDouble.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_UsedSpace].SnapshotDouble.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_DriveHotSwap].StatString.RegisterForUse(true);

                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_Drive].StatString.SetValue = "No drive ";

                m_FrameGenerator = (FrameGenerator)m_AppData.FrameGenerator;


                m_DriveManager = new DriveManager(m_AppData, OnExternalDriveChange, Paths.StorageDir);

                // alway use external storage

                if (m_AppData.RunninAsService)
                {
                    int count = 0;
                    Paths.Drive           = m_DriveManager.GetDrive(ref count);
                    PauseFlag.DriveExists = true;
                    if (count > 1)
                    {
                        PauseFlag.Pause = true;
                        m_Log.Log("Too many external drives on start", ErrorLog.LOG_TYPE.FATAL);
                        //m_MessageBoxMessage = "Too many external drives on start. Please connect only one external drive and re-start the LPR Service.";
                        //RunMessageBoxDialog();
                    }
                    else if (Paths.Drive == null)
                    {
                        PauseFlag.Pause = true;

                        m_Log.Log("External Drive not found", ErrorLog.LOG_TYPE.FATAL);
                        //  m_MessageBoxMessage = "External drive not found. Please connect one external drive";
                        PauseFlag.DriveExists = false;
                        // RunMessageBoxDialog();
                    }
                }



                m_ConsumerID = m_FrameGenerator.GetNewConsumerID();

                m_NewFrameQ         = new ThreadSafeQueue <FRAME>(240, "QueueOverruns_DVR_NewFrameQ", m_AppData);
                m_MotionDetectedQ   = new ThreadSafeQueue <FRAME>(240, "QueueOverruns_DVR_MotionDetectedQ", m_AppData);
                m_DirectyToStorageQ = new ThreadSafeQueue <FRAME>(240, "QueueOverruns_DVR_DirectyToStorageQ", m_AppData);
                m_NewLPRRecordQ     = new ThreadSafeQueue <FRAME>(m_LPRRecordQueLen, "QueueOverruns_DVR_NewLPRRecordQ", m_AppData);
                m_TempFileList      = new ThreadSafeList <TEMPFILES>(120);


                m_NumSourceChannels = (m_AppData.RunninAsService) ? m_AppData.MAX_PHYSICAL_CHANNELS : m_AppData.MAX_VIRTUAL_CHANNELS;

                m_PreMotionRecords = new PRE_MOTION_RECORDS[m_NumSourceChannels];

                m_DVRLoopThread = new Thread(DVRLoop);

                m_ReportDVRStats = new Thread(ReportDVRStatusLoop);

                m_TempFileCleanUpThread = new Thread(TempFilesCleanUpLoop);

                m_MaintainFileSystemSizeLimit = new Thread(MaintainFileSystemSizeLimitLoop);
            }
            catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); }
        }