예제 #1
0
        public Form1()
        {
            InitializeComponent();

            m_AppData = new APPLICATION_DATA();

            m_Log = new ErrorLog(m_AppData);

            m_AppData.Logger = m_Log;

            this.FormClosing += new FormClosingEventHandler(Form1_FormClosing);

            m_S2255Controller = new S2255Controller.S2255Controller(S2255Controller.S2255Controller.PAL_NTSC_MODE.NTSC, m_AppData);
        }
예제 #2
0
파일: Form1.cs 프로젝트: anndream/anpr-1
        public Form1()
        {
            InitializeComponent();

            m_AppData = new APPLICATION_DATA();

            m_Log = new ErrorLog(m_AppData);

            m_AppData.Logger = m_Log;

            this.FormClosing += new FormClosingEventHandler(Form1_FormClosing);

            m_S2255Controller = new S2255Controller.S2255Controller(S2255Controller.S2255Controller.PAL_NTSC_MODE.NTSC, m_AppData);
        }
예제 #3
0
        public S2255Device(int index,int handle, APPLICATION_DATA appData, int videoStandard, S2255Controller.S2255DevicePortChannelMappings portMappings)
        {
            m_DeviceHandle = handle;
            m_DeviceIndex = index;
            m_AppData = appData;
            m_VideoStandard = videoStandard;
            m_PortMappings = portMappings;

            singleton = new object();

             //   m_AppData.AddOnClosing(Stop, APPLICATION_DATA.CLOSE_ORDER.FIRST);

            OnNewFrame = new OnNewFrameEvent[4];

            unsafe
            {
                _Obj_of_Type_HANDLE_NEW_BUFFER_FROM_S2255 = OnNewFrameFromDevice;

                unsafeMethodCallbackPtr = Marshal.GetFunctionPointerForDelegate(_Obj_of_Type_HANDLE_NEW_BUFFER_FROM_S2255);
            }

            m_Log = (ErrorLog)m_AppData.Logger;

            TimeAtLastFrame = DateTime.Now;

            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.PHYSICAL_CHANNELS.PhysicalChannels_c0].Peak.RegisterForUse(true);
            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.PHYSICAL_CHANNELS.PhysicalChannels_c1].Peak.RegisterForUse(true);
            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.PHYSICAL_CHANNELS.PhysicalChannels_c2].Peak.RegisterForUse(true);
            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.PHYSICAL_CHANNELS.PhysicalChannels_c3].Peak.RegisterForUse(true);

            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.PHYSICAL_CHANNELS.PhysicalChannels_c0].PerSecond.RegisterForUse(true);
            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.PHYSICAL_CHANNELS.PhysicalChannels_c1].PerSecond.RegisterForUse(true);
            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.PHYSICAL_CHANNELS.PhysicalChannels_c2].PerSecond.RegisterForUse(true);
            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.PHYSICAL_CHANNELS.PhysicalChannels_c3].PerSecond.RegisterForUse(true);

            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.PHYSICAL_CHANNELS.PhysicalChannels_c0].RunningAverage.RegisterForUse(true);
            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.PHYSICAL_CHANNELS.PhysicalChannels_c1].RunningAverage.RegisterForUse(true);
            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.PHYSICAL_CHANNELS.PhysicalChannels_c2].RunningAverage.RegisterForUse(true);
            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.PHYSICAL_CHANNELS.PhysicalChannels_c3].RunningAverage.RegisterForUse(true);
        }
