// Add new camera to the collection and run it
		public bool Add(VsCamera camera)
		{
            try
            {
                // create video
                if (camera.CreateVideoSource())
                {
                    // add to the pool
                    InnerList.Add(camera);

                    // crate analyzer source
                    camera.CreateAnalyserSource();

                    // create encoder source
                    camera.CreateEncoderSource();

                    // start camera
                    camera.Start();

                    return true;
                }
            }
            catch (Exception err)
            {
                logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
            }
			return false;
		}
        // Add new camera to the collection and run it
        public bool Add(VsCamera camera)
        {
            try
            {
                // create video
                if (camera.CreateVideoSource())
                {
                    // add to the pool
                    InnerList.Add(camera);

                    // crate analyzer source
                    camera.CreateAnalyserSource();

                    // create encoder source
                    camera.CreateEncoderSource();

                    // start camera
                    camera.Start();

                    return(true);
                }
            }
            catch (Exception err)
            {
                logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
            }
            return(false);
        }
        // Ensure the camera is stopped
        public void Remove(VsCamera camera)
        {
            // lock
            Monitor.Enter(this);

            try
            {
                int n = InnerList.Count;
                for (int i = 0; i < n; i++)
                {
                    if (InnerList[i] == camera)
                    {
                        if (camera.Running)
                        {
                            camera.Stop();
                        }
                        camera.CloseVideoSource();
                        camera.CloseAnalyserSource();
                        camera.CloseEncoderSource();
                        InnerList.RemoveAt(i);
                        break;
                    }
                }
            }
            catch (Exception err)
            {
                logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
            }
            finally
            {
                // unlock
                Monitor.Exit(this);
            }
        }
 // Remove camera from the collection
 public void Remove(VsCamera camera)
 {
     try
     {
         InnerList.Remove(camera);
     }
     catch (Exception err)
     {
         logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
     }
 }
        // Thread entry point
        private void WorkerThread()
        {
            while (!stopEvent.WaitOne(0, true))
            {
                // lock
                Monitor.Enter(this);

                try
                {
                    int n = InnerList.Count;

                    // check each camera
                    for (int i = 0; i < n; i++)
                    {
                        VsCamera camera = (VsCamera)InnerList[i];

                        if (!camera.Running)
                        {
                            camera.CloseVideoSource();
                            camera.CloseAnalyserSource();
                            camera.CloseEncoderSource();
                            InnerList.RemoveAt(i);
                            i--;
                            n--;
                        }
                    }
                }
                catch (Exception err)
                {
                    logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
                }
                finally
                {
                    // unlock
                    Monitor.Exit(this);
                }

                // sleep for a while
                Thread.Sleep(300);
            }

            try
            {
                // Exiting, so kill'em all
                foreach (VsCamera camera in InnerList)
                {
                    camera.Stop();
                }
            }
            catch (Exception err)
            {
                logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
            }
        }
Exemple #6
0
		// Add new camera to the collection
		public void Add(VsCamera camera)
		{
            try
            {
                InnerList.Add(camera);
            }
            catch (Exception err)
            {
                logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
            }
		}
Exemple #7
0
		// Construction
		public VsAnalyzerDialog(VsCoreServer vsCore, VsCamera vsCam)
		{
            this.AddPage(vsAnalyzerSetting);
            vsAnalyzerSetting.CoreMonitor = vsCoreMonitor;
            vsAnalyzerSetting.Camera = vsCam;

            // set current core
            vsCamera = vsCam;
            vsCoreMonitor = vsCore;

            this.Text = "Analyzer";
            this.buttonApply.Visible = true;
            this.backButton.Visible = false;
            this.nextButton.Visible = false;
            this.imagePanel.Visible = false;
        }
 // Add new camera to the collection and run it
 public void Add(VsCamera camera)
 {
     // lock
     Monitor.Enter(this);
     try
     {
         // add to the pool
         InnerList.Add(camera);
     }
     catch (Exception err)
     {
         logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
     }
     finally
     {
         // unlock
         Monitor.Exit(this);
     }
 }
Exemple #9
0
        // Set camera
        public void SetCamera(int cameraID, VsCamera vsCam)
        {
            try
            {
                if (vsCameraList.Count >= MaxCam)
                {
                    return;
                }

                // add to list
                vsCameraList.Add(new CameraList(cameraID, vsCam));

                // generate layout
                GenerateLayout();
            }
            catch (Exception err)
            {
                logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
            }
        }
