[chronojump] New feature: speed start options on runs and runsI



commit 8c7066174fbd86ce60ceb88f0d583407cca25106
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sat Jan 5 19:30:31 2013 +0100

    New feature: speed start options on runs and runsI

 glade/chronojump.glade    |  151 ++++++++++++++++++++++++++++++++++++++++++++-
 src/execute/run.cs        |  102 ++++++++++++++++++++++---------
 src/gui/chronojump.cs     |  110 +++++++++++++++++++--------------
 src/gui/run.cs            |   22 +++++++
 src/sqlite/main.cs        |   14 ++++-
 src/sqlite/preferences.cs |    2 +
 6 files changed, 323 insertions(+), 78 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 5042dd5..9391f4d 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -4407,17 +4407,91 @@ weight</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkHSeparator" id="hseparator4">
+                                                            <widget class="GtkVBox" id="vbox_run_speed_start">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">6</property>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label104">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
+                                                            <property name="tooltip" translatable="yes">"Speed start" means when athlete does not start with "contact" on the first platform or photocell.
+It starts before and arrives there with some speed.</property>
+                                                            <property name="xalign">0</property>
+                                                            <property name="label" translatable="yes">What to do on speed start?</property>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkVBox" id="vbox71">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">4</property>
+                                                            <child>
+                                                            <widget class="GtkRadioButton" id="radio_runs_speed_start_arrival">
+                                                            <property name="label" translatable="yes">Time starts on arrival at first device</property>
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">False</property>
+                                                            <property name="use_action_appearance">False</property>
+                                                            <property name="active">True</property>
+                                                            <property name="draw_indicator">True</property>
+                                                            <signal name="toggled" handler="on_radio_runs_speed_start_toggled" swapped="no"/>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkRadioButton" id="radio_runs_speed_start_leaving">
+                                                            <property name="label" translatable="yes">Time starts on leaving first device</property>
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">False</property>
+                                                            <property name="use_action_appearance">False</property>
+                                                            <property name="active">True</property>
+                                                            <property name="draw_indicator">True</property>
+                                                            <property name="group">radio_runs_speed_start_arrival</property>
+                                                            <signal name="toggled" handler="on_radio_runs_speed_start_toggled" swapped="no"/>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
                                                             <property name="fill">True</property>
                                                             <property name="position">2</property>
                                                             </packing>
                                                             </child>
                                                             <child>
+                                                            <widget class="GtkHSeparator" id="hseparator4">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">3</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkVBox" id="vbox84">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -4587,7 +4661,7 @@ weight</property>
                                                             <packing>
                                                             <property name="expand">False</property>
                                                             <property name="fill">False</property>
-                                                            <property name="position">3</property>
+                                                            <property name="position">4</property>
                                                             </packing>
                                                             </child>
                                                             </widget>
@@ -4778,6 +4852,79 @@ weight</property>
                                                             <property name="position">1</property>
                                                             </packing>
                                                             </child>
+                                                            <child>
+                                                            <widget class="GtkVBox" id="vbox_run_i_speed_start">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">6</property>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label106">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="tooltip" translatable="yes">"Speed start" means when athlete does not start with "contact" on the first platform or photocell.
+It starts before and arrives there with some speed.</property>
+                                                            <property name="xalign">0</property>
+                                                            <property name="label" translatable="yes">What to do on speed start?</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkVBox" id="vbox25">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">4</property>
+                                                            <child>
+                                                            <widget class="GtkRadioButton" id="radio_runs_i_speed_start_arrival">
+                                                            <property name="label" translatable="yes">Time starts on arrival at first device</property>
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">False</property>
+                                                            <property name="use_action_appearance">False</property>
+                                                            <property name="active">True</property>
+                                                            <property name="draw_indicator">True</property>
+                                                            <signal name="toggled" handler="on_radio_runs_i_speed_start_toggled" swapped="no"/>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkRadioButton" id="radio_runs_i_speed_start_leaving">
+                                                            <property name="label" translatable="yes">Time starts on leaving first device	</property>
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">False</property>
+                                                            <property name="use_action_appearance">False</property>
+                                                            <property name="draw_indicator">True</property>
+                                                            <property name="group">radio_runs_i_speed_start_arrival</property>
+                                                            <signal name="toggled" handler="on_radio_runs_i_speed_start_toggled" swapped="no"/>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">2</property>
+                                                            </packing>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/src/execute/run.cs b/src/execute/run.cs
index 9ab9b35..19e2fed 100644
--- a/src/execute/run.cs
+++ b/src/execute/run.cs
@@ -39,14 +39,15 @@ public class RunExecute : EventExecute
 	//changes a bit on runSimple and runInterval
 	//explained at each of the updateTimeProgressBar() 
 	protected enum runPhases {
-		PRE_RUNNING, PLATFORM_INI, RUNNING, PLATFORM_END
+		PRE_RUNNING, PLATFORM_INI_YES_TIME, PLATFORM_INI_NO_TIME, RUNNING, PLATFORM_END
 	}
 	protected runPhases runPhase;
 		
 	protected bool checkDoubleContact;
 	protected int checkDoubleContactTime;
 	protected Constants.DoubleContact checkDoubleContactMode;
