Ejemplo n.º 1
0
        public void Init(double fps, TVStandard tvStd, BGFlags bgFlags)
        {
            LastEncoderParams = new EncoderParams {
                FPS = fps, TVStandard = tvStd, BGFlags = bgFlags
            };
            if (FEncoderRingBuffer != null)
            {
                FEncoderRingBuffer.Dispose();
            }

            var encoder = new Encoder(AudioEngine.Instance.Settings.SampleRate, fps, tvStd, bgFlags);

            FEncoderRingBuffer = new LTCPullBuffer(encoder);
            FInitialized       = true;
        }
Ejemplo n.º 2
0
 public void Dispose()
 {
     EncoderParams?.Dispose();
     RtcSession?.Dispose();
 }
Ejemplo n.º 3
0
    private void runEncoderCaptureNoRDotNetInitialize()
    {
        EncoderParams ep = new EncoderParams(
                preferences.EncoderCaptureMinHeight(encoderConfigurationCurrent.has_inertia),
                getExercisePercentBodyWeightFromComboCapture (),
                Util.ConvertToPoint(findMass(Constants.MassType.BODY)),
                Util.ConvertToPoint(findMass(Constants.MassType.EXTRA)),
                findEccon(true),					//force ecS (ecc-conc separated)
                "-",		//analysis
                "none",		//analysisVariables (not needed in create curves). Cannot be blank
                getEncoderAnalysisOptions(),	//used on capture for pass the 'p' of propulsive
                preferences.encoderCaptureCheckFullyExtended,
                preferences.encoderCaptureCheckFullyExtendedValue,
                encoderConfigurationCurrent,
                Util.ConvertToPoint(preferences.encoderSmoothCon),	//R decimal: '.'
                   	0, 			//curve is not used here
                image_encoder_width, image_encoder_height,
                preferences.CSVExportDecimalSeparator
                );

        EncoderStruct es = new EncoderStruct(
                UtilEncoder.GetEncoderScriptCaptureNoRdotNet(),//1st option used here to allow to call the main capture script
                UtilEncoder.GetEncoderCaptureTempFileName(),   //2nd option used here to print the captured data file
                "none", //UtilEncoder.GetEncoderCurvesTempFileName(),
                UtilEncoder.GetEncoderScriptsPathWithoutLastSep(),
                UtilEncoder.GetEncoderTempPathWithoutLastSep(),
                ep);

        encoderRProcCapture.StartOrContinue(es);
    }
Ejemplo n.º 4
0
    void on_button_encoder_export_all_curves_file_selected(string selectedFileName)
    {
        string analysisOptions = getEncoderAnalysisOptions();

        string displacedMass = Util.ConvertToPoint( lastEncoderSQLSignal.extraWeight + (
                    getExercisePercentBodyWeightFromName(lastEncoderSQLSignal.exerciseName) *
                    currentPersonSession.Weight
                    ) );

        EncoderParams ep = new EncoderParams(
                lastEncoderSQLSignal.minHeight,
                getExercisePercentBodyWeightFromName (lastEncoderSQLSignal.exerciseName),
                Util.ConvertToPoint(findMass(Constants.MassType.BODY)),
                Util.ConvertToPoint(findMass(Constants.MassType.EXTRA)),
                findEccon(false), //do not force ecS (ecc-conc separated) //not taken from lastEncoderSQLSignal because there is (true)
                "exportCSV",
                "none",						//analysisVariables (not needed in create curves). Cannot be blank
                analysisOptions,
                preferences.encoderCaptureCheckFullyExtended,
                preferences.encoderCaptureCheckFullyExtendedValue,
                encoderConfigurationCurrent,
                Util.ConvertToPoint(preferences.encoderSmoothCon),	//R decimal: '.'
                -1,
                image_encoder_width,
                image_encoder_height,
                preferences.CSVExportDecimalSeparator
                );

        string dataFileName = UtilEncoder.GetEncoderDataTempFileName();

        EncoderStruct encoderStruct = new EncoderStruct(
                dataFileName,
                UtilEncoder.GetEncoderGraphTempFileName(),
                Util.GetEncoderExportTempFileName(),
                UtilEncoder.GetEncoderScriptsPathWithoutLastSep(),
                UtilEncoder.GetEncoderTempPathWithoutLastSep(),
                ep);

        encoderRProcAnalyze.ExportFileName = selectedFileName;

        encoderRProcAnalyze.SendData(
                Util.ChangeSpaceAndMinusForUnderscore(currentPerson.Name) + "-" +
                Util.ChangeSpaceAndMinusForUnderscore(lastEncoderSQLSignal.exerciseName) +
                    "-(" + displacedMass + "Kg)",
                false, 			//do not use neuromuscularProfile script
                preferences.RGraphsTranslate
                );
        encoderRProcAnalyze.StartOrContinue(encoderStruct);

        //encoder_pulsebar_capture.Text = string.Format(Catalog.GetString(
        //			"Exported to {0}."), UtilEncoder.GetEncoderExportTempFileName());
    }
