Beispiel #1
0
        public void vsListView_Update(object sender, VsMotionEventArgs e)
        {
            VsMotion vsMotion = (VsMotion)e.Motion.Clone();

            String [] strItem = { vsMotion.DateStart.ToString(), vsMotion.CameraName, vsMotion.EventName };

            ListViewItem item = new ListViewItem(strItem);

            this.listView1.Items.Add(item);
            item.Selected = true;
            item.EnsureVisible();
        }
Beispiel #2
0
        public void motionSelected()
        {
            try
            {
                int      index = selectedIndex;
                VsMotion m     = motions[index];
                url = service.getMjpegProxyUrlOfMotionParameter(m.MotionID.ToString(), m.timeBegin, height, width, fps, quanlity);

                Live();
                //    textBox3.Text = "" + m.timeBegin + " To " + m.timeEnd;
                //    vlCplayer1.playFileUrl(url.FilesURL);
            }
            catch (Exception err)
            {
                //logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace); ;
            }
        }
Beispiel #3
0
        public virtual void EventAlert()
        {
            try
            {
                if (MotionOut != null)
                {
                    VsMotion vsMotion = new VsMotion(CameraName, LocalHost, DateTime.Now, analyserName);
                    MotionOut(this, new VsMotionEventArgs(vsMotion));
                    vsMotion.Dispose(); vsMotion = null;

                    logger.Log(LogLevel.Info, "Camera: " + CameraName + ", Host: " + LocalHost + ", Analyzer: " + analyserName);
                }
            }
            catch (Exception err)
            {
                logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
            }
        }
Beispiel #4
0
        public void motionSelected()
        {
            try
            {
                radioButtonVideo_CheckedChanged(null, null);

                int       index = listEvents.SelectedIndex;
                VsMotion  m     = motions[index];
                VsFileURL url   = engine.getFileUrlOfMotion(m.MotionID.ToString(), m.timeBegin);

                textBox3.Text = "" + m.timeBegin + " To " + m.timeEnd;
                vlCplayer1.playFileUrl(url.FilesURL);
            }
            catch (Exception err)
            {
                logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
            }
        }
Beispiel #5
0
    private List <VsMotion> getMotionOfCamAsPeriod(DateTime timeBegin, DateTime timeEnd, string cameraID)
    {
        List <VsMotion> motionList = new List <VsMotion>();

        string[] TableNames = VsTableName.getMonthTableName("data", timeBegin, timeEnd);

        foreach (string tableName in TableNames)
        {
            MySqlConnection conn = this.connecting(ConnString);
            MySqlCommand    comm = conn.CreateCommand();
            comm.CommandText = String.Format(
                "SELECT  `m_id` AS `MotionID`,  `m_ip_camera` AS `CameraID`,  `m_ip_processor` AS `Processor`,  `m_date_start` AS `TimeBegin`,  `m_date_end` AS `TimeEnd`,  `m_algo_name` AS `algoName`,  `m_detail` AS `detail` "
                + " FROM  `{3}` "
                + " where `m_date_start` >= '{0}'  And `m_date_start` <='{1}' And  `m_ip_camera` = '{2}'  ORDER BY   `m_date_start` ",
                tConv(timeBegin), tConv(timeEnd), cameraID, tableName);
            try
            {
                MySqlDataReader aReader = comm.ExecuteReader();

                while (aReader.Read())
                {
                    VsMotion m = new VsMotion();

                    m.MotionID  = Int32.Parse(aReader["MotionID"].ToString());
                    m.cameraID  = aReader["CameraID"].ToString();
                    m.processor = aReader["Processor"].ToString();
                    m.timeBegin = DateTime.Parse(aReader["TimeBegin"].ToString());
                    m.timeEnd   = DateTime.Parse(aReader["TimeEnd"].ToString());

                    m.r_algo_name = aReader["algoName"].ToString();
                    m.r_detail    = aReader["detail"].ToString();

                    motionList.Add(m);
                }
            }
            catch { }
            finally
            {
                conn.Close();
            }
        }
        return(motionList);
    }
