Exemplo n.º 1
0
    public override Result PlayFile(string filename)
    {
        if (process != null || filename == "")
        {
            return(new Result(false, ""));
        }

        executable = "mplayer";
        List <string> parameters = new List <string>();

        parameters.Insert(0, filename);
        //parameters.Insert (0, "-noborder"); //on X11 can be: title "Chronojump"". -noborder makes no accept 's', or 'q'
        if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.LINUX)
        {
            parameters.Insert(0, "-title");              //on X11 can be: title "Chronojump"". -noborder makes no accept 's', or 'q'
            parameters.Insert(1, "Chronojump video");
        }
        else
        {
            parameters.Insert(0, "-noborder");
        }


        process = new Process();
        bool success = ExecuteProcess.RunAtBackground(ref process, executable, parameters, false, true, false, true, true);

        if (!success)
        {
            process = null;
            return(new Result(false, "", programMplayerNotInstalled));
        }

        Running = true;
        return(new Result(true, ""));
    }
Exemplo n.º 2
0
    private void createButtons()
    {
        FakeButtonCloseSerialPort = new Gtk.Button();
        Gtk.Button button_close_serial_port = new Gtk.Button("Close serial port (debug)");
        button_close_serial_port.Clicked += new EventHandler(on_button_close_serial_port_clicked);

        Gtk.Button button_OSX_readme = new Gtk.Button("MacOSX Readme");
        button_OSX_readme.Clicked += new EventHandler(on_button_OSX_readme_clicked);

        //---- button close start --->
        Gtk.Button button_close = new Gtk.Button("Close Window");
        button_close.Clicked += new EventHandler(on_button_close_clicked);

        Gtk.AccelGroup ag = new Gtk.AccelGroup();          //button can be called clicking Escape key
        chronopic_register_win.AddAccelGroup(ag);

        button_close.AddAccelerator
            ("activate", ag, new Gtk.AccelKey
                (Gdk.Key.Escape, Gdk.ModifierType.None,
                Gtk.AccelFlags.Visible));
        //<---- button close end

        //add buttons to containers
        Gtk.HButtonBox hbox = new Gtk.HButtonBox();
        //hbox.Add(button_close_serial_port);

        if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.MACOSX)
        {
            hbox.Add(button_OSX_readme);
        }

        hbox.Add(button_close);

        vbox_main.Add(hbox);
    }
Exemplo n.º 3
0
    public Config()
    {
        Maximized     = false;
        CustomButtons = false;
        UseVideo      = true;

        //currently disabled AutodetectPort by default on MACOSX
        if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.MACOSX)
        {
            AutodetectPort = AutodetectPortEnum.INACTIVE;
        }
        else
        {
            AutodetectPort = AutodetectPortEnum.ACTIVE;
        }

        OnlyEncoderGravitatory              = false;
        OnlyEncoderInertial                 = false;
        EncoderCaptureShowOnlyBars          = false;
        EncoderUpdateTreeViewWhileCapturing = true;
        PersonWinHide      = false;
        EncoderAnalyzeHide = false;
        SessionMode        = SessionModeEnum.STANDARD;
        RunScriptOnExit    = "";
    }
Exemplo n.º 4
0
    //Not used on encoder
    private void playVideo(string fileName)
    {
        //constructor for playpreview
        webcamPlay = new WebcamFfmpeg(Webcam.Action.PLAYFILE, UtilAll.GetOSEnum(), "", "", "");
        Webcam.Result result = webcamPlay.PlayFile(fileName);

        /*
         * TODO: reimplement this with ffmpeg
         *
         * if(File.Exists(fileName)) {
         *      LogB.Information("Play video starting...");
         *      PlayerBin player = new PlayerBin();
         *      player.Open(fileName);
         *
         *      //without these lines works also but has less functionalities (speed, go to ms)
         *      Gtk.Window d = new Gtk.Window(Catalog.GetString("Playing video"));
         *      d.Add(player);
         *      d.Modal = true;
         *      d.SetDefaultSize(500,400);
         *      d.ShowAll();
         *      d.DeleteEvent += delegate(object sender, DeleteEventArgs e) {player.Close(); player.Dispose();};
         *
         *      if(play) {
         *              LogB.Information("Play video playing...");
         *              player.Play();
         *      }
         *      return true;
         * }
         */
    }
