예제 #1
0
        public Task Execute(IJobExecutionContext context)
        {
            if (!ServiceProvider.DeviceManager.SelectedCameraDevice.IsBusy)
            {
                try
                {
                    if (ServiceProvider.Settings.DefaultSession.TimeLapseSettings.Capture)
                    {
                        if (ServiceProvider.Settings.DefaultSession.TimeLapseSettings.Bracketing)
                        {
                            var _bracketingViewModel = new BracketingViewModel();
                            Task.Factory.StartNew(new Action(_bracketingViewModel.Start));
                            StaticHelper.Instance.SystemMessage = _bracketingViewModel.Error;
                        }
                        else
                        {
                            ServiceProvider.WindowsManager.ExecuteCommand(CmdConsts.Capture);
                        }
                    }
                    if (ServiceProvider.Settings.DefaultSession.TimeLapseSettings.CaptureAll)
                    {
                        ServiceProvider.WindowsManager.ExecuteCommand(CmdConsts.CaptureAll);
                    }
                    if (ServiceProvider.Settings.DefaultSession.TimeLapseSettings.CaptureScript)
                    {
                        if (Path.GetExtension(ServiceProvider.Settings.DefaultSession.TimeLapseSettings.ScriptFile.ToLower()) == ".tcl")
                        {
                            try
                            {
                                var manager = new TclScripManager();
                                manager.Execute(File.ReadAllText(ServiceProvider.Settings.DefaultSession.TimeLapseSettings.ScriptFile));
                            }
                            catch (Exception exception)
                            {
                                Log.Error("Script error", exception);
                                StaticHelper.Instance.SystemMessage = "Script error :" + exception.Message;
                            }
                        }
                        else
                        {
                            var script = ServiceProvider.ScriptManager.Load(ServiceProvider.Settings.DefaultSession.TimeLapseSettings.ScriptFile);
                            script.CameraDevice = ServiceProvider.DeviceManager.SelectedCameraDevice;
                            ServiceProvider.ScriptManager.Execute(script);
                        }
                    }
                }
                catch (Exception exception)
                {
                    Log.Error("Timelapse error ", exception);
                    StaticHelper.Instance.SystemMessage = "Capture error";
                }
            }

            //throw new NotImplementedException();
            Console.WriteLine("Hello, JOb executed");
            return(Task.FromResult(0));
        }
