[chronojump] Added runExecuteInspector to completely debug run intervallic races
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Added runExecuteInspector to completely debug run intervallic races
- Date: Mon, 19 Mar 2018 19:17:35 +0000 (UTC)
commit fa9bb44f2128c117f14a4047ce2c6cde594782d2
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Mar 19 20:16:51 2018 +0100
Added runExecuteInspector to completely debug run intervallic races
glade/app1.glade | 33 ++++++++++++
src/chronojump.cs | 2 +
src/execute/event.cs | 37 +++++++++++++-
src/execute/run.cs | 133 +++++++++++++++++++++++++++++++++++++++++++++++-
src/gui/chronojump.cs | 11 ++++
5 files changed, 210 insertions(+), 6 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 837c195..fc56378 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -1631,6 +1631,9 @@
<placeholder/>
</child>
<child>
+ <placeholder/>
+ </child>
+ <child>
<widget class="GtkLabel"
id="label_start_selector_jumps">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -8675,6 +8678,11 @@ EncoderInertialCapture</property>
<property name="can_focus">False</property>
<property name="spacing">2</property>
<child>
+ <widget class="GtkHBox" id="hbox254">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">2</property>
+ <child>
<widget class="GtkButton"
id="button_video_play_this_test">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -8699,6 +8707,28 @@ EncoderInertialCapture</property>
</packing>
</child>
<child>
+ <widget class="GtkButton"
id="button_inspect_last_test">
+ <property name="label">Inspect</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="has_tooltip">True</property>
+ <signal name="clicked"
handler="on_button_inspect_last_test_clicked" swapped="no"/>
+ <accelerator key="v" signal="clicked"/>
+ </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">0</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkButton"
id="button_delete_last_test">
<property name="visible">True</property>
<property name="sensitive">False</property>
@@ -24766,6 +24796,9 @@ then click this button.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
diff --git a/src/chronojump.cs b/src/chronojump.cs
index d2c7de2..8c4742a 100644
--- a/src/chronojump.cs
+++ b/src/chronojump.cs
@@ -426,6 +426,8 @@ public class ChronoJump
Sqlite.Open();
+//TODO: fix this to the new code
+
string versionAvailableKnown = SqlitePreferences.Select("versionAvailable", true);
if( versionAvailable != Constants.ServerOffline && new Version(versionAvailable) > new
Version(progVersion) ) {
//check if available version is higher than known available version
diff --git a/src/execute/event.cs b/src/execute/event.cs
index 3f33bf3..f238086 100644
--- a/src/execute/event.cs
+++ b/src/execute/event.cs
@@ -140,8 +140,6 @@ public class EventExecute
//on animation lights and discriminative should be false
public bool StartIn = true;
public Gtk.Button FakeButtonReactionTimeStart;
-
-
//protected EventExecuteWindow eventExecuteWin;
//protected ChronoJumpWindow app1;
@@ -473,7 +471,12 @@ public class EventExecute
public virtual void Manage2() {
}
-
+
+ public virtual string GetInspectorMessages()
+ {
+ return "";
+ }
+
//from confirm_window cancel button (thread has not started)
//this is NOT called when a event has started and user click on "Cancel"
protected void cancel_event_before_start(object o, EventArgs args)
@@ -545,3 +548,31 @@ public class EventExecute
}
+public class InOut
+{
+ private bool contactIn;
+ private DateTime dt;
+ private string message;
+
+ public InOut (bool contactIn, DateTime dt, string message)
+ {
+ this.contactIn = contactIn;
+ this.dt = dt;
+ this.message = message;
+ }
+
+ public override string ToString()
+ {
+ string str = "\n- ";
+ if(contactIn)
+ str += "IN / ";
+ else
+ str += "OUT / ";
+
+ str += dt.ToShortTimeString();
+ if(message != "")
+ str += " / " + message;
+
+ return str;
+ }
+}
diff --git a/src/execute/run.cs b/src/execute/run.cs
index b49ba80..711a9e4 100644
--- a/src/execute/run.cs
+++ b/src/execute/run.cs
@@ -20,7 +20,7 @@
using System;
using System.Data;
-
+using System.Collections.Generic; //List
using System.Threading;
using System.IO.Ports;
using Mono.Unix;
@@ -492,6 +492,7 @@ public class RunIntervalExecute : RunExecute
bool RSABellDone;
//private Chronopic cp;
+ private static RunExecuteInspector runEI;
public RunIntervalExecute() {
}
@@ -586,6 +587,13 @@ public class RunIntervalExecute : RunExecute
if(! simulated)
Chronopic.InitCancelAndFinish();
+ runEI = new RunExecuteInspector(
+ RunExecuteInspector.Types.RUN_INTERVAL,
+ speedStartArrival,
+ checkDoubleContactMode,
+ checkDoubleContactTime
+ );
+ runEI.ChangePhase(RunExecuteInspector.Phases.START);
do {
if(simulated)
ok = true;
@@ -611,8 +619,15 @@ public class RunIntervalExecute : RunExecute
runPhase = runPhases.PLATFORM_INI_YES_TIME;
//run starts
initializeTimer(); //timerCount = 0
+
+ runEI.ChangePhase(RunExecuteInspector.Phases.IN,
+ "TimerStart");
} else
+ {
runPhase = runPhases.PLATFORM_INI_NO_TIME;
+ runEI.ChangePhase(RunExecuteInspector.Phases.IN,
+ "No timer start until leave plaform");
+ }
feedbackMessage = "";
needShowFeedbackMessage = true;
@@ -627,6 +642,8 @@ public class RunIntervalExecute : RunExecute
if(simulated)
timestamp = simulatedTimeLast * 1000; //conversion to
milliseconds
+ string runEIString = "";
+
if(checkDoubleContactMode != Constants.DoubleContact.NONE) {
if(timestamp <= checkDoubleContactTime) {
/*
@@ -637,6 +654,10 @@ public class RunIntervalExecute : RunExecute
*/
timestampDCn ++;
timestampDCFlightTimes += timestamp;
+
runEI.ChangePhase(RunExecuteInspector.Phases.IN,
+ string.Format("RUNNING,
DOUBLECONTACT, timestamp: {0}, " +
+ "has been added to
timestampDCFLightTimes: {1}", timestamp/1000.0, timestampDCFlightTimes/1000.0));
+
continue;
}
else {
@@ -645,21 +666,37 @@ public class RunIntervalExecute : RunExecute
Constants.DoubleContact.FIRST) {
/* user want first flight
time,
then add all DC times*/
+
+ double timestampTemp =
timestamp;
timestamp +=
timestampDCFlightTimes +
timestampDCContactTimes;
+
+ runEIString =
string.Format("RUNNING, DoubleContactMode.FIRST, timestamp was: {0} " +
+ "added
DCFLightTimes: {1} and DCContactTimes: {2}, " +
+ "now
timestamp is: {3}",
+
timestampTemp/1000.0, timestampDCFlightTimes/1000.0, timestampDCContactTimes/1000.0, timestamp/1000.0);
}
else if(checkDoubleContactMode ==
Constants.DoubleContact.LAST) {
//user want last flight time,
take that
// so we don't need to change
timestamp. Or we could do (it triggers a warning):
// timestamp = timestamp;
+
+ runEIString =
string.Format("RUNNING, DoubleContactMode.LAST" +
+ "do not
change timestamp, timestamp is: {0}", timestamp/1000.0);
}
else { /* do the avg of all flights
and contacts
then add to last timestamp
*/
+ double timestampTemp =
timestamp;
timestamp +=
(timestampDCFlightTimes +
timestampDCContactTimes)
/ timestampDCn;
+
+ runEIString =
string.Format("RUNNING, DoubleContactMode.AVERAGE, timestamp was: {0} " +
+ "added
(DCFLightTimes: {1} + DCContactTimes: {2}) / n: {3}, " +
+ "now
timestamp is: {4}",
+
timestampTemp/1000.0, timestampDCFlightTimes/1000.0, timestampDCContactTimes/1000.0, timestampDCn/1000.0,
timestamp/1000.0);
}
//init values of timestampDC for next
track
@@ -670,6 +707,9 @@ public class RunIntervalExecute : RunExecute
//note in double contacts mode timestamp can have added
DCFlightTimes and DCContactTimes. So contact time is not only on lastTc
double myRaceTime = lastTc + timestamp/1000.0;
+
+ runEI.ChangePhase(RunExecuteInspector.Phases.IN, runEIString
+ "; trackTime: " + myRaceTime.ToString());
+
LogB.Information(string.Format("RACE ({0}) TC: {1}; TV: {2};
TOTALTIME: {3}", tracks, lastTc, timestamp/1000.0, myRaceTime));
if(intervalTimesString.Length > 0) { equal = "="; }
@@ -740,11 +780,12 @@ public class RunIntervalExecute : RunExecute
}
else if (platformState == Chronopic.Plataforma.OFF && loggedState ==
States.ON) {
//it's out, was inside (= has abandoned platform)
-
+
lastTc = 0;
if(runPhase == runPhases.PLATFORM_INI_NO_TIME) {
//run starts
initializeTimer();
+ runEI.ChangePhase(RunExecuteInspector.Phases.OUT, "Timer
start");
feedbackMessage = "";
needShowFeedbackMessage = true;
@@ -755,15 +796,26 @@ public class RunIntervalExecute : RunExecute
// measuringReactionTime or not, if speedStartArrival, 1st
race time should include lastTc
if(speedStartArrival)
+ {
lastTc = timestamp / 1000.0;
+ runEI.ChangePhase(RunExecuteInspector.Phases.OUT,
+ string.Format("SpeedStartArrival, tc = {0}",
lastTc));
+ }
feedbackMessage = "";
needShowFeedbackMessage = true;
} else {
if(checkDoubleContactMode != Constants.DoubleContact.NONE &&
timestampDCn > 0)
+ {
timestampDCContactTimes += timestamp;
- else
+ runEI.ChangePhase(RunExecuteInspector.Phases.OUT,
+ string.Format("RUNNING double contact,
timestampDCContactTimes = {0}", timestampDCContactTimes/1000.0));
+ }
+ else {
lastTc = timestamp / 1000.0;
+ runEI.ChangePhase(RunExecuteInspector.Phases.OUT,
+ string.Format("RUNNING, tc = {0}", lastTc));
+ }
//RSA
@@ -788,6 +840,7 @@ public class RunIntervalExecute : RunExecute
}
}
} while ( ! success && ! cancel && ! finish );
+ runEI.ChangePhase(RunExecuteInspector.Phases.END);
if (finish) {
runPhase = runPhases.PLATFORM_END;
@@ -1014,6 +1067,11 @@ public class RunIntervalExecute : RunExecute
needEndEvent = true; //used for hiding some buttons on eventWindow, and also for
updateTimeProgressBar here
}
}
+
+ public override string GetInspectorMessages()
+ {
+ return runEI.ToString();
+ }
/*
public string IntervalTimesString
@@ -1071,3 +1129,72 @@ public class RunIntervalExecute : RunExecute
~RunIntervalExecute() {}
}
+public class RunExecuteInspector
+{
+ public enum Types { RUN_SIMPLE, RUN_INTERVAL }
+ private Types type;
+
+ public enum Phases { START, IN, OUT, END }
+ private DateTime dtStarted;
+ private DateTime dtEnded;
+
+ private bool speedStartArrival;
+ Constants.DoubleContact checkDoubleContactMode;
+ int checkDoubleContactTime;
+
+ private List<InOut> listInOut;
+
+
+ //constructor
+ public RunExecuteInspector(Types type, bool speedStartArrival,
+ Constants.DoubleContact checkDoubleContactMode, int checkDoubleContactTime)
+ {
+ this.type = type;
+ this.speedStartArrival = speedStartArrival;
+ this.checkDoubleContactMode = checkDoubleContactMode;
+ this.checkDoubleContactTime = checkDoubleContactTime;
+
+ listInOut = new List<InOut>();
+ }
+
+ //public methods
+
+ public void ChangePhase(Phases phase)
+ {
+ ChangePhase(phase, "");
+ }
+ public void ChangePhase(Phases phase, string message)
+ {
+ DateTime dt = DateTime.Now;
+
+ if(phase == Phases.START)
+ dtStarted = dt;
+ else if(phase == Phases.END)
+ dtEnded = dt;
+ else // (phase == Phases.IN || phases == Phases.OUT)
+ {
+ InOut inOut = new InOut(phase == Phases.IN, dt, message);
+ listInOut.Add(inOut);
+ //listInOut.Add(new InOut(phase == Phases.IN, dt, message));
+ }
+ }
+
+ public override string ToString()
+ {
+ string report = "Report of race started at: " + dtStarted.ToShortTimeString();
+ report += "\n" + "Type: " + type.ToString();
+ report += "\n" + "SpeedStartArrival: " + speedStartArrival;
+ report += "\n" + "CheckDoubleContactMode: " + checkDoubleContactMode;
+ report += "\n" + "CheckDoubleContactTime: " + checkDoubleContactTime;
+
+ report += "\n" + "Chronopic changes:";
+ foreach(InOut inOut in listInOut)
+ {
+ report += inOut.ToString();
+ }
+ report += "\n\n";
+ report += "\n" + "Ended: " + dtEnded.ToShortTimeString();
+
+ return report;
+ }
+}
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 08842b2..9a926c7 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -324,6 +324,7 @@ public partial class ChronoJumpWindow
[Widget] Gtk.Box vbox_last_test_buttons;
[Widget] Gtk.Button button_video_play_this_test;
[Widget] Gtk.Button button_delete_last_test;
+ [Widget] Gtk.Button button_inspect_last_test;
[Widget] Gtk.Button button_upload_session;
[Widget] Gtk.HBox hbox_chronopics_and_more;
@@ -3078,6 +3079,7 @@ public partial class ChronoJumpWindow
radio_mode_contacts_jumps_profile.Visible = false;
radio_mode_contacts_sprint.Visible = false;
notebook_analyze.CurrentPage = 0;
+ button_inspect_last_test.Visible = false;
if(m == Constants.Menuitem_modes.JUMPSSIMPLE || m == Constants.Menuitem_modes.JUMPSREACTIVE)
{
@@ -3132,6 +3134,8 @@ public partial class ChronoJumpWindow
radio_mode_contacts_general.Visible = true;
radio_mode_contacts_sprint.Visible = true;
}
+
+ button_inspect_last_test.Visible = true;
}
radio_mode_contacts_jumps_profile.Hide();
if(radio_mode_contacts_sprint.Active)
@@ -4688,6 +4692,7 @@ public partial class ChronoJumpWindow
{
//test can be deleted if not cancelled
button_delete_last_test.Sensitive = ! currentEventExecute.Cancel;
+ button_inspect_last_test.Sensitive = ! currentEventExecute.Cancel;
if ( ! currentEventExecute.Cancel ) {
currentRunInterval = (RunInterval) currentEventExecute.EventDone;
@@ -5888,6 +5893,12 @@ LogB.Debug("X");
}
}
+ private void on_button_inspect_last_test_clicked (object o, EventArgs args)
+ {
+ if(currentEventExecute != null)
+ new DialogMessage(Constants.MessageTypes.INFO,
currentEventExecute.GetInspectorMessages());
+ }
+
private void deleted_last_test_update_widgets() {
vbox_last_test_buttons.Sensitive = false;
UtilGtk.ClearDrawingArea(event_execute_drawingarea, event_execute_pixmap);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]