Ejemplo n.º 1
0
 public int Parse(string[] args)
 {
     if (args == null || args.Length == 0)
     {
         Console.WriteLine("Wrong usage");
         Console.WriteLine("Parameters");
         Console.WriteLine("/c <one line command>");
         Console.WriteLine("/host <host address>");
         Console.WriteLine("/clean");
         Console.ReadLine();
         return(-1);
     }
     try
     {
         var arguments = new InputArguments(args, "/", true);
         if (!arguments.Contains("/c"))
         {
             Console.WriteLine("Missing command");
             Console.WriteLine("/c <one line command>");
             return(-1);
         }
         string mess = Send(arguments["/c"], "DCCPipe", arguments.Contains("/host") ? arguments["/host"] : ".",
                            15000);
         if (arguments.Contains("/clean"))
         {
             var lines = PipeServerT.Pharse(mess);
             if (lines.ContainsKey("response"))
             {
                 if (lines["response"].StartsWith("["))
                 {
                     var list = JsonConvert.DeserializeObject <List <string> >(lines["response"]);
                     foreach (string s in list)
                     {
                         Console.WriteLine(s);
                     }
                 }
                 else
                 {
                     Console.WriteLine(lines["response"]);
                 }
             }
             else
             {
                 Console.WriteLine(lines["message"]);
             }
         }
         else
         {
             Console.WriteLine(mess);
         }
         return(0);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error :");
         Console.WriteLine(ex.Message);
         Console.WriteLine(ex.StackTrace);
         return(-1);
     }
 }
