[chronojump] RSA core done



commit d308d1ed85dd0a95381e38005e959a77c7f60e3a
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Apr 27 16:07:03 2012 +0200

    RSA core done

 glade/chronojump.glade |   47 ++++++++++++++++++++++-------
 src/execute/event.cs   |   17 +++++++++-
 src/execute/run.cs     |   76 ++++++++++++++++++++++++++++++++++--------------
 src/gui/run.cs         |    6 +++-
 src/runType.cs         |   15 ++++++++-
 src/sqlite/main.cs     |   24 ++++++++++++++-
 src/sqlite/runType.cs  |    5 ++-
 src/util.cs            |   35 +++++++++++++++++++++-
 8 files changed, 182 insertions(+), 43 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 2373e00..0587e69 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -15522,6 +15522,7 @@ Chronopic</property>
                                                             <packing>
                                                             <property name="expand">False</property>
                                                             <property name="fill">False</property>
+                                                            <property name="padding">8</property>
                                                             <property name="position">9</property>
                                                             </packing>
                                                             </child>
@@ -15669,20 +15670,20 @@ Chronopic</property>
                                                             <widget class="GtkHBox" id="hbox 1">
                                                             <property name="visible">True</property>
                                                             <child>
-                                                            <widget class="GtkRadioButton" id="extra_window_radio_jump_rj_j">
+                                                            <widget class="GtkRadioButton" id="extra_window_radio_jump_rj_hexagon">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
                                                             <property name="receives_default">False</property>
                                                             <property name="has_tooltip">True</property>
-                                                            <property name="tooltip" translatable="yes">Simple jump with no special technique</property>
+                                                            <property name="tooltip" translatable="yes">CounterMovement Jump</property>
                                                             <property name="relief">none</property>
-                                                            <property name="active">True</property>
                                                             <property name="draw_indicator">False</property>
+                                                            <property name="group">extra_window_radio_jump_rj_j</property>
                                                             <signal name="toggled" handler="on_extra_window_jumps_rj_test_changed"/>
                                                             <child>
-                                                            <widget class="GtkLabel" id="label_extra_window_radio_jump_rj_j">
+                                                            <widget class="GtkLabel" id="label_extra_window_radio_jump_rj_hexagon">
                                                             <property name="visible">True</property>
-                                                            <property name="label" translatable="yes">RJ(j)</property>
+                                                            <property name="label" translatable="yes">Hexagon</property>
                                                             </widget>
                                                             </child>
                                                             </widget>
@@ -15741,20 +15742,20 @@ Chronopic</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkRadioButton" id="extra_window_radio_jump_rj_hexagon">
+                                                            <widget class="GtkRadioButton" id="extra_window_radio_jump_rj_j">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
                                                             <property name="receives_default">False</property>
                                                             <property name="has_tooltip">True</property>
-                                                            <property name="tooltip" translatable="yes">CounterMovement Jump</property>
+                                                            <property name="tooltip" translatable="yes">Simple jump with no special technique</property>
                                                             <property name="relief">none</property>
+                                                            <property name="active">True</property>
                                                             <property name="draw_indicator">False</property>
-                                                            <property name="group">extra_window_radio_jump_rj_j</property>
                                                             <signal name="toggled" handler="on_extra_window_jumps_rj_test_changed"/>
                                                             <child>
-                                                            <widget class="GtkLabel" id="label_extra_window_radio_jump_rj_hexagon">
+                                                            <widget class="GtkLabel" id="label_extra_window_radio_jump_rj_j">
                                                             <property name="visible">True</property>
-                                                            <property name="label" translatable="yes">Hexagon</property>
+                                                            <property name="label" translatable="yes">RJ(j)</property>
                                                             </widget>
                                                             </child>
                                                             </widget>
@@ -15803,6 +15804,7 @@ Chronopic</property>
                                                             <packing>
                                                             <property name="expand">False</property>
                                                             <property name="fill">False</property>
+                                                            <property name="padding">8</property>
                                                             <property name="position">4</property>
                                                             </packing>
                                                             </child>
@@ -16537,6 +16539,28 @@ Chronopic</property>
                                                             </packing>
                                                             </child>
                                                             <child>
