[chronojump] Fixed 653477 photocells double-cut. And run improv



commit ae8848e8b8b617cce7042d2f444c58363ee506ab
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sat Jan 5 22:03:44 2013 +0100

    Fixed 653477 photocells double-cut. And run improv

 glade/chronojump.glade |   30 +++-
 src/execute/jump.cs    |   22 +--
 src/execute/run.cs     |  447 ++++++++++--------------------------------------
 3 files changed, 127 insertions(+), 372 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 16cfe8f..1e77145 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -4406,6 +4406,17 @@ weight</property>
                                                             </packing>
                                                             </child>
                                                             <child>
+                                                            <widget class="GtkHSeparator" id="hseparator6">
+                                                            <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">2</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkVBox" id="vbox_run_speed_start">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -4476,7 +4487,7 @@ It starts before and arrives there with some speed.</property>
                                                             <packing>
                                                             <property name="expand">True</property>
                                                             <property name="fill">True</property>
-                                                            <property name="position">2</property>
+                                                            <property name="position">3</property>
                                                             </packing>
                                                             </child>
                                                             <child>
@@ -4487,7 +4498,7 @@ It starts before and arrives there with some speed.</property>
                                                             <packing>
                                                             <property name="expand">False</property>
                                                             <property name="fill">True</property>
-                                                            <property name="position">3</property>
+                                                            <property name="position">4</property>
                                                             </packing>
                                                             </child>
                                                             <child>
@@ -4660,7 +4671,7 @@ It starts before and arrives there with some speed.</property>
                                                             <packing>
                                                             <property name="expand">False</property>
                                                             <property name="fill">False</property>
-                                                            <property name="position">4</property>
+                                                            <property name="position">5</property>
                                                             </packing>
                                                             </child>
                                                             </widget>
@@ -4852,6 +4863,17 @@ It starts before and arrives there with some speed.</property>
                                                             </packing>
                                                             </child>
                                                             <child>
+                                                            <widget class="GtkHSeparator" id="hseparator7">
+                                                            <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">2</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkVBox" id="vbox_run_i_speed_start">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -4922,7 +4944,7 @@ It starts before and arrives there with some speed.</property>
                                                             <packing>
                                                             <property name="expand">True</property>
                                                             <property name="fill">True</property>
-                                                            <property name="position">2</property>
+                                                            <property name="position">3</property>
                                                             </packing>
                                                             </child>
                                                             </widget>
diff --git a/src/execute/jump.cs b/src/execute/jump.cs
index 5015265..063b145 100644
--- a/src/execute/jump.cs
+++ b/src/execute/jump.cs
@@ -360,15 +360,6 @@ public class JumpExecute : EventExecute
 		return false; //this kind of events (simple or Dj jumps) cannot be finished by time
 	}
 	
-	protected override void updateTimeProgressBar() {
-		//has no finished, but move progressbar time
-		progressBarEventOrTimePreExecution(
-				false, //isEvent false: time
-				false, //activity mode
-				-1	//don't want to show info on label
-				); 
-	}
-
 	protected override void write()
 	{
 		string tcString = "";
@@ -818,12 +809,14 @@ public class JumpRjExecute : JumpExecute
 	}
 	
 	protected override void updateProgressBarForFinish() {
+		/*
 		progressBarEventOrTimePreExecution(
 				false, //isEvent false: time
 				true, //percentageMode: it has finished, show bar at 100%
 				//limitAsDouble
 				Util.GetTotalTime(tcString, tvString)
 				);  
+				*/
 	}
 
 	protected override void updateTimeProgressBar() {
@@ -838,11 +831,12 @@ public class JumpRjExecute : JumpExecute
 					); 
 		else
 			//after show a progressBar with time value
-			progressBarEventOrTimePreExecution(
-					false, //isEvent false: time
-					!jumpsLimited, //if jumpsLimited: activity, if timeLimited: fraction
-					timerCount
-					); 
+			if(! finish) 
+				progressBarEventOrTimePreExecution(
+						false, //isEvent false: time
+						!jumpsLimited, //if jumpsLimited: activity, if timeLimited: fraction
+						timerCount
+						); 
 	}
 
 