예제 #2
0
 private void StartL()
 {
     if (IsRunning)
     {
         return;
     }
     if (_bracketingViewModel != null)
     {
         _bracketingViewModel.Stop();
     }
     _bracketingViewModel = null;
     IsRunning            = true;
     _timeLapseStartTime  = DateTime.Now;
     _lastCaptureTime     = DateTime.Now;
     Log.Debug("Timelapse start");
     _totalCaptures  = 0;
     _timer.Interval = FullSpeed ? 100 : ((1000 * Resolution) + FineTune);
     _timer.Start();
     _lastTime = DateTime.Now;
     TimeDiff  = 0;
     TimeLapseSettings.Started = true;
     ServiceProvider.Settings.Save(ServiceProvider.Settings.DefaultSession);
 }
 private void StartL()
 {
     if (IsRunning)
         return;
     if (_bracketingViewModel != null)
         _bracketingViewModel.Stop();
     _bracketingViewModel = null;
     IsRunning = true;
     _timeLapseStartTime = DateTime.Now;
     _lastCaptureTime = DateTime.Now;
     Log.Debug("Timelapse start");
     _totalCaptures = 0;
     _timer.Interval = FullSpeed ? 100 : ((1000*Resolution) + FineTune);
     _timer.Start();
     _lastTime = DateTime.Now;
     TimeDiff = 0;
     TimeLapseSettings.Started = true;
     ServiceProvider.Settings.Save(ServiceProvider.Settings.DefaultSession);
 }
        void _timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            
            TimeDiff += (DateTime.Now - _lastTime).TotalMilliseconds - (1000*Resolution);
            _lastTime = DateTime.Now;

            if (!IsActive)
            {
                IsActive = CheckStart();
                if (IsActive)
                    _firstLapseStartTime = DateTime.Now;
            }
            RaisePropertyChanged(() => StatusText);
            if (!IsActive)
                return;
            if (IsActive)
            {
                if (Math.Round((DateTime.Now - _lastCaptureTime).TotalSeconds) >= TimeBetweenShots || (FullSpeed && !ServiceProvider.DeviceManager.SelectedCameraDevice.IsBusy))
                {
                    _lastCaptureTime = DateTime.Now;
                    _totalCaptures++;
                    try
                    {
                        if (Capture)
                        {
                            if (Bracketing)
                            {
                                if (_bracketingViewModel == null)
                                    _bracketingViewModel = new BracketingViewModel();
                                Task.Factory.StartNew(new Action(_bracketingViewModel.Start));
                                StaticHelper.Instance.SystemMessage = _bracketingViewModel.Error;
                            }
                            else
                            {
                            ServiceProvider.WindowsManager.ExecuteCommand(CmdConsts.Capture);                                
                            }
                        }
                        if (CaptureAll)
                            ServiceProvider.WindowsManager.ExecuteCommand(CmdConsts.CaptureAll);
                        if (CaptureScript)
                        {
                            if (Path.GetExtension(ScriptFile.ToLower()) == ".tcl")
                            {
                                try
                                {
                                    var manager = new TclScripManager();
                                    manager.Execute(File.ReadAllText(ScriptFile));
                                }
                                catch (Exception exception)
                                {
                                    Log.Error("Script error", exception);
                                    StaticHelper.Instance.SystemMessage = "Script error :" + exception.Message;
                                }
                            }
                            else
                            {
                                var script = ServiceProvider.ScriptManager.Load(ScriptFile);
                                script.CameraDevice = ServiceProvider.DeviceManager.SelectedCameraDevice;
                                ServiceProvider.ScriptManager.Execute(script);
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        Log.Error("Timelapse error ", exception);
                        StaticHelper.Instance.SystemMessage = "Capture error";
                    }
                }
                if (CheckStop())
                {
                    IsActive = false;
                    if (!StartDaily)
                    {
                        IsRunning = false;
                        _timer.Stop();
                    }
                }
            }
        }
 private void StartL()
 {
     if (IsRunning)
         return;
     if (_bracketingViewModel != null)
         _bracketingViewModel.Stop();
     _bracketingViewModel = null;
     IsRunning = true;
     _timeLapseStartTime = DateTime.Now;
     _lastCaptureTime = DateTime.Now;
     Log.Debug("Timelapse start");
     _totalCaptures = 0;
     _timer.Interval = FullSpeed ? 100 : 1000;
     _timer.Start();
 }
예제 #6
0
        private void StartL()
        {
            if (IsRunning)
            {
                return;
            }

            // construct a scheduler factory
            ISchedulerFactory schedFact = new StdSchedulerFactory();

            // get a scheduler, start the schedular before triggers or anything else
            if (sched == null)
            {
                sched = schedFact.GetScheduler();
            }

            // create job
            IJobDetail job = JobBuilder.Create <SimpleJob>()
                             .WithIdentity("job1", "group1")
                             .Build();

            // create trigger

            var triggerB = TriggerBuilder.Create()
                           .WithIdentity("trigger1", "group1");

            if (StartIn)
            {
                triggerB =
                    triggerB.StartAt(DateBuilder.FutureDate((StartHour * 60 * 60) + (StartMinute * 60) + StartSecond,
                                                            IntervalUnit.Second));
            }

            if (StartAt)
            {
                triggerB =
                    triggerB.StartAt(DateBuilder.DateOf(StartHour, StartMinute, StartSecond, StartDate.Day, StartDate.Month, StartDate.Year));
            }
            if (StartDaily)
            {
                ISet <DayOfWeek> days = new HashSet <DayOfWeek>();
                if (StartDay0)
                {
                    days.Add(DayOfWeek.Sunday);
                }
                if (StartDay1)
                {
                    days.Add(DayOfWeek.Monday);
                }
                if (StartDay2)
                {
                    days.Add(DayOfWeek.Tuesday);
                }
                if (StartDay3)
                {
                    days.Add(DayOfWeek.Wednesday);
                }
                if (StartDay4)
                {
                    days.Add(DayOfWeek.Thursday);
                }
                if (StartDay5)
                {
                    days.Add(DayOfWeek.Friday);
                }
                if (StartDay6)
                {
                    days.Add(DayOfWeek.Saturday);
                }

                triggerB =
                    triggerB.WithDailyTimeIntervalSchedule(
                        x =>
                        x.WithIntervalInSeconds(TimeBetweenShots).WithMisfireHandlingInstructionFireAndProceed()
                        .StartingDailyAt(new TimeOfDay(StartHour, StartMinute, StartSecond))
                        .EndingDailyAt(new TimeOfDay(StopHour, StopMinute, StopSecond))
                        .OnDaysOfTheWeek(days)
                        );
            }
            else
            {
                if (StopAtPhotos)
                {
                    triggerB =
                        triggerB.WithSimpleSchedule(
                            x =>
                            x.WithIntervalInSeconds(TimeBetweenShots)
                            .WithRepeatCount(StopCaptureCount)
                            .WithMisfireHandlingInstructionNowWithExistingCount());
                }
                else if (StopIn)
                {
                    triggerB =
                        triggerB.WithSimpleSchedule(
                            x =>
                            x.WithIntervalInSeconds(TimeBetweenShots)
                            .WithMisfireHandlingInstructionNowWithExistingCount()
                            .WithRepeatCount(((StopHour * 60 * 60) + (StopMinute * 60) + StopSecond) / TimeBetweenShots));
                }
                else
                {
                    triggerB =
                        triggerB.WithSimpleSchedule(
                            x =>
                            x.WithIntervalInSeconds(TimeBetweenShots)
                            .WithMisfireHandlingInstructionNowWithExistingCount()
                            .RepeatForever());
                }

                if (StopAt)
                {
                    triggerB =
                        triggerB.EndAt(DateBuilder.DateOf(StopHour, StopMinute, StopSecond, StopDate.Day, StopDate.Month,
                                                          StopDate.Year));
                }
            }

            trigger = triggerB.Build();


            // Schedule the job using the job and trigger
            sched.ScheduleJob(job, trigger);
            sched.Start();

            if (_bracketingViewModel != null)
            {
                _bracketingViewModel.Stop();
            }
            _bracketingViewModel = null;
            IsRunning            = true;
            _timeLapseStartTime  = DateTime.Now;
            _lastCaptureTime     = DateTime.Now;
            Log.Debug("Timelapse start");
            _totalCaptures  = 0;
            _timer.Interval = 1000;
            _timer.Start();
            _lastTime = DateTime.Now;
            TimeLapseSettings.Started = true;
            ServiceProvider.Settings.Save(ServiceProvider.Settings.DefaultSession);
        }
예제 #7
0
        void _timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            TimeDiff += (DateTime.Now - _lastTime).TotalMilliseconds - (1000 * Resolution);
            _lastTime = DateTime.Now;

            if (!IsActive)
            {
                IsActive = CheckStart();
                if (IsActive)
                {
                    _firstLapseStartTime = DateTime.Now;
                }
            }
            RaisePropertyChanged(() => StatusText);
            if (!IsActive)
            {
                return;
            }
            if (IsActive)
            {
                if (Math.Round((DateTime.Now - _lastCaptureTime).TotalSeconds) >= TimeBetweenShots || (FullSpeed && !ServiceProvider.DeviceManager.SelectedCameraDevice.IsBusy))
                {
                    _lastCaptureTime = DateTime.Now;
                    _totalCaptures++;
                    try
                    {
                        if (Capture)
                        {
                            if (Bracketing)
                            {
                                if (_bracketingViewModel == null)
                                {
                                    _bracketingViewModel = new BracketingViewModel();
                                }
                                Task.Factory.StartNew(new Action(_bracketingViewModel.Start));
                                StaticHelper.Instance.SystemMessage = _bracketingViewModel.Error;
                            }
                            else
                            {
                                ServiceProvider.WindowsManager.ExecuteCommand(CmdConsts.Capture);
                            }
                        }
                        if (CaptureAll)
                        {
                            ServiceProvider.WindowsManager.ExecuteCommand(CmdConsts.CaptureAll);
                        }
                        if (CaptureScript)
                        {
                            if (Path.GetExtension(ScriptFile.ToLower()) == ".tcl")
                            {
                                try
                                {
                                    var manager = new TclScripManager();
                                    manager.Execute(File.ReadAllText(ScriptFile));
                                }
                                catch (Exception exception)
                                {
                                    Log.Error("Script error", exception);
                                    StaticHelper.Instance.SystemMessage = "Script error :" + exception.Message;
                                }
                            }
                            else
                            {
                                var script = ServiceProvider.ScriptManager.Load(ScriptFile);
                                script.CameraDevice = ServiceProvider.DeviceManager.SelectedCameraDevice;
                                ServiceProvider.ScriptManager.Execute(script);
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        Log.Error("Timelapse error ", exception);
                        StaticHelper.Instance.SystemMessage = "Capture error";
                    }
                }
                if (CheckStop())
                {
                    IsActive = false;
                    if (!StartDaily)
                    {
                        IsRunning = false;
                        _timer.Stop();
                    }
                }
            }
        }