Exemple #1
0
    private bool pulseGTKEncoderCaptureAndCurves()
    {
        if(needToCallPrepareEncoderGraphs)
        {
            image_encoder_width = UtilGtk.WidgetWidth(viewport_image_encoder_capture)-5;
            image_encoder_height = UtilGtk.WidgetHeight(viewport_image_encoder_capture)-5;

            prepareEncoderGraphs(false, false); //do not erase them
            needToCallPrepareEncoderGraphs = false;
        }

        if(! encoderThread.IsAlive || encoderProcessCancel) {
            LogB.Information("End from capture");
            LogB.ThreadEnding();
            finishPulsebar(encoderActions.CURVES_AC);

            if(encoderProcessCancel) {
                //stop video
                encoderStopVideoRecord();
            }

            //if on inertia and already showing instructions, return to page 0
            if(notebook_encoder_capture_or_instructions.Page == 1)
                notebook_encoder_capture_or_instructions.Page = 0;

            LogB.ThreadEnded();
            return false;
        }
        if(capturingCsharp == encoderCaptureProcess.CAPTURING)
        {
            updatePulsebar(encoderActions.CAPTURE); //activity on pulsebar

            //capturingSendCurveToR(); //unused, done while capturing
            readingCurveFromR();

            if(encoderConfigurationCurrent.has_inertia)
                updateEncoderCaptureGraphPaint(UpdateEncoderPaintModes.INERTIAL);
            else
                updateEncoderCaptureGraphPaint(UpdateEncoderPaintModes.GRAVITATORY);

            if(needToRefreshTreeviewCapture)
            {
                //LogB.Error("HERE YES");
                //LogB.Error(encoderCaptureStringR);

                treeviewEncoderCaptureRemoveColumns();
                eCapture.Ecca.curvesAccepted = createTreeViewEncoderCapture(encoderCaptureStringR);

                //if(plotCurvesBars) {
                string mainVariable = Constants.GetEncoderVariablesCapture(preferences.encoderCaptureMainVariable);
                double mainVariableHigher = repetitiveConditionsWin.GetMainVariableHigher(mainVariable);
                double mainVariableLower = repetitiveConditionsWin.GetMainVariableLower(mainVariable);
                //TODO:
                //captureCurvesBarsData.Add(new EncoderBarsData(meanSpeed, maxSpeed, meanPower, peakPower));
                //captureCurvesBarsData.Add(new EncoderBarsData(20, 39, 10, 40));

                plotCurvesGraphDoPlot(mainVariable, mainVariableHigher, mainVariableLower, captureCurvesBarsData,
                        repetitiveConditionsWin.EncoderInertialDiscardFirstThree,
                        true);	//capturing
                //}

                needToRefreshTreeviewCapture = false;
            }

            //changed trying to fix crash of nuell 27/may/2016
            //LogB.Debug(" Cap:", encoderThread.ThreadState.ToString());
            LogB.Information(" Cap:" + encoderThread.ThreadState.ToString());
        } else if(capturingCsharp == encoderCaptureProcess.STOPPING) {
            //stop video
            encoderStopVideoRecord();

            //don't allow to press cancel or finish
            button_encoder_capture_cancel.Sensitive = false;
            button_encoder_capture_finish.Sensitive = false;
            button_encoder_capture_finish_cont.Sensitive = false;

            capturingCsharp = encoderCaptureProcess.STOPPED;
        } else {	//STOPPED
            LogB.Debug("at pulseGTKEncoderCaptureAndCurves stopped");
            //do curves, capturingCsharp has ended
            updatePulsebar(encoderActions.CURVES); //activity on pulsebar
            //LogB.Debug(" Cur:", encoderThread.ThreadState.ToString());
            LogB.Information(" Cur:" + encoderThread.ThreadState.ToString());
        }

        Thread.Sleep (25);

        return true;
    }
Exemple #2
0
    //TODO:put zoom,unzoom (at side of delete curve)  in capture curves (for every curve)
    //
    //TODO: capture also with webcam an attach it to signal or curve
    //
    //TODO: peak power in eccentric in absolute values
    //
    //TODO: on cross, spline and force speed and power speed should have a spar value higher, like 0.7. On the other hand, the other cross graphs, haveload(mass) in the X lot more discrete, there is good to put 0.5
    private void encoderInitializeStuff()
    {
        encoder_pulsebar_capture.Fraction = 1;
        encoder_pulsebar_capture.Text = "";
        encoder_pulsebar_analyze.Fraction = 1;
        encoder_pulsebar_analyze.Text = "";

        //read from SQL
        encoderConfigurationCurrent = SqliteEncoder.LoadEncoderConfiguration();

        encoderCaptureListStore = new Gtk.ListStore (typeof (EncoderCurve));

        encSelReps = new EncoderSelectRepetitions();

        //the glade cursor_changed does not work on mono 1.2.5 windows
        //treeview_encoder_capture_curves.CursorChanged += on_treeview_encoder_capture_curves_cursor_changed;
        //changed, now unselectable because there are the checkboxes

        createEncoderCombos();

        encoderConfigurationGUIUpdate();

        //on start it's concentric and powerbars. Eccon-together should be unsensitive
        check_encoder_analyze_eccon_together.Sensitive = false;

        //spin_encoder_capture_inertial.Value = Convert.ToDouble(Util.ChangeDecimalSeparator(
        //			SqlitePreferences.Select("inertialmomentum")));

        //initialize capture and analyze classes
        encoderRProcCapture = new EncoderRProcCapture();
        encoderRProcAnalyze = new EncoderRProcAnalyze();

        captureCurvesBarsData = new ArrayList(0);

        try {
            playVideoEncoderInitialSetup();
        } catch {
            //it crashes on Raspberry, Banana
        }

        capturingCsharp = encoderCaptureProcess.STOPPED;

        //done here because in Glade we cannot use the TextBuffer.Changed
        textview_encoder_signal_comment.Buffer.Changed += new EventHandler(on_textview_encoder_signal_comment_key_press_event);

        configInit();

        array1RM = new ArrayList();
    }