Ejemplo n.º 2
0
        //[STAThread]
        static int  Main(string[] args)
        {
            Console.WriteLine("digiCamControl command line utility");
            Console.WriteLine();
            _arguments = new InputArguments(args, "/");
            if (!args.Any() || _arguments.Contains("help"))
            {
                ShowHelp();
                Console.ReadLine();
                return(0);
            }
            InitApplication();
            if (ServiceProvider.DeviceManager.ConnectedDevices.Count == 0)
            {
                Console.WriteLine("No connected device was found ! Exiting");
                return(0);
            }
            int exitCodes = ExecuteArgs();

            Thread.Sleep(500);
            while (CamerasAreBusy())
            {
                Thread.Sleep(1);
            }
            if (_arguments.Contains("wait"))
            {
                int time = 0;
                int.TryParse(_arguments["wait"], out time);
                if (time > 0)
                {
                    Console.Write("Waiting {0} milliseconds", time);
                    Thread.Sleep(time);
                }
                else
                {
                    Console.Write("Press any key ...");
                    Console.ReadLine();
                }
            }
            return(exitCodes);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Attempts to read connection properties from input arguments and sets Config properties accordingly.
        /// <para>Input arguments must contain the following keys: -server SERVER_NAME -database DATABASE_NAME -username USERNAME -password PASSWORD</para>
        /// </summary>
        /// <param name="args">Args to set connection properties from.</param>
        /// <returns>True if all properties are available and set, otherwise false.</returns>
        internal static bool TrySetConnectionParameters(InputArguments args)
        {
            if (args.Contains("server"))
            {
                Config.Instance.Server = args["server"];
            }
            else
            {
                return(false);
            }

            if (args.Contains("database"))
            {
                Config.Instance.Database = args["database"];
            }
            else
            {
                return(false);
            }

            if (args.Contains("username"))
            {
                Config.Instance.Username = args["username"];
            }
            else
            {
                return(false);
            }

            if (args.Contains("password"))
            {
                Config.Instance.Password = args["password"];
            }
            else
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Attempts to read connection properties from input arguments and sets Config properties accordingly.
        /// <para>Input arguments must contain the following keys: -database DATABASE_FILE_PATH</para>
        /// </summary>
        /// <param name="args">Args to set connection properties from.</param>
        /// <returns>True if all properties are available and set, otherwise false.</returns>
        internal static bool TrySetConnectionParameters(InputArguments args)
        {
            if (args.Contains("database"))
            {
                Config.Instance.Database = args["database"];
            }
            else
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 5
0
        //[STAThread]
        static int  Main(string[] args)
        {
            Console.WriteLine("digiCamControl command line utility");
            Console.WriteLine();

            _arguments = new InputArguments(args, "/");
            if (!args.Any() || _arguments.Contains("help"))
            {
                ShowHelp();
                Console.ReadLine();
                return(0);
            }
            InitApplication();
            Thread.Sleep(1000);
            while (CamerasAreBusy())
            {
                Thread.Sleep(1);
            }
            if (args != null && args.Count() == 1 && File.Exists(args[0]))
            {
                RunScript(args[0]);
                return(0);
            }
            if (ServiceProvider.DeviceManager.ConnectedDevices.Count == 0)
            {
                Console.WriteLine("No connected device was found ! Exiting");
                return(0);
            }
            int exitCodes = ExecuteArgs();

            Thread.Sleep(250);
            Thread thread = new Thread(WaitForCameras);

            thread.Start();

            Dispatcher.Run();

            return(exitCodes);
        }
Ejemplo n.º 6
0
        //[STAThread]
        private static int Main(string[] args)
        {
            Console.WriteLine("digiCamControl command line utility");
            Console.WriteLine();

            _arguments = new InputArguments(args, "/");
            if (!args.Any() || _arguments.Contains("help"))
            {
                ShowHelp();
                Console.ReadLine();
                return 0;
            }
            InitApplication();
            Thread.Sleep(1000);
            while (CamerasAreBusy())
            {
                Thread.Sleep(1);
            }
            if (args != null && args.Count() == 1 && File.Exists(args[0]))
            {
                RunScript(args[0]);
                return 0;
            }
            if (ServiceProvider.DeviceManager.ConnectedDevices.Count == 0)
            {
                Console.WriteLine("No connected device was found ! Exiting");
                return 0;
            }
            int exitCodes = ExecuteArgs();
            Thread.Sleep(250);
            Thread thread = new Thread(WaitForCameras);
            thread.Start();

            Dispatcher.Run();

            return exitCodes;
        }
Ejemplo n.º 7
0
        static void WaitForCameras()
        {
            while (CamerasAreBusy())
            {
                Thread.Sleep(1);
            }
            if (_arguments.Contains("wait"))
            {
                int time = 0;
                int.TryParse(_arguments["wait"], out time);
                if (time > 0)
                {
                    Dispatcher.CurrentDispatcher.Invoke(
                        new Action(() => Console.Write("Waiting {0} milliseconds", time)));

                    Thread.Sleep(time);
                }
                else
                {
                    Dispatcher.CurrentDispatcher.Invoke(new Action(() => Console.Write("Press any key ...")));

                    Console.ReadLine();
                }
            }
            System.Environment.Exit(0);
        }
Ejemplo n.º 8
0
        //[STAThread]
        private static int Main(string[] args)
        {
            ServiceProvider.ConfigureLog();
            Log.InfoWithWriteLine("digiCamControl command line utility running\n");

            _arguments = new InputArguments(args, "/");
            if (!args.Any() || _arguments.Contains("help"))
            {
                ShowHelp();
                Console.ReadLine();
                return(0);
            }
            if (_arguments.Contains("verbose"))
            {
                Log.IsVerbose = true;
                Log.InfoWithWriteLine(String.Format("Running in /verbose mode\n\t{0}\n\t{1}\n", ApplicationInformation.ExecutingAssembly, ApplicationInformation.CompileDate));
            }

            if (Log.IsVerbose)
            {
                Log.VerboseWithWriteLine("Input arguments:");
                int argc = 0;
                foreach (string arg in args)
                {
                    Log.VerboseWithWriteLine(String.Format("     [{0,-2}]. {1}", argc, arg));
                    argc++;
                }
                Log.VerboseWithWriteLine(String.Format("\nProcessed arguments:\n{0}\n", _arguments.ToString("     ")));
            }

            InitApplication();
            Thread.Sleep(1000);
            while (CamerasAreBusy())
            {
                Thread.Sleep(1);
            }
            if (args != null && args.Count() == 1 && File.Exists(args[0]))
            {
                RunScript(args[0]);
                return(0);
            }
            if (ServiceProvider.DeviceManager.ConnectedDevices.Count == 0)
            {
                Console.WriteLine("No connected device was found ! Exiting");
                return(0);
            }
            int exitCodes = ExecuteArgs();

            Thread.Sleep(250);

            if ((Log.IsVerbose) && (_arguments.Contains("capture") ||
                                    _arguments.Contains("capturenoaf") ||
                                    _arguments.Contains("captureall") ||
                                    _arguments.Contains("captureallnoaf")))
            {
                /* We report this here, since the capture command has already fired above and that populated the data! */
                foreach (CameraControl.Devices.BaseCameraDevice _b in ServiceProvider.DeviceManager.ConnectedDevices)
                {
                    StringBuilder c = new StringBuilder(_b.ToString());

                    c.Append(String.Format("\n\tAdvanced properties ({0}):", _b.AdvancedProperties.Count));
                    foreach (Object x in _b.AdvancedProperties)
                    {
                        if (x is CameraControl.Devices.Classes.PropertyValue <long> )
                        {
                            CameraControl.Devices.Classes.PropertyValue <long> l = (CameraControl.Devices.Classes.PropertyValue <long>)x;
                            c.Append(String.Format("\n\t\t{0} {1}", l.Tag, l.Value));
                        }
                        else if (x is CameraControl.Devices.Classes.PropertyValue <int> )
                        {
                            CameraControl.Devices.Classes.PropertyValue <int> i = (CameraControl.Devices.Classes.PropertyValue <int>)x;
                            c.Append(String.Format("\n\t\t{0} {1}", i.Tag, i.Value));
                        }
                        else if (x is CameraControl.Devices.Classes.PropertyValue <uint> )
                        {
                            CameraControl.Devices.Classes.PropertyValue <uint> u = (CameraControl.Devices.Classes.PropertyValue <uint>)x;
                            c.Append(String.Format("\n\t\t{0} {1}", u.Tag, u.Value));
                        }
                    }
                    Log.VerboseWithWriteLineAlways(c);
                }
            }

            Thread thread = new Thread(WaitForCameras);

            thread.Start();

            Dispatcher.Run();

            return(exitCodes);
        }
Ejemplo n.º 9
0
        static int ExecuteArgs()
        {
            try
            {
                if (_arguments.Contains("session"))
                {
                    PhotoSession session = ServiceProvider.Settings.GetSession(_arguments["session"]);
                    if (session != null)
                    {
                        Console.WriteLine("Using session {0}", _arguments["session"]);
                        ServiceProvider.Settings.DefaultSession = session;
                    }
                    else
                    {
                        Console.WriteLine("Session not found {0}! Using default session", _arguments["session"]);
                    }
                }
                if (_arguments.Contains("preset"))
                {
                    CameraPreset preset = ServiceProvider.Settings.GetPreset(_arguments["preset"]);
                    if (preset != null)
                    {
                        Console.WriteLine("Using preset {0}", _arguments["preset"]);
                        foreach (ICameraDevice cameraDevice in ServiceProvider.DeviceManager.ConnectedDevices)
                        {
                            preset.Set(cameraDevice);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Preset not found {0}!", _arguments["preset"]);
                    }
                }
                if (_arguments.Contains("folder"))
                {
                    if (string.IsNullOrEmpty(_arguments["folder"]))
                    {
                        Console.WriteLine("No folder !!!");
                    }
                    else
                    {
                        ServiceProvider.Settings.DefaultSession.Folder = _arguments["folder"];
                    }
                }
                if (_arguments.Contains("filenametemplate"))
                {
                    if (string.IsNullOrEmpty(_arguments["filenametemplate"]))
                    {
                        Console.WriteLine("Wrong filename !!!");
                    }
                    else
                    {
                        ServiceProvider.Settings.DefaultSession.FileNameTemplate = _arguments["filenametemplate"];
                    }
                }
                if (_arguments.Contains("counter"))
                {
                    int    i   = 0;
                    string val = _arguments["counter"];
                    if (string.IsNullOrEmpty(_arguments["counter"]) || !int.TryParse(val, out i))
                    {
                        Console.WriteLine("Wrong counter !!!");
                    }
                    else
                    {
                        ServiceProvider.Settings.DefaultSession.Counter = i;
                    }
                }
                if (_arguments.Contains("filename"))
                {
                    _outFilename = _arguments["filename"];
                    //if(string.IsNullOrEmpty(_outFilename))
                    //{
                    //    SaveFileDialog dlg = new SaveFileDialog();
                    //    dlg.Filter = "Jpg file (*.jpg)|*.jpg|All files|*.*";
                    //    if(dlg.ShowDialog()==DialogResult.OK)
                    //    {
                    //        _outFilename = dlg.FileName;
                    //    }
                    //}
                }
                if (_arguments.Contains("iso"))
                {
                    if (string.IsNullOrEmpty(_arguments["iso"]))
                    {
                        Console.WriteLine("No iso number !!!");
                    }
                    else
                    {
                        Thread.Sleep(200);
                        ServiceProvider.DeviceManager.SelectedCameraDevice.IsoNumber.SetValue(_arguments["iso"]);
                    }
                }
                if (_arguments.Contains("aperture"))
                {
                    if (string.IsNullOrEmpty(_arguments["aperture"]))
                    {
                        Console.WriteLine("No aperture number !!!");
                    }
                    else
                    {
                        Thread.Sleep(200);
                        ServiceProvider.DeviceManager.SelectedCameraDevice.FNumber.SetValue("ƒ/" + _arguments["aperture"]);
                    }
                }
                if (_arguments.Contains("shutter"))
                {
                    if (string.IsNullOrEmpty(_arguments["shutter"]))
                    {
                        Console.WriteLine("No shutter number !!!");
                    }
                    else
                    {
                        Thread.Sleep(200);
                        ServiceProvider.DeviceManager.SelectedCameraDevice.ShutterSpeed.SetValue(_arguments["shutter"]);
                    }
                }
                if (_arguments.Contains("ec"))
                {
                    if (string.IsNullOrEmpty(_arguments["ec"]))
                    {
                        Console.WriteLine("No ec number !!!");
                    }
                    else
                    {
                        Thread.Sleep(200);
                        ServiceProvider.DeviceManager.SelectedCameraDevice.ExposureCompensation.SetValue(_arguments["ec"]);
                    }
                }
                if (_arguments.Contains("capture"))
                {
                    try
                    {
                        ServiceProvider.DeviceManager.SelectedCameraDevice.CapturePhoto();
                    }
                    catch (Exception exception)
                    {
                        ServiceProvider.DeviceManager.SelectedCameraDevice.IsBusy = false;
                        Console.WriteLine("Error occurred while capturing photo " + exception);
                        return(1);
                    }
                    return(0);
                }
                if (_arguments.Contains("capturenoaf"))
                {
                    try
                    {
                        ServiceProvider.DeviceManager.SelectedCameraDevice.CapturePhotoNoAf();
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine("Error occurred while capturing photo " + exception);
                        ServiceProvider.DeviceManager.SelectedCameraDevice.IsBusy = false;
                        return(1);
                    }

                    return(0);
                }
                if (_arguments.Contains("captureall"))
                {
                    foreach (ICameraDevice cameraDevice in ServiceProvider.DeviceManager.ConnectedDevices)
                    {
                        ICameraDevice device = cameraDevice;
                        new Thread(device.CapturePhoto).Start();
                    }
                }
                if (_arguments.Contains("captureallnoaf"))
                {
                    foreach (ICameraDevice cameraDevice in ServiceProvider.DeviceManager.ConnectedDevices)
                    {
                        ICameraDevice device = cameraDevice;
                        new Thread(device.CapturePhotoNoAf).Start();
                    }
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception);
                Console.WriteLine(exception.Message);
                return(1);
            }
            return(0);
        }
Ejemplo n.º 10
0
 public int Parse(string[] args)
 {
     if (args == null || args.Length == 0)
     {
         Console.WriteLine("Wrong usage");
         ShowHelp();
         return(-1);
     }
     try
     {
         var arguments = new InputArguments(args, "/", true);
         if (arguments.Contains("/help"))
         {
             ShowHelp();
             return(0);
         }
         if (!arguments.Contains("/c"))
         {
             Console.WriteLine("ERROR: Missing command");
             ShowHelp();
             return(-1);
         }
         string mess = Send(arguments["/c"], "DCCPipe", arguments.Contains("/host") ? arguments["/host"] : ".",
                            15000);
         if (arguments.Contains("/clean"))
         {
             var lines = PipeServerT.Pharse(mess);
             if (lines.ContainsKey("response"))
             {
                 if (lines["response"].StartsWith("["))
                 {
                     var list = JsonConvert.DeserializeObject <List <string> >(lines["response"]);
                     foreach (string s in list)
                     {
                         Console.WriteLine(s);
                     }
                 }
                 else if (lines.ContainsKey("message"))
                 {
                     Console.WriteLine(lines["response"] + " " + lines["message"]);
                 }
                 else if (!lines["response"].Equals("null"))
                 {
                     Console.WriteLine(lines["response"]);
                 }
             }
             else
             {
                 Console.WriteLine(lines["message"]);
             }
         }
         else
         {
             Console.WriteLine(mess);
         }
         return(0);
     }
     catch (TimeoutException ex)
     {
         Console.WriteLine("Timeout Error (is the GUI running?):");
         Console.WriteLine(ex.Message);
         Console.WriteLine(ex.StackTrace);
         return(-1);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error :");
         Console.WriteLine(ex.Message);
         Console.WriteLine(ex.StackTrace);
         return(-1);
     }
 }