Exemple #10
0
        // Add camera
        public VsCamera AddCamera(String cameraName,
            String providerName, Hashtable prividerConfig)
        {
            try
            {
                // if this name is already exist
                if (GetCameraByName(cameraName) != null)
                    return null;

                // create new camera
                VsCamera vsCamera = new VsCamera(cameraName, SyncTimer);

                // set provider
                vsCamera.Provider = vsProviders.GetProviderByName(providerName);
                if (vsCamera.Provider == null) return null;
                vsCamera.CameraConfiguration = vsCamera.Provider.LoadConfiguration(prividerConfig);
                if (vsCamera.CameraConfiguration == null) return null;

                // set analyser
                Hashtable analyserConfig = new Hashtable();
                String analyserName = "VsMotionDetector.VsMotionDetectorDescription";
                analyserConfig.Add("AlgorithmName", "VsMotionDetectorDescription");
                analyserConfig.Add("MotionLevel", "0.012");

                vsCamera.Analyser = vsAnalysers.GetAnalyserByName(analyserName);
                if (vsCamera.Analyser == null) return null;
                vsCamera.AnalyserConfiguration = vsCamera.Analyser.LoadConfiguration(analyserConfig);
                if (vsCamera.AnalyserConfiguration == null) return null;

                // set encoder
                Hashtable encoderConfig = new Hashtable();
                String encoderName = "VsAviEncoder.VsAviEncoderDescription";
                encoderConfig.Add("ImageWidth", "320");
                encoderConfig.Add("ImageHeight", "240");
                encoderConfig.Add("CodecsName", "Windows Media Codecs 9.0");
                encoderConfig.Add("Quality", "100");

                vsCamera.Encoder = vsEncoders.GetEncoderByName(encoderName);
                if (vsCamera.Encoder == null) return null;
                vsCamera.EncoderConfiguration = vsCamera.Encoder.LoadConfiguration(encoderConfig);
                if (vsCamera.EncoderConfiguration == null) return null;

                // add camera
                AddCamera(vsCamera);

                return vsCamera;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return null;
        }
Exemple #11
0
        // Add camera
        public VsCamera AddCamera(String cameraName,
            String providerName, Hashtable prividerConfig,
            String analyserName, Hashtable analyserConfig,
            String encoderName, Hashtable encoderConfig)
        {
            try
            {
                // if this name is already exist
                if (GetCameraByName(cameraName) != null)
                    return null;

                // create new camera
                VsCamera vsCamera = new VsCamera(cameraName, SyncTimer);

                // set provider
                vsCamera.Provider = vsProviders.GetProviderByName(providerName);
                if (vsCamera.Provider == null) return null;
                vsCamera.CameraConfiguration = vsCamera.Provider.LoadConfiguration(prividerConfig);
                if (vsCamera.CameraConfiguration == null) return null;

                // set analyser
                vsCamera.Analyser = vsAnalysers.GetAnalyserByName(analyserName);
                if (vsCamera.Analyser == null) return null;
                vsCamera.AnalyserConfiguration = vsCamera.Analyser.LoadConfiguration(analyserConfig);
                if (vsCamera.AnalyserConfiguration == null) return null;

                // set encoder
                vsCamera.Encoder = vsEncoders.GetEncoderByName(encoderName);
                if (vsCamera.Encoder == null) return null;
                vsCamera.EncoderConfiguration = vsCamera.Encoder.LoadConfiguration(encoderConfig);
                if (vsCamera.EncoderConfiguration == null) return null;

                // add camera
                AddCamera(vsCamera);
                return vsCamera;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return null;
        }
Exemple #12
0
 public CameraList(int id, VsCamera camera)
 {
     CameraID      = id;
     CameraHandler = camera;
 }
Exemple #13
0
 public CameraList(int id, VsCamera camera)
 {
     CameraID = id;
     CameraHandler = camera;
 }
Exemple #14
0
        public void ActivatePropertyControl(VsDeviceType propType, String propName)
        {
            vsPropertyType = propType;
            vsTypeName = propName;

            this.Enabled = true;

            switch (vsPropertyType)
            {
                case VsDeviceType.CAMERA:
                    CameraProperty();
                    this.vsCamera = vsCoreMonitor.GetCameraByName(vsTypeName);
                    break;
                case VsDeviceType.CHANNEL:
                    ChannelProperty();
                    this.vsChannel = vsCoreMonitor.GetChannelByName(vsTypeName);
                    break;
                case VsDeviceType.PAGE:
                    PageProperty();
                    this.vsPage = vsCoreMonitor.GetPageByName(vsTypeName);
                    break;
            }
        }
		// Ensure the camera is stopped
		public void Remove(VsCamera camera)
		{
			// lock
			Monitor.Enter(this);

            try
            {
                int n = InnerList.Count;
                for (int i = 0; i < n; i++)
                {
                    if (InnerList[i] == camera)
                    {
                        if (camera.Running)
                            camera.Stop();
                        camera.CloseVideoSource();
                        camera.CloseAnalyserSource();
                        camera.CloseEncoderSource();
                        InnerList.RemoveAt(i);
                        break;
                    }
                }
            }
            catch (Exception err)
            {
                logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
            }
            finally
            {
                // unlock
                Monitor.Exit(this);
            }
		}
		// Add new camera to the collection and run it
		public void Add(VsCamera camera)
		{
			// lock
			Monitor.Enter(this);
            try
            {
                // add to the pool
                InnerList.Add(camera);
            }
            catch (Exception err)
            {
                logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
            }
            finally
            {
                // unlock
                Monitor.Exit(this);
            }
		}
		// Remove camera from the collection and signal to stop it
		public void Remove(VsCamera camera)
		{
            try
            {
                InnerList.Remove(camera);

                // signal to stop
                camera.SignalToStop();
            }
            catch (Exception err)
            {
                logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
            }
		}
Exemple #18
0
        // Delete camera
        public bool DeleteCamera(VsCamera camera)
        {
            try
            {
                // delete from list
                vsCameras.Remove(camera);

                // save
                if (bSaveConfig) SaveCameras();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return true;
        }
Exemple #19
0
 // Check camera
 public bool CheckCamera(VsCamera camera)
 {
     try
     {
         foreach (VsCamera c in vsCameras)
         {
             if ((camera.CameraName == c.CameraName) && ((camera.CameraID == 0) || (camera.CameraID != c.CameraID)))
                 return false;
         }
         return true;
     }
     catch (Exception err)
     {
         logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
     }
     return false;
 }
Exemple #20
0
        // Load vsCameras
        private void LoadCameras(XmlTextReader reader)
        {
            try
            {
                // load all vsCameras
                while (reader.Name == "Camera")
                {
                    int depth = reader.Depth;
                    int vsId = int.Parse(reader.GetAttribute("id"));
                    string vsName = reader.GetAttribute("name");
                    string vsDesc = reader.GetAttribute("desc");
                    bool bRun = Convert.ToBoolean(reader.GetAttribute("run"));
                    bool bAnalysis = Convert.ToBoolean(reader.GetAttribute("analyse"));
                    bool bRecord = Convert.ToBoolean(reader.GetAttribute("record"));
                    bool bEventAlert = Convert.ToBoolean(reader.GetAttribute("event"));
                    bool bDataAlert = Convert.ToBoolean(reader.GetAttribute("data"));

                    // create new camera
                    VsCamera camera = new VsCamera(vsId, 
                        vsName, 
                        vsDesc,
                        vsSyncTimer,
                        vsPcHost, vsPcDirt,
                        vsDbHost, vsDbUser, vsDbPasswd, vsDbDatabase,
                        vsSmtpHost, vsSmtpUser, vsSmtpPasswd, vsEmailFrom, vsEmailTo,
                        vsPreview, vsStream, bAnalysis, bRecord, bEventAlert, bDataAlert, bMailAlert);

                    // camera configuration
                    camera.Provider = vsProviders.GetProviderByName(reader.GetAttribute("provider"));
                    camera.Analyser = vsAnalysers.GetAnalyserByName(reader.GetAttribute("analyzer"));
                    camera.Encoder = vsEncoders.GetEncoderByName(reader.GetAttribute("encoder"));

                    // load provider configuration
                    if (camera.Provider != null)
                        camera.CameraConfiguration = camera.Provider.LoadConfiguration(reader);

                    // load analyser configuration
                    if (camera.Analyser != null)
                        camera.AnalyserConfiguration = camera.Analyser.LoadConfiguration(reader);

                    // load encoder configuration
                    if (camera.Encoder != null)
                        camera.EncoderConfiguration = camera.Encoder.LoadConfiguration(reader);

                    // add camera
                    vsCameras.Add(camera);

                    if (camera.CameraID >= vsNextCameraID)
                        vsNextCameraID = camera.CameraID + 1;

                    // move to next node
                    reader.Read();

                    // move to next element node
                    while (reader.NodeType == XmlNodeType.EndElement)
                        reader.Read();
                    if (reader.Depth < depth)
                        return;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemple #21
0
        // drag drop into window
        void VsCameraViewer_DragDrop(object sender, DragEventArgs e)
        {
            this.BorderStyle = BorderStyle.None;

            if (vsStatus == VsViewStatusType.VIEW_CONNECTING || vsStatus == VsViewStatusType.VIEW_CONNECTED) return;

            string send = (string)e.Data.GetData(typeof(string));
            string[] cmd = send.Split('\\');

            vsDeviceName = cmd[1];
            // check if not root node
            if (cmd.Length == 2 && cmd[0] == "Analyzers")
            {
                // set flag
                vsDeviceType = VsDeviceType.CAMERA;
                vsStatus = VsViewStatusType.VIEW_CONNECTING;

                // update event
                this.vsUpdateEvent(this, new VsMonitorEventArgs(
                    new VsParameter(VsAppControlType.APP_SIGLEVIEW, VsAppControlType.APP_SIGLEVIEW, vsDeviceType, vsDeviceName)));

                labelStatus.Text = "Connecting...";
                // the current camera is connected
                if (!vsCoreMonitor.ConnectingCamera(vsDeviceName))
                {
                    // not connected
                    // try to connect
                    if (!vsCoreMonitor.ConnectCamera(vsDeviceName, false))
                        return;

                    // cache current camera
                    vsCamera = vsCoreMonitor.GetCameraByName(vsDeviceName);
                }

                // the camera is connected
                // attach to current view
                vsCoreMonitor.AttachCameraView(vsDeviceName, this);
                vsAttachType = VsAttachType.ATTACH_RECEIVER;

                // enable toolbox
                buttonStop.Enabled = true;
                buttonAttach.Enabled = true;
                buttonAnalyzer.Enabled = true;
            }
            else if (cmd.Length == 2 && cmd[0] == "Layouts")
            {
                // set flag
                vsDeviceType = VsDeviceType.CHANNEL;
                vsStatus = VsViewStatusType.VIEW_CONNECTING;

                // update event
                this.vsUpdateEvent(this, new VsMonitorEventArgs(
                    new VsParameter(VsAppControlType.APP_SIGLEVIEW, VsAppControlType.APP_SIGLEVIEW, vsDeviceType, vsDeviceName)));

                // the current channel is connected
                if (!vsCoreMonitor.ConnectingChannel(vsDeviceName))
                {
                    // not connected
                    // try to connect
                    if (!vsCoreMonitor.ConnectChannel(vsDeviceName, false))
                        return;

                    // cache current camera
                    vsChannel = vsCoreMonitor.GetChannelByName(vsDeviceName);
                }

                // the camera is connected
                // attach to current view
                vsCoreMonitor.AttachChannelView(vsDeviceName, this);

                // enable toolbox
                buttonStop.Enabled = true;
                buttonAttach.Enabled = true;
                buttonAnalyzer.Enabled = true;
            }
        }
Exemple #22
0
 // New camera
 public VsCamera NewCamera(String cameraName)
 {
     try
     {
         VsCamera vsCamera = new VsCamera(cameraName, SyncTimer);
         return vsCamera;
     }
     catch (Exception err)
     {
         logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
     }
     return null;
 }
Exemple #23
0
        private void buttonConnecter_Click(object sender, EventArgs e)
        {
            switch (vsPropertyType)
            {
                case VsDeviceType.CAMERA:
                    {
                        this.vsCamera = vsCoreMonitor.GetCameraByName(vsTypeName);

                        if (vsCamera == null) return;
                        if (vsCamera.Running)
                            vsCoreMonitor.DisconnectCamera(vsTypeName);
                        else vsCoreMonitor.ConnectCamera(vsTypeName, false);                     
                    }
                    break;
                case VsDeviceType.CHANNEL:
                    {
                        this.vsChannel = vsCoreMonitor.GetChannelByName(vsTypeName);
                        if (vsChannel == null) return;
                        if (vsChannel.Running)
                            vsCoreMonitor.DisconnectChannel(vsTypeName);
                        else vsCoreMonitor.ConnectChannel(vsTypeName, false);
                    }
                    break;
                case VsDeviceType.PAGE:
                    {
                        this.vsPage = vsCoreMonitor.GetPageByName(vsTypeName);
                        if (vsPage == null) return;
                        if (vsPage.Running)
                            vsCoreMonitor.DisconnectPage(vsTypeName);
                        else vsCoreMonitor.ConnectPage(vsTypeName, false);
                    }
                    break;
            }
        }
Exemple #24
0
        // Add camera
        public void AddCamera(VsCamera camera)
        {
            try
            {
                camera.CameraID = vsNextCameraID++;
                vsCameras.Add(camera);

                // save
                if (bSaveConfig) SaveCameras();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemple #25
0
        // Set camera
        public void SetCamera(int cameraID, VsCamera vsCam)
        {
            try
            {
                if (vsCameraList.Count >= MaxCam) return;

                // add to list
                vsCameraList.Add(new CameraList(cameraID, vsCam));

                // generate layout
                GenerateLayout();
            }
            catch (Exception err)
            {
                logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
            }
        }
Exemple #26
0
		// On page changing
		protected override void OnPageChanging(int page)
		{
			if (page == 1)
			{
				// switching to vsCamera settings
                vsCamera = vsCameraDescription.Camera;
                vsCameraSetting.Camera = vsCamera;
                vsAnalyzerSetting.Camera = vsCamera;
                vsEncoderSetting.Camera = vsCamera;
            }
			base.OnPageChanging(page);
		}