Ejemplo n.º 5
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
    //called on calculatecurves, recalculate and load
    private void encoderDoCurvesGraphR(string analysisSent)
    {
        LogB.Debug("encoderDoCurvesGraphR() start");
        string analysis = analysisSent;

        string analysisOptions = getEncoderAnalysisOptions();

        //without this we loose the videoURL on recalculate
        string videoURL = "";
        if(encoderSignalUniqueID != null && encoderSignalUniqueID != "-1") {
            string file = Util.GetVideoFileName(currentSession.UniqueID,
                Constants.TestTypes.ENCODER, Convert.ToInt32(encoderSignalUniqueID));

            if(file != null && file != "" && File.Exists(file))
                videoURL = file;
        }

        //see explanation on the top of this file
        lastEncoderSQLSignal = new EncoderSQL(
                "-1",
                currentPerson.UniqueID,
                currentSession.UniqueID,
                getExerciseIDFromCombo(exerciseCombos.CAPTURE),
                findEccon(true), 	//force ecS (ecc-conc separated)
                UtilGtk.ComboGetActive(combo_encoder_laterality),
                Util.ConvertToPoint(findMass(Constants.MassType.EXTRA)), //when save on sql, do not include person weight
                "",	//signalOrCurve,
                "", 	//fileSaved,	//to know date do: select substr(name,-23,19) from encoder;
                "",	//path,			//url
                preferences.encoderCaptureTime,
                preferences.EncoderCaptureMinHeight(encoderConfigurationCurrent.has_inertia),
                Util.RemoveTildeAndColonAndDot(textview_encoder_signal_comment.Buffer.Text), //desc,
                "", videoURL,		//status, videoURL
                encoderConfigurationCurrent,
                "","","",	//future1, 2, 3
                Util.FindOnArray(':', 2, 1, UtilGtk.ComboGetActive(combo_encoder_exercise_capture),
                    encoderExercisesTranslationAndBodyPWeight)	//exerciseName (english)
                );

        EncoderParams ep = new EncoderParams(
                preferences.EncoderCaptureMinHeight(encoderConfigurationCurrent.has_inertia),
                getExercisePercentBodyWeightFromComboCapture (),
                Util.ConvertToPoint(findMass(Constants.MassType.BODY)),
                Util.ConvertToPoint(findMass(Constants.MassType.EXTRA)),
                findEccon(true),					//force ecS (ecc-conc separated)
                analysis,
                "none",				//analysisVariables (not needed in create curves). Cannot be blank
                analysisOptions,
                preferences.encoderCaptureCheckFullyExtended,
                preferences.encoderCaptureCheckFullyExtendedValue,
                encoderConfigurationCurrent,
                Util.ConvertToPoint(preferences.encoderSmoothCon),	//R decimal: '.'
                   	0, 			//curve is not used here
                image_encoder_width, image_encoder_height,
                preferences.CSVExportDecimalSeparator
                );

        EncoderStruct es = new EncoderStruct(
                UtilEncoder.GetEncoderDataTempFileName(),
                UtilEncoder.GetEncoderGraphTempFileName(),
                UtilEncoder.GetEncoderCurvesTempFileName(),
                UtilEncoder.GetEncoderScriptsPathWithoutLastSep(),
                UtilEncoder.GetEncoderTempPathWithoutLastSep(),
                ep);

        string title = Util.ChangeSpaceAndMinusForUnderscore(currentPerson.Name) + "-" +
            Util.ChangeSpaceAndMinusForUnderscore(UtilGtk.ComboGetActive(combo_encoder_exercise_capture));
        if(encoderConfigurationCurrent.has_inertia)
            title += "-(" + encoderConfigurationCurrent.inertiaTotal.ToString() + " " + Catalog.GetString("Inertia M.") + ")";
        else
            title += "-(" + Util.ConvertToPoint(findMass(Constants.MassType.DISPLACED)) + "Kg)";

        encoderRProcAnalyze.SendData(
                title,
                false,	//do not use neuromuscularProfile script
                preferences.RGraphsTranslate
                );
        bool result = encoderRProcAnalyze.StartOrContinue(es);

        if(result)
            //store this to show 1,2,3,4,... or 1e,1c,2e,2c,... in RenderN
            //if is not stored, it can change when changed eccon radiobutton on cursor is in treeview
            ecconLast = findEccon(false);
        else {
            encoderProcessProblems = true;
        }
        LogB.Debug("encoderDoCurvesGraphR() end");
    }