Beispiel #6
0
        // On new frame ready
        //[MethodImpl(MethodImplOptions.Synchronized)]
        public void FrameIn(object sender, VsMotionEventArgs e)
        {
            try
            {
                /*
                 * if (eventBuffer.Count > 1000 / syncTimer)
                 * {
                 *  VsMotion rm = (VsMotion)eventBuffer.Dequeue();
                 *  rm.Dispose(); rm = null;
                 *  logger.Log(LogLevel.Warn, DateTime.Now.ToString() + "; frame removed from EventAlert");
                 * }*/

                VsMotion img = (VsMotion)e.Motion.Clone();
                eventBuffer.Enqueue(img);
            }
            catch (Exception err)
            {
                logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);
            }
        }
Beispiel #7
0
    private List<VsMotion> getMotionOfCamAsPeriod(DateTime timeBegin, DateTime timeEnd, string cameraID)
    {

        List<VsMotion> motionList = new List<VsMotion>();
        string[] TableNames = VsTableName.getMonthTableName("data", timeBegin, timeEnd);

        foreach (string tableName in TableNames)
        {
            MySqlConnection conn = this.connecting(ConnString);
            MySqlCommand comm = conn.CreateCommand();
            comm.CommandText = String.Format(
                "SELECT  `m_id` AS `MotionID`,  `m_ip_camera` AS `CameraID`,  `m_ip_processor` AS `Processor`,  `m_date_start` AS `TimeBegin`,  `m_date_end` AS `TimeEnd`,  `m_algo_name` AS `algoName`,  `m_detail` AS `detail` "
                 + " FROM  `{3}` "
                 + " where `m_date_start` >= '{0}'  And `m_date_start` <='{1}' And  `m_ip_camera` = '{2}'  ORDER BY   `m_date_start` ", 
                 tConv(timeBegin), tConv(timeEnd), cameraID, tableName);
            try
            {
                MySqlDataReader aReader = comm.ExecuteReader();

                while (aReader.Read())
                {
                    VsMotion m = new VsMotion();

                    m.MotionID = Int32.Parse(aReader["MotionID"].ToString());
                    m.cameraID = aReader["CameraID"].ToString();
                    m.processor = aReader["Processor"].ToString();
                    m.timeBegin = DateTime.Parse(aReader["TimeBegin"].ToString());
                    m.timeEnd = DateTime.Parse(aReader["TimeEnd"].ToString());

                    m.r_algo_name = aReader["algoName"].ToString();
                    m.r_detail = aReader["detail"].ToString();

                    motionList.Add(m);
                }
            }
            catch { }
            finally
            {
                conn.Close();
            }
        }
        return motionList;
    }
Beispiel #8
0
        private void process_NewFrame(object stateInfo)
        {
            VsMotion lastMotion = null;

            Thread.CurrentThread.Priority = ThreadPriority.Lowest;

            try
            {
                // get new one
                if (eventBuffer.Count > 0)
                {
                    lastMotion = (VsMotion)eventBuffer.Dequeue();
                }

                if (lastMotion != null)
                {
                    try
                    {
                        strConnect = String.Format("server={0};user id={1}; password={2}; database={3}; pooling=false",
                                                   DataHost, DataUser, DataPasswd, DataDatabase);

                        connectSQL = new MySqlConnection(strConnect);
                        connectSQL.Open();
                    }
                    catch (MySqlException err)
                    {
                        logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);

                        if (connectSQL != null)
                        {
                            connectSQL.Dispose();
                            connectSQL = null;
                        }
                    }

                    if (connectSQL != null)
                    {
                        MySqlCommand cmdSQL;

                        TableCheck(connectSQL);
                        lastMotion.TableName = TableName;

                        cmdSQL = new MySqlCommand(lastMotion.Sql, connectSQL);

                        try
                        {
                            cmdSQL.ExecuteNonQuery();
                        }
                        catch (MySqlException err)
                        {
                            logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);
                        }

                        cmdSQL.Dispose();
                    }

                    if (connectSQL != null)
                    {
                        try
                        {
                            connectSQL.Close();
                            connectSQL.Dispose();
                            connectSQL = null;
                        }
                        catch (Exception err)
                        {
                            logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
                        }
                    }
                }
            }
            catch (Exception err)
            {
                if (connectSQL != null)
                {
                    connectSQL.Dispose();
                    connectSQL = null;
                }

                logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);
            }
        }