コード例 #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 CheckForUpdate()
        {
            var scriptFile = ServiceProvider.Settings.StartupScript;

            if (scriptFile != null && File.Exists(scriptFile))
            {
                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);
                }
            }
            if ((DateTime.Now - ServiceProvider.Settings.LastUpdateCheckDate).TotalDays > 7)
            {
                if (!ServiceProvider.Branding.CheckForUpdate)
                {
                    return;
                }

                Thread.Sleep(2000);
                ServiceProvider.Settings.LastUpdateCheckDate = DateTime.Now;
                ServiceProvider.Settings.Save();
                Dispatcher.Invoke(new Action(() => NewVersionWnd.CheckForUpdate(false)));
            }
            else
            {
                if (!ServiceProvider.Branding.ShowWelcomeScreen || !ServiceProvider.Branding.OnlineReference)
                {
                    return;
                }

                // show welcome screen only if not start minimized
                if (!ServiceProvider.Settings.StartMinimized)
                {
                    Dispatcher.Invoke(new Action(() =>
                    {
                        var wnd = new Welcome();
                        wnd.ShowDialog();
                    }));
                }
            }
        }
コード例 #3
0
 private void mnu_run_Click(object sender, RoutedEventArgs e)
 {
     if (IsXmlActive())
     {
         mnu_save_Click(null, null);
         ScriptObject scriptObject = null;
         try
         {
             lst_output.Items.Clear();
             scriptObject = ServiceProvider.ScriptManager.Load(ScriptFileName);
             scriptObject.CameraDevice = ServiceProvider.DeviceManager.SelectedCameraDevice;
         }
         catch (Exception exception)
         {
             AddOutput("Loading error :" + exception.Message);
             return;
         }
         if (ServiceProvider.ScriptManager.Verify(scriptObject))
         {
             ServiceProvider.ScriptManager.Execute(scriptObject);
         }
         else
         {
             AddOutput("Error in script. Running aborted ! ");
         }
     }
     else
     {
         try
         {
             lst_outputTcl.Items.Clear();
             _manager.Execute(textEditorTcl.Text);
         }
         catch (Exception exception)
         {
             AddOutput("Error in script. Running aborted ! ");
         }
     }
 }
コード例 #4
0
        private void StartupThread()
        {
            foreach (var cameraDevice in ServiceProvider.DeviceManager.ConnectedDevices)
            {
                Log.Debug("cameraDevice_CameraInitDone 1");
                var          property = cameraDevice.LoadProperties();
                CameraPreset preset   = ServiceProvider.Settings.GetPreset(property.DefaultPresetName);
                // multiple canon cameras block with this settings

                if ((cameraDevice is CanonSDKBase && ServiceProvider.Settings.LoadCanonTransferMode) || !(cameraDevice is CanonSDKBase))
                {
                    cameraDevice.CaptureInSdRam = property.CaptureInSdRam;
                }

                Log.Debug("cameraDevice_CameraInitDone 1a");
                if (ServiceProvider.Settings.SyncCameraDateTime)
                {
                    try
                    {
                        cameraDevice.DateTime = DateTime.Now;
                    }
                    catch (Exception exception)
                    {
                        Log.Error("Unable to sysnc date time", exception);
                    }
                }
                if (preset != null)
                {
                    try
                    {
                        Thread.Sleep(500);
                        cameraDevice.WaitForCamera(5000);
                        preset.Set(cameraDevice);
                    }
                    catch (Exception e)
                    {
                        Log.Error("Unable to load default preset", e);
                    }
                }
            }
            var scriptFile = ServiceProvider.Settings.StartupScript;

            if (scriptFile != null && File.Exists(scriptFile))
            {
                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);
                }
            }
            if ((DateTime.Now - ServiceProvider.Settings.LastUpdateCheckDate).TotalDays > 7)
            {
                if (!ServiceProvider.Branding.CheckForUpdate)
                {
                    return;
                }

                Thread.Sleep(2000);
                ServiceProvider.Settings.LastUpdateCheckDate = DateTime.Now;
                ServiceProvider.Settings.Save();
                Dispatcher.Invoke(new Action(() => NewVersionWnd.CheckForUpdate(false)));
            }
            else
            {
                if (!ServiceProvider.Branding.ShowWelcomeScreen || !ServiceProvider.Branding.OnlineReference)
                {
                    return;
                }

                // show welcome screen only if not start minimized
                if (!ServiceProvider.Settings.StartMinimized)
                {
                    Dispatcher.Invoke(() =>
                    {
                        try
                        {
                            var wnd = new Welcome();
                            wnd.ShowDialog();
                        }
                        catch
                        {
                        }
                    });
                }
            }
        }
コード例 #5
0
 void _timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     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)
                 {
                     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();
             }
         }
     }
 }