Ejemplo n.º 6
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 encoderDoAnalyze()
    {
        EncoderParams ep = new EncoderParams();
        string dataFileName = "";

        string analysisOptions = getEncoderAnalysisOptions();

        //use this send because we change it to send it to R
        //but we don't want to change encoderAnalysis because we want to know again if == "cross" (or "1RM")
        //encoderAnalysis can be "cross" and sendAnalysis be "Speed / Load"
        //encoderAnalysis can be "1RM" and sendAnalysis be "1RMBadilloBench, ...
        string sendAnalysis = encoderAnalysis;

        //see doProcess at encoder/graph.R
        string analysisVariables = "none"; //cannot be blank

        string crossName = "";
        if(sendAnalysis == "cross") {
            crossName = Util.FindOnArray(':',1,0,UtilGtk.ComboGetActive(combo_encoder_analyze_cross),
                        encoderAnalyzeCrossTranslation);

            if(
                    crossName == "Power / Load" || crossName == "Speed / Load" ||
                    crossName == "Force / Load" || crossName == "Speed,Power / Load" ||
                    crossName == "Force / Speed"|| crossName == "Power / Speed" )
            {
                //convert: "Force / Speed" in: "Force;Speed;mean"
                string [] crossNameFull = crossName.Split(new char[] {' '});
                analysisVariables = crossNameFull[0] + ";" + crossNameFull[2]; //[1]=="/"
                if(check_encoder_analyze_mean_or_max.Active)
                    analysisVariables += ";mean";
                else
                    analysisVariables += ";max";
            }
            else if (crossName == "Power / Date" || crossName == "Speed / Date" || crossName == "Force / Date" )
            {
                /*
                 * In order to recycle paintCrossVariables in encoder/graph.R,
                 * we send "Force / Date" as "Force;Load;(mean or max);Date" and there variables will be swapped
                 */
                //convert: "Force / Date" in: "Force;Load;mean;Date"
                string [] crossNameFull = crossName.Split(new char[] {' '});
                analysisVariables = crossNameFull[0] + ";Load";
                if(check_encoder_analyze_mean_or_max.Active)
                    analysisVariables += ";mean;Date";
                else
                    analysisVariables += ";max;Date";
            }

        }

        string my1RMName = "";
        if(sendAnalysis == "1RM") {
            my1RMName = Util.FindOnArray(':',1,0,UtilGtk.ComboGetActive(combo_encoder_analyze_1RM),
                        encoderAnalyze1RMTranslation);

            //(my1RMName == "1RM Any exercise") done below different for curve and signal
            if(my1RMName == "1RM Bench Press") {
                sendAnalysis = "1RMBadilloBench";
                analysisOptions = "p";
            } else if(my1RMName == "1RM Squat") {
                sendAnalysis = "1RMBadilloSquat";
                analysisOptions = "p";
            }
        }

        if(sendAnalysis == "powerBars" || sendAnalysis == "single" || sendAnalysis == "side")
            analysisVariables = getAnalysisVariables(sendAnalysis);

        if( ! radio_encoder_analyze_individual_current_set.Active) //not current set
        {
            string myEccon = "ec";
            if(! check_encoder_analyze_eccon_together.Active)
                myEccon = "ecS";
            int myCurveNum = -1;
            if(sendAnalysis == "single")
                myCurveNum = Convert.ToInt32(UtilGtk.ComboGetActive(
                            combo_encoder_analyze_curve_num_combo));

            dataFileName = UtilEncoder.GetEncoderGraphInputMulti();

            //neuromuscularProfile works only with ec, do not use c curves
            EncoderSQL.Eccons ecconSelect = EncoderSQL.Eccons.ALL;
            if(encoderAnalysis == "neuromuscularProfile") {
                ecconSelect = EncoderSQL.Eccons.ecS;
            }

            //double bodyMass = Convert.ToDouble(currentPersonSession.Weight);

            //select curves for this person
            ArrayList data = new ArrayList();

            if(radio_encoder_analyze_individual_current_session.Active)
            {
                //select currentPerson, currentSession curves
                //onlyActive is false to have all the curves
                //this is a need for "single" to select on display correct curve
                data = SqliteEncoder.Select(
                        false, -1, currentPerson.UniqueID, currentSession.UniqueID, getEncoderGI(),
                        getExerciseIDFromCombo(exerciseCombos.ANALYZE),
                        "curve", ecconSelect,
                        false, true);
            }
            else if(radio_encoder_analyze_groupal_current_session.Active)
            {
                for (int i=0 ; i < encSelReps.EncoderCompareInter.Count ; i ++) {
                    ArrayList dataPre = SqliteEncoder.Select(
                            false, -1,
                            Util.FetchID(encSelReps.EncoderCompareInter[i].ToString()),
                            currentSession.UniqueID,
                            getEncoderGI(),
                            getExerciseIDFromCombo(exerciseCombos.ANALYZE),
                            "curve", EncoderSQL.Eccons.ALL,
                            false, //onlyActive=false. Means: all saved repetitions
                            true);
                    foreach(EncoderSQL eSQL in dataPre) {
                        eSQL.status = "active"; //force all to be active on interperson
                        data.Add(eSQL);
                    }
                }
                LogB.Information("ENCODERCOMPAREINTER GROUP");
                foreach (string str in encSelReps.EncoderCompareInter)
                    LogB.Information(str);
            } else if(radio_encoder_analyze_individual_all_sessions.Active)
            {
                for (int i=0 ; i < encSelReps.EncoderCompareInter.Count ; i ++) {
                    ArrayList dataPre = SqliteEncoder.Select(
                            false, -1,
                            currentPerson.UniqueID,
                            Util.FetchID(encSelReps.EncoderCompareInter[i].ToString()),
                            getEncoderGI(),
                            getExerciseIDFromCombo(exerciseCombos.ANALYZE),
                            "curve", EncoderSQL.Eccons.ALL,
                            false, //onlyActive=false. Means: all saved repetitions
                            true);
                    foreach(EncoderSQL eSQL in dataPre) {
                        string comboWeightsValue = UtilGtk.ComboGetActive(combo_encoder_analyze_weights);
                        if(check_encoder_intersession_x_is_date.Active &&
                                comboWeightsValue != Catalog.GetString("All weights") &&
                                comboWeightsValue != Util.ChangeDecimalSeparator(eSQL.extraWeight))
                            continue;

                        eSQL.status = "active"; //force all to be active on intersession
                        data.Add(eSQL);
                    }
                }
                LogB.Information("ENCODERCOMPAREINTER INTERSESSION");
                foreach (string str in encSelReps.EncoderCompareInter)
                    LogB.Information(str);
            }

            //1RM is calculated using curves
            //cannot be curves of different exercises
            //because is 1RM of a person on an exercise
            //this is checked at: "on_button_encoder_analyze_clicked()"
            if(encoderAnalysis == "1RM" &&
                    (my1RMName == "1RM Bench Press" || my1RMName == "1RM Squat" || my1RMName == "1RM Any exercise") )
            {
                //get exercise ID
                int exID = -1;
                foreach(EncoderSQL eSQL in data) {
                    if(eSQL.status == "active") {
                        exID = eSQL.exerciseID;
                        break;
                    }
                }

                if(my1RMName == "1RM Any exercise") {
                    //get speed1RM (from exercise of curve on SQL, not from combo)
                    EncoderExercise exTemp = (EncoderExercise) SqliteEncoder.SelectEncoderExercises(
                        false , exID, false)[0];

                    sendAnalysis = "1RMAnyExercise";
                        analysisVariables = Util.ConvertToPoint(exTemp.speed1RM) + ";" +
                        SqlitePreferences.Select("encoder1RMMethod");
                    analysisOptions = "p";
                }
            }

            //-1 because data will be different on any curve
            ep = new EncoderParams(
                    -1,
                    -1, 		//exercisePercentBodyWeight
                    "-1",		//massBody
                    "-1",		//massExtra
                    myEccon,	//this decides if analysis will be together or separated
                    sendAnalysis,
                    analysisVariables,
                    analysisOptions,
                    preferences.encoderCaptureCheckFullyExtended,
                    preferences.encoderCaptureCheckFullyExtendedValue,
                    new EncoderConfiguration(),
                    Util.ConvertToPoint(preferences.encoderSmoothCon),	//R decimal: '.'
                    myCurveNum,
                    image_encoder_width,
                    image_encoder_height,
                    preferences.CSVExportDecimalSeparator
                    );

            //create dataFileName
            TextWriter writer = File.CreateText(dataFileName);
            writer.WriteLine("status,seriesName,exerciseName,massBody,massExtra,dateTime,fullURL,eccon,percentBodyWeight," +
                    "econfName, econfd, econfD, econfAnglePush, econfAngleWeight, econfInertia, econfGearedDown, laterality");

            ArrayList eeArray = SqliteEncoder.SelectEncoderExercises(false, -1, false);
            EncoderExercise ex = new EncoderExercise();

            LogB.Information("AT ANALYZE");

            int iteratingPerson = -1;
            int iteratingSession = -1;
            double iteratingMassBody = -1;
            int countSeries = 1;

            Sqlite.Open();
            foreach(EncoderSQL eSQL in data) {
                foreach(EncoderExercise eeSearch in eeArray)
                    if(eSQL.exerciseID == eeSearch.uniqueID)
                        ex = eeSearch;

                LogB.Debug(" AT ANALYZE 1.1 ");
                //massBody change if we are comparing different persons or sessions
                if(eSQL.personID != iteratingPerson || eSQL.sessionID != iteratingSession) {
                    iteratingMassBody = SqlitePersonSession.SelectAttribute(
                            true, eSQL.personID, eSQL.sessionID, Constants.Weight);
                }
                LogB.Debug(" AT ANALYZE 1.2 ");

                //seriesName
                string seriesName = "";
                if(radio_encoder_analyze_groupal_current_session.Active)
                {
                    foreach(string str in encSelReps.EncoderCompareInter)
                        if(Util.FetchID(str) == eSQL.personID)
                            seriesName = Util.FetchName(str);
                } else if(radio_encoder_analyze_individual_all_sessions.Active)
                {
                    foreach(string str in encSelReps.EncoderCompareInter) {
                        LogB.Information(str);
                        if(Util.FetchID(str) == eSQL.sessionID)
                            seriesName = Util.FetchName(str);
                    }
                    if(seriesName == "")
                        seriesName = currentSession.DateShortAsSQL;
                }
                if(seriesName == "")
                    seriesName = currentPerson.Name;

                /*
                 * to avoid problems on reading files from R and strange character encoding
                 * (this problem happens in Parallels (MacOSX)
                 * copy to temp
                 * and tell the csv file that it's in temp
                 */

                string safeFullURL = Path.Combine(Path.GetTempPath(),
                        "chronojump_enc_curve_" + countSeries.ToString() + ".txt");
                string fullURL = safeFullURL;

                try {
                    File.Copy(eSQL.GetFullURL(false), safeFullURL, true);
                    fullURL = fullURL.Replace("\\","/");	//R needs this separator path: "/" in all systems
                } catch {
                    fullURL = eSQL.GetFullURL(true);	//convertPathToR
                }

                writer.WriteLine(eSQL.status + "," +
                        Util.ChangeChars(seriesName,","," ") + "," + //person name cannot have commas
                        ex.name + "," +
                        Util.ConvertToPoint(iteratingMassBody).ToString() + "," +
                        Util.ConvertToPoint(Convert.ToDouble(eSQL.extraWeight)) + "," +
                        eSQL.GetDate(true) + "," +
                        fullURL + "," +
                        eSQL.eccon + "," + 	//this is the eccon of every curve
                        ex.percentBodyWeight.ToString() + "," +
                        eSQL.encoderConfiguration.ToStringOutput(EncoderConfiguration.Outputs.RCSV) + "," +
                        eSQL.LateralityToEnglish()
                        );
                countSeries ++;
            }
            writer.Flush();
            LogB.Debug(" closing writer ");
            writer.Close();
            LogB.Debug(" disposing writer ");
            ((IDisposable)writer).Dispose();
            LogB.Debug(" AT ANALYZE 2 ");
            Sqlite.Close();

        } else {	//current set
            if(encoderAnalysis == "1RM") {
                if(my1RMName == "1RM Any exercise") {
                    //get speed1RM (from combo)
                    EncoderExercise ex = (EncoderExercise) SqliteEncoder.SelectEncoderExercises(
                            false, getExerciseIDFromCombo(exerciseCombos.CAPTURE), false)[0];

                    sendAnalysis = "1RMAnyExercise";
                    analysisVariables = Util.ConvertToPoint(ex.speed1RM) + ";" +
                        SqlitePreferences.Select("encoder1RMMethod");
                    analysisOptions = "p";
                }
                else if(my1RMName == "1RM Indirect") {
                    sendAnalysis = "1RMIndirect";
                }
            }

            //if combo_encoder_analyze_curve_num_combo "All" is selected, then use a 0, else get the number
            int curveNum = 0; //all
            if(Util.IsNumber(UtilGtk.ComboGetActive(combo_encoder_analyze_curve_num_combo), false))
                curveNum = Convert.ToInt32(UtilGtk.ComboGetActive(combo_encoder_analyze_curve_num_combo));

            ep = new EncoderParams(
                    preferences.EncoderCaptureMinHeight(encoderConfigurationCurrent.has_inertia),
                    getExercisePercentBodyWeightFromComboCapture (),
                    Util.ConvertToPoint(findMass(Constants.MassType.BODY)),
                    Util.ConvertToPoint(findMass(Constants.MassType.EXTRA)),
                    findEccon(false),		//do not force ecS (ecc-conc separated)
                    sendAnalysis,
                    analysisVariables,
                    analysisOptions,
                    preferences.encoderCaptureCheckFullyExtended,
                    preferences.encoderCaptureCheckFullyExtendedValue,
                    encoderConfigurationCurrent,
                    Util.ConvertToPoint(preferences.encoderSmoothCon),	//R decimal: '.'
                    curveNum,
                    image_encoder_width,
                    image_encoder_height,
                    preferences.CSVExportDecimalSeparator
                    );

            dataFileName = UtilEncoder.GetEncoderDataTempFileName();
        }

        EncoderStruct encoderStruct = new EncoderStruct(
                dataFileName,
                UtilEncoder.GetEncoderGraphTempFileName(),
                UtilEncoder.GetEncoderAnalyzeTableTempFileName(),
                UtilEncoder.GetEncoderScriptsPathWithoutLastSep(),
                UtilEncoder.GetEncoderTempPathWithoutLastSep(),
                ep);

        string titleStr = Util.ChangeSpaceAndMinusForUnderscore(currentPerson.Name);

        if(encoderAnalysis == "neuromuscularProfile")
            titleStr = "Neuromuscular Profile" + "-" + titleStr;
        else {
            //on signal show encoder exercise, but not in curves because every curve can be of a different exercise
            if(radio_encoder_analyze_individual_current_set.Active) //current set
                titleStr += "-" + Util.ChangeSpaceAndMinusForUnderscore(UtilGtk.ComboGetActive(combo_encoder_exercise_capture));
        }

        encoderRProcAnalyze.SendData(
                titleStr,
                encoderAnalysis == "neuromuscularProfile",
                preferences.RGraphsTranslate);

        encoderRProcAnalyze.StartOrContinue(encoderStruct);
    }