-		
+	
+	protected bool speedStartArrival;	
 	
 	public RunExecute() {
 	}
@@ -58,7 +59,7 @@ public class RunExecute : EventExecute
 			double progressbarLimit, ExecutingGraphData egd,
 			bool checkDoubleContact, int checkDoubleContactTime, 
 			Constants.DoubleContact checkDoubleContactMode,
-			Gtk.Image image_simulated_warning
+			bool speedStartArrival, Gtk.Image image_simulated_warning
 			)
 	{
 		this.personID = personID;
@@ -78,6 +79,7 @@ public class RunExecute : EventExecute
 		this.checkDoubleContact = checkDoubleContact;
 		this.checkDoubleContactTime = checkDoubleContactTime;
 		this.checkDoubleContactMode = checkDoubleContactMode;
+		this.speedStartArrival = speedStartArrival;	
 		this.image_simulated_warning = image_simulated_warning;	
 		
 		fakeButtonUpdateGraph = new Gtk.Button();
@@ -132,7 +134,7 @@ Log.WriteLine("MANAGE(b)!!!!");
 
 			loggedState = States.ON;
 			startIn = true;
-			runPhase = runPhases.PLATFORM_INI;
+			runPhase = runPhases.PLATFORM_INI_NO_TIME;
 		} else if (platformState==Chronopic.Plataforma.OFF) {
 			feedbackMessage = Catalog.GetString("You are OUT, RUN when prepared!");
 			needShowFeedbackMessage = true; 
@@ -186,6 +188,7 @@ Log.WriteLine("MANAGE(3)!!!!");
 	protected override void waitEvent ()
 	{
 		double timestamp = 0;
+		double timestampFirstContact = 0; //used when runPhase == runPhases.PLATFORM_INI_YES_TIME;
 
 		double timestampDCFlightTimes = -1; //sum of the flight times that happen in small time
 		double timestampDCContactTimes = -1;//sum of the contact times that happen in small time
@@ -208,7 +211,11 @@ Log.WriteLine("MANAGE(3)!!!!");
 					loggedState = States.ON;
 					
 					if(runPhase == runPhases.PRE_RUNNING) {
-						runPhase = runPhases.PLATFORM_INI;
+						if(speedStartArrival) {
+							runPhase = runPhases.PLATFORM_INI_YES_TIME;
+							initializeTimer(); //timerCount = 0
+						} else
+							runPhase = runPhases.PLATFORM_INI_NO_TIME;
 						
 						updateProgressBar = new UpdateProgressBar (
 								true, //isEvent
@@ -266,6 +273,10 @@ Log.WriteLine("MANAGE(3)!!!!");
 							success = true;
 
 						if(success) {
+							//add the first contact time if PLATFORM_INI_YES_TIME
+							if(timestampFirstContact > 0)
+								timestamp += timestampFirstContact;
+
 							time = timestamp / 1000.0;
 							write();
 
@@ -293,7 +304,10 @@ Log.WriteLine("MANAGE(3)!!!!");
 					if(checkDoubleContact && timestampDCn > 0)
 						timestampDCContactTimes += timestamp;
 					else {
-						initializeTimer();
+						if(runPhase == runPhases.PLATFORM_INI_YES_TIME)
+							timestampFirstContact = timestamp;
+						else if(runPhase == runPhases.PLATFORM_INI_NO_TIME)
+							initializeTimer(); //timerCount = 0
 
 						//update event progressbar
 						updateProgressBar = new UpdateProgressBar (
@@ -325,15 +339,20 @@ Log.WriteLine("MANAGE(3)!!!!");
 	}
 	
 	protected override void updateTimeProgressBar() {
-		/* 4 situations:
+		/* 5 situations:
 		 *   1- if we start out and have not arrived to platform, it should be a pulse with no time value on label:
-				case runPhases.PRE_RUNNING
-		 *   2-  if we are on the platform, it should be a pulse with no time value on label:
-				case runPhases.PLATFORM_INI
+		 *		case runPhases.PRE_RUNNING
+		 *   2-  if we are on the platform, it should be a pulse
+		 *   		a) if speedStartArrival (time starts at arriving at platform) 
+		 *   		then time starts and have to be time value on label:
+		 *			case runPhases.PLATFORM_INI_YES_TIME
+		 *   		b) if ! speedStartArrival (time starts at leaving platform)
+		 *   		then time starts and do not have to be time value on label:
+		 *			case runPhases.PLATFORM_INI_NO_TIME
 		 *   3- if we leave the platform, it should be a pulse with timerCount on label:
-				case runPhases.RUNNING
+		 *		case runPhases.RUNNING
 		 *   4- if we arrive (finish), it should be a pulse with chronopic time on label:
-				case runPhases.PLATFORM_END
+		 *		case runPhases.PLATFORM_END
 		 */
 		
 		double myTimeValue = 0;
@@ -341,9 +360,12 @@ Log.WriteLine("MANAGE(3)!!!!");
 			case runPhases.PRE_RUNNING:
 				myTimeValue = -1; //don't show nothing on label_timer 
 				break;
-			case runPhases.PLATFORM_INI:
+			case runPhases.PLATFORM_INI_NO_TIME:
 				myTimeValue = -1;
 				break;
+			case runPhases.PLATFORM_INI_YES_TIME:
+				myTimeValue = timerCount; //show time from the timerCount
+				break;
 			case runPhases.RUNNING:
 				myTimeValue = timerCount; //show time from the timerCount
 				break;
@@ -450,7 +472,7 @@ public class RunIntervalExecute : RunExecute
 			double progressbarLimit, ExecutingGraphData egd ,
 			bool checkDoubleContact, int checkDoubleContactTime, 
 			Constants.DoubleContact checkDoubleContactMode,
-			Gtk.Image image_simulated_warning
+			bool speedStartArrival, Gtk.Image image_simulated_warning
 			)
 	{
 		this.personID = personID;
@@ -488,6 +510,7 @@ public class RunIntervalExecute : RunExecute
 		this.checkDoubleContact = checkDoubleContact;
 		this.checkDoubleContactTime = checkDoubleContactTime;
 		this.checkDoubleContactMode = checkDoubleContactMode;
+		this.speedStartArrival = speedStartArrival;	
 		this.image_simulated_warning = image_simulated_warning;	
 	
 		fakeButtonUpdateGraph = new Gtk.Button();
@@ -781,12 +804,16 @@ public class RunIntervalExecute : RunExecute
 					//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 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;
-						//run starts
-						initializeTimer();
-					
+						if(speedStartArrival) {
+							runPhase = runPhases.PLATFORM_INI_YES_TIME;
+							//run starts
+							initializeTimer(); //timerCount = 0
+						} else
+							runPhase = runPhases.PLATFORM_INI_NO_TIME;
+
 						feedbackMessage = "";
 						needShowFeedbackMessage = true; 
 					}
@@ -929,13 +956,18 @@ 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) {
+					if(runPhase == runPhases.PLATFORM_INI_NO_TIME) {
 						//run starts
 						initializeTimer();
 						lastTc = 0;
 
 						feedbackMessage = "";
 						needShowFeedbackMessage = true; 
+					} else if(runPhase == runPhases.PLATFORM_INI_YES_TIME) {
+						lastTc = timestamp/1000.0;
+					
+						feedbackMessage = "";
+						needShowFeedbackMessage = true; 
 					} else {
 						lastTc = timestamp/1000.0;
 						
@@ -1004,7 +1036,10 @@ public class RunIntervalExecute : RunExecute
 		//check that the run started
 		//if( ! tracksLimited && limitAsDouble != -1 && timerCount > limitAsDouble 
 		if( ! tracksLimited && limitAsDouble != -1 && Util.GetTotalTime(intervalTimesString) > limitAsDouble 
-				&& !(runPhase == runPhases.PRE_RUNNING) && !(runPhase == runPhases.PLATFORM_INI)) 
+				&& !(runPhase == runPhases.PRE_RUNNING) 
+				&& !(runPhase == runPhases.PLATFORM_INI_NO_TIME)
+				&& !(runPhase == runPhases.PLATFORM_INI_YES_TIME)
+				) 
 			return true;
 		else
 			return false;
@@ -1019,15 +1054,20 @@ public class RunIntervalExecute : RunExecute
 	}
 
 	protected override void updateTimeProgressBar() {
-		/* 4 situations:
+		/* 5 situations:
 		 *   1- if we start out and have not arrived to platform, it should be a pulse with no time value on label:
-		 *   		case runPhases.PRE_RUNNING
-		 *   2- we started in, and we haven't leaved the platform, a pulse but with no time value on label:
-		 *   		case runPhases.PLATFORM_INI
+		 *		case runPhases.PRE_RUNNING
+		 *   2-  if we are on the platform, it should be a pulse
+		 *   		a) if speedStartArrival (time starts at arriving at platform) 
+		 *   		then time starts and have to be time value on label:
+		 *			case runPhases.PLATFORM_INI_YES_TIME
+		 *   		b) if ! speedStartArrival (time starts at leaving platform)
+		 *   		then time starts and do not have to be time value on label:
+		 *			case runPhases.PLATFORM_INI_NO_TIME
 		 *   3- we are in the platform or outside at any time except 1,2 and 4. timerCount have to be shown, and progress should be Fraction or Pulse depending on if it's time limited or not:
-		 *   		case runPhases.RUNNING
-		 *  4.- we have arrived (or jump finished at any time):
-		 *   		case runPhases.PLATFORM_END
+		 *		case runPhases.RUNNING
+		 *   4- if we arrive (finish), it should be a pulse with chronopic time on label:
+		 *		case runPhases.PLATFORM_END
 		 */
 		
 		double myTimeValue = 0;
@@ -1037,10 +1077,14 @@ public class RunIntervalExecute : RunExecute
 				percentageMode = false;
 				myTimeValue = -1; //don't show nothing on label_timer 
 				break;
-			case runPhases.PLATFORM_INI:
+			case runPhases.PLATFORM_INI_NO_TIME:
 				percentageMode = false;
 				myTimeValue = -1;
 				break;
+			case runPhases.PLATFORM_INI_YES_TIME:
+				percentageMode = !tracksLimited;
+				myTimeValue = timerCount; //show time from the timerCount
+				break;
 			case runPhases.RUNNING:
 				percentageMode = !tracksLimited;
 				myTimeValue = timerCount; //show time from the timerCount
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index d62a8e3..d3379bc 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -745,104 +745,122 @@ public partial class ChronoJumpWindow
 	private void loadPreferences () 
 	{
 		Log.WriteLine (string.Format(Catalog.GetString("Chronojump database version file: {0}"), 
-				SqlitePreferences.Select("databaseVersion") ));
-		
+					SqlitePreferences.Select("databaseVersion") ));
+
 		//chronopicPort = SqlitePreferences.Select("chronopicPort");
-		
+
 		prefsDigitsNumber = Convert.ToInt32 ( SqlitePreferences.Select("digitsNumber") );
 
 		checkbutton_allow_finish_rj_after_time.Active = ( SqlitePreferences.Select("allowFinishRjAfterTime") == "True" );
-			
+
 		if ( SqlitePreferences.Select("showHeight") == "True" ) 
 			showHeight = true;
-		 else 
+		else 
 			showHeight = false;
-		
+
 		if ( SqlitePreferences.Select("showPower") == "True" ) 
 			showPower = true;
-		 else 
+		else 
 			showPower = false;
-			
+
 		if ( SqlitePreferences.Select("showInitialSpeed") == "True" ) 
 			showInitialSpeed = true;
-		 else 
+		else 
 			showInitialSpeed = false;
-		
+
 		if ( SqlitePreferences.Select("showAngle") == "True" ) 
 			showAngle = true;
-		 else 
+		else 
 			showAngle = false;
-		
-		
+
+
 		//only one of showQIndex or showDjIndex can be true. Also none of them
 		if ( SqlitePreferences.Select("showQIndex") == "True" ) 
 			showQIndex = true;
-		 else 
+		else 
 			showQIndex = false;
-		
-			
+
+
 		if ( SqlitePreferences.Select("showDjIndex") == "True" ) 
 			showDjIndex = true;
-		 else 
+		else 
 			showDjIndex = false;
-		
-			
-		
+
+
+
 		if ( SqlitePreferences.Select("simulated") == "True" ) {
-//			simulated = true;
+			//			simulated = true;
 			//menuitem_simulated.Active = true;
 
-//			cpRunning = false;
+			//			cpRunning = false;
 		} else {
-//			simulated = false;
-			
-//			cpRunning = true;
+			//			simulated = false;
+
+			//			cpRunning = true;
 		}
-		
+
 		if ( SqlitePreferences.Select("askDeletion") == "True" ) 
 			askDeletion = true;
-		 else 
+		else 
 			askDeletion = false;
-		
+
 
 		if ( SqlitePreferences.Select("weightStatsPercent") == "True" ) 
 			weightPercentPreferred = true;
-		 else 
+		else 
 			weightPercentPreferred = false;
-		
-		
+
+
 		if ( SqlitePreferences.Select("heightPreferred") == "True" ) 
 			heightPreferred = true;
-		 else 
+		else 
 			heightPreferred = false;
-		
-		
+
+
 		if ( SqlitePreferences.Select("metersSecondsPreferred") == "True" ) 
 			metersSecondsPreferred = true;
-		 else 
+		else 
 			metersSecondsPreferred = false;
-		
+
 		if ( SqlitePreferences.Select("volumeOn") == "True" ) 
 			volumeOn = true;
-		 else 
+		else 
 			volumeOn = false;
-		
-		 if ( SqlitePreferences.Select("videoOn") == "True" ) 
+
+		if ( SqlitePreferences.Select("videoOn") == "True" ) 
 			videoOn = true;
-		 else 
+		else 
 			videoOn = false;
-	
+
+
+		//load preferences, update radios, but not update database
+		update_sqlite_at_runs_speed_radios = false;
+
+		if ( SqlitePreferences.Select("runSpeedStartArrival") == "True" ) 
+			radio_runs_speed_start_arrival.Active = true;
+		else
+			radio_runs_speed_start_leaving.Active = true;
+
+		if ( SqlitePreferences.Select("runISpeedStartArrival") == "True" ) 
+			radio_runs_i_speed_start_arrival.Active = true;
+		else
+			radio_runs_i_speed_start_leaving.Active = true;
+		
+		update_sqlite_at_runs_speed_radios = true;
+
+
+
 		//change language works on windows. On Linux let's change the locale
 		//if(Util.IsWindows())
 		//	languageChange();
-			
+
 		//pass to report
 		report.PrefsDigitsNumber = prefsDigitsNumber;
 		report.HeightPreferred = heightPreferred;
 		report.WeightStatsPercent = weightPercentPreferred;
 		report.Progversion = progVersion;
-		
-		
+
+
 		Log.WriteLine ( Catalog.GetString ("Preferences loaded") );
 	}
 
@@ -3421,7 +3439,7 @@ Log.WriteLine("DDD 2");
 				checkbutton_runs_prevent_double_contact.Active, 
 				(int) spinbutton_runs_prevent_double_contact.Value,
 				getDoubleContactModes(true),	//true: runSimple
-				image_simulated_warning
+				radio_runs_speed_start_arrival.Active, image_simulated_warning
 				);
 		
 		if (!chronopicWin.Connected) 
@@ -3543,7 +3561,7 @@ Log.WriteLine("DDD 2");
 				checkbutton_runs_i_prevent_double_contact.Active, 
 				(int) spinbutton_runs_i_prevent_double_contact.Value,
 				getDoubleContactModes(false),	//false: not runSimple
-				image_simulated_warning
+				radio_runs_i_speed_start_arrival.Active, image_simulated_warning
 				);
 		
 		
diff --git a/src/gui/run.cs b/src/gui/run.cs
index 7c6e2bf..bd7abd9 100644
--- a/src/gui/run.cs
+++ b/src/gui/run.cs
@@ -949,6 +949,8 @@ partial class ChronoJumpWindow
 	[Widget] Gtk.RadioButton radio_runs_prevent_double_contact_first;
 	[Widget] Gtk.RadioButton radio_runs_prevent_double_contact_average;
 	[Widget] Gtk.RadioButton radio_runs_prevent_double_contact_last;
+	[Widget] Gtk.RadioButton radio_runs_speed_start_arrival;
+	[Widget] Gtk.RadioButton radio_runs_speed_start_leaving;
 	
 	//options runs interval
 	[Widget] Gtk.Label extra_window_runs_interval_label_distance;
@@ -965,6 +967,8 @@ partial class ChronoJumpWindow
 	[Widget] Gtk.RadioButton radio_runs_i_prevent_double_contact_first;
 	[Widget] Gtk.RadioButton radio_runs_i_prevent_double_contact_average;
 	[Widget] Gtk.RadioButton radio_runs_i_prevent_double_contact_last;
+	[Widget] Gtk.RadioButton radio_runs_i_speed_start_arrival;
+	[Widget] Gtk.RadioButton radio_runs_i_speed_start_leaving;
 	
 
 	//selected test labels	
@@ -1272,6 +1276,24 @@ partial class ChronoJumpWindow
 		vbox_runs_i_prevent_double_contact.Visible = checkbutton_runs_i_prevent_double_contact.Active;
 	}
 
+
+	bool update_sqlite_at_runs_speed_radios = false;
+	private void on_radio_runs_speed_start_toggled (object o, EventArgs args) {
+		if(update_sqlite_at_runs_speed_radios) {
+			if(radio_runs_speed_start_arrival.Active)
+				SqlitePreferences.Update("runSpeedStartArrival", "True", false);
+			else
+				SqlitePreferences.Update("runSpeedStartArrival", "False", false);
+		}
+	}
+	private void on_radio_runs_i_speed_start_toggled (object o, EventArgs args) {
+		if(update_sqlite_at_runs_speed_radios) {
+			if(radio_runs_i_speed_start_arrival.Active)
+				SqlitePreferences.Update("runISpeedStartArrival", "True", false);
+			else
+				SqlitePreferences.Update("runISpeedStartArrival", "False", false);
+		}
+	}
 }
 
 
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index 86a7d14..53d8016 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -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.86";
+	static string lastChronojumpDatabaseVersion = "0.87";
 
 	public Sqlite() {
 	}