+                                                            <widget class="GtkRadioButton" id="extra_window_radio_run_interval_rsa_test_1">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">False</property>
+                                                            <property name="has_tooltip">True</property>
+                                                            <property name="relief">none</property>
+                                                            <property name="draw_indicator">False</property>
+                                                            <property name="group">extra_window_radio_run_interval_by_laps</property>
+                                                            <signal name="toggled" handler="on_extra_window_runs_interval_test_changed"/>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label_extra_window_radio_run_interval_rsa_test_1">
+                                                            <property name="visible">True</property>
+                                                            <property name="label" translatable="yes">RSA test 1</property>
+                                                            </widget>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="position">4</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkRadioButton" id="extra_window_radio_run_interval_more">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
@@ -16572,7 +16596,8 @@ Chronopic</property>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
-                                                            <property name="position">4</property>
+                                                            <property name="padding">8</property>
+                                                            <property name="position">5</property>
                                                             </packing>
                                                             </child>
                                                           </widget>
diff --git a/src/execute/event.cs b/src/execute/event.cs
index 634d587..f7a0729 100644
--- a/src/execute/event.cs
+++ b/src/execute/event.cs
@@ -15,7 +15,7 @@
  *  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-2011   Xavier de Blas <xaviblas gmail com> 
+ * Copyright (C) 2004-2012   Xavier de Blas <xaviblas gmail com> 
  */
 
 using System;
@@ -58,6 +58,8 @@ public class EventExecute
 	}
 	protected eventType needUpdateGraphType;
 	
+	protected bool needShowCountDown;	//RSA
+
 	//protected string syncMessage;
 	//protected bool needShowSyncMessage;
 	protected string feedbackMessage;
@@ -311,7 +313,14 @@ public class EventExecute
 			needSensitiveButtonFinish = false;
 		}
 		
-		if(needShowFeedbackMessage) {
+		//RSA
+		if(needShowCountDown) 
+		{
+			feedbackMessage = countDownMessage();
+			egd.Textview_message.Buffer = UtilGtk.TextViewPrint(feedbackMessage);
+		} 
+		else if(needShowFeedbackMessage) 
+		{
 			egd.Textview_message.Buffer = UtilGtk.TextViewPrint(feedbackMessage);
 			needShowFeedbackMessage = false;
 		}
@@ -435,6 +444,10 @@ public class EventExecute
 		fakeButtonUpdateGraph.Click();
 	}
 	
+	protected virtual string countDownMessage() {
+		return "";
+	}
+	
 	protected virtual bool shouldFinishByTime() {
 		return true;
 	}
diff --git a/src/execute/run.cs b/src/execute/run.cs
index 132224f..93de27b 100644
--- a/src/execute/run.cs
+++ b/src/execute/run.cs
@@ -15,7 +15,7 @@
  *  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-2011   Xavier de Blas <xaviblas gmail com> 
+ * Copyright (C) 2004-2012   Xavier de Blas <xaviblas gmail com> 
  */
 
 using System;
@@ -236,7 +236,7 @@ Log.WriteLine("MANAGE(3)!!!!");
 							2 //normal run, phase 2/3
 							);  
 					needUpdateEventProgressBar = true;
-					
+				
 					feedbackMessage = "";
 					needShowFeedbackMessage = true; 
 					
@@ -369,7 +369,10 @@ public class RunIntervalExecute : RunExecute
 
 
 	string distancesString; //if distances are variable (distanceInterval == -1), this is used
-	double distanceIntervalFixed; //if distanceInterval i -1, then Fixed is the corresponding base on distancesString
+	double distanceIntervalFixed; //if distanceInterval == -1, then Fixed is the corresponding base on distancesString
+	double lastTc;		//useful to know time on contact platform because intervalTimesString does not differentiate
+							
+	bool RSABellDone;
 
 	//private Chronopic cp;
 
@@ -450,12 +453,11 @@ public class RunIntervalExecute : RunExecute
 		
 		int countForSavingTempTable = 0;
 	