diff --git a/src/execute/run.cs b/src/execute/run.cs
index 19e2fed..e01e52b 100644
--- a/src/execute/run.cs
+++ b/src/execute/run.cs
@@ -528,243 +528,6 @@ public class RunIntervalExecute : RunExecute
 		eventDone = new RunInterval();
 	}
 
-/*	
-	protected override void waitEventPreDoubleContacts ()
-	{
-		double timestamp = 0;
-		bool success = false;
-		string equal = "";
-		
-		//initialize variables
-		intervalTimesString = "";
-		tracks = 0;
-		bool ok;
-		timerCount = 0;
-		//bool initialized = false;
-		int countForSavingTempTable = 0;
-		lastTc = 0;
-		distanceIntervalFixed = distanceInterval;
-		
-		do {
-			if(simulated) 
-				ok = true;
-			else 
-				ok = cp.Read_event(out timestamp, out platformState);
-		
-	
-			if (ok && !cancel && !finish) {
-				if(distanceInterval == -1)
-					distanceIntervalFixed = Util.GetRunIVariableDistancesStringRow(distancesString, (int) tracks);
-
-				if (platformState == Chronopic.Plataforma.ON && loggedState == States.OFF) {
-					//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;
-						//run starts
-						initializeTimer();
-					
-						feedbackMessage = "";
-						needShowFeedbackMessage = true; 
-					}
-					else {
-						runPhase = runPhases.RUNNING;
-						//has arrived and not in the "running previous"
-						
-						//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) {
-							//has arrived, unlimited
-							if(simulated)
-								timestamp = simulatedTimeLast * 1000; //conversion to milliseconds
-							
-							double myRaceTime = lastTc + timestamp/1000.0;
-							
-							if(intervalTimesString.Length > 0) { equal = "="; }
-							intervalTimesString = intervalTimesString + equal + myRaceTime.ToString();
-							updateTimerCountWithChronopicData(intervalTimesString);
-							tracks ++;	
-								
-							updateProgressBar= new UpdateProgressBar (
-									true, //isEvent
-									true, //unlimited: activity mode
-									tracks
-									);  
-							needUpdateEventProgressBar = true;
-							
-							distanceTotal = Util.GetRunITotalDistance(distanceInterval, distancesString, tracks);
-
-							//update graph
-							PrepareEventGraphRunIntervalObject = new PrepareEventGraphRunInterval(
-									distanceIntervalFixed, myRaceTime, intervalTimesString, distanceTotal, distancesString);
-
-							needUpdateGraphType = eventType.RUNINTERVAL;
-							needUpdateGraph = true;
-							
-							
-							//put button_finish as sensitive when first jump is done (there's something recordable)
-							if(tracks == 1)
-								needSensitiveButtonFinish = true;
-						}
-						else {
-							//has arrived, limited
-							if (tracksLimited) {
-								//has arrived, limited by tracks
-								tracks ++;	
-
-								if(simulated)
-									timestamp = simulatedTimeLast * 1000; //conversion to milliseconds
-
-								double myRaceTime = lastTc + timestamp/1000.0;
-								if(intervalTimesString.Length > 0) { equal = "="; }
-								intervalTimesString = intervalTimesString + equal + myRaceTime.ToString();
-								updateTimerCountWithChronopicData(intervalTimesString);
-
-
-								//save temp table if needed
-								countForSavingTempTable ++;
-								if(countForSavingTempTable == timesForSavingRepetitive) {
-									writeRunInterval(true); //tempTable
-									countForSavingTempTable = 0;
-								}
-
-	
-								if(tracks >= limitAsDouble) 
-								{
-									//finished
-									writeRunInterval(false); //tempTable = false
-									success = true;
-									runPhase = runPhases.PLATFORM_END;
-								}
-								
-								//progressBarEventOrTimePreExecution(
-								updateProgressBar= new UpdateProgressBar (
-										true, //isEvent
-										true, //tracksLimited: percentageMode
-										tracks
-										);  
-								needUpdateEventProgressBar = true;
-							
-								distanceTotal = Util.GetRunITotalDistance(distanceInterval, distancesString, tracks);
-							
-								//update graph
-								PrepareEventGraphRunIntervalObject = new PrepareEventGraphRunInterval(
-										distanceIntervalFixed, myRaceTime, intervalTimesString, distanceTotal, distancesString);
-
-								needUpdateGraphType = eventType.RUNINTERVAL;
-								needUpdateGraph = true;
-
-								//put button_finish as sensitive when first jump is done (there's something recordable)
-								if(tracks == 1)
-									needSensitiveButtonFinish = true;
-							} else {
-								//has arrived, limited by time
-								runPhase = runPhases.RUNNING;
-								
-								if(simulated)
-									timestamp = simulatedTimeLast * 1000; //conversion to milliseconds
-								
-								double myRaceTime = lastTc + timestamp/1000.0;
-
-								if(intervalTimesString.Length > 0) { equal = "="; }
-								intervalTimesString = intervalTimesString + equal + myRaceTime.ToString();
-								updateTimerCountWithChronopicData(intervalTimesString);
-								tracks ++;	
-
-								//save temp table if needed
-								countForSavingTempTable ++;
-								if(countForSavingTempTable == timesForSavingRepetitive) {
-									writeRunInterval(true); //tempTable
-									countForSavingTempTable = 0;
-								}
-								
-								updateProgressBar= new UpdateProgressBar (
-										true, //isEvent
-										false, //timeLimited: activity mode
-										tracks
-										);  
-								needUpdateEventProgressBar = true;
-								
-								distanceTotal = Util.GetRunITotalDistance(distanceInterval, distancesString, tracks);
-							
-								//update graph
-								PrepareEventGraphRunIntervalObject = new PrepareEventGraphRunInterval(
-										distanceIntervalFixed, myRaceTime, intervalTimesString, distanceTotal, distancesString);
-
-								needUpdateGraphType = eventType.RUNINTERVAL;
-								needUpdateGraph = true;
-
-								//put button_finish as sensitive when first jump is done (there's something recordable)
-								if(tracks == 1)
-									needSensitiveButtonFinish = true;
-							}
-						}
-					}
-				}
-				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();
-						lastTc = 0;
-
-						feedbackMessage = "";
-						needShowFeedbackMessage = true; 
-					} 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 );
-
-		if (finish) {
-			//write();
-			//write only if there's a run at minimum
-			if(Util.GetNumberOfJumps(intervalTimesString, false) >= 1) {
-				writeRunInterval(false); //tempTable = false
-			
-				totallyFinished = true;
-			} else {
-				//cancel a run if clicked finish before any events done, or ended by time without events
-				cancel = true;
-			}
-
-			runPhase = runPhases.PLATFORM_END;
-		}
-		if(cancel || finish) {
-			//event will be raised, and managed in chronojump.cs
-			fakeButtonFinished.Click();
-			
-			totallyCancelled = true;
-		}
-	}
-*/
 
 	protected override void waitEvent ()
 	{
@@ -823,64 +586,75 @@ 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(checkDoubleContact) {
+							if(timestamp <= checkDoubleContactTime) {
+								/*
+								   when checking double contact
+								   first time that timestamp < checkDoubleContactTime
+								   and we arrived (it's a flight time)
+								   record this time as timestampDCFlightTimes
+								 */
+								timestampDCn ++;
+								timestampDCFlightTimes += timestamp;
+								continue;
+							}
+							else {
+								if(timestampDCn > 0) {
+									if(checkDoubleContactMode == 
+											Constants.DoubleContact.FIRST) {
+										/* user want first flight time,
+										   then add all DC times*/
+										timestamp += timestampDCFlightTimes + 
+											timestampDCContactTimes;
+									}
+									else if(checkDoubleContactMode == 
+											Constants.DoubleContact.LAST) {
+										//user want last flight time, take that
+										timestamp = timestamp;
+									}
+									else {	/* do the avg of all flights and contacts
+										   then add to last timestamp */
+										timestamp += 
+											(timestampDCFlightTimes + 
+											 timestampDCContactTimes) 
+											/ timestampDCn;
+									}
+								}
+							}
+						}
+				
+
+						if(simulated)
+								timestamp = simulatedTimeLast * 1000; //conversion to milliseconds
+
+						double myRaceTime = lastTc + timestamp/1000.0;
+
+						if(intervalTimesString.Length > 0) { equal = "="; }
+						intervalTimesString = intervalTimesString + equal + myRaceTime.ToString();
+						updateTimerCountWithChronopicData(intervalTimesString);
+						tracks ++;	
+
+						//save temp table if needed
+						countForSavingTempTable ++;
+						if(countForSavingTempTable == timesForSavingRepetitive) {
+								writeRunInterval(true); //tempTable
+								countForSavingTempTable = 0;
+						}
 					
 						if(limitAsDouble == -1) {
 							//has arrived, unlimited
-							if(simulated)
-								timestamp = simulatedTimeLast * 1000; //conversion to milliseconds
-							
-							double myRaceTime = lastTc + timestamp/1000.0;
-							
-							if(intervalTimesString.Length > 0) { equal = "="; }
-							intervalTimesString = intervalTimesString + equal + myRaceTime.ToString();
-							updateTimerCountWithChronopicData(intervalTimesString);
-							tracks ++;	
-								
 							updateProgressBar= new UpdateProgressBar (
 									true, //isEvent
 									true, //unlimited: activity mode
 									tracks
 									);  
 							needUpdateEventProgressBar = true;
-							
-							distanceTotal = Util.GetRunITotalDistance(distanceInterval, distancesString, tracks);
-
-							//update graph
-							PrepareEventGraphRunIntervalObject = new PrepareEventGraphRunInterval(
-									distanceIntervalFixed, myRaceTime, intervalTimesString, distanceTotal, distancesString);
-
-							needUpdateGraphType = eventType.RUNINTERVAL;
-							needUpdateGraph = true;
-							
-							
-							//put button_finish as sensitive when first jump is done (there's something recordable)
-							if(tracks == 1)
-								needSensitiveButtonFinish = true;
 						}
 						else {
 							//has arrived, limited
 							if (tracksLimited) {
 								//has arrived, limited by tracks
-								tracks ++;	
-
-								if(simulated)
-									timestamp = simulatedTimeLast * 1000; //conversion to milliseconds
-
-								double myRaceTime = lastTc + timestamp/1000.0;
-								if(intervalTimesString.Length > 0) { equal = "="; }
-								intervalTimesString = intervalTimesString + equal + myRaceTime.ToString();
-								updateTimerCountWithChronopicData(intervalTimesString);
-
-
-								//save temp table if needed
-								countForSavingTempTable ++;
-								if(countForSavingTempTable == timesForSavingRepetitive) {
-									writeRunInterval(true); //tempTable
-									countForSavingTempTable = 0;
-								}
-
-	
 								if(tracks >= limitAsDouble) 
 								{
 									//finished
@@ -888,7 +662,6 @@ public class RunIntervalExecute : RunExecute
 									success = true;
 									runPhase = runPhases.PLATFORM_END;
 								}
-								
 								//progressBarEventOrTimePreExecution(
 								updateProgressBar= new UpdateProgressBar (
 										true, //isEvent
@@ -896,61 +669,30 @@ public class RunIntervalExecute : RunExecute
 										tracks
 										);  
 								needUpdateEventProgressBar = true;
-							
-								distanceTotal = Util.GetRunITotalDistance(distanceInterval, distancesString, tracks);
-							
-								//update graph
-								PrepareEventGraphRunIntervalObject = new PrepareEventGraphRunInterval(
-										distanceIntervalFixed, myRaceTime, intervalTimesString, distanceTotal, distancesString);
-
-								needUpdateGraphType = eventType.RUNINTERVAL;
-								needUpdateGraph = true;
-
-								//put button_finish as sensitive when first jump is done (there's something recordable)
-								if(tracks == 1)
-									needSensitiveButtonFinish = true;
 							} else {
 								//has arrived, limited by time
-								runPhase = runPhases.RUNNING;
-								
-								if(simulated)
-									timestamp = simulatedTimeLast * 1000; //conversion to milliseconds
-								
-								double myRaceTime = lastTc + timestamp/1000.0;
-
-								if(intervalTimesString.Length > 0) { equal = "="; }
-								intervalTimesString = intervalTimesString + equal + myRaceTime.ToString();
-								updateTimerCountWithChronopicData(intervalTimesString);
-								tracks ++;	
-
-								//save temp table if needed
-								countForSavingTempTable ++;
-								if(countForSavingTempTable == timesForSavingRepetitive) {
-									writeRunInterval(true); //tempTable
-									countForSavingTempTable = 0;
-								}
-								
 								updateProgressBar= new UpdateProgressBar (
 										true, //isEvent
 										false, //timeLimited: activity mode
 										tracks
 										);  
 								needUpdateEventProgressBar = true;
-								
-								distanceTotal = Util.GetRunITotalDistance(distanceInterval, distancesString, tracks);
-							
-								//update graph
-								PrepareEventGraphRunIntervalObject = new PrepareEventGraphRunInterval(
-										distanceIntervalFixed, myRaceTime, intervalTimesString, distanceTotal, distancesString);
-
-								needUpdateGraphType = eventType.RUNINTERVAL;
-								needUpdateGraph = true;
-
-								//put button_finish as sensitive when first jump is done (there's something recordable)
-								if(tracks == 1)
-									needSensitiveButtonFinish = true;
 							}
 						}
+
+						distanceTotal = Util.GetRunITotalDistance(distanceInterval, distancesString, tracks);
+
+						//update graph
+						PrepareEventGraphRunIntervalObject = new PrepareEventGraphRunInterval(
+								distanceIntervalFixed, myRaceTime, intervalTimesString, 
+								distanceTotal, distancesString);
+
+						needUpdateGraphType = eventType.RUNINTERVAL;
+						needUpdateGraph = true;
+
+						//put button_finish as sensitive when first jump is done (there's something recordable)
+						if(tracks == 1)
+							needSensitiveButtonFinish = true;
 					}
 				}
 				else if (platformState == Chronopic.Plataforma.OFF && loggedState == States.ON) {
@@ -969,18 +711,22 @@ public class RunIntervalExecute : RunExecute
 						feedbackMessage = "";
 						needShowFeedbackMessage = true; 
 					} 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;
