Beispiel #1
0
    private void updatePulsebar(encoderActions action)
    {
        if(action == encoderActions.CAPTURE && radio_encoder_capture_cont.Active) {
            encoder_pulsebar_capture.Text = "";
            encoder_pulsebar_capture.Pulse();
            return;
        }

        if(action == encoderActions.CAPTURE || action == encoderActions.CAPTURE_IM)
        {
            int selectedTime = preferences.encoderCaptureTime;
            if(action == encoderActions.CAPTURE_IM)
                selectedTime = preferences.encoderCaptureTimeIM;

            encoder_pulsebar_capture.Fraction = Util.DivideSafeFraction(
                    (selectedTime - eCapture.Countdown), selectedTime);
            encoder_pulsebar_capture.Text = eCapture.Countdown + " s";

            return;
        }

        try {
            string contents = Catalog.GetString("Please, wait.");
            double fraction = -1;
            /*
            if(Util.FileExists(UtilEncoder.GetEncoderStatusTempFileName())) {
                contents = Util.ReadFile(UtilEncoder.GetEncoderStatusTempFileName(), true);
                //contents is:
                //(1/5) Starting R
                //(5/5) R tasks done

                //-48: ascii 0 char
                if(System.Char.IsDigit(contents[1]) && System.Char.IsDigit(contents[3]))
                    fraction = Util.DivideSafeFraction(
                            Convert.ToInt32(contents[1]-48), Convert.ToInt32(contents[3]-48) );
            }
            */

            if(Util.FileExists(UtilEncoder.GetEncoderStatusTempBaseFileName() + "6.txt"))
            {
                fraction = 6;
                contents = Catalog.GetString("R tasks done");
            }
            else if(Util.FileExists(UtilEncoder.GetEncoderStatusTempBaseFileName() + "5.txt"))
            {
                fraction = 5;
                contents = "Smoothing done";
            } else if(Util.FileExists(UtilEncoder.GetEncoderStatusTempBaseFileName() + "4.txt"))
            {
                fraction = 4;
                if(encoderRProcAnalyze.CurvesReaded > 0)
                    contents = encoderRProcAnalyze.CurvesReaded.ToString();
                else
                    contents = Catalog.GetString("Repetitions processed");
            } else if(Util.FileExists(UtilEncoder.GetEncoderStatusTempBaseFileName() + "3.txt"))
            {
                fraction = 3;
                if(encoderRProcAnalyze.CurvesReaded > 0)
                    contents = encoderRProcAnalyze.CurvesReaded.ToString();
                else
                    contents = Catalog.GetString("Starting process");
            } else if(Util.FileExists(UtilEncoder.GetEncoderStatusTempBaseFileName() + "2.txt"))
            {
                fraction = 2;
                contents = Catalog.GetString("Loading libraries");
            } else if(Util.FileExists(UtilEncoder.GetEncoderStatusTempBaseFileName() + "1.txt"))
            {
                fraction = 1;
                contents = Catalog.GetString("Starting R");
            }

            if(action == encoderActions.CURVES || action == encoderActions.LOAD) {
                if(fraction == -1)
                    encoder_pulsebar_capture.Pulse();
                else
                    encoder_pulsebar_capture.Fraction = Util.DivideSafeFraction(fraction, 6);

                encoder_pulsebar_capture.Text = contents;
            } else {
                if(fraction == -1)
                    encoder_pulsebar_analyze.Pulse();
                else
                    encoder_pulsebar_analyze.Fraction = Util.DivideSafeFraction(fraction, 6);

                encoder_pulsebar_analyze.Text = contents;
            }
        } catch {
            //UtilEncoder.GetEncoderStatusTempBaseFileName() 1,2,3,4,5 is deleted at the end of the process
            //this can make crash updatePulsebar sometimes
            LogB.Warning("catched at updatePulsebar");
        }
    }
Beispiel #2
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();
        }
    }