예제 #4
0
        // inputs
        //
        //   jpegs from hardware devices
        //   bitmaps from hardware devices
        //   GPS from stored data or hardware devices
        //   Camera name source info from stored configuration
        //   video files on disk
        //   still images on disk


        // outputs
        //
        //    bitmaps to LPR, with source, time and GPS
        //    jpegs to DVR, with source, time and GPS
        //
        //
        //
        //

        public FrameGenerator(APPLICATION_DATA appData, bool AsService)
        {
            try
            {
                m_AppData = appData;
                m_AppData.AddOnClosing(OnClose, APPLICATION_DATA.CLOSE_ORDER.MIDDLE);
                m_Log = (ErrorLog)m_AppData.Logger;

                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_FrameCnt].Peak.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_FrameCnt].PerSecond.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_FrameCnt].RunningAverage.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_FrameCnt].Snapshot.RegisterForUse(true);

                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_MotionDetectionPendingQ].Peak.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_MotionDetectionPendingQ].PerSecond.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_MotionDetectionPendingQ].RunningAverage.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_MotionDetectionPendingQ].Snapshot.RegisterForUse(true);

                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_NonMotionFramePushQ].Peak.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_NonMotionFramePushQ].PerSecond.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_NonMotionFramePushQ].RunningAverage.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_NonMotionFramePushQ].Snapshot.RegisterForUse(true);

                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_GPSLocation].StatString.RegisterForUse(true);

                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.MOTION_DETECTION.MotionDetector_DroppedFrames].Accumulator.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.MOTION_DETECTION.MotionDetector_FrameCnt].Accumulator.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.MOTION_DETECTION.MotionDetector_FramesDetected].Accumulator.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.MOTION_DETECTION.MotionDetector_ProcessQCnt].Snapshot.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.MOTION_DETECTION.MotionDetector_ProcessQCnt].Peak.RegisterForUse(true);

                m_EabledChannelArray = new bool[m_AppData.MAX_PHYSICAL_CHANNELS];// used tell the 2255 device which of its channels are enabled

                m_LastJPEGReceived = new LAST_JPEG_RECEIVED[m_AppData.MAX_PHYSICAL_CHANNELS];
                m_Channels         = new CHANNEL[m_AppData.MAX_PHYSICAL_CHANNELS];
                for (int c = 0; c < m_AppData.MAX_PHYSICAL_CHANNELS; c++)
                {
                    m_LastJPEGReceived[c] = new LAST_JPEG_RECEIVED();
                    m_Channels[c]         = new CHANNEL(c);
                }

                LoadChannelNames();



                m_ConsumerIDs = new CONSUMER_ID();

                m_CurrentGPSPosition = m_NoPositionAvailable;


                m_MotionDetectionQ = new ThreadSafeQueue <FRAME>(m_MotionDetectionQueLevel, "QueueOverruns_FG_MotionDetectionQ", m_AppData);
                m_AppData.MotionDetectionGettingBehind = false;


                //////////////////////////////////////
                //
                // start the thread that pushes new frames to the registered consumers

                m_AllFramesConsumerPushQ = new ThreadSafeQueue <CONSUMER_PUSH>(240, "QueueOverruns_FG_AllFramesConsumerPushQ", m_AppData);

                m_MotionDetectedConsumerPushQ = new ThreadSafeQueue <CONSUMER_PUSH>(240, "QueueOverruns_FG_MotionDetectedConsumerPushQ", m_AppData); //120

                PushThread          = new Thread(PushLoop);
                PushThread.Priority = ThreadPriority.AboveNormal;
                PushThread.Start();

                m_MotionDetectionThread = new Thread(MotionDetectionLoop);
                m_MotionDetectionThread.Start();



                //////////////////////////////////////
                //
                // start the S2255 controller

                // the 2255 controller has a polling loop that looks for 2255 devices to be added/deleted by the user plugging/unplugging the cables
                //  as new devices are detected, the stored config data is read and the channels are assigned and start running as appropriate
                //   the image data flows into this class via callbacks. this class then pushes the data up a layer after adding GPS and time stamps.

                if (AsService)
                {
                    try
                    {
                        S2255Controller.S2255Controller.PAL_NTSC_MODE videoStandard = S2255Controller.S2255Controller.PAL_NTSC_MODE.NTSC;

                        string NTSC_PAL = UserSettings.Get(UserSettingTags.VideoSetup_PAL_NTSC);
                        if (NTSC_PAL != null)
                        {
                            if (NTSC_PAL.Equals(UserSettingTags.VideoSetup_PAL))
                            {
                                videoStandard = S2255Controller.S2255Controller.PAL_NTSC_MODE.PAL;
                            }
                        }

                        unsafe
                        {
                            m_S2255Controller             = new S2255Controller.S2255Controller(videoStandard, m_AppData, m_EabledChannelArray);
                            m_S2255Controller.OnNewFrame += new S2255Controller.S2255Controller.OnNewFrameFromDeviceEvent(OnReceiveNewImageFromS2255Device);
                            m_S2255Controller.StartThreads();
                        }
                    }
                    catch (Exception ex)
                    {
                        m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL);
                    }


                    //////////////////////////////////////
                    //
                    // start the GPS Controller


                    string GPSPort = FindDevicePort.GetGPSCommPort();
                    m_GPSController = new GPSController(PutNewGPSData, m_AppData);

                    if (m_S2255Controller.GetReadyStatus)
                    {
                        m_FrameGenReadyStatus = true;
                    }
                    else
                    {
                        m_FrameGenReadyStatus = false;
                    }
                }

                if (!AsService)
                {
                    MovieFileController             = new MovieFiles(m_AppData);
                    MovieFileController.OnNewImage += new MovieFiles.OnNewImageEvent(MovieFiles_OnNewImage);
                    MovieFileController.Start();
                }
            }
            catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); }
        }