Ejemplo n.º 7
0
    public EncoderStruct(string InputData, string OutputGraph, string OutputData1, string OutputData2,
		       EncoderParams Ep)
    {
        this.InputData = InputData;
        this.OutputGraph = OutputGraph;
        this.OutputData1 = OutputData1;
        this.OutputData2 = OutputData2;
        this.Ep = Ep;
    }
Ejemplo n.º 8
0
		public void Init(double fps, TVStandard tvStd, BGFlags bgFlags)
		{
		    LastEncoderParams = new EncoderParams { FPS = fps, TVStandard = tvStd, BGFlags = bgFlags };
			if(FEncoderRingBuffer != null)
				FEncoderRingBuffer.Dispose();
			
			var encoder = new Encoder(AudioEngine.Instance.Settings.SampleRate, fps, tvStd, bgFlags);
			FEncoderRingBuffer = new LTCPullBuffer(encoder);
			FInitialized = true;
		}
Ejemplo n.º 9
0
    //TODO: garantir path windows
    void on_button_encoder_capture_clicked(object o, EventArgs args)
    {
        double heightHigherCondition = -1;
        if(repetitiveConditionsWin.EncoderHeightHigher)
            heightHigherCondition = repetitiveConditionsWin.EncoderHeightHigherValue;
        double heightLowerCondition = -1;
        if(repetitiveConditionsWin.EncoderHeightLower)
            heightLowerCondition = repetitiveConditionsWin.EncoderHeightLowerValue;

        double meanSpeedHigherCondition = -1;
        if(repetitiveConditionsWin.EncoderMeanSpeedHigher)
            meanSpeedHigherCondition = repetitiveConditionsWin.EncoderMeanSpeedHigherValue;
        double meanSpeedLowerCondition = -1;
        if(repetitiveConditionsWin.EncoderMeanSpeedLower)
            meanSpeedLowerCondition = repetitiveConditionsWin.EncoderMeanSpeedLowerValue;

        double maxSpeedHigherCondition = -1;
        if(repetitiveConditionsWin.EncoderMaxSpeedHigher)
            maxSpeedHigherCondition = repetitiveConditionsWin.EncoderMaxSpeedHigherValue;
        double maxSpeedLowerCondition = -1;
        if(repetitiveConditionsWin.EncoderMaxSpeedLower)
            maxSpeedLowerCondition = repetitiveConditionsWin.EncoderMaxSpeedLowerValue;

        int powerHigherCondition = -1;
        if(repetitiveConditionsWin.EncoderPowerHigher)
            powerHigherCondition = repetitiveConditionsWin.EncoderPowerHigherValue;
        int powerLowerCondition = -1;
        if(repetitiveConditionsWin.EncoderPowerLower)
            powerLowerCondition = repetitiveConditionsWin.EncoderPowerLowerValue;

        int peakPowerHigherCondition = -1;
        if(repetitiveConditionsWin.EncoderPeakPowerHigher)
            peakPowerHigherCondition = repetitiveConditionsWin.EncoderPeakPowerHigherValue;
        int peakPowerLowerCondition = -1;
        if(repetitiveConditionsWin.EncoderPeakPowerLower)
            peakPowerLowerCondition = repetitiveConditionsWin.EncoderPeakPowerLowerValue;

        //capture data
        EncoderParams ep = new EncoderParams(
                (int) spin_encoder_capture_time.Value,
                (int) spin_encoder_capture_min_height.Value,
                Convert.ToInt32(
                    Util.FindOnArray(':', 2, 3, UtilGtk.ComboGetActive(combo_encoder_exercise),
                    encoderExercisesTranslationAndBodyPWeight) ),	//ex.percentBodyWeight
                findMass(true),
                Util.ConvertToPoint((double) spin_encoder_smooth.Value), //R decimal: '.'
                findEccon(true),					//force ecS (ecc-conc separated)
                heightHigherCondition, heightLowerCondition,
                meanSpeedHigherCondition, meanSpeedLowerCondition,
                maxSpeedHigherCondition, maxSpeedLowerCondition,
                powerHigherCondition, powerLowerCondition,
                peakPowerHigherCondition, peakPowerLowerCondition
                );

        EncoderStruct es = new EncoderStruct(
                "",					//no data input
                "",					//no graph ouptut
                Util.GetEncoderDataTempFileName(), "", ep);

        Util.RunPythonEncoder(Constants.EncoderScriptCapture, es, true);

        encoderTimeStamp = UtilDate.ToFile(DateTime.Now);
        encoderSignalUniqueID = "-1"; //mark to know that there's no ID for this until it's saved on database

        encoderThreadStart(encoderModes.CAPTURE);
    }