Exemplo n.º 5
0
    /*
     * VIDEO
     */

    public static List <string> GetVideoDevices()
    {
        /*
         * TODO: reimplement this with ffmpeg
         *
         * List<LongoMatch.Video.Utils.Device> devices = LongoMatch.Video.Utils.Device.ListVideoDevices();
         * string [] devicesStr = new String[devices.Count];
         * int count = 0;
         * LogB.Information("Searching video devices");
         * foreach(LongoMatch.Video.Utils.Device dev in devices) {
         *      devicesStr[count++] = dev.ID.ToString();
         *      LogB.Information(dev.ID.ToString());
         * }
         * return devicesStr;
         */


        //on Linux search for video0, video1, ...
        if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.LINUX)
        {
            return(GetVideoDevicesLinux());
        }
        else if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.WINDOWS)
        {
            return(GetVideoDevicesWindows());
        }
        else
        {
            return(new List <string>());
        }
    }
Exemplo n.º 6
0
    public FfmpegCapture(string[] args)
    {
        if (args.Length != 1)
        {
            Console.WriteLine("Need to pass the videoDevice");
            return;
        }

        os          = UtilAll.GetOSEnum();
        videoDevice = args[0];

        if (os == UtilAll.OperatingSystems.WINDOWS)
        {
            captureExecutable = System.IO.Path.Combine(Util.GetPrefixDir(), "bin/ffmpeg.exe");
        }

        process = new Process();
        List <string> parameters = createParametersOnlyCapture();
        //List<string> parameters = createParametersCaptureAndDelayedView();
        bool success = ExecuteProcess.RunAtBackground(ref process, captureExecutable, parameters,
                                                      true, false, true); //createNoWindow, useShellExecute, redirectInput

        if (!success)
        {
            streamWriter = null;
            process      = null;
            //return new Result (false, "", programFfmpegNotInstalled);
            return;
        }

        processID    = process.Id;
        streamWriter = process.StandardInput;
        Running      = true;

        Console.WriteLine("Recording 5 seconds ...");
        for (int countA = 4; countA >= 0; countA--)
        {
            System.Threading.Thread.Sleep(1000);
            Console.WriteLine(countA.ToString());
        }

        int sessionID = 0;

        Constants.TestTypes testType = Constants.TestTypes.RUN;
        int testID = 1;

        ExitAndFinish(sessionID, testType, testID);

        Console.WriteLine("Recorded, copied, and deleted ok. Now we are going to play it");

        PlayFile(Util.GetVideoFileName(sessionID, testType, testID));

        //return new Result (true, "");
    }
Exemplo n.º 7
0
    private void on_button_video_debug_clicked(object o, EventArgs args)
    {
        string executable = "debug";

        if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.WINDOWS)
        {
            executable = System.IO.Path.Combine(Util.GetPrefixDir(), "bin/debug.bat");
        }

        LogB.Information("Calling debug: " + executable);
        ExecuteProcess.Result execute_result = ExecuteProcess.run(executable, true, true);
        LogB.Information("Called debug.");
    }