-		double lastTc = 0;
+		lastTc = 0;
 					
 		distanceIntervalFixed = distanceInterval;
 		
 		do {
-
 			if(simulated) 
 				ok = true;
 			else 
@@ -470,6 +472,9 @@ public class RunIntervalExecute : RunExecute
 					//has arrived
 					loggedState = States.ON;
 					
+					//show RSA count down only on air		
+					needShowCountDown = false;
+					
 					//if we start out, and we arrive to the platform for the first time, don't record nothing
 					if(runPhase == runPhases.PRE_RUNNING) {
 						runPhase = runPhases.RUNNING;
@@ -485,6 +490,8 @@ public class RunIntervalExecute : RunExecute
 						
 						//if interval run is "unlimited" not limited by tracks, nor time, 
 						//then play with the progress bar until finish button is pressed
+					
+					
 						if(limitAsDouble == -1) {
 							
 							if(simulated)
@@ -629,7 +636,7 @@ public class RunIntervalExecute : RunExecute
 				}
 				else if (platformState == Chronopic.Plataforma.OFF && loggedState == States.ON) {
 					//it's out, was inside (= has abandoned platform)
-		
+							
 					if(runPhase == runPhases.PLATFORM_INI) {
 						//run starts
 						initializeTimer();
@@ -637,14 +644,27 @@ public class RunIntervalExecute : RunExecute
 
 						feedbackMessage = "";
 						needShowFeedbackMessage = true; 
-					} else
+					} else {
 						lastTc = timestamp/1000.0;
 						
+						//RSA
+						double RSAseconds = Util.GetRunIVariableDistancesThisRowIsRSA(
+								distancesString, Convert.ToInt32(tracks));
+						if(RSAseconds > 0) {
+							RSABellDone = false;
+							needShowCountDown = true;
+						} else {
+							needShowCountDown = false;
+							feedbackMessage = "";
+							needShowFeedbackMessage = true;
+						}
+					}
+
+						
 					runPhase = runPhases.RUNNING;
 
 					//change the automata state
 					loggedState = States.OFF;
-
 				}
 			}
 		} while ( ! success && ! cancel && ! finish );
@@ -670,7 +690,19 @@ public class RunIntervalExecute : RunExecute
 			totallyCancelled = true;
 		}
 	}
-	
+
+	protected override string countDownMessage() {
+		double waitSeconds = Util.GetRunIVariableDistancesThisRowIsRSA(distancesString, Convert.ToInt32(tracks))
+			 - (timerCount - Util.GetTotalTime(intervalTimesString) - lastTc);
+
+		if (waitSeconds < 0 && ! RSABellDone) {
+			Util.PlaySound(Constants.SoundTypes.GOOD, volumeOn);
+			RSABellDone = true;
+		}
+
+		return string.Format(Catalog.GetString("Wait {0} seconds"), Util.TrimDecimals(waitSeconds, 1));
+	}
+
 	protected override bool shouldFinishByTime() {
 		//check if it should finish now (time limited, not unlimited and time exceeded)
 		//check that the run started
@@ -739,14 +771,14 @@ public class RunIntervalExecute : RunExecute
 				
 	protected void writeRunInterval(bool tempTable)
 	{
-		int tracks = 0;
+		int tracksHere = 0; //different than globakl tracks variable
 		string limitString = "";
 
 		//if user clicked in finish earlier
 		if(finish) {
 			if(tracksLimited) {
-				tracks = Util.GetNumberOfJumps(intervalTimesString, false);
-				limitString = tracks.ToString() + "R";
+				tracksHere = Util.GetNumberOfJumps(intervalTimesString, false);
+				limitString = tracksHere.ToString() + "R";
 			} else {
 				//when we mark that run should finish by time, chronopic thread is probably capturing data
 				//check if it captured more than date limit, and if it has done, delete last(s) run(s)
@@ -773,22 +805,22 @@ public class RunIntervalExecute : RunExecute
 						}
 					}
 				}
-				//tracks are defined here (and not before) because can change on "while(eventPassed)" before
-				tracks = Util.GetNumberOfJumps(intervalTimesString, false);
+				//tracksHere are defined here (and not before) because can change on "while(eventPassed)" before
+				tracksHere = Util.GetNumberOfJumps(intervalTimesString, false);
 				limitString = Util.GetTotalTime(intervalTimesString) + "T";
 			}
 		} else {
 			if(tracksLimited) {
 				limitString = limitAsDouble.ToString() + "R";
-				tracks = (int) limitAsDouble;
+				tracksHere = (int) limitAsDouble;
 			} else {
 				limitString = limitAsDouble.ToString() + "T";
 				string [] myStringFull = intervalTimesString.Split(new char[] {'='});
-				tracks = myStringFull.Length;
+				tracksHere = myStringFull.Length;
 			}
 		}
 