Exemple #3
0
    /*
     * end of update encoder capture graph stuff
     */
    /* thread stuff */
    private void encoderThreadStart(encoderActions action)
    {
        encoderProcessCancel = false;

        if(action == encoderActions.CAPTURE || action == encoderActions.CAPTURE_IM)
        {
            //encoder_pulsebar_capture.Text = Catalog.GetString("Please, wait.");
            LogB.Information("encoderThreadStart begins");

            if(action == encoderActions.CAPTURE) {
                runEncoderCaptureNoRDotNetInitialize();
            }

            image_encoder_width = UtilGtk.WidgetWidth(viewport_image_encoder_capture)-5;
            image_encoder_height = UtilGtk.WidgetHeight(viewport_image_encoder_capture)-5;

            //don't need to be false because ItemToggled is deactivated during capture
            treeview_encoder_capture_curves.Sensitive = true;

            //on continuous mode do not erase bars at beginning of capture in order to see last bars
            if(action == encoderActions.CAPTURE && radio_encoder_capture_cont.Active) {
                prepareEncoderGraphs(false, true); //bars, signal
                plotCurvesGraphDoPlotMessage("Previous set");
            } else
                prepareEncoderGraphs(true, true);

            //eccaCreated = false;

            if(action == encoderActions.CAPTURE) {
                encoderStartVideoRecord();

                //remove treeview columns
                if( ! (action == encoderActions.CAPTURE && radio_encoder_capture_cont.Active) )
                    treeviewEncoderCaptureRemoveColumns();

                encoderCaptureStringR = new List<string>();
                encoderCaptureStringR.Add(
                        ",series,exercise,mass,start,width,height," +
                        "meanSpeed,maxSpeed,maxSpeedT," +
                        "meanPower,peakPower,peakPowerT,pp_ppt," +
                        "meanForce, maxForce, maxForceT");

                string filename = UtilEncoder.GetEncoderCaptureTempFileName();
                if(File.Exists(filename))
                    File.Delete(filename);

                encoderCaptureReadedLines = 0;
                deleteAllCapturedCurveFiles();

                capturingCsharp = encoderCaptureProcess.CAPTURING;
            }

            if(action == encoderActions.CAPTURE) {
                captureCurvesBarsData = new ArrayList();

                needToRefreshTreeviewCapture = false;

                if(encoderConfigurationCurrent.has_inertia)
                    eCapture = new EncoderCaptureInertial();
                else
                    eCapture = new EncoderCaptureGravitatory();

                int recordingTime = preferences.encoderCaptureTime;
                if(radio_encoder_capture_cont.Active)  {
                    recordingTime = 0;
                    encoderProcessFinishContMode = false; //will be true when finish button is pressed
                }

                eCapture.InitGlobal(
                        encoder_capture_signal_drawingarea.Allocation.Width,
                        encoder_capture_signal_drawingarea.Allocation.Height,
                        recordingTime,
                        preferences.encoderCaptureInactivityEndTime,
                        radio_encoder_capture_cont.Active,
                        findEccon(true),
                        chronopicRegister.ConnectedOfType(ChronopicRegisterPort.Types.ENCODER).Port
                        );

                encoderThread = new Thread(new ThreadStart(encoderDoCaptureCsharp));
                GLib.Idle.Add (new GLib.IdleHandler (pulseGTKEncoderCaptureAndCurves));
            }
            else { //action == encoderActions.CAPTURE_IM)

                eCapture = new EncoderCaptureIMCalc();
                eCapture.InitGlobal(
                        encoder_capture_signal_drawingarea.Allocation.Width,
                        encoder_capture_signal_drawingarea.Allocation.Height,
                        preferences.encoderCaptureTimeIM,
                        preferences.encoderCaptureInactivityEndTime,
                        false,
                        findEccon(true),
                        chronopicRegister.ConnectedOfType(ChronopicRegisterPort.Types.ENCODER).Port
                        );

                encoderThread = new Thread(new ThreadStart(encoderDoCaptureCsharpIM));
                GLib.Idle.Add (new GLib.IdleHandler (pulseGTKEncoderCaptureIM));
            }

            encoderShowCaptureDoingButtons(true);

            LogB.Information("encoderThreadStart middle");
            encoderButtonsSensitive(encoderSensEnum.PROCESSINGCAPTURE);

            LogB.ThreadStart();
            encoderThread.Start();
        } else if(
                action == encoderActions.CURVES ||
                action == encoderActions.LOAD ||
                action == encoderActions.CURVES_AC)	//this does not run a pulseGTK
        {

            if(action == encoderActions.CURVES || action == encoderActions.LOAD)
            {
                //______ 1) prepareEncoderGraphs

                //image_encoder_width = UtilGtk.WidgetWidth(viewport_image_encoder_capture)-5;
                //make graph half width of Chronojump window
                //but if video is disabled, then make it wider because thegraph will be much taller
                if(useVideo)
                    image_encoder_width = Convert.ToInt32(UtilGtk.WidgetWidth(app1) / 2);
                else
                    image_encoder_width = Convert.ToInt32(UtilGtk.WidgetWidth(app1));

                //-2 to accomadate the width slider without needing a height slider
                image_encoder_height = UtilGtk.WidgetHeight(viewport_image_encoder_capture) -2;

                prepareEncoderGraphs(true, true);

                //_______ 2) run stuff

                //don't need because ItemToggled is deactivated during capture
                //treeview_encoder_capture_curves.Sensitive = false;

                encoderThread = new Thread(new ThreadStart(encoderDoCurvesGraphR_curves));
                if(action == encoderActions.CURVES)
                    GLib.Idle.Add (new GLib.IdleHandler (pulseGTKEncoderCurves));
                else // action == encoderActions.LOAD
                    GLib.Idle.Add (new GLib.IdleHandler (pulseGTKEncoderLoad));
                encoderButtonsSensitive(encoderSensEnum.PROCESSINGR);

                LogB.ThreadStart();
                encoderThread.Start();
            } else { //CURVES_AC
                //______ 1) prepareEncoderGraphs
                //don't call directly to prepareEncoderGraphs() here because it's called from a Non-GTK thread
                needToCallPrepareEncoderGraphs = true; //needToCallPrepareEncoderGraphs will not erase them

                //this is defined on capture process
                //image_encoder_width = UtilGtk.WidgetWidth(viewport_image_encoder_capture)-5;
                //image_encoder_height = UtilGtk.WidgetHeight(viewport_image_encoder_capture)-5;

                //_______ 2) run stuff
                //this does not run a pulseGTK
                encoderDoCurvesGraphR_curvesAC();
                encoderButtonsSensitive(encoderSensEnum.PROCESSINGR);
            }
        } else { //encoderActions.ANALYZE

            //the -5 is because image is inside (is smaller than) viewport
            image_encoder_width = UtilGtk.WidgetWidth(scrolledwindow_image_encoder_analyze)-10;
            image_encoder_height = UtilGtk.WidgetHeight(scrolledwindow_image_encoder_analyze)-10;
            if(encoderAnalysis == "single") {
                image_encoder_height -= UtilGtk.WidgetHeight(table_encoder_analyze_instant); //to allow hslides and table
            }

            encoder_pulsebar_analyze.Text = Catalog.GetString("Please, wait.");
            encoderRProcAnalyze.status = EncoderRProc.Status.WAITING;

            encoderRProcAnalyze.CrossValidate = checkbutton_crossvalidate.Active;

            encoderThread = new Thread(new ThreadStart(encoderDoAnalyze));
            GLib.Idle.Add (new GLib.IdleHandler (pulseGTKEncoderAnalyze));

            encoderButtonsSensitive(encoderSensEnum.PROCESSINGR);
            treeview_encoder_analyze_curves.Sensitive = false;
            button_encoder_analyze_image_save.Sensitive = false;
            button_encoder_analyze_AB_save.Sensitive = false;
            button_encoder_analyze_table_save.Sensitive = false;
            button_encoder_analyze_1RM_save.Visible = false;

            LogB.ThreadStart();
            encoderThread.Start();
        }
    }
Exemple #4
0
    //this is called by non gtk thread. Don't do gtk stuff here
    //I suppose reading gtk is ok, changing will be the problem
    private void encoderDoCaptureCsharp()
    {
        bool capturedOk = eCapture.Capture(
                UtilEncoder.GetEncoderDataTempFileName(),
                encoderRProcCapture
                );

        //wait to ensure capture thread has ended
        Thread.Sleep(50);

        LogB.Debug("Going to stop");
        capturingCsharp = encoderCaptureProcess.STOPPING;

        //will start calcule curves thread
        if(capturedOk) {
            LogB.Debug("Going to encoderCalculeCurves");
            encoderCalculeCurves(encoderActions.CURVES_AC);
        } else
            encoderProcessCancel = true;
    }