@@ -1173,6 +1173,17 @@ class Sqlite
 				dbcon.Close();
 				currentVersion = "0.86";
 			}
+			if(currentVersion == "0.86") {
+				dbcon.Open();
+				Log.WriteLine("Added run speed start preferences on sqlite"); 
+
+				SqlitePreferences.Insert ("runSpeedStartArrival", "True");
+				SqlitePreferences.Insert ("runISpeedStartArrival", "True");
+				SqlitePreferences.Update ("databaseVersion", "0.87", true); 
+				
+				dbcon.Close();
+				currentVersion = "0.87";
+			}
 		}
 
 		//if changes are made here, remember to change also in CreateTables()
@@ -1311,6 +1322,7 @@ class Sqlite
 		SqliteCountry.initialize();
 		
 		//changes [from - to - desc]
+		//0.86 - 0.87 Converted DB to 0.87 Added run speed start preferences on sqlite
 		//0.85 - 0.86 Converted DB to 0.86 videoOn: TRUE
 		//0.84 - 0.85 Converted DB to 0.85 Added slCMJ jump 
 		//0.83 - 0.84 Converted DB to 0.84 Added first RSA test 
diff --git a/src/sqlite/preferences.cs b/src/sqlite/preferences.cs
index 4f0d853..715e7f0 100644
--- a/src/sqlite/preferences.cs
+++ b/src/sqlite/preferences.cs
@@ -62,6 +62,8 @@ class SqlitePreferences : Sqlite
 		Insert ("videoOn", "True"); 
 		Insert ("evaluatorServerID", "-1");
 		Insert ("versionAvailable", "");
+		Insert ("runSpeedStartArrival", "True");
+		Insert ("runISpeedStartArrival", "True");
 		
 		Random rnd = new Random();
 		string machineID = rnd.Next().ToString();



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