Exemplo n.º 8
0
    private void createButtons()
    {
        Frame frame = new Frame();

        frame.ShadowType  = ShadowType.In;
        frame.LabelXalign = 0f;
        frame.LabelYalign = 0.5f;

        frame.Label = Catalog.GetString("There is a known problem on macOS:");
        Gtk.Label label_macOS = new Gtk.Label(
            Catalog.GetString("If Chronopic is disconnected after jumps or runs execution,\nthat port will be blocked until restart of machine."));

        Gtk.VBox vbox_m = new Gtk.VBox();
        vbox_m.PackStart(label_macOS, false, false, 8);

        Gtk.HBox hbox_m = new Gtk.HBox();
        hbox_m.PackStart(vbox_m, false, false, 8);

        if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.MACOSX)
        {
            frame.Add(hbox_m);
            vbox_main.Add(frame);
        }

        FakeButtonCloseSerialPort = new Gtk.Button();
        Gtk.Button button_close_serial_port = new Gtk.Button("Close serial port (debug)");
        button_close_serial_port.Clicked += new EventHandler(on_button_close_serial_port_clicked);

        //---- button close start --->
        Gtk.Button button_close = new Gtk.Button("Close Window");
        button_close.CanFocus = true;
        button_close.IsFocus  = true;
        button_close.Clicked += new EventHandler(on_button_close_clicked);

        Gtk.AccelGroup ag = new Gtk.AccelGroup();          //button can be called clicking Escape key
        chronopic_register_win.AddAccelGroup(ag);

        button_close.AddAccelerator
            ("activate", ag, new Gtk.AccelKey
                (Gdk.Key.Escape, Gdk.ModifierType.None,
                Gtk.AccelFlags.Visible));
        //<---- button close end

        //add buttons to containers
        Gtk.HButtonBox hbox = new Gtk.HButtonBox();
        //hbox.Add(button_close_serial_port);

        hbox.Add(button_close);

        vbox_main.Add(hbox);
    }
Exemplo n.º 9
0
    public static List <string> GetDevices()
    {
        string executable = "ffmpeg";

        if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.WINDOWS)
        {
            executable = System.IO.Path.Combine(Util.GetPrefixDir(), "bin/ffmpeg.exe");
        }

        List <string> parameters = createParameters();

        ExecuteProcess.Result execute_result = ExecuteProcess.run(executable, parameters);

        Console.WriteLine("---- stdout: ----");
        Console.WriteLine(execute_result.stdout);
        Console.WriteLine("---- stderr: ----");
        Console.WriteLine(execute_result.stderr);
        Console.WriteLine("-----------------");

        if (!execute_result.success)
        {
            Console.WriteLine("WebcamFfmpegGetDevicesWindows error: " + execute_result.stderr);

            /*
             * on Windows the -i dummy produces an error, so stderr exists and success is false
             * stdout has the list of devices and stderr also
             * check if in stdout there's the: "DirectShow video devices" string and if not exists, really we have an error
             */
            if (execute_result.stdout != null && execute_result.stdout != "" &&
                execute_result.stdout.Contains("DirectShow video devices"))
            {
                Console.WriteLine("Calling parse with stdout");
                return(parse(execute_result.stdout));
            }

            if (execute_result.stderr != null && execute_result.stderr != "" &&
                execute_result.stderr.Contains("DirectShow video devices"))
            {
                Console.WriteLine("Calling parse with stderr");
                return(parse(execute_result.stderr));
            }

            return(new List <string>());
        }
        else
        {
            return(parse(execute_result.stdout));
        }
    }
Exemplo n.º 10
0
 public ChronopicRegister Do()
 {
     if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.LINUX)
     {
         return(new ChronopicRegisterLinux());
     }
     else if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.MACOSX)
     {
         return(new ChronopicRegisterMac());
     }
     else         // WINDOWS
     {
         return(new ChronopicRegisterWindows());
     }
 }
Exemplo n.º 11
0
 public static string [] GetPorts()
 {
     if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.LINUX)
     {
         return(Directory.GetFiles("/dev/", "ttyUSB*"));
     }
     else if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.MACOSX)
     {
         return(Directory.GetFiles("/dev/", "tty.usbserial*"));
     }
     else         // WINDOWS
     {
         return(SerialPort.GetPortNames());
     }
 }
Exemplo n.º 12
0
    protected string pBinURL()
    {
        string pBin = "Rscript";

        if (UtilAll.IsWindows())
        {
            //on Windows we need the \"str\" to call without problems in path with spaces
            pBin = "\"" + System.IO.Path.Combine(Util.GetPrefixDir(), "bin" + Path.DirectorySeparatorChar + "Rscript.exe") + "\"";
        }
        else if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.MACOSX)
        {
            pBin = Constants.RScriptOSX;
        }

        LogB.Information("pBin:", pBin);
        return(pBin);
    }