예제 #5
0
        void SendImageToConsumer(object image, S2255Controller.COMPRESSION_MODE frmType, int cindex)
        {
            FRAME frame = new FRAME(m_AppData);

            if (frmType == S2255Controller.COMPRESSION_MODE.BITMAP)
            {
                frame.Bmp = (Bitmap)image;
                frame.Jpeg = null;
            }
            else
            {
                frame.Bmp = null;
                frame.Jpeg = (byte[])image;
            }

            frame.SourceName = chanSourceNames[cindex];
            frame.SourceChannel = cindex;

            if (OnNewFrame[frame.SourceChannel] != null) OnNewFrame[frame.SourceChannel](frame);
        }
예제 #6
0
        // inputs
        //
        //   jpegs from hardware devices
        //   bitmaps from hardware devices
        //   GPS from stored data or hardware devices
        //   Camera name source info from stored configuration
        //   video files on disk
        //   still images on disk
        // outputs
        //
        //    bitmaps to LPR, with source, time and GPS
        //    jpegs to DVR, with source, time and GPS
        //    
        //
        //
        //
        public FrameGenerator( APPLICATION_DATA appData,bool AsService)
        {
            try
            {

                m_AppData = appData;
                m_AppData.AddOnClosing(OnClose, APPLICATION_DATA.CLOSE_ORDER.MIDDLE);
                m_Log = (ErrorLog)m_AppData.Logger;

                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_FrameCnt].Peak.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_FrameCnt].PerSecond.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_FrameCnt].RunningAverage.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_FrameCnt].Snapshot.RegisterForUse(true);

                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_MotionDetectionPendingQ].Peak.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_MotionDetectionPendingQ].PerSecond.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_MotionDetectionPendingQ].RunningAverage.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_MotionDetectionPendingQ].Snapshot.RegisterForUse(true);

                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_NonMotionFramePushQ].Peak.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_NonMotionFramePushQ].PerSecond.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_NonMotionFramePushQ].RunningAverage.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_NonMotionFramePushQ].Snapshot.RegisterForUse(true);

                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.FRAME_GENERATOR.FrameGen_GPSLocation].StatString.RegisterForUse(true);

                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.MOTION_DETECTION.MotionDetector_DroppedFrames].Accumulator.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.MOTION_DETECTION.MotionDetector_FrameCnt].Accumulator.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.MOTION_DETECTION.MotionDetector_FramesDetected].Accumulator.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.MOTION_DETECTION.MotionDetector_ProcessQCnt].Snapshot.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.MOTION_DETECTION.MotionDetector_ProcessQCnt].Peak.RegisterForUse(true);

                m_EabledChannelArray = new bool[m_AppData.MAX_PHYSICAL_CHANNELS];// used tell the 2255 device which of its channels are enabled

                m_LastJPEGReceived = new LAST_JPEG_RECEIVED[m_AppData.MAX_PHYSICAL_CHANNELS];
                m_Channels = new CHANNEL[m_AppData.MAX_PHYSICAL_CHANNELS];
                for (int c = 0; c < m_AppData.MAX_PHYSICAL_CHANNELS; c++)
                {
                    m_LastJPEGReceived[c] = new LAST_JPEG_RECEIVED();
                    m_Channels[c] = new CHANNEL(c);
                }

                LoadChannelNames();

                m_ConsumerIDs = new CONSUMER_ID();

                m_CurrentGPSPosition = m_NoPositionAvailable;

                m_MotionDetectionQ = new ThreadSafeQueue<FRAME>(m_MotionDetectionQueLevel, "QueueOverruns_FG_MotionDetectionQ", m_AppData);
                m_AppData.MotionDetectionGettingBehind = false;

                //////////////////////////////////////
                //
                // start the thread that pushes new frames to the registered consumers

                m_AllFramesConsumerPushQ = new ThreadSafeQueue<CONSUMER_PUSH>(240, "QueueOverruns_FG_AllFramesConsumerPushQ", m_AppData);

                m_MotionDetectedConsumerPushQ = new ThreadSafeQueue<CONSUMER_PUSH>(240, "QueueOverruns_FG_MotionDetectedConsumerPushQ", m_AppData); //120

                PushThread = new Thread(PushLoop);
                PushThread.Priority = ThreadPriority.AboveNormal;
                PushThread.Start();

                m_MotionDetectionThread = new Thread(MotionDetectionLoop);
                m_MotionDetectionThread.Start();

                //////////////////////////////////////
                //
                // start the S2255 controller

                // the 2255 controller has a polling loop that looks for 2255 devices to be added/deleted by the user plugging/unplugging the cables
                //  as new devices are detected, the stored config data is read and the channels are assigned and start running as appropriate
                //   the image data flows into this class via callbacks. this class then pushes the data up a layer after adding GPS and time stamps.

                if (AsService)
                {
                    try
                    {

                        S2255Controller.S2255Controller.PAL_NTSC_MODE videoStandard = S2255Controller.S2255Controller.PAL_NTSC_MODE.NTSC;

                        string NTSC_PAL = UserSettings.Get(UserSettingTags.VideoSetup_PAL_NTSC);
                        if (NTSC_PAL != null)
                        {
                            if (NTSC_PAL.Equals(UserSettingTags.VideoSetup_PAL))
                                videoStandard = S2255Controller.S2255Controller.PAL_NTSC_MODE.PAL;
                        }

                        unsafe
                        {
                            m_S2255Controller = new S2255Controller.S2255Controller(videoStandard, m_AppData, m_EabledChannelArray);
                            m_S2255Controller.OnNewFrame += new S2255Controller.S2255Controller.OnNewFrameFromDeviceEvent(OnReceiveNewImageFromS2255Device);
                            m_S2255Controller.StartThreads();
                        }
                    }
                    catch (Exception ex)
                    {
                        m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL);
                    }

                    //////////////////////////////////////
                    //
                    // start the GPS Controller

                    string GPSPort = FindDevicePort.GetGPSCommPort();
                    m_GPSController = new GPSController(PutNewGPSData, m_AppData);

                    if (m_S2255Controller.GetReadyStatus)
                        m_FrameGenReadyStatus = true;
                    else
                        m_FrameGenReadyStatus = false;
                }

                if (!AsService)
                {
                    MovieFileController = new MovieFiles(m_AppData);
                    MovieFileController.OnNewImage += new MovieFiles.OnNewImageEvent(MovieFiles_OnNewImage);
                    MovieFileController.Start();
                }

            }
            catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL);}
        }