+						if(checkDoubleContact && timestampDCn > 0)
+							timestampDCContactTimes += timestamp;
+						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;
+							  }
 						}
 					}
 
@@ -1045,14 +791,6 @@ public class RunIntervalExecute : RunExecute
 			return false;
 	}
 	
-	protected override void updateProgressBarForFinish() {
-		progressBarEventOrTimePreExecution(
-				false, //isEvent false: time
-				true, //percentageMode: it has finished, show bar at 100%
-				limitAsDouble
-				);  
-	}
-
 	protected override void updateTimeProgressBar() {
 		/* 5 situations:
 		 *   1- if we start out and have not arrived to platform, it should be a pulse with no time value on label:
@@ -1095,13 +833,14 @@ public class RunIntervalExecute : RunExecute
 				//but chronojump.cs will update info soon with chronopic value
 				break;
 		}
-				
-		progressBarEventOrTimePreExecution(
-				false, //isEvent false: time
-				//!tracksLimited, //if tracksLimited: activity, if timeLimited: fraction
-				percentageMode,
-				myTimeValue
-				); 
+			
+		if(! finish) 
+			progressBarEventOrTimePreExecution(
+					false, //isEvent false: time
+					//!tracksLimited, //if tracksLimited: activity, if timeLimited: fraction
+					percentageMode,
+					myTimeValue
+					); 
 	}
 
 	private void updateTimerCountWithChronopicData(string timesString) {



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