Exemplo n.º 13
0
    private void on_button_video_watch_clicked(object o, EventArgs args)
    {
        if (File.Exists(videoFileName))
        {
            LogB.Information("Exists and clicked " + videoFileName);

            /*
             * using mplayer
             *
             * Webcam webcam = new WebcamMplayer ();
             * Webcam.Result result = webcam.PlayFile(videoFileName);
             */

            //using ffmpeg
            Webcam        webcam = new WebcamFfmpeg(Webcam.Action.PLAYFILE, UtilAll.GetOSEnum(), "", "", "");
            Webcam.Result result = webcam.PlayFile(videoFileName);
        }
    }
Exemplo n.º 14
0
    private void startChronojump(bool sendLog)
    {
        //wait until all sql calls are done in other thread
        //then there will be no more a try to open an already opened dbcon
        LogB.SQL("Checking if all SQL calls done on sqliteThings thread");
        while (!allSQLCallsDoneOnSqliteThingsThread)
        {
        }
        LogB.SQL("all SQL done! starting Chronojump");

        string topMessage = "";

        if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.LINUX && !linuxUserHasDialout())
        {
            topMessage = Catalog.GetString("Need dialout permissions to read from device.") + "\n" +
                         Catalog.GetString("Check software page on Chronojump website");
        }

        new ChronoJumpWindow(progVersion, progName, runningFileName, splashWin, sendLog, messageToShowOnBoot, topMessage);
    }
Exemplo n.º 15
0
    /*
     * VIDEO
     */

    public static WebcamDeviceList GetVideoDevices()
    {
        WebcamFfmpegGetDevices w;

        if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.LINUX)
        {
            w = new WebcamFfmpegGetDevicesLinux();
        }
        else if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.WINDOWS)
        {
            w = new WebcamFfmpegGetDevicesWindows();
        }
        else
        {
            w = new WebcamFfmpegGetDevicesMac();
        }

        WebcamDeviceList wd_list = w.GetDevices();

        return(wd_list);
    }
Exemplo n.º 16
0
    private void createButtons()
    {
        label_macOSX      = new Gtk.Label();
        label_macOSX.Text = Catalog.GetString("There is a known problem with MacOSX:") + "\n" +
                            Catalog.GetString("If Chronopic is disconnected after jumps or runs execution,\nthat port will be blocked until restart of machine.") + "\n\n" +
                            Catalog.GetString("We are working on a solution.");
        if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.MACOSX)
        {
            vbox_main.Add(label_macOSX);
        }

        FakeButtonCloseSerialPort = new Gtk.Button();
        Gtk.Button button_close_serial_port = new Gtk.Button("Close serial port (debug)");
        button_close_serial_port.Clicked += new EventHandler(on_button_close_serial_port_clicked);

        //---- button close start --->
        Gtk.Button button_close = new Gtk.Button("Close Window");
        button_close.Clicked += new EventHandler(on_button_close_clicked);

        Gtk.AccelGroup ag = new Gtk.AccelGroup();          //button can be called clicking Escape key
        chronopic_register_win.AddAccelGroup(ag);

        button_close.AddAccelerator
            ("activate", ag, new Gtk.AccelKey
                (Gdk.Key.Escape, Gdk.ModifierType.None,
                Gtk.AccelFlags.Visible));
        //<---- button close end

        //add buttons to containers
        Gtk.HButtonBox hbox = new Gtk.HButtonBox();
        //hbox.Add(button_close_serial_port);

        hbox.Add(button_close);

        vbox_main.Add(hbox);
    }
Exemplo n.º 17
0
 public WebcamManage()
 {
     os            = UtilAll.GetOSEnum();
     ReallyStarted = false;
 }