Ejemplo n.º 10
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 encoderCreateCurvesGraphR()
    {
        EncoderParams ep = new EncoderParams(
                (int) spin_encoder_capture_min_height.Value,
                Convert.ToInt32(
                    Util.FindOnArray(':', 2, 3, UtilGtk.ComboGetActive(combo_encoder_exercise),
                    encoderExercisesTranslationAndBodyPWeight) ),	//ex.percentBodyWeight
                findMass(true),
                findEccon(true),					//force ecS (ecc-conc separated)
                "curves",
                Util.ConvertToPoint((double) spin_encoder_smooth.Value), //R decimal: '.'
                   	0, 			//curve is not used here
                image_encoder_width, image_encoder_height);

        EncoderStruct es = new EncoderStruct(
                Util.GetEncoderDataTempFileName(),
                Util.GetEncoderGraphTempFileName(),
                Util.GetEncoderCurvesTempFileName(),
                "NULL", ep);

        Util.RunPythonEncoder(Constants.EncoderScriptGraphCall, es,false);

        //store this to show 1,2,3,4,... or 1e,1c,2e,2c,... in RenderN
        //if is not stored, it can change when changed eccon radiobutton on cursor is in treeview
        ecconLast = findEccon(false);
    }
Ejemplo n.º 11
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 analyze()
    {
        EncoderParams ep = new EncoderParams();
        string dataFileName = "";

        //use this send because we change it to send it to R
        //but we don't want to change encoderAnalysis because we want to know again if == "cross"
        string sendAnalysis = encoderAnalysis;

        if(sendAnalysis == "cross") {
            string crossName = Util.FindOnArray(':',1,0,UtilGtk.ComboGetActive(combo_encoder_analyze_cross),
                        encoderAnalyzeCrossTranslation);
            //convert: "Force / Speed" in: "cross.Force.Speed.mean"
            string [] crossNameFull = crossName.Split(new char[] {' '});
            sendAnalysis += "." + crossNameFull[0] + "." + crossNameFull[2]; //[1]=="/"
            if(radiobutton_encoder_analyze_mean.Active)
                sendAnalysis += ".mean";
            else
                sendAnalysis += ".max";
        }

        if(radiobutton_encoder_analyze_data_user_curves.Active) {
            string myEccon = "ec";
            if(! radiobutton_encoder_eccon_together.Active)
                myEccon = "ecS";
            int myCurveNum = -1;
            if(sendAnalysis == "single")
                myCurveNum = (int) spin_encoder_analyze_curve_num.Value;

            //-1 because data will be different on any curve
            ep = new EncoderParams(
                    -1,
                    Convert.ToInt32(
                        Util.FindOnArray(':', 2, 3, UtilGtk.ComboGetActive(combo_encoder_exercise),
                        encoderExercisesTranslationAndBodyPWeight) ),
                    "-1",			//mass
                    myEccon,	//this decides if analysis will be together or separated
                    sendAnalysis,
                    "-1",
                    myCurveNum,
                    image_encoder_width,
                    image_encoder_height);

            dataFileName = Util.GetEncoderGraphInputMulti();

            //create dataFileName
            double bodyMass = Convert.ToDouble(currentPersonSession.Weight);
            ArrayList data = SqliteEncoder.Select(false, -1,
                    currentPerson.UniqueID, currentSession.UniqueID, "curve");

            TextWriter writer = File.CreateText(dataFileName);
            writer.WriteLine("exerciseName,mass,smoothingOne,dateTime,fullURL,eccon");
            foreach(EncoderSQL eSQL in data) {
                double mass = Convert.ToDouble(eSQL.extraWeight); //TODO: future problem if this has '%'
                EncoderExercise ex = (EncoderExercise)
                    SqliteEncoder.SelectEncoderExercises(eSQL.exerciseID,false)[0];
                mass += bodyMass * ex.percentBodyWeight / 100.0;

                writer.WriteLine(ex.name + "," + Util.ConvertToPoint(mass).ToString() + "," +
                        Util.ConvertToPoint(eSQL.smooth) + "," + eSQL.GetDate(true) + "," +
                        eSQL.GetFullURL() + "," +
                        eSQL.eccon	//this is the eccon of every curve
                        );
            }
            writer.Flush();
            ((IDisposable)writer).Dispose();
        } else {
            ep = new EncoderParams(
                    (int) spin_encoder_capture_min_height.Value,
                    Convert.ToInt32(
                        Util.FindOnArray(':', 2, 3, UtilGtk.ComboGetActive(combo_encoder_exercise),
                        encoderExercisesTranslationAndBodyPWeight) ),
                    findMass(true),
                    findEccon(false),		//do not force ecS (ecc-conc separated)
                    sendAnalysis,
                    Util.ConvertToPoint((double) spin_encoder_smooth.Value), //R decimal: '.'
                    (int) spin_encoder_analyze_curve_num.Value,
                    image_encoder_width,
                    image_encoder_height);

            dataFileName = Util.GetEncoderDataTempFileName();
        }

        EncoderStruct encoderStruct = new EncoderStruct(
                dataFileName,
                Util.GetEncoderGraphTempFileName(),
                "NULL", "NULL", ep);		//no data ouptut

        Util.RunPythonEncoder(Constants.EncoderScriptGraphCall, encoderStruct, false);
    }