-		distanceTotal = Util.GetRunITotalDistance(distanceInterval, distancesString, tracks);
+		distanceTotal = Util.GetRunITotalDistance(distanceInterval, distancesString, tracksHere);
 		timeTotal = Util.GetTotalTime(intervalTimesString); 
 		
 
@@ -800,7 +832,7 @@ public class RunIntervalExecute : RunExecute
 		if(tempTable)
 			SqliteRunInterval.Insert(false, Constants.TempRunIntervalTable, "NULL", personID, sessionID, type, 
 					distanceTotal, timeTotal,
-					distanceInterval, intervalTimesString, tracks, 
+					distanceInterval, intervalTimesString, tracksHere, 
 					description,
 					limitString,
 					Util.BoolToNegativeInt(simulated),
@@ -809,7 +841,7 @@ public class RunIntervalExecute : RunExecute
 		else {
 			uniqueID = SqliteRunInterval.Insert(false, Constants.RunIntervalTable, "NULL", personID, sessionID, type, 
 					distanceTotal, timeTotal,
-					distanceInterval, intervalTimesString, tracks, 
+					distanceInterval, intervalTimesString, tracksHere, 
 					description,
 					limitString,
 					Util.BoolToNegativeInt(simulated),
@@ -817,14 +849,14 @@ public class RunIntervalExecute : RunExecute
 					);
 
 			//define the created object
-			eventDone = new RunInterval(uniqueID, personID, sessionID, type, distanceTotal, timeTotal, distanceInterval, intervalTimesString, tracks, description, limitString, Util.BoolToNegativeInt(simulated), !startIn); 
+			eventDone = new RunInterval(uniqueID, personID, sessionID, type, distanceTotal, timeTotal, distanceInterval, intervalTimesString, tracksHere, description, limitString, Util.BoolToNegativeInt(simulated), !startIn); 
 
 
 			string tempValuesString = "";
 			if(tracksLimited) 
-				tempValuesString = " (" + distanceIntervalFixed + "x" + tracks + "R), " + Catalog.GetString("Time") + ": " + Util.TrimDecimals( timeTotal.ToString(), pDN);
+				tempValuesString = " (" + distanceIntervalFixed + "x" + tracksHere + "R), " + Catalog.GetString("Time") + ": " + Util.TrimDecimals( timeTotal.ToString(), pDN);
 			else
-				tempValuesString = " (" + distanceIntervalFixed + "x" + Util.TrimDecimals( timeTotal.ToString(), pDN) + "T), " + Catalog.GetString("Tracks") + ": " + tracks;
+				tempValuesString = " (" + distanceIntervalFixed + "x" + Util.TrimDecimals( timeTotal.ToString(), pDN) + "T), " + Catalog.GetString("Tracks") + ": " + tracksHere;
 
 			/*
 			string myStringPush =   Catalog.GetString("Last run") + ": " + RunnerName + ", " + 
diff --git a/src/gui/run.cs b/src/gui/run.cs
index 3aa5c51..4e42af1 100644
--- a/src/gui/run.cs
+++ b/src/gui/run.cs
@@ -15,7 +15,7 @@
  *  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> 
+ * Copyright (C) 2004-2012   Xavier de Blas <xaviblas gmail com> 
  */
 
 using System;
@@ -926,6 +926,7 @@ partial class ChronoJumpWindow
 	[Widget] Gtk.Label label_extra_window_radio_run_interval_by_time;
 	[Widget] Gtk.Label label_extra_window_radio_run_interval_unlimited;
 	[Widget] Gtk.Label label_extra_window_radio_run_interval_mtgug;
+	[Widget] Gtk.Label label_extra_window_radio_run_interval_rsa_test_1;
 	[Widget] Gtk.Label label_extra_window_radio_run_interval_more;
 	
 	//radio notebook_execute	
@@ -933,6 +934,7 @@ partial class ChronoJumpWindow
 	[Widget] Gtk.RadioButton extra_window_radio_run_interval_by_time;
 	[Widget] Gtk.RadioButton extra_window_radio_run_interval_unlimited;
 	[Widget] Gtk.RadioButton extra_window_radio_run_interval_mtgug;
+	[Widget] Gtk.RadioButton extra_window_radio_run_interval_rsa_test_1;
 	[Widget] Gtk.RadioButton extra_window_radio_run_interval_more;
 
 	//options runs
@@ -1001,6 +1003,7 @@ partial class ChronoJumpWindow
 		else if(extra_window_radio_run_interval_by_time.Active) currentRunIntervalType = new RunType("byTime");
 		else if(extra_window_radio_run_interval_unlimited.Active) currentRunIntervalType = new RunType("unlimited");
 		else if(extra_window_radio_run_interval_mtgug.Active) currentRunIntervalType = new RunType("MTGUG");
+		else if(extra_window_radio_run_interval_rsa_test_1.Active) currentRunIntervalType = new RunType("RSA 8-4-R3-5");
 
 		extra_window_runs_interval_initialize(currentRunIntervalType);
 	}
@@ -1203,6 +1206,7 @@ partial class ChronoJumpWindow
 		else if(type.Name == "byTime") extra_window_radio_run_interval_by_time.Active = true;
 		else if(type.Name == "unlimited") extra_window_radio_run_interval_unlimited.Active = true;
 		else if(type.Name == "MTGUG") extra_window_radio_run_interval_mtgug.Active = true;
+		else if(type.Name == "RSA 8-4-R3-5") extra_window_radio_run_interval_rsa_test_1.Active = true;
 		else {
 			//don't do this:
 			//extra_window_radio_run_interval_more.Active = true;
diff --git a/src/runType.cs b/src/runType.cs
index bddecd8..2c97156 100644
--- a/src/runType.cs
+++ b/src/runType.cs
@@ -15,7 +15,7 @@
  *  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> 
+ *  Copyright (C) 2004-2012   Xavier de Blas <xaviblas gmail com> 
  */
 
 using System;
@@ -34,6 +34,7 @@ public class RunType : EventType
 					//when distance is -1, distancesString is distance of each track, 
 					//	eg: "7-5-9" for a runInterval with three tracks of 7, 5 and 9 meters each
 					//	this is nice for agility tests
+	 				//	and RSA: distancesString 8-4-R3-5   means: 8m, 4m, rest 3 seconds, 5m
 
 	public RunType() {
 		type = Types.RUN;
@@ -47,7 +48,7 @@ public class RunType : EventType
 			"Agility-Illinois", "Agility-Shuttle-Run" , "Agility-ZigZag",
 			"byLaps", "byTime", "unlimited", 
 			"20m10times", "7m30seconds", "20m endurance", 
-			"MTGUG", "Gesell-DBT"
+			"MTGUG", "Gesell-DBT", "RSA 8-4-R3-5"
 		};
 
 		foreach(string search in predefinedTests)
@@ -386,6 +387,16 @@ public class RunType : EventType
 				"<b>" + Catalog.GetString("Abstract:") + "</b>\n" +
 				"http://linkinghub.elsevier.com/retrieve/pii/S0167494308001763";;
 
+		} else if(name == "RSA 8-4-R3-5") {
+			hasIntervals 	= true; 
+			distance 	= -1;
+			tracksLimited 	= true;
+			fixedValue 	= 4;
+			unlimited 	= false;
+			isPredefined	= true;
+			description	= "RSA testing";
+			imageFileName = "run_interval.png";
+			distancesString = "8-4-R3-5";	//this intervallic run has different distance for each track
 		}
 
 	}
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index 76363a3..000da0e 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -15,7 +15,7 @@
  *  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-2011   Xavier de Blas <xaviblas gmail com> 