Exemplo n.º 18
0
    public static void Main(string [] args)
    {    /*
          *     bool timeLogPassedOk = Log.Start(args);
          *     Log.WriteLine(string.Format("Time log passed: {0}", timeLogPassedOk.ToString()));
          *     Log.WriteLine(string.Format("Client database option 1 in ... " + Util.GetDatabaseDir()));
          *     Log.WriteLine(string.Format("Client database option 2 in ... " + Util.GetDatabaseTempDir()));
          */
        LogSync.Initialize();
        //1.4.10
        Log.Start();
        LogB.Debugging = true;         //now LogB.Debug will be shown. Also there will be thread info on Warning, Error, Information
        if (args.Length > 0 && args[0] == "printAll")
        {
            LogB.PrintAllThreads = true;
        }

        var envPath  = Environment.GetEnvironmentVariable("PATH");
        var rBinPath = "";

        baseDirectory = Util.GetPrefixDir();

        /*
         * location of gtkrc file
         * DISABLED tight now because on windows there are inestabilities on jumps results
         * and on Mode menu
         */
        //Rc.AddDefaultFile (Util.GetThemeFile());
        //LogB.Information("gtk theme:" + Util.GetThemeFile());

        if (UtilAll.IsWindows())
        {
            //Environment.SetEnvironmentVariable ("R_HOME", RelativeToPrefix ("library"));
            //rBinPath = RelativeToPrefix ("lib");
            //rBinPath = RelativeToPrefix ("library");
            //var rPath = System.Environment.Is64BitProcess ? @"C:\Program Files\R\R-3.0.2\bin\x64" : @"C:\Program Files\R\R-3.0.2\bin\i386";
            string x64   = "bin" + System.IO.Path.DirectorySeparatorChar + "x64";
            string i386  = "bin" + System.IO.Path.DirectorySeparatorChar + "i386";
            var    rPath = System.Environment.Is64BitProcess ?
                           System.IO.Path.Combine(baseDirectory, x64) : System.IO.Path.Combine(baseDirectory, i386);

            if (Directory.Exists(rPath) == false)
            {
                LogB.Error("Could not found the specified path to the directory containing R.dll: ", rPath);
                throw new DirectoryNotFoundException(string.Format("Could not found the specified path to the directory containing R.dll: {0}", rPath));
            }

            var newPath = string.Format("{0}{1}{2}", rPath, System.IO.Path.PathSeparator, envPath);
            LogB.Information("newPath:", newPath);

            System.Environment.SetEnvironmentVariable("PATH", newPath);
            LogB.Information("path:", System.Environment.GetEnvironmentVariable("PATH"));

            //use this because we don't want to look at the registry
            //we don't want to force user to install R
            Environment.SetEnvironmentVariable("R_HOME", baseDirectory);
            LogB.Information("R_HOME:", baseDirectory);
        }
        else
        {
            switch (UtilAll.GetOSEnum())
            {
            case UtilAll.OperatingSystems.MACOSX:
                LogB.Information(Environment.GetEnvironmentVariable("R_HOME"));
                rBinPath = "/Library/Frameworks/R.Framework/Libraries";
                Environment.SetEnvironmentVariable("R_HOME", "/Library/Frameworks/R.Framework/Resources");
                Environment.SetEnvironmentVariable("PATH", rBinPath + Path.PathSeparator + envPath);
                LogB.Information("environments");
                LogB.Information(Environment.GetEnvironmentVariable("R_HOME"));
                LogB.Information(Environment.GetEnvironmentVariable("PATH"));

                //Gstreamer stuff
                string prefix = "/Applications/Chronojump.app/Contents/Home/";
                Environment.SetEnvironmentVariable("GST_PLUGIN_PATH", prefix + "lib/gstreamer-0.10");
                Environment.SetEnvironmentVariable("GST_PLUGIN_SYSTEM_PATH", prefix + "lib/gstreamer-0.10");
                Environment.SetEnvironmentVariable("GST_PLUGIN_SCANNER_PATH", prefix + "lib/gstreamer-0.10/gst-plugin-scanner");
                break;

            case UtilAll.OperatingSystems.LINUX:
                rBinPath = @"/usr/lib/R/lib";
                Environment.SetEnvironmentVariable("R_HOME", @"/usr/lib/R");
                Environment.SetEnvironmentVariable("PATH", envPath + Path.PathSeparator + rBinPath);
                break;
            }
        }

        LogB.Information("Platform:" + Environment.OSVersion.Platform);

        LogB.Information("baseDir0:", System.AppDomain.CurrentDomain.BaseDirectory);
        LogB.Information("baseDir1:", baseDirectory);
        LogB.Information("envPath+rBinPath:", envPath + Path.PathSeparator + rBinPath);


        //UtilCSV.ReadValues("/tmp/chronojump-encoder-graph-input-multi.csv");

        if (UtilAll.IsWindows())
        {
            Environment.SetEnvironmentVariable("GST_PLUGIN_PATH", RelativeToPrefix("lib\\gstreamer-0.10"));
        }

        //this call has to be done to chronojump.prg
        //chronojump.prg createBlankDB
        //this creates a blank database and exists.
        //Then new user will have an updated database without the need of creating in
        if (args.Length > 0 && args[0] == "createBlankDB")
        {
            createBlankDB();
            Environment.Exit(1);
        }

        if (args.Length > 0 && args[0] == "createBlankDBServer")
        {
            createBlankDBServer();
            Environment.Exit(1);
        }


        string language = "";

        if (File.Exists(System.IO.Path.Combine(Util.GetDatabaseDir(), "chronojump.db")))
        {
            try {
                Sqlite.Connect();

                /*
                 * chronojump 1.5.2 converts DB 1.24 to 1.25 changing language to ""
                 * but this operation is done later (on sqliteThings)
                 * We need here! to define the language from the beginning
                 * so we use language = "" if version is prior to 1.25
                 */
                string currentDBVersion       = SqlitePreferences.Select("databaseVersion", false);
                double currentDBVersionDouble = Convert.ToDouble(Util.ChangeDecimalSeparator(currentDBVersion));
                if (currentDBVersionDouble < Convert.ToDouble(Util.ChangeDecimalSeparator("1.25")))
                {
                    language = "";
                }
                else
                {
                    language = SqlitePreferences.Select("language", false);
                }

                Sqlite.DisConnect();

                if (language != "")
                {
                    //convert pt-BR to pt_BR
                    if (language.Contains("-"))
                    {
                        language = language.Replace("-", "_");
                    }

                    Environment.SetEnvironmentVariable("LANGUAGE", language);              //works
#if OSTYPE_WINDOWS
                    g_setenv("LANGUAGE", language, true);
#endif
                }
            }
            catch {
                LogB.Warning("Problem reading language on start");
            }
        }

        Catalog.Init("chronojump", System.IO.Path.Combine(Util.GetPrefixDir(), "share/locale"));

        new ChronoJump(args);
    }
