コード例 #1
0
        /// <summary>
        /// Updates the config file based on the list populated
        /// returns MotionSensorSettings, with settings updated for whatever is in the config file
        /// </summary>
        /// <returns></returns>
        public MotionSensorSetup UpdateConfig()
        {
            MotionSensorSetup result = new MotionSensorSetup();
            UpdateWebConfig();

            //update the result where appropriate
            foreach(MotionSensorConfig config in list)
            {
                foreach (PropertyInfo property in typeof(MotionSensorSetup).GetProperties())
                {
                    if (property.Name == config.configName && config.userInput != null)
                    {
                        property.SetValue(result, config.userInput);
                    }

                    if (config.configName.ToLower() == "emailalarmto" && config.userInput.Length > 0)
                    {
                        if (result.emailAlarm == null) { result.emailAlarm = new Alarms.EmailAlarm(); }
                        result.emailAlarm.emailAddress = config.userInput;
                    }
                    else if (config.configName.ToLower() == "emailsubject" && config.userInput.Length > 0)
                    {
                        if (result.emailAlarm == null) { result.emailAlarm = new Alarms.EmailAlarm(); }
                        result.emailAlarm.emailSubject = config.userInput;
                    }
                }
            }

            result.camera = cameraModel;
            return result;
        }
コード例 #2
0
        public MotionSensorStartup(MotionSensorSetup setup)
        {
            //setup the extractor
            imageExtractor = new ImageExtractor(setup.camera);
            imageExtractor.framerateBroadcast += new ImageExtractor.FramerateBroadcastEvent(FramerateBroadcastEventHandler);
            imageExtractor.asyncrohous = true;

            //set up the save file object
            imageSaver = new ImageSaver(setup.imageSaveLocation, "movement", setup.camera.cameraId);
            imageSaver.saveToFileServer = true; //setup.saveImagesToFileServer;
            imageSaver.saveToDatabase = setup.saveImagesToDatabase;
            imageSaver.ParentDirectory = setup.imageSaveLocation;
            captureId = imageSaver.captureId;

            //set up the database object
            if(setup.saveImagesToDatabase)
            {
                database = new CaptureDb(ConfigurationManager.ConnectionStrings["LOCALDB"].ConnectionString);
                database.CreateCaptureSession(captureId, imageSaver.SaveDirectory);
                detectionId = database.CreateDetectionSession(captureId);
                imageSaver.detectionId = detectionId;
            }

            //setup the motion sensor
            motionSensor = new MotionSensor_2a();
            motionSensor.settings = new MotionSensorSettings();
            motionSensor.settings.LoadDefaults();

            motionSensor.motionDetected += new MotionSensor_2.MotionDetected(imageSaver.ImageCreatedAsync);

            //create the validator 
            imageValidator = new ImageValidator();
            imageValidator.ListenForImages(imageExtractor);
            imageValidator.imageValidated += new ImageValidator.ImageValidatedEvent(motionSensor.ImageCreatedAsync);//subscribe to events from the validator

            //setup the alarms
            alarms = new List<IAlarm>();
            if (setup.emailAlarm != null)
            {
                alarms.Add(setup.emailAlarm as EmailAlarm);
                imageSaver.imageCreated += new ImageSaver.ImageSavedEvent(setup.emailAlarm.ImageExtracted);
            }

            imageExtractor.Run();

        }
コード例 #3
0
        public MotionSensorStartup(MotionSensorSetup setup)
        {
            //setup the extractor
            imageExtractor = new ImageExtractor(setup.camera);
            imageExtractor.framerateBroadcast += new ImageExtractor.FramerateBroadcastEvent(FramerateBroadcastEventHandler);
            imageExtractor.asyncrohous         = true;

            //set up the save file object
            imageSaver = new ImageSaver(setup.imageSaveLocation, "movement", setup.camera.cameraId);
            imageSaver.saveToFileServer = true; //setup.saveImagesToFileServer;
            imageSaver.saveToDatabase   = setup.saveImagesToDatabase;
            imageSaver.ParentDirectory  = setup.imageSaveLocation;
            captureId = imageSaver.captureId;

            //set up the database object
            if (setup.saveImagesToDatabase)
            {
                database = new CaptureDb(ConfigurationManager.ConnectionStrings["LOCALDB"].ConnectionString);
                database.CreateCaptureSession(captureId, imageSaver.SaveDirectory);
                detectionId            = database.CreateDetectionSession(captureId);
                imageSaver.detectionId = detectionId;
            }

            //setup the motion sensor
            motionSensor          = new MotionSensor_2a();
            motionSensor.settings = new MotionSensorSettings();
            motionSensor.settings.LoadDefaults();

            motionSensor.motionDetected += new MotionSensor_2.MotionDetected(imageSaver.ImageCreatedAsync);

            //create the validator
            imageValidator = new ImageValidator();
            imageValidator.ListenForImages(imageExtractor);
            imageValidator.imageValidated += new ImageValidator.ImageValidatedEvent(motionSensor.ImageCreatedAsync);//subscribe to events from the validator

            //setup the alarms
            alarms = new List <IAlarm>();
            if (setup.emailAlarm != null)
            {
                alarms.Add(setup.emailAlarm as EmailAlarm);
                imageSaver.imageCreated += new ImageSaver.ImageSavedEvent(setup.emailAlarm.ImageExtracted);
            }

            imageExtractor.Run();
        }
コード例 #4
0
        /// <summary>
        /// Updates the config file based on the list populated
        /// returns MotionSensorSettings, with settings updated for whatever is in the config file
        /// </summary>
        /// <returns></returns>
        public MotionSensorSetup UpdateConfig()
        {
            MotionSensorSetup result = new MotionSensorSetup();

            UpdateWebConfig();

            //update the result where appropriate
            foreach (MotionSensorConfig config in list)
            {
                foreach (PropertyInfo property in typeof(MotionSensorSetup).GetProperties())
                {
                    if (property.Name == config.configName && config.userInput != null)
                    {
                        property.SetValue(result, config.userInput);
                    }

                    if (config.configName.ToLower() == "emailalarmto" && config.userInput.Length > 0)
                    {
                        if (result.emailAlarm == null)
                        {
                            result.emailAlarm = new Alarms.EmailAlarm();
                        }
                        result.emailAlarm.emailAddress = config.userInput;
                    }
                    else if (config.configName.ToLower() == "emailsubject" && config.userInput.Length > 0)
                    {
                        if (result.emailAlarm == null)
                        {
                            result.emailAlarm = new Alarms.EmailAlarm();
                        }
                        result.emailAlarm.emailSubject = config.userInput;
                    }
                }
            }

            result.camera = cameraModel;
            return(result);
        }
コード例 #5
0
        /// <summary>
        /// Tests the MotionSensorStartup wrapper which is used to fire a motion
        /// detection session, mimics what would come in from a webservice
        /// </summary>
        static void TestStartup()
        {
            MotionSensorSetup setup = new MotionSensorSetup();
            setup.camera = new ImageAnalysis.Camera.CameraModel();
            setup.camera.cameraIpAddress = "192.168.0.8";
            setup.imageSaveLocation = @"d:\motion";
            setup.saveImagesToFileServer = true;

            setup.emailAlarm = new ImageAnalysis.Alarms.EmailAlarm();
            setup.emailAlarm.emailAddress = "*****@*****.**";

            MotionSensorStartup motionSensor = new MotionSensorStartup(setup);

        }