+ * Copyright (C) 2004-2012   Xavier de Blas <xaviblas gmail com> 
  */
 
 using System;
@@ -72,7 +72,7 @@ class Sqlite
 	 * Important, change this if there's any update to database
 	 * Important2: if database version get numbers higher than 1, check if the comparisons with currentVersion works ok
 	 */
-	static string lastChronojumpDatabaseVersion = "0.83";
+	static string lastChronojumpDatabaseVersion = "0.84";
 
 	public Sqlite() {
 	}
@@ -1132,6 +1132,25 @@ class Sqlite
 				dbcon.Close();
 				currentVersion = "0.83";
 			}
+			if(currentVersion == "0.83") {
+				dbcon.Open();
+				
+				RunType type = new RunType();
+				type.Name = "RSA 8-4-R3-5";
+				type.Distance = -1;
+				type.TracksLimited = true;
+				type.FixedValue = 4;
+				type.Unlimited = false;
+				type.Description = "RSA testing";
+				type.DistancesString = "8-4-R3-5";
+				SqliteRunIntervalType.Insert(type, Constants.RunIntervalTypeTable, true);
+
+				Log.WriteLine("Added 1st RSA test.");
+
+				SqlitePreferences.Update ("databaseVersion", "0.84", true); 
+				dbcon.Close();
+				currentVersion = "0.84";
+			}
 		}
 
 		//if changes are made here, remember to change also in CreateTables()