Exemplo n.º 19
0
    public override Result CapturePrepare(CaptureTypes captureType)
    {
        if (process != null)
        {
            return(new Result(false, ""));
        }

        string tempFile = Util.GetWebcamPhotoTempFileNamePost(videoDeviceToFilename());

        Util.FileDelete(tempFile);

        List <string> parameters = new List <string>();
        //-noborder -nosound -tv driver=v4l2:gain=1:width=400:height=400:device=/dev/video0:fps=10:outfmt=rgb16 tv:// -vf screenshot=/tmp/chronojump-last-photo
        //parameters.Insert (0, "-noborder"); //on X11 can be: title "Chronojump"". -noborder makes no accept 's', or 'q'

        int i = 0;

        if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.LINUX)
        {
            parameters.Insert(i++, "-title");               //on X11 can be: title "Chronojump"". -noborder makes no accept 's', or 'q'
            if (captureType == CaptureTypes.PHOTO)
            {
                parameters.Insert(i++, "Chronojump snapshot");
            }
            else             //if(captureType == CaptureTypes.VIDEO)
            {
                parameters.Insert(i++, "Chronojump video record");
            }
        }
        else
        {
            parameters.Insert(i++, "-noborder");
        }

        parameters.Insert(i++, "-nosound");
        parameters.Insert(i++, "-tv");
        parameters.Insert(i++, "driver=v4l2:gain=1:width=400:height=400:device=" + videoDevice + ":fps=10:outfmt=rgb16");
        parameters.Insert(i++, "tv://");
        parameters.Insert(i++, "-vf");
        parameters.Insert(i++, "screenshot=" + Util.GetWebcamPhotoTempFileNamePre(videoDeviceToFilename()));

        process = new Process();
        bool success = ExecuteProcess.RunAtBackground(ref process, executable, parameters, true, false, true, true, true);          //redirectInput, redirectOutput, redirectError

        if (!success)
        {
            streamWriter = null;
            process      = null;
            return(new Result(false, "", programMplayerNotInstalled));
        }

        /*
         * experimental double camera start
         */
        /*
         * List<string> parametersB = parameters;
         * parametersB[4] = "driver=v4l2:gain=1:width=400:height=400:device=/dev/video1:fps=10:outfmt=rgb16";
         * parametersB[7] = "screenshot=/tmp/b/chronojump-last-photo";
         * Process processB = new Process();
         * ExecuteProcess.RunAtBackground (processB, executable, parametersB, true); //redirectInput
         */
        /*
         * experimental double camera end
         */


        streamWriter = process.StandardInput;
        Running      = true;

        return(new Result(true, ""));
    }