Beispiel #3
0
    // -------------- end of drawingarea_encoder_analyze_instant
    private void finishPulsebar(encoderActions action)
    {
        if(
                action == encoderActions.CAPTURE ||
                action == encoderActions.CAPTURE_IM ||
                action == encoderActions.CURVES ||
                action == encoderActions.CURVES_AC ||
                action == encoderActions.LOAD )
        {
            LogB.Information("ffffffinishPulsebarrrrr");

            //save video will be later at encoderSaveSignalOrCurve, because there encoderSignalUniqueID will be known

            if(action == encoderActions.CURVES || action == encoderActions.CURVES_AC)
                sensitiveGuiEventDone();

            if(encoderProcessCancel || encoderProcessProblems) {
                //tis notebook has capture (signal plotting), and curves (shows R graph)
                if(notebook_encoder_capture.CurrentPage == 0 )
                    notebook_encoder_capture.NextPage();
                encoder_pulsebar_capture.Fraction = 1;

                if(encoderProcessProblems) {
                    new DialogMessage(Constants.MessageTypes.WARNING,
                            Catalog.GetString("Sorry. Error doing graph.") +
                            "\n" + Catalog.GetString("Maybe R is not installed.") +
                            "\n" + Catalog.GetString("Please, install it from here:") +
                            "\n\nhttp://cran.cnr.berkeley.edu/bin/macosx/R-latest.pkg");
                    encoderProcessProblems = false;
                } else {
                    if(action == encoderActions.CAPTURE_IM)
                        encoder_configuration_win.Button_encoder_capture_inertial_do_ended(0,"Cancelled");
                    else
                        encoder_pulsebar_capture.Text = Catalog.GetString("Cancelled");
                }
            }
            else if( (action == encoderActions.CAPTURE || action == encoderActions.CAPTURE_IM)
                    && encoderProcessFinish ) {
                encoder_pulsebar_capture.Text = Catalog.GetString("Finished");
            }
            else if(action == encoderActions.CURVES || action == encoderActions.CURVES_AC || action == encoderActions.LOAD)
            {
                //this notebook has capture (signal plotting), and curves (shows R graph)
                if(notebook_encoder_capture.CurrentPage == 0)
                    notebook_encoder_capture.NextPage();

                List<string> contents = Util.ReadFileAsStringList(UtilEncoder.GetEncoderCurvesTempFileName());

                image_encoder_capture = UtilGtk.OpenImageSafe(
                        UtilEncoder.GetEncoderGraphTempFileName(),
                        image_encoder_capture);

                encoderUpdateTreeViewCapture(contents); //this updates encoderCaptureCurves
                image_encoder_capture.Sensitive = true;

                //plot curves bars graph
                string mainVariable = Constants.GetEncoderVariablesCapture(preferences.encoderCaptureMainVariable);
                double mainVariableHigher = repetitiveConditionsWin.GetMainVariableHigher(mainVariable);
                double mainVariableLower = repetitiveConditionsWin.GetMainVariableLower(mainVariable);

                captureCurvesBarsData = new ArrayList();
                foreach (EncoderCurve curve in encoderCaptureCurves) {
                    captureCurvesBarsData.Add(new EncoderBarsData(
                                Convert.ToDouble(curve.MeanSpeed),
                                Convert.ToDouble(curve.MaxSpeed),
                                Convert.ToDouble(curve.MeanForce),
                                Convert.ToDouble(curve.MaxForce),
                                Convert.ToDouble(curve.MeanPower),
                                Convert.ToDouble(curve.PeakPower)
                                ));
                }

                maxPowerIntersessionOnCapture = findMaxPowerIntersession();
                plotCurvesGraphDoPlot(mainVariable, mainVariableHigher, mainVariableLower, captureCurvesBarsData,
                        repetitiveConditionsWin.EncoderInertialDiscardFirstThree,
                        false);	//not capturing

                button_encoder_signal_save_comment.Label = Catalog.GetString("Save comment");
                button_encoder_signal_save_comment.Sensitive = false;

                //autosave signal (but not in load)
                if(action == encoderActions.CURVES || action == encoderActions.CURVES_AC)
                {
                    bool needToAutoSaveCurve = false;
                    if(
                            encoderSignalUniqueID == "-1" &&	//if we just captured
                            (preferences.encoderAutoSaveCurve == Constants.EncoderAutoSaveCurve.ALL ||
                            preferences.encoderAutoSaveCurve == Constants.EncoderAutoSaveCurve.BEST ||
                            preferences.encoderAutoSaveCurve == Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE) )
                        needToAutoSaveCurve = true;

                    encoder_pulsebar_capture.Text = encoderSaveSignalOrCurve(false, "signal", 0); //this updates encoderSignalUniqueID

                    if(needToAutoSaveCurve)
                        encoderCaptureSaveCurvesAllNoneBest(preferences.encoderAutoSaveCurve,
                                Constants.GetEncoderVariablesCapture(preferences.encoderCaptureMainVariable));

                } else
                    encoder_pulsebar_capture.Text = "";

                /*
                 * if we captured, but encoderSignalUniqueID has not been changed on encoderSaveSignalOrCurve
                 * because there are no curves (problems detecting, or minimal height so big
                 * then do not continue
                 * because with a value of -1 there will be problems in
                 * SqliteEncoder.Select(false, Convert.ToInt32(encoderSignalUniqueID), ...)
                 */
                LogB.Information(" encoderSignalUniqueID:" + encoderSignalUniqueID);
                if(encoderSignalUniqueID != "-1")
                {

                    // TODO: we never use findEccon() return value. We might be able to stop calling findEccon()
                    // since it doesn't seem to do anything else other than returning the value.
                    // This needs to be checked if working on this code.
                    findEccon(true);

                    /*
                     * (0) open Sqlite
                     * (1) if found curves of this signal
                     * 	(1a) this curves are with different eccon, or with different encoderConfiguration.name
                     * 		(1a1) delete the curves (files)
                     * 		(1a2) delete the curves (encoder table)
                     * 		(1a3) and also delete from (encoderSignalCurves table)
                     * 	(1b) or different exercise, or different laterality or different extraWeight,
                     * 		or different encoderConfiguration (but the name is the same)
                     * 		(1b1) update curves with new data
                     * (2) update analyze labels and combos
                     * (3) update meanPower on SQL encoder
                     * (4) close Sqlite
                     */

                    Sqlite.Open(); // (0)

                    bool deletedUserCurves = false;
                    EncoderSQL currentSignalSQL = (EncoderSQL) SqliteEncoder.Select(
                            true, Convert.ToInt32(encoderSignalUniqueID), 0, 0, getEncoderGI(),
                            -1, "", EncoderSQL.Eccons.ALL,
                            false, true)[0];

                    ArrayList data = SqliteEncoder.Select(
                            true, -1, currentPerson.UniqueID, currentSession.UniqueID, getEncoderGI(),
                            -1, "curve", EncoderSQL.Eccons.ALL,
                            false, true);
                    foreach(EncoderSQL eSQL in data)
                    {
                        if(currentSignalSQL.GetDate(false) == eSQL.GetDate(false)) 		// (1)
                        {
                            // (1a)
                            if(findEccon(true) != eSQL.eccon ||
                                    encoderConfigurationCurrent.name != eSQL.encoderConfiguration.name)
                            {
                                Util.FileDelete(eSQL.GetFullURL(false));					// (1a1)
                                Sqlite.Delete(true, Constants.EncoderTable, Convert.ToInt32(eSQL.uniqueID));	// (1a2)
                                SqliteEncoder.DeleteSignalCurveWithCurveID(true, Convert.ToInt32(eSQL.uniqueID)); // (1a3)
                                deletedUserCurves = true;
                            } else {							// (1b)
                                if(currentSignalSQL.exerciseID != eSQL.exerciseID)
                                    Sqlite.Update(true, Constants.EncoderTable, "exerciseID",
                                            "", currentSignalSQL.exerciseID.ToString(),
                                            "uniqueID", eSQL.uniqueID.ToString());

                                if(currentSignalSQL.extraWeight != eSQL.extraWeight)
                                    Sqlite.Update(true, Constants.EncoderTable, "extraWeight",
                                            "", currentSignalSQL.extraWeight,
                                            "uniqueID", eSQL.uniqueID.ToString());

                                if(currentSignalSQL.laterality != eSQL.laterality)
                                    Sqlite.Update(true, Constants.EncoderTable, "laterality",
                                            "", currentSignalSQL.laterality,
                                            "uniqueID", eSQL.uniqueID.ToString());

                                if( currentSignalSQL.encoderConfiguration.ToStringOutput(EncoderConfiguration.Outputs.SQL) !=
                                        eSQL.encoderConfiguration.ToStringOutput(EncoderConfiguration.Outputs.SQL) )
                                {
                                    Sqlite.Update(true, Constants.EncoderTable, "encoderConfiguration",
                                            "", currentSignalSQL.encoderConfiguration.ToStringOutput(
                                                EncoderConfiguration.Outputs.SQL),
                                            "uniqueID", eSQL.uniqueID.ToString());
                                }
                            }
                        }
                    }
                    if(deletedUserCurves) {
                        //TODO: change encSelReps and this will change labels
                        updateUserCurvesLabelsAndCombo(true); 	// (2)
                    }

                    // (3) update meanPower on SQL encoder
                    findAndMarkSavedCurves(true, true); //SQL opened; update curve SQL records (like future1: meanPower)

                    Sqlite.Close(); 					// (4)

                }

                playVideoEncoderPrepare(false); //do not play

                //set encoder video labels
                string videofile = Util.GetVideoFileName(currentSession.UniqueID,
                        Constants.TestTypes.ENCODER, Convert.ToInt32(encoderSignalUniqueID));
                if(videofile != null && videofile != "" && File.Exists(videofile)) {
                    label_video_encoder_filename.Text = Util.GetVideoFileNameOnlyName(
                            Constants.TestTypes.ENCODER,
                            Convert.ToInt32(encoderSignalUniqueID));
                    textview_video_encoder_folder.Buffer.Text = Util.GetVideoFileNameOnlyFolder(currentSession.UniqueID);
                    button_video_encoder_open_folder.Visible = true;
                } else
                    button_video_encoder_open_folder.Visible = false;
            }

            if(action == encoderActions.CAPTURE_IM && ! encoderProcessCancel && ! encoderProcessProblems)
            {
                string imResultText = Util.ChangeDecimalSeparator(
                        Util.ReadFile(UtilEncoder.GetEncoderSpecialDataTempFileName(), true) );
                LogB.Information("imResultText = |" + imResultText + "|");

                if(imResultText == "NA" || imResultText == "-1" || imResultText == "")
                    encoder_configuration_win.Button_encoder_capture_inertial_do_ended (0, "Error capturing. Maybe more oscillations are needed.");
                else {
                    //script calculates Kg*m^2 -> GUI needs Kg*cm^2
                    encoder_configuration_win.Button_encoder_capture_inertial_do_ended (
                            Convert.ToDouble(imResultText) * 10000.0, "");
                }

                encoderButtonsSensitive(encoderSensEnum.DONENOSIGNAL);
            } else {
                encoderButtonsSensitive(encoderSensEnumStored);

                //an user has one active concentric curve
                //signal of this curve is loaded
                //user change to ecc-con and recalculate
                //then that concentrinc curve disappears
                //button_encoder_analyze have to be unsensitive because there are no curves:
                button_encoder_analyze_sensitiveness();

                //LogB.Debug(Enum.Parse(typeof(encoderActions), action.ToString()).ToString());
                //LogB.Debug(encoderProcessCancel.ToString());

                if(encoderProcessCancel)
                    removeSignalFromGuiBecauseDeletedOrCancelled();
            }

            encoder_pulsebar_capture.Fraction = 1;
            //analyze_image_save only has not to be sensitive now because capture graph will be saved
            image_encoder_analyze.Sensitive = false;
            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;

            encoderShowCaptureDoingButtons(false);

            if(action == encoderActions.CURVES_AC)
            {
                restTime.AddOrModify(currentPerson.UniqueID, true);
                updateRestTimes();
            }

            if(action == encoderActions.CURVES_AC && radio_encoder_capture_cont.Active && ! encoderProcessFinishContMode)
                on_button_encoder_capture_clicked (new object (), new EventArgs ());

            //on inertial, check after capture if string was not fully extended and was corrected
            if(getMenuItemMode() == Constants.Menuitem_modes.POWERINERTIAL &&
                    action == encoderActions.CURVES_AC &&
                    Util.FileExists(UtilEncoder.GetEncoderSpecialDataTempFileName()))
            {
                string str = Util.ReadFile(UtilEncoder.GetEncoderSpecialDataTempFileName(), true);
                if(str != null && str == "SIGNAL CORRECTED")
                    new DialogMessage(Constants.MessageTypes.WARNING,
                        Catalog.GetString("Set corrected. string was not fully extended at the beginning."));
            }

        } else { //ANALYZE
            if(encoderProcessCancel) {
                encoder_pulsebar_analyze.Text = Catalog.GetString("Cancelled");
            } else {
                //TODO pensar en si s'ha de fer 1er amb mida petita i despres amb gran (en el zoom),
                //o si es una sola i fa alguna edicio

                if(encoderAnalysis == "single") {
                    drawingarea_encoder_analyze_cairo_pixbuf = UtilGtk.OpenPixbufSafe(
                            UtilEncoder.GetEncoderGraphTempFileName(),
                            drawingarea_encoder_analyze_cairo_pixbuf);

                    drawingarea_encoder_analyze_instant.QueueDraw(); //will fire ExposeEvent

                    button_encoder_analyze_AB_save.Visible = checkbutton_encoder_analyze_b.Active;

                    notebook_encoder_analyze.CurrentPage = 1;
                } else {
                    //maybe image is still not readable
                    image_encoder_analyze = UtilGtk.OpenImageSafe(
                            UtilEncoder.GetEncoderGraphTempFileName(),
                            image_encoder_analyze);

                    button_encoder_analyze_AB_save.Visible = false;

                    notebook_encoder_analyze.CurrentPage = 0;
                }

                encoder_pulsebar_analyze.Text = "";

                string contents = Util.ReadFile(UtilEncoder.GetEncoderAnalyzeTableTempFileName(), false);
                if (contents != null && contents != "") {
                    if(radiobutton_encoder_analyze_neuromuscular_profile.Active) {
                        treeviewEncoderAnalyzeRemoveColumns();
                        encoderAnalyzeListStore = new Gtk.ListStore (typeof (EncoderCurve));
                        createTreeViewEncoderAnalyzeNeuromuscular(contents);
                    } else if(
                            radiobutton_encoder_analyze_1RM.Active &&
                            Util.FindOnArray(':',1,0,UtilGtk.ComboGetActive(combo_encoder_analyze_1RM),
                                encoderAnalyze1RMTranslation) == "1RM Indirect") {
                        treeviewEncoderAnalyzeRemoveColumns();
                        encoderAnalyzeListStore = new Gtk.ListStore (typeof (List<double>));
                    } else {
                        treeviewEncoderAnalyzeRemoveColumns();
                        encoderAnalyzeListStore = new Gtk.ListStore (typeof (EncoderCurve));
                        createTreeViewEncoderAnalyze(contents);
                    }
                }

                if(encoderAnalysis == "single") {
                    eai = new EncoderAnalyzeInstant();
                    eai.ReadArrayFile(UtilEncoder.GetEncoderInstantDataTempFileName());
                    eai.ReadGraphParams(UtilEncoder.GetEncoderSpecialDataTempFileName());

                    //ranges should have max value the number of the lines of csv file minus the header
                    hscale_encoder_analyze_a.SetRange(1, eai.speed.Count);
                    hscale_encoder_analyze_b.SetRange(1, eai.speed.Count);
                    //eai.PrintDebug();
                }

            }

            button_encoder_analyze.Visible = true;
            hbox_encoder_analyze_progress.Visible = false;

            encoder_pulsebar_analyze.Fraction = 1;
            encoderButtonsSensitive(encoderSensEnumStored);
            image_encoder_analyze.Sensitive = true;
            treeview_encoder_analyze_curves.Sensitive = true;

            button_encoder_analyze_image_save.Sensitive = true;
            button_encoder_analyze_AB_save.Sensitive = true;
            button_encoder_analyze_table_save.Sensitive = true;

            string my1RMName = Util.FindOnArray(':',1,0,UtilGtk.ComboGetActive(combo_encoder_analyze_1RM),
                        encoderAnalyze1RMTranslation);
            button_encoder_analyze_1RM_save.Visible =
                (radiobutton_encoder_analyze_1RM.Active &&
                (my1RMName == "1RM Bench Press" || my1RMName == "1RM Squat" ||
                 my1RMName == "1RM Any exercise" || my1RMName == "1RM Indirect") );
            /*
             * TODO: currently disabled because
             * on_button_encoder_analyze_1RM_save_clicked () reads getExerciseNameFromTable()
             * and encoderAnalyzeListStore is not created because "1RM Indirect"
             * currently prints no data on OutputData1
             *
             * Solution will be to print data there with a new format
             * (new columns) like neuromuscular has done
             */
        }

        treeview_encoder_capture_curves.Sensitive = true;

        //delete the status filenames
        Util.FileDelete(UtilEncoder.GetEncoderStatusTempBaseFileName() + "1.txt");
        Util.FileDelete(UtilEncoder.GetEncoderStatusTempBaseFileName() + "2.txt");
        Util.FileDelete(UtilEncoder.GetEncoderStatusTempBaseFileName() + "3.txt");
        Util.FileDelete(UtilEncoder.GetEncoderStatusTempBaseFileName() + "4.txt");
        Util.FileDelete(UtilEncoder.GetEncoderStatusTempBaseFileName() + "5.txt");
        Util.FileDelete(UtilEncoder.GetEncoderStatusTempBaseFileName() + "6.txt");

        //for chronojumpWindowTests
        LogB.Information("finishPulseBar DONE: " + action.ToString());
        if(
                action == encoderActions.LOAD ||	//load
                action == encoderActions.CURVES )	//recalculate
            chronojumpWindowTestsNext();
    }
Beispiel #4
0
 //action can be CURVES_AC (After Capture) (where signal does not exists, need to define it)
 //CAPTURE_EXTERNAL, CURVES, LOAD (signal is defined)
 //CAPTURE_EXTERNAL is not implemented because it's deprecated
 void encoderCalculeCurves(encoderActions action)
 {
     if(action == encoderActions.CURVES_AC)
     {
         encoderTimeStamp = UtilDate.ToFile(DateTime.Now);
         encoderSignalUniqueID = "-1"; //mark to know that there's no ID for this until it's saved on database
         encoderThreadStart(action);
     } else {
         //calculate and recalculate saves the curve at end
         //load does not save the curve
            if(File.Exists(UtilEncoder.GetEncoderDataTempFileName()))
                encoderThreadStart(action);
            else
                encoder_pulsebar_capture.Text = Catalog.GetString("Missing data.");
     }
 }