Find() public static method

public static Find ( ArrayList papsArray, int personID ) : int
papsArray ArrayList
personID int
return int
Exemplo n.º 1
0
    protected void printJumpsRj(bool showSubjumps, string title)
    {
        int dec = preferences.digitsNumber;       //decimals

        ArrayList myData        = new ArrayList(1);
        bool      isFirstHeader = true;

        if (myJumpsRj.Length > 0)
        {
            printTitles(title);
        }

        foreach (string jump in myJumpsRj)
        {
            if (showSubjumps)
            {
                myData = new ArrayList(1);
            }

            string weightName = Catalog.GetString("Weight");
            if (preferences.weightStatsPercent)
            {
                weightName += " %";
            }
            else
            {
                weightName += " Kg";
            }

            //TODO: add power and stiffness

            //if show subjumps show this every time, else show only one
            if (isFirstHeader || showSubjumps)
            {
                myData.Add("\n" +
                           Catalog.GetString("Person ID") + ":" +
                           Catalog.GetString("Person name") + ":" +
                           Catalog.GetString("jump ID") + ":" +
                           Catalog.GetString("jump Type") + ":" +
                           Catalog.GetString("TC Max") + ":" +
                           Catalog.GetString("TF Max") + ":" +
                           Catalog.GetString("Max Height") + ":" +
                           Catalog.GetString("Max Initial Speed") + ":" +
                           Catalog.GetString("TC AVG") + ":" +
                           Catalog.GetString("TF AVG") + ":" +
                           Catalog.GetString("AVG Height") + ":" +
                           Catalog.GetString("AVG Initial Speed") + ":" +
                           Catalog.GetString("Fall") + ":" +
                           weightName + ":" +
                           Catalog.GetString("Jumps") + ":" +
                           Catalog.GetString("Time") + ":" +
                           Catalog.GetString("Limited") + ":" +
                           Catalog.GetString("Description") + ":" +
                           //Catalog.GetString("Angles") + ":" +
                           Catalog.GetString("Simulated")
                           );
                isFirstHeader = false;
            }

            string [] myStr = jump.Split(new char[] { ':' });


            //find weight of person and extra weight
            int papsPosition = PersonAndPSUtil.Find(myPersonsAndPS,
                                                    Convert.ToInt32(myStr[2])); //personID

            if (papsPosition == -1)
            {
                LogB.Error("PersonsAndPSUtil don't found person:", myStr[2]);
                return;
            }

            double personWeight    = ((PersonAndPS)myPersonsAndPS[papsPosition]).ps.Weight;
            double extraWeightInKg = Util.WeightFromPercentToKg(
                Convert.ToDouble(myStr[8]),
                personWeight);

            string extraWeightPrint = "";
            if (preferences.weightStatsPercent)
            {
                extraWeightPrint = myStr[8];
            }
            else
            {
                extraWeightPrint = extraWeightInKg.ToString();
            }

            //end of find weight of person and extra weight

            myData.Add(
                myStr[2] + ":" +                                                                         //jumpRj.personID
                myStr[0] + ":" + myStr[1] + ":" +                                                        //person.name, jumpRj.uniqueID
                //myStr[2] + ":" +  myStr[3] + ":" +    //jumpRj.personID, jumpRj.sessionID
                myStr[4] + ":" +                                                                         //jumpRj.type
                Util.TrimDecimals(myStr[6], dec) + ":" +                                                 //jumpRj.tcMax
                Util.TrimDecimals(myStr[5], dec) + ":" +                                                 //jumpRj.tvMax
                Util.TrimDecimals(Util.GetHeightInCentimeters(myStr[5]), dec) + ":" +                    //Max height
                Util.TrimDecimals(Util.GetInitialSpeed(
                                      myStr[5], preferences.metersSecondsPreferred), dec) + ":" +        //Max initial speed (true:m/s)
                Util.TrimDecimals(myStr[11], dec) + ":" +                                                //jumpRj.tcAvg
                Util.TrimDecimals(myStr[10], dec) + ":" +                                                //jumpRj.tvAvg
                Util.TrimDecimals(Util.GetHeightInCentimeters(myStr[10]), dec) + ":" +                   //Avg height
                Util.TrimDecimals(Util.GetInitialSpeed(
                                      myStr[10], preferences.metersSecondsPreferred), dec) + ":" +       //Avg Initial speed (true:m/s)
                myStr[7] + ":" +                                                                         //jumpRj.Fall
                //myStr[8] + ":" +  myStr[14] + ":" +   //jumpRj.Weight, jumpRj.Jumps
                Util.TrimDecimals(extraWeightPrint, dec) + ":" + myStr[14] + ":" +                       //jumpRj.Weight, jumpRj.Jumps
                Util.TrimDecimals(myStr[15], dec) + ":" + Util.GetLimitedRounded(myStr[16], dec) + ":" + //jumpRj.Time, jumpRj.Limited
                Util.RemoveNewLine(myStr[9], true) + ":" +                                               //jumpRj.Description
                //myStr[17] + ":" +     //jumpRj.Angle
                Util.SimulatedTestNoYes(Convert.ToInt32(myStr[18]))                                      //simulated
                );

            if (showSubjumps)
            {
                writeData(myData);

                myData = new ArrayList(1);
                //print tvString and tcString
                string [] tvString = myStr[12].Split(new char[] { '=' });
                string [] tcString = myStr[13].Split(new char[] { '=' });
                int       count    = 0;
                myData.Add(" " + ":" + Catalog.GetString("TC") +
                           ":" + Catalog.GetString("TF") +
                           ":" + Catalog.GetString("Height") +
                           ":" + Catalog.GetString("Power") +
                           ":" + Catalog.GetString("Stiffness")
                           );

                //print Total, AVG, SD
                myData.Add(Catalog.GetString("Total") + ":" +
                           Util.TrimDecimals(Util.GetTotalTime(myStr[13]).ToString(), dec) + ":" +
                           Util.TrimDecimals(Util.GetTotalTime(myStr[12]).ToString(), dec));
                myData.Add(Catalog.GetString("AVG") + ":" +
                           Util.TrimDecimals(Util.GetAverage(myStr[13]).ToString(), dec) + ":" +
                           Util.TrimDecimals(Util.GetAverage(myStr[12]).ToString(), dec));
                myData.Add(Catalog.GetString("SD") + ":" +
                           Util.TrimDecimals(Util.CalculateSD(
                                                 Util.ChangeEqualForColon(myStr[13]),
                                                 Util.GetTotalTime(myStr[13]),
                                                 Util.GetNumberOfJumps(myStr[13], false)).ToString(),
                                             dec) + ":" +
                           Util.TrimDecimals(Util.CalculateSD(
                                                 Util.ChangeEqualForColon(myStr[12]),
                                                 Util.GetTotalTime(myStr[12]),
                                                 Util.GetNumberOfJumps(myStr[12], false)).ToString(),
                                             dec));

                foreach (string myTv in tvString)
                {
                    double tc = Convert.ToDouble(tcString[count]);
                    double tv = Convert.ToDouble(myTv);

                    //on first jump use fall from RJ option
                    //on next jumps calculate from previous TV
                    double fall;
                    if (count == 0)
                    {
                        fall = Convert.ToDouble(myStr[7]);                         //jumpRj.Fall
                    }
                    else
                    {
                        fall = Convert.ToDouble(Util.GetHeightInCentimeters(tvString[count - 1].ToString()));
                    }

                    myData.Add((count + 1).ToString() + ":" +
                               Util.TrimDecimals(tc, dec) + ":" +
                               Util.TrimDecimals(tv, dec) + ":" +
                               Util.TrimDecimals(Util.GetHeightInCentimeters(tv.ToString()), dec) + ":" +
                               Util.TrimDecimals(getPower(tc, tv, personWeight, extraWeightInKg, fall), dec) + ":" +
                               Util.TrimDecimals(Util.GetStiffness(personWeight, extraWeightInKg, tv, tc), dec)
                               );
                    count++;
                }
                writeData(myData);
                writeData("VERTICAL-SPACE");
            }
        }

        //if not showSubjumps write data at last for not having every row as TH
        if (!showSubjumps)
        {
            writeData(myData);
        }
    }