Exemplo n.º 20
0
    private void configInit()
    {
        //trying new Config class
        configChronojump = new Config();
        configChronojump.Read();
        LogB.Information("Config:\n" + configChronojump.ToString());

        /*
         * TODO: do an else to any option
         * is good to do the else here because user can import a configuration at any time
         * and things need to be restored to default position in glade
         *
         * But note this has to be executed only if it has changed!!
         */

        if (configChronojump.Maximized)
        {
            app1.Maximize();
        }
        if (configChronojump.CustomButtons)
        {
            //---- capture tab ----

            hbox_encoder_capture_extra_mass_no_raspberry.Visible = false;
            hbox_encoder_capture_extra_mass_raspberry.Visible    = true;

            button_encoder_select.HeightRequest = 40;
            //this will make all encoder capture controls taller
            button_encoder_capture.SetSizeRequest(125, 60);

            spin_encoder_im_weights_n.Visible = false;
            hbox_encoder_im_weights_n.Visible = true;

            //---- analyze tab ----

            hbox_encoder_analyze_signal_or_curves.HeightRequest = 40;
            button_encoder_analyze.SetSizeRequest(120, 40);
        }
        if (!configChronojump.UseVideo)
        {
            alignment_video_encoder.Visible = false;
        }

        //show only power
        if (configChronojump.OnlyEncoderGravitatory)
        {
            select_menuitem_mode_toggled(Constants.Menuitem_modes.POWERGRAVITATORY);
        }
        else if (configChronojump.OnlyEncoderInertial)
        {
            select_menuitem_mode_toggled(Constants.Menuitem_modes.POWERINERTIAL);
        }

        if (configChronojump.EncoderCaptureShowOnlyBars)
        {
            //attention: this makes encoder_capture_signal_drawingarea == null
            vpaned_encoder_capture_video_and_set_graph.Visible = false;

            vpaned_encoder_main.Remove(alignment_treeview_encoder_capture_curves);
            vbox_treeview_encoder_at_second_page.PackStart(alignment_treeview_encoder_capture_curves);
            notebook_encoder_capture_main.ShowTabs = true;
        }
        else
        {
            /*
             * is good to do the else here because user can import a configuration at any time
             * and things need to be restored to default position in glade
             *
             * But note this has to be executed only if it has changed!!
             */
            /*
             * notebook_encoder_capture_main.ShowTabs = false;
             * vbox_treeview_encoder_at_second_page.Remove(alignment_treeview_encoder_capture_curves);
             * vpaned_encoder_main.PackStart(alignment_treeview_encoder_capture_curves);
             */
        }

        encoderUpdateTreeViewWhileCapturing = configChronojump.EncoderUpdateTreeViewWhileCapturing;

        if (configChronojump.PersonWinHide)
        {
            //vbox_persons.Visible = false;
            notebook_session_person.Visible = false;
            hbox_encoder_person.Visible     = true;
        }

        if (configChronojump.EncoderAnalyzeHide)
        {
            hbox_encoder_sup_capture_analyze_two_buttons.Visible = false;
        }

        if (configChronojump.SessionMode == Config.SessionModeEnum.UNIQUE || configChronojump.SessionMode == Config.SessionModeEnum.MONTHLY)
        {
            main_menu.Visible = false;
            app1.Decorated    = false;
            hbox_menu_and_preferences_outside_menu.Visible = true;

            if (configChronojump.SessionMode == Config.SessionModeEnum.UNIQUE)
            {
                if (!Sqlite.Exists(false, Constants.SessionTable, "session"))
                {
                    //this creates the session and inserts at DB
                    currentSession = new Session(
                        "session", "", DateTime.Today,                                  //name, place, dateTime
                        Constants.SportUndefinedID, Constants.SpeciallityUndefinedID, Constants.LevelUndefinedID,
                        "", Constants.ServerUndefinedID);                               //comments, serverID
                }
                else
                {
                    currentSession = SqliteSession.SelectByName("session");
                }
            }
            else
            {
                //configChronojump.SessionMode == Config.SessionModeEnum.MONTHLY

                string yearMonthStr = UtilDate.GetCurrentYearMonthStr();
                LogB.Information("yearMonthStr: " + yearMonthStr);
                if (!Sqlite.Exists(false, Constants.SessionTable, yearMonthStr))
                {
                    //this creates the session and inserts at DB
                    currentSession = new Session(
                        yearMonthStr, "", DateTime.Today,                                 //name, place, dateTime
                        Constants.SportUndefinedID, Constants.SpeciallityUndefinedID, Constants.LevelUndefinedID,
                        "", Constants.ServerUndefinedID);                                 //comments, serverID

                    //insert personSessions from last month
                    string yearLastMonthStr = UtilDate.GetCurrentYearLastMonthStr();
                    if (Sqlite.Exists(false, Constants.SessionTable, yearLastMonthStr))
                    {
                        Session s = SqliteSession.SelectByName(yearLastMonthStr);

                        //import all persons from last session
                        List <PersonSession> personSessions = SqlitePersonSession.SelectPersonSessionList(s.UniqueID);

                        //convert all personSessions to currentSession
                        //and nullify UniqueID in order to be inserted incrementally by SQL
                        foreach (PersonSession ps in personSessions)
                        {
                            ps.UniqueID  = -1;
                            ps.SessionID = currentSession.UniqueID;
                        }


                        //insert personSessions using a transaction
                        new SqlitePersonSessionTransaction(personSessions);
                    }
                }
                else
                {
                    currentSession = SqliteSession.SelectByName(yearMonthStr);
                }
            }

            on_load_session_accepted();
        }

        //TODO
        //RunScriptOnExit

        /*
         * if(linuxType == linuxTypeEnum.NETWORKS) {
         *      //mostrar directament el power
         *      select_menuitem_mode_toggled(Constants.Menuitem_modes.POWER);
         *
         *      //no mostrar menu
         *      main_menu.Visible = false;
         *
         *      //no mostrar persones
         *      //vbox_persons.Visible = false;
         *      //TODO: rfid can be here, also machine, maybe weight, other features
         *      //time, gym, ...
         *
         *      //show rfid
         *      hbox_rfid.Visible = true;
         *
         *      //to test display, just make sensitive the top controls, but beware there's no session yet and no person
         *      notebook_sup.Sensitive = true;
         *      hbox_encoder_sup_capture_analyze.Sensitive = true;
         *      notebook_encoder_sup.Sensitive = false;
         * }
         */

        hbox_rfid.Visible = (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.LINUX);
    }
Exemplo n.º 21
0
 private void playPreview()
 {
     //constructor for playpreview
     webcamPlay = new WebcamFfmpeg(Webcam.Action.PLAYPREVIEW, UtilAll.GetOSEnum(), preferences.videoDevice, preferences.videoDeviceResolution, preferences.videoDeviceFramerate);
     Webcam.Result result = webcamPlay.PlayPreviewNoBackground();
 }