[chronojump] runInterval stats
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] runInterval stats
- Date: Mon, 14 Mar 2011 19:30:29 +0000 (UTC)
commit fb3a2155a5fd8f61a3e1488c931d447526cb8af5
Author: Xavier de Blas <xaviblas gmail com>
Date: Sun Mar 13 18:52:16 2011 +0100
runInterval stats
po/POTFILES.in | 1 +
src/Makefile.am | 1 +
src/constants.cs | 1 +
src/gui/stats.cs | 42 +++++--
src/sqlite/stat.cs | 134 +++++++++++++++++++++-
src/statType.cs | 28 ++++-
src/stats/main.cs | 4 +-
src/stats/runIntervallic.cs | 273 +++++++++++++++++++++++++++++++++++++++++++
src/util.cs | 41 +++++++
9 files changed, 504 insertions(+), 21 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index e6e8433..7759c43 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -74,6 +74,7 @@ src/stats/rjEvolution.cs
src/stats/rjIndex.cs
src/stats/rjPotencyBosco.cs
src/stats/runSimple.cs
+src/stats/runIntervallic.cs
src/stats/sjCmjAbk.cs
src/stats/sjCmjAbkPlus.cs
src/treeViewEvent.cs
diff --git a/src/Makefile.am b/src/Makefile.am
index 54d17db..692eca9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -116,6 +116,7 @@ FILES = \
stats/potency.cs\
stats/rjAVGSD.cs\
stats/runSimple.cs\
+ stats/runIntervallic.cs\
stats/graphs/graphData.cs\
stats/graphs/graphROptions.cs\
stats/graphs/graphSerie.cs\
diff --git a/src/constants.cs b/src/constants.cs
index 879f93e..87e0bcc 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -238,6 +238,7 @@ public class Constants
public static string TypeJumpsSimpleWithTC = Catalog.GetString("Jumps: Simple with TC");
public static string TypeJumpsReactive = Catalog.GetString("Jumps: Reactive");
public static string TypeRunsSimple = Catalog.GetString("Runs: Simple");
+ public static string TypeRunsIntervallic = Catalog.GetString("Runs: Intervallic");
//strings
public static string AllJumpsName = Catalog.GetString("See all jumps");
diff --git a/src/gui/stats.cs b/src/gui/stats.cs
index d979118..b1e30aa 100644
--- a/src/gui/stats.cs
+++ b/src/gui/stats.cs
@@ -137,6 +137,7 @@ public class StatsWindow {
Constants.TypeJumpsSimpleWithTC,
Constants.TypeJumpsReactive,
Constants.TypeRunsSimple,
+ Constants.TypeRunsIntervallic,
};
private static string [] comboStatsSubTypeWithTCOptions = {
@@ -615,6 +616,17 @@ public class StatsWindow {
combo_stats_stat_apply_to.Sensitive = true;
combo_stats_stat_apply_to.Active = 0;
}
+ else if (UtilGtk.ComboGetActive(combo_stats_stat_type) == Constants.TypeRunsIntervallic )
+ {
+ UtilGtk.ComboUpdate(combo_stats_stat_subtype, comboStatsSubTypeSimpleOptions, "");
+ combo_stats_stat_subtype.Sensitive = false;
+ combo_stats_stat_subtype.Active = 0;
+
+ UtilGtk.ComboUpdate(combo_stats_stat_apply_to,
+ SqliteRunIntervalType.SelectRunIntervalTypes(Constants.AllRunsName, true), ""); //only select name
+ combo_stats_stat_apply_to.Sensitive = true;
+ combo_stats_stat_apply_to.Active = 0;
+ }
fillTreeView_stats(false);
}
@@ -684,9 +696,10 @@ public class StatsWindow {
}
/*
- if is RjEvolution, show mark consecutives, graph only with lines and transposed
+ if is RjEvolution, or runInervallic show mark consecutives, graph only with lines and transposed
*/
- if (UtilGtk.ComboGetActive(combo_stats_stat_subtype) == Catalog.GetString("Evolution") ) {
+ if ( UtilGtk.ComboGetActive(combo_stats_stat_subtype) == Catalog.GetString("Evolution") ||
+ UtilGtk.ComboGetActive(combo_stats_stat_type) == Constants.TypeRunsIntervallic ) {
hbox_mark_consecutives.Show();
checkbutton_transposed.Active = true;
checkbutton_transposed.Sensitive = false;
@@ -789,10 +802,14 @@ public class StatsWindow {
sendSelectedSessions = selectedSessions;
}
- int rj_evolution_mark_consecutives = -1;
- if (UtilGtk.ComboGetActive(combo_stats_stat_subtype) == Catalog.GetString("Evolution") &&
+ //the mark best jumps or runs is only on rjEvolution and runInterval
+ //runInterval has only one stat subtype and is like rjEvolution
+ int evolution_mark_consecutives = -1;
+ if (
+ ( UtilGtk.ComboGetActive(combo_stats_stat_subtype) == Catalog.GetString("Evolution") ||
+ UtilGtk.ComboGetActive(combo_stats_stat_type) == Constants.TypeRunsIntervallic ) &&
checkbutton_mark_consecutives.Active ) {
- rj_evolution_mark_consecutives = Convert.ToInt32 ( spinbutton_mark_consecutives.Value );
+ evolution_mark_consecutives = Convert.ToInt32 ( spinbutton_mark_consecutives.Value );
}
ArrayList markedRows = new ArrayList();
@@ -820,7 +837,7 @@ public class StatsWindow {
heightPreferred,
weightStatsPercent,
markedRows,
- rj_evolution_mark_consecutives,
+ evolution_mark_consecutives,
graphROptions,
graph,
toReport //always false in this class
@@ -1054,17 +1071,19 @@ public class StatsWindow {
return;
//some stats should not be showed as limited jumps
- if(statisticType == Constants.TypeJumpsReactive &&
+ if( (statisticType == Constants.TypeJumpsReactive &&
( statisticSubType == Catalog.GetString("Evolution") ||
statisticSubType == Constants.RJAVGSDRjIndexName ||
- statisticSubType == Constants.RJAVGSDQIndexName)
- ) {
+ statisticSubType == Constants.RJAVGSDQIndexName) )
+ || statisticType == Constants.TypeRunsIntervallic )
+ {
//don't allow Evolution be multisession
radiobutton_current_session.Active = true;
radiobutton_selected_sessions.Sensitive = false;
//has no sense to study the AVG of rj tv tc evolution string
- //nota fair to make avg of each subjump,
+ //not fair to make avg of each subjump,
//specially when some RJs have more jumps than others
+ //TODO: check this for runInterval
if(radiobutton_stats_jumps_person_average.Active) {
radiobutton_stats_jumps_person_bests.Active = true;
}
@@ -1271,7 +1290,8 @@ public class StatsWindow {
//in the first the value of Entry.Text is "";
return;
} else {
- if (statisticSubType == Catalog.GetString("Evolution") &&
+ if ( ( statisticSubType == Catalog.GetString("Evolution") ||
+ statisticType == Constants.TypeRunsIntervallic ) &&
checkbutton_mark_consecutives.Active ) {
statisticSubType += "." + ( spinbutton_mark_consecutives.Value ).ToString();
}
diff --git a/src/sqlite/stat.cs b/src/sqlite/stat.cs
index b5d7072..122e526 100644
--- a/src/sqlite/stat.cs
+++ b/src/sqlite/stat.cs
@@ -558,7 +558,7 @@ class SqliteStat : Sqlite
}
- //for rjEvolution (for know the name of columns)
+ //for rjEvolution (to know the number of columns)
public static int ObtainMaxNumberOfJumps (string sessionString)
{
dbcon.Open();
@@ -586,6 +586,37 @@ class SqliteStat : Sqlite
return 0;
}
}
+
+ //for start/RunIntervallic (to know the number of columns)
+ public static int ObtainMaxNumberOfRuns (string sessionString)
+ {
+ dbcon.Open();
+ dbcmd.CommandText = "SELECT MAX(tracks) from runInterval " + sessionString +
+ "group by tracks order by tracks DESC limit 1";
+ //this is done because if no jumps, and we don't write last line, it returns a blank line
+ //and this crashes when converted to string
+ Log.WriteLine(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+ SqliteDataReader reader;
+ reader = dbcmd.ExecuteReader();
+ int myReturn = 0;
+
+ bool found = false;
+ if(reader.Read()) {
+ found = true;
+ //should be "floored" down because tracks are float and if we normally round, can be to a high value
+ //flooring ensures that there will be the exepcted number of values between '=' on intervalTimesString
+ myReturn = Convert.ToInt32(Math.Floor(Convert.ToDouble(reader[0].ToString())));
+ }
+ reader.Close();
+ dbcon.Close();
+
+ if (found) {
+ return myReturn;
+ } else {
+ return 0;
+ }
+ }
//convert the strings of TFs and TCs separated by '=' in
//one string mixed and separated by ':' (starting by an ':')
@@ -716,6 +747,107 @@ class SqliteStat : Sqlite
return myArray;
}
+ //maxRuns for make all the results of same length (fill it with '-'s)
+ //only simple session
+ public static ArrayList RunInterval (string sessionString, bool multisession, string operationString, string runType, bool showSex, int maxRuns)
+ {
+ string tp = Constants.PersonTable;
+
+ string ini = "";
+ string end = "";
+ if(operationString == "MAX") {
+ ini = "MAX(";
+ end = ")";
+ } else if(operationString == "AVG") {
+ ini = "AVG(";
+ end = ")";
+ }
+
+ string orderByString = "ORDER BY ";
+ string moreSelect = "";
+ moreSelect = ini + "(distanceTotal / timeTotal *1.0)" + end + " AS speed, distanceInterval, intervalTimesString, distancesString"; //*1.0 for having double division
+
+ //manage allRuns
+ string fromString = " FROM " + Constants.RunIntervalTable + ", " +
+ tp + ", " + Constants.RunIntervalTypeTable + " ";
+ string runTypeString = " AND " + Constants.RunIntervalTable + ".type == '" + runType + "' ";
+ if(runType == Constants.AllRunsName) {
+ moreSelect = moreSelect + ", " + Constants.RunIntervalTable + ".type ";
+ runTypeString = "";
+ }
+
+ //if we use AVG or MAX, then we have to group by the results
+ //if there's more than one session, it sends the avg or max
+ string groupByString = "";
+ if (ini.Length > 0) {
+ groupByString = " GROUP BY " +
+ Constants.RunIntervalTable + ".personID, " +
+ Constants.RunIntervalTable + ".sessionID ";
+ }
+ //if multisession, order by person.name, sessionID for being able to present results later
+ //if(multisession) {
+ // orderByString = orderByString + tp + ".name, jumpRj.sessionID, ";
+ //}
+
+ dbcon.Open();
+ dbcmd.CommandText = "SELECT " + tp + ".name, " + tp + ".sex, sessionID, " + moreSelect +
+ fromString +
+ sessionString +
+ runTypeString +
+ " AND " + Constants.RunIntervalTable + ".personID == " + tp + ".uniqueID " +
+ " AND " + Constants.RunIntervalTable + ".type == " + Constants.RunIntervalTypeTable + ".name " +
+ groupByString +
+ orderByString + " speed DESC ";
+
+ Log.WriteLine(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+
+ SqliteDataReader reader;
+ reader = dbcmd.ExecuteReader();
+
+ string showSexString = "";
+ string showRunTypeString = "";
+ string returnSessionString = "";
+ ArrayList myArray = new ArrayList(2);
+ while(reader.Read()) {
+ if(showSex) {
+ showSexString = "." + reader[1].ToString() ;
+ }
+ //manage allRuns (show runType beside name (and sex))
+ //but only if it's not an AVG of different jumps
+ if(runType == Constants.AllRunsName && operationString != "AVG") {
+ showRunTypeString = " (" + reader[7].ToString() + ")";
+ }
+
+ /*
+ if(multisession) {
+ returnSessionString = ":" + reader[2].ToString();
+ }
+ */
+
+ //convert the strings of distance, time separated by '=' in
+ //one string of speed and separated by ':'
+ string intervalSpeeds = Util.GetRunISpeedsString(
+ Convert.ToDouble(reader[4].ToString()), //distanceInterval
+ Util.ChangeDecimalSeparator(reader[5].ToString()), //intervalTimesString
+ Util.ChangeDecimalSeparator(reader[6].ToString()), //distancesString
+ ":", //new separator
+ maxRuns
+ );
+Log.WriteLine(intervalSpeeds);
+
+
+ myArray.Add (reader[0].ToString() + showSexString + showRunTypeString +
+ returnSessionString + ":" + //session
+ Util.ChangeDecimalSeparator(reader[3].ToString()) + ":" + //speed
+ intervalSpeeds
+ );
+ }
+ reader.Close();
+ dbcon.Close();
+ return myArray;
+ }
+
public static ArrayList IeIub (string sessionString, bool multisession, string ini, string end, string jump1, string jump2, bool showSex)
{
string tp = Constants.PersonTable;
diff --git a/src/statType.cs b/src/statType.cs
index 7799093..ecb81e2 100644
--- a/src/statType.cs
+++ b/src/statType.cs
@@ -69,7 +69,7 @@ public class StatType {
string statisticSubType;
string statisticApplyTo;
Gtk.TreeView treeview_stats;
- int rj_evolution_mark_consecutives;
+ int evolution_mark_consecutives;
ArrayList markedRows;
ArrayList personsWithData;
@@ -106,7 +106,7 @@ public class StatType {
ArrayList sendSelectedSessions, int prefsDigitsNumber, bool sex_active,
int statsJumpsType, int limit, bool heightPreferred, bool weightStatsPercent,
ArrayList markedRows,
- int rj_evolution_mark_consecutives,
+ int evolution_mark_consecutives,
GraphROptions gRO,
bool graph, bool toReport)
{
@@ -118,7 +118,7 @@ public class StatType {
this.markedRows = markedRows;
- this.rj_evolution_mark_consecutives = rj_evolution_mark_consecutives;
+ this.evolution_mark_consecutives = evolution_mark_consecutives;
this.graph = graph;
this.toReport = toReport;
@@ -161,7 +161,7 @@ public class StatType {
ArrayList sendSelectedSessions, int prefsDigitsNumber, bool sex_active,
int statsJumpsType, int limit, bool heightPreferred, bool weightStatsPercent,
ArrayList markedRows,
- int rj_evolution_mark_consecutives,
+ int evolution_mark_consecutives,
GraphROptions gRO,
bool graph, bool toReport, TextWriter writer, string fileName,
int statCount
@@ -173,7 +173,7 @@ public class StatType {
this.markedRows = markedRows;
- this.rj_evolution_mark_consecutives = rj_evolution_mark_consecutives;
+ this.evolution_mark_consecutives = evolution_mark_consecutives;
this.graph = graph;
this.toReport = toReport;
@@ -345,9 +345,9 @@ public class StatType {
else if(statisticSubType == Catalog.GetString("Evolution"))
{
if(graph)
- myStat = new GraphRjEvolution (myStatTypeStruct, rj_evolution_mark_consecutives);
+ myStat = new GraphRjEvolution (myStatTypeStruct, evolution_mark_consecutives);
else
- myStat = new StatRjEvolution(myStatTypeStruct, rj_evolution_mark_consecutives, treeview_stats);
+ myStat = new StatRjEvolution(myStatTypeStruct, evolution_mark_consecutives, treeview_stats);
}
else if(statisticSubType == Constants.RJAVGSDRjIndexName)
{
@@ -376,6 +376,20 @@ public class StatType {
else
myStat = new StatRunSimple (myStatTypeStruct, treeview_stats);
}
+ else if(statisticType == Constants.TypeRunsIntervallic)
+ {
+ if(statisticApplyTo.Length == 0) {
+ Log.WriteLine("Simple-ret");
+ return false;
+ }
+
+ //if(graph)
+ //myStat = new GraphRunIntervallic (myStatTypeStruct, evolution_mark_consecutives);
+ //else
+ if(!graph)
+ myStat = new StatRunIntervallic (myStatTypeStruct,
+ evolution_mark_consecutives, treeview_stats);
+ }
myStat.FakeButtonRowCheckedUnchecked.Clicked +=
new EventHandler(on_fake_button_row_checked_clicked);
diff --git a/src/stats/main.cs b/src/stats/main.cs
index 1cb0a23..06bec7d 100644
--- a/src/stats/main.cs
+++ b/src/stats/main.cs
@@ -54,7 +54,7 @@ public class Stat
protected ArrayList sessions;
protected int dataColumns; //for SimpleSession
- protected string jumpType;
+ protected string jumpType; //mean also runType
protected bool showSex;
protected int statsJumpsType;
protected int limit;
@@ -83,7 +83,7 @@ public class Stat
protected string allValuesString = Catalog.GetString("All values");
protected string avgValuesString = Catalog.GetString("Avg values of each jumper");
- protected int numContinuous; //for stats rj evolution
+ protected int numContinuous; //for stats rj evolution and runIntervallic
//for raise a signal and manage it on src/gui/stats.cs
//signal will be catched first in src/statType.cs and there a equal signal will be raised
diff --git a/src/stats/runIntervallic.cs b/src/stats/runIntervallic.cs
new file mode 100644
index 0000000..4d9cc41
--- /dev/null
+++ b/src/stats/runIntervallic.cs
@@ -0,0 +1,273 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * ChronoJump is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Copyright (C) 2004-2009 Xavier de Blas <xaviblas gmail com>
+ */
+
+using System;
+using System.Data;
+using Gtk;
+using System.Collections; //ArrayList
+using Mono.Unix;
+
+
+public class StatRunIntervallic : Stat
+{
+ protected int maxRuns;
+
+ //if this is not present i have problems like (No overload for method `xxx' takes `0' arguments) with some inherited classes
+ public StatRunIntervallic ()
+ {
+ this.showSex = false;
+ this.statsJumpsType = 0;
+ this.limit = 0;
+ }
+
+ public StatRunIntervallic (StatTypeStruct myStatTypeStruct, int numContinuous, Gtk.TreeView treeview)
+ {
+ completeConstruction (myStatTypeStruct, treeview);
+
+ this.numContinuous = numContinuous;
+
+ string sessionString = obtainSessionSqlString(sessions, "runInterval");
+
+ //we need to know the run with more tracks for prepare columns
+ maxRuns = SqliteStat.ObtainMaxNumberOfRuns(sessionString);
+
+ this.dataColumns = maxRuns +1; //for simplesession (avg speed, speed of each track)
+
+ //only simplesession
+ store = getStore(dataColumns +1); //jumper, datacolumns
+ string [] columnsString;
+
+ //in report, show only 10 tracks every row,
+ //if there are more tracks to show, let's cut them
+ if(toReport && maxRuns > 10 ) {
+ columnsString = new String[13]; //person, index, count, 10 tracks
+ } else {
+ columnsString = new String[dataColumns +1];
+ }
+ columnsString[0] = Catalog.GetString("Person");
+ columnsString[1] = Catalog.GetString("Speed");
+
+//TODO: check this
+ if(toReport && maxRuns > 10) {
+ columnsString[2] = Catalog.GetString("Count");
+ for(int i=0; i < maxRuns && i < 10; i++) {
+ columnsString[i+3] = Catalog.GetString("Speed"); //cols: 3, 4, 5, ...
+ }
+ } else {
+ for(int i=0; i < maxRuns; i++) {
+//TODO: check this
+ columnsString[i+2] = Catalog.GetString("Speed") + (i+1).ToString(); //cols: 3, 4, 5, ...
+ }
+ }
+
+ if(toReport) {
+ reportString = prepareHeadersReport(columnsString);
+ } else {
+ treeview.Model = store;
+ prepareHeaders(columnsString);
+ }
+ }
+
+ protected int findBestContinuous(string [] statValues, int numContinuous)
+ {
+ //if numContinuous is 3, we check the best consecutive three time values
+ int bestPos=-1; //position where the three best group values start
+ //will return -1 if less than three runs
+ double bestCount=-10000; //best value found of 3 pairs
+
+ //start in pos 2 because first is name, second is speed
+ for ( int i=2; i < statValues.Length -numContinuous ; i=i+1 )
+ {
+ double myCount = 0;
+ bool runFinished = false;
+ //read the n consecutive values
+ for (int j=i; j < i + numContinuous ; j=j+1 )
+ {
+ if( statValues[j] == "-") {
+ runFinished = true;
+ break;
+ }
+ double speed = Convert.ToDouble(statValues[i]);
+ myCount += speed;
+ }
+
+ //if found a max, record it
+ if(myCount > bestCount && !runFinished) {
+ bestCount = myCount;
+ bestPos = i;
+ }
+ }
+ return bestPos;
+ }
+
+ protected string [] markBestContinuous(string [] statValues, int numContinuous, int bestPos) {
+ if(toReport) {
+ for ( int i=0; i < statValues.Length ; i=i+1 ) {
+
+ if(i >= bestPos && i < bestPos+numContinuous) {
+ statValues[i] = "<font color=\"red\">" + statValues[i] + "</font>";
+ }
+ }
+ } else {
+ // this marks the first and the last with '[' and ']'
+ statValues[bestPos] = "[" + statValues[bestPos];
+ statValues[bestPos + numContinuous -1] = statValues[bestPos + numContinuous -1] + "]";
+ }
+
+ return statValues;
+ }
+
+ //for stripping off unchecked rows in report
+ //private int rowsPassedToReport = 1;
+ private int rowsPassedToReport = 0;
+
+ protected override void printData (string [] statValues)
+ {
+ if(numContinuous != -1) {
+ int bestPos = findBestContinuous(statValues, numContinuous);
+ if(bestPos != -1) {
+ statValues = markBestContinuous(statValues, numContinuous, bestPos);
+ }
+ }
+
+ if(toReport) {
+ bool allowedRow = false;
+ for(int i=0; i < markedRows.Count; i++) {
+ if(Convert.ToInt32(markedRows[i]) == rowsPassedToReport) {
+ allowedRow = true;
+ break;
+ }
+ }
+ if(allowedRow) {
+ reportString += "<TR>";
+ //in report, if there are more than 5 runs, break the row
+ if(maxRuns > 5) {
+ //show 5 runs in a row (every run has 1 col: time)
+ int countCols = -1; //jumper, count (from -1 to 0)
+ int countRows = 0;
+ for (int i=0; i < statValues.Length ; i++)
+ {
+ //if a jump is shorter than the others,
+ //there's no need of filling rows with '-' in every cell
+ if(countCols >= 1 && statValues[i] == "-") {
+ break;
+ }
+
+ //when countCols is 0, and countRows is 0 we should print the first 'Count'
+ if(countCols == 0 && countRows == 0) {
+ reportString += "<TD>1-5</TD>";
+ }
+
+ //change line
+ if(countCols >= 10) {
+ reportString += "</TR><TR><TD> </TD>";
+ countRows ++;
+ countCols = 0;
+ reportString += "<TD>" + (countRows*5 + 1) + "-" +
+ (countRows*5 +5) + "</TD>";
+ }
+ reportString += "<TD>" + statValues[i] + "</TD>";
+ countCols ++;
+ }
+ } else {
+ for (int i=0; i < statValues.Length ; i++) {
+ reportString += "<TD>" + statValues[i] + "</TD>";
+ }
+ }
+ reportString += "</TR>\n";
+ }
+ rowsPassedToReport ++;
+ } else {
+ //iter = store.AppendValues (statValues);
+ iter = new TreeIter();
+
+ //iter = store.Append (iter); //doesn't work
+ //store.Append (out iter); //add new row and make iter point to it
+ iter = store.AppendNode ();
+
+ //addAllNoneIfNeeded(statValues.Length);
+
+ TreePath myPath = store.GetPath(iter);
+
+ if(statValues[0] != Catalog.GetString("AVG") && statValues[0] != Catalog.GetString("SD")) {
+ store.SetValue(iter, 0, true); //first col is true if it's not AVG or SD
+ markedRows.Add(myPath.ToString());
+ //Log.WriteLine("FROM PRINTDATA (EVOLUTION) Added to markedRows row:{0}", myPath.ToString());
+ }
+
+ for(int i=0; i < statValues.Length; i++) {
+ store.SetValue(iter, i+1, statValues[i]);
+ }
+ }
+ }
+
+
+
+ public override void PrepareData()
+ {
+ string sessionString = obtainSessionSqlString(sessions, "runInterval");
+ //only simplesession
+ bool multisession = false;
+
+ //we send maxRuns for make all the results of same length (fill it with '-'s)
+ //
+ // cannot be avg in this statistic
+ // TODO: change this, it can be AVG
+
+ string operation = ""; //no need of "MAX", there's an order by (index) desc
+ //and clenaDontWanted will do his work
+ processDataSimpleSession ( cleanDontWanted (
+ SqliteStat.RunInterval(sessionString, multisession,
+ operation, jumpType, showSex, maxRuns),
+ statsJumpsType, limit),
+ false, dataColumns); //don't print AVG and SD at end of row (has no sense) TODO: change this
+ }
+
+ public override string ToString ()
+ {
+ string selectedValuesString = "";
+ if(statsJumpsType == 0) { //all jumps
+ selectedValuesString = allValuesString;
+ } else if(statsJumpsType == 1) { //limit
+ selectedValuesString = string.Format(Catalog.GetString("First {0} values"), limit);
+ } else if(statsJumpsType == 2) { //best of each jumper
+ selectedValuesString = string.Format(Catalog.GetString("Max {0} values of each person"), limit);
+ }
+ /* this option is not possible in this statistic
+ * TODO: change this
+ else if(statsJumpsType == 3) { //avg of each jumper
+ selectedValuesString = avgValuesString;
+ }
+ */
+
+ string [] strFull = sessions[0].ToString().Split(new char[] {':'});
+ string mySessionString = Catalog.GetString (" session ") +
+ strFull[0] + "(" + strFull[2] + ")";
+
+ string bestResalted = "";
+ if(numContinuous != -1) {
+ bestResalted = string.Format(Catalog.GetString(" (best {0} consecutive runs marked)"), numContinuous);
+ }
+
+ return string.Format(Catalog.GetString("{0} in Run Intervallic applied to {1} on {2}{3}"), selectedValuesString, jumpType, mySessionString, bestResalted);
+ }
+}
+
+
diff --git a/src/util.cs b/src/util.cs
index f435bb4..36e9b1b 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1256,6 +1256,47 @@ public class Util
}
return searchedValue;
}
+
+ public static string GetRunISpeedsString(double distanceInterval, string timesString,
+ string distancesString, string separator, int maxRuns) {
+
+Log.WriteLine("VVV");
+Log.WriteLine(distanceInterval.ToString());
+Log.WriteLine(distancesString);
+Log.WriteLine(timesString);
+Log.WriteLine(separator);
+Log.WriteLine("WWW");
+ string [] times = timesString.Split(new char[] {'='});
+ string [] distances = distancesString.Split(new char[] {'-'});
+ string speeds = "";
+ string sep = "";
+ double distance;
+ int i;
+ for(i=0; i < times.Length; i++) {
+ double time = Convert.ToDouble(times[i]);
+
+ //if has variable distance each track
+ if(distanceInterval == -1.0) {
+Log.WriteLine("-1");
+ int distPos = i % distances.Length;
+ distance = Convert.ToDouble(distances[distPos]);
+ } else {
+Log.WriteLine("NO -1");
+ distance = distanceInterval;
+ }
+
+//Log.WriteLine("d: {0}, t:{1}, d/t:{2}", distance, time, distance /time*1.0);
+ speeds += sep + (distance / time * 1.0).ToString();
+ sep = separator;
+Log.WriteLine(speeds);
+ }
+Log.WriteLine("RRR");
+ //fill the row with 0's equalling largest row
+ for(int j=i; j < maxRuns; j++) {
+ speeds = speeds + ":-:-";
+ }
+ return speeds;
+ }
public static double ConvertFeetInchesToCm(int feet, double inches) {
return feet * 30.48 + inches * 2.54;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]