Exemplo n.º 2
0
    protected void printJumps(string title)
    {
        int dec = preferences.digitsNumber;         //decimals

        string weightName = Catalog.GetString("Weight");

        if (preferences.weightStatsPercent)
        {
            weightName += " %";
        }
        else
        {
            weightName += " Kg";
        }

        if (myJumps.Length > 0)
        {
            printTitles(title);

            ArrayList myData = new ArrayList(1);
            myData.Add("\n" +
                       Catalog.GetString("Person ID") + ":" +
                       Catalog.GetString("Person name") + ":" +
                       Catalog.GetString("jump ID") + ":" +
                       Catalog.GetString("Type") + ":" +
                       Catalog.GetString("TC") + ":" +
                       Catalog.GetString("TF") + ":" +
                       Catalog.GetString("Fall") + ":" +
                       weightName + ":" +
                       Catalog.GetString("Height") + ":" +
                       Catalog.GetString("Power") + ":" +
                       Catalog.GetString("Stiffness") + ":" +
                       Catalog.GetString("Initial Speed") + ":" +
                       Catalog.GetString("Description") + ":" +
                       Catalog.GetString("Angle") + ":" +
                       Catalog.GetString("Simulated")
                       );


            foreach (string jumpString in myJumps)
            {
                string [] myStr = jumpString.Split(new char[] { ':' });


                //find weight of person and extra weight
                int papsPosition = PersonAndPSUtil.Find(myPersonsAndPS,
                                                        Convert.ToInt32(myStr[2])); //personID

                if (papsPosition == -1)
                {
                    LogB.Error("PersonsAndPSUtil don't found person:", myStr[2]);
                    return;
                }

                double personWeight    = ((PersonAndPS)myPersonsAndPS[papsPosition]).ps.Weight;
                double extraWeightInKg = Util.WeightFromPercentToKg(
                    Convert.ToDouble(myStr[8]),
                    personWeight);

                string extraWeightPrint = "";
                if (preferences.weightStatsPercent)
                {
                    extraWeightPrint = myStr[8];
                }
                else
                {
                    extraWeightPrint = extraWeightInKg.ToString();
                }

                //end of find weight of person and extra weight

                double fall = Convert.ToDouble(myStr[7]);
                double tc   = Convert.ToDouble(myStr[6]);
                double tf   = Convert.ToDouble(myStr[5]);

                myData.Add(
                    myStr[2] + ":" + myStr[0] + ":" +                                                 //person.UniqueID, person.Name
                    myStr[1] + ":" +                                                                  //jump.uniqueID
                    myStr[4] + ":" + Util.TrimDecimals(myStr[6], dec) + ":" +                         //jump.type, jump.tc
                    Util.TrimDecimals(myStr[5], dec) + ":" + Util.TrimDecimals(myStr[7], dec) + ":" + //jump.tv, jump.fall
                    Util.TrimDecimals(extraWeightPrint, dec) + ":" +
                    Util.TrimDecimals(Util.GetHeightInCentimeters(myStr[5]), dec) + ":" +
                    Util.TrimDecimals(getPower(tc, tf, personWeight, extraWeightInKg, fall), dec) + ":" +
                    Util.TrimDecimals(Util.GetStiffness(personWeight, extraWeightInKg, tf, tc), dec) + ":" +
                    Util.TrimDecimals(Util.GetInitialSpeed(myStr[5], preferences.metersSecondsPreferred), dec) + ":" + //true: m/s
                    Util.RemoveNewLine(myStr[9], true) + ":" +                                                         //jump.description
                    Util.TrimDecimals(myStr[10], dec) + ":" +                                                          //jump.angle
                    Util.SimulatedTestNoYes(Convert.ToInt32(myStr[11]))                                                //jump.simulated

                    );
            }

            writeData(myData);
            writeData("VERTICAL-SPACE");
        }
    }