@@ -1268,6 +1287,7 @@ class Sqlite
 		SqliteCountry.initialize();
 		
 		//changes [from - to - desc]
+		//0.83 - 0.84 Converted DB to 0.84 Added first RSA test 
 		//0.82 - 0.83 Converted DB to 0.83 Created encoder table
 		//0.81 - 0.82 Converted DB to 0.82 Added videoOn 
 		//0.80 - 0.81 Converted DB to 0.81 Added tempRunInterval initial speed
diff --git a/src/sqlite/runType.cs b/src/sqlite/runType.cs
index 92bb3ca..1b36831 100644
--- a/src/sqlite/runType.cs
+++ b/src/sqlite/runType.cs
@@ -15,7 +15,7 @@
  *  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> 
+ * Copyright (C) 2004-2012   Xavier de Blas <xaviblas gmail com> 
  */
 
 using System;
@@ -317,7 +317,8 @@ class SqliteRunIntervalType : SqliteRunType
 			"20m10times:20:1:10:0:Run 10 times a 20m distance:",	//only in more runs
 			"7m30seconds:7:0:30:0:Make max laps in 30 seconds:",	//only in more runs
 			"20m endurance:20:0:0:1:Continue running in 20m distance:",	//only in more runs
-			"MTGUG:-1:1:3:0:Modified time Getup and Go test:1-7-19"
+			"MTGUG:-1:1:3:0:Modified time Getup and Go test:1-7-19",
+			"RSA 8-4-R2-5:-1:1:4:0:RSA testing:8-4-R3-5"
 		};
 		foreach(string myString in iniRunTypes) {
 			//RunIntervalTypeInsert(myString, true);
diff --git a/src/util.cs b/src/util.cs
index ac2949c..fc730a3 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1358,12 +1358,31 @@ public class Util
 
 	/* 
 	 * when distances are variable on run interval 
+	 */ 
+	/*
+	 * RSA has this code:
+	 * runIntervalType distancesString 8-5-R6-9   means: 8m, 5m, rest 6 seconds, 9m
 	 */
+
+	
+	//returns 0 if not RSA, if RSA, returns seconds
+	public static double GetRunIVariableDistancesThisRowIsRSA(string distancesString, int row) {
+		string [] str = distancesString.Split(new char[] {'-'});
+		row = row % str.Length;
+		if(str[row].StartsWith("R"))
+			return Convert.ToDouble(str[row].Substring(1));
+		else
+			return 0;
+	}
+
 	//thought for values starting by 0
 	public static double GetRunIVariableDistancesStringRow(string distancesString, int row) {
 		string [] str = distancesString.Split(new char[] {'-'});
 		row = row % str.Length;
-		return Convert.ToDouble(str[row]);
+		if(str[row].StartsWith("R"))
+			return 0;
+		else	
+			return Convert.ToDouble(str[row]);
 	}
 	
 	public static double GetRunIVariableDistancesDistanceDone(string distancesString, int tracks) {
@@ -1392,6 +1411,11 @@ public class Util
 			double time = Convert.ToDouble(times[i]);
 		
 			int distPos = i % times.Length;
+
+			//RSA is not counted as speed
+			if(distances[distPos].StartsWith("R"))
+				continue;
+
 			double distance = Convert.ToDouble(distances[distPos]);
 
 			double speed = distance / time;
@@ -1421,6 +1445,15 @@ public class Util
 			//if has variable distance each track
 			if(distanceInterval == -1.0) {
 				int distPos = i % distances.Length;
+			
+				//RSA is not counted as speed
+				if(distances[distPos].StartsWith("R")) {
+					//if don't want to show the speed as 0, then delete next two lines
+					speeds += sep + "0"; 
+					sep = separator;
+					continue;
+				}
+
 				distance = Convert.ToDouble(distances[distPos]);
 			} else 
 				distance = distanceInterval;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]