[chronojump] prevent double contacts runInterval (50%)
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] prevent double contacts runInterval (50%)
- Date: Wed, 2 Jan 2013 16:58:04 +0000 (UTC)
commit 3b4ac40579cb0d46605900279c87f29c071765ba
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Jan 2 15:19:20 2013 +0100
prevent double contacts runInterval (50%)
glade/chronojump.glade | 205 +++++++++++++++++++++++++++++++++++++++++++++---
src/execute/run.cs | 55 +++++++------
src/gui/chronojump.cs | 50 ++++++++----
src/gui/run.cs | 13 +++-
4 files changed, 266 insertions(+), 57 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 1899626..a2c074f 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -313,13 +313,10 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">0</property>
- <property name="use_underline">True</property>
+ <property name="label" translatable="yes"><b>0</b></property>
+ <property name="use_markup">True</property>
<property name="ellipsize">end</property>
<property name="max_width_chars">25</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
</widget>
<packing>
<property name="expand">False</property>
@@ -1177,6 +1174,7 @@ Chronopic</property>
<widget class="GtkNotebook" id="notebook_execute">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="show_tabs">False</property>
<property name="show_border">False</property>
<child>
<widget class="GtkFrame" id="frame2">
@@ -4601,6 +4599,7 @@ weight</property>
<widget class="GtkVBox" id="vbox31">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="spacing">6</property>
<child>
<widget class="GtkLabel" id="extra_window_label_runs_interval_no_options">
<property name="height_request">100</property>
@@ -4620,7 +4619,7 @@ weight</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
- <widget class="GtkVBox" id="vbox71">
+ <widget class="GtkHBox" id="hbox104">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
@@ -4632,7 +4631,7 @@ weight</property>
(between platforms)</property>
</widget>
<packing>
- <property name="expand">True</property>
+ <property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
@@ -4686,14 +4685,13 @@ weight</property>
</child>
</widget>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">True</property>
- <property name="padding">4</property>
<property name="position">0</property>
</packing>
</child>
<child>
- <widget class="GtkVBox" id="vbox72">
+ <widget class="GtkHBox" id="hbox68">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
@@ -4704,7 +4702,7 @@ weight</property>
<property name="label" translatable="yes">Limited by</property>
</widget>
<packing>
- <property name="expand">True</property>
+ <property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
@@ -4756,21 +4754,204 @@ weight</property>
</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">False</property>
<property name="fill">True</property>
- <property name="padding">4</property>
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <widget class="GtkHSeparator" id="hseparator5">
+ <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="vbox22">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <widget class="GtkCheckButton" id="checkbutton_runs_i_prevent_double_contact">
+ <property name="label" translatable="yes">Prevent double contacts (recommended)</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_checkbutton_runs_i_prevent_double_contact_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="GtkAlignment" id="alignment3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <widget class="GtkVBox" id="vbox_runs_i_prevent_double_contact">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">4</property>
+ <child>
+ <widget class="GtkLabel" id="label35">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Fix if found two or more contacts in</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox67">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <widget class="GtkSpinButton" id="spinbutton_runs_i_prevent_double_contact">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">â</property>
+ <property name="invisible_char_set">True</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ <property name="adjustment">1000 0 3000 100 1000 0</property>
+ <property name="snap_to_ticks">True</property>
+ <property name="numeric">True</property>
+ <property name="update_policy">if-valid</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
+ <property name="padding">12</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label36">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">ms</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkAlignment" id="alignment10">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <widget class="GtkVBox" id="vbox24">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">4</property>
+ <child>
+ <widget class="GtkRadioButton" id="radio_runs_i_prevent_double_contact_first">
+ <property name="label" translatable="yes">Take first contact (recommended)</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>
+ </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_prevent_double_contact_average">
+ <property name="label" translatable="yes">Take average</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_prevent_double_contact_first</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkRadioButton" id="radio_runs_i_prevent_double_contact_last">
+ <property name="label" translatable="yes">Take last contact</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_prevent_double_contact_first</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ </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">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
<property name="position">3</property>
</packing>
</child>
diff --git a/src/execute/run.cs b/src/execute/run.cs
index 2b9bd0b..28bcadb 100644
--- a/src/execute/run.cs
+++ b/src/execute/run.cs
@@ -43,9 +43,9 @@ public class RunExecute : EventExecute
}
protected runPhases runPhase;
- private bool checkDoubleContact;
- private int checkDoubleContactTime;
- private Constants.DoubleContact checkDoubleContactMode;
+ protected bool checkDoubleContact;
+ protected int checkDoubleContactTime;
+ protected Constants.DoubleContact checkDoubleContactMode;
public RunExecute() {
@@ -186,7 +186,7 @@ Log.WriteLine("MANAGE(3)!!!!");
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
- double timestampDCN = 0; //number of flight times
+ double timestampDCn = 0; //number of flight times
bool success = false;
bool ok;
@@ -230,11 +230,11 @@ Log.WriteLine("MANAGE(3)!!!!");
and we arrived (it's a flight time)
record this time as timestampDCFlightTimes
*/
- timestampDCN ++;
+ timestampDCn ++;
timestampDCFlightTimes += timestamp;
}
else {
- if(timestampDCN > 0) {
+ if(timestampDCn > 0) {
if(checkDoubleContactMode ==
Constants.DoubleContact.FIRST) {
/* user want first flight time,
@@ -252,7 +252,7 @@ Log.WriteLine("MANAGE(3)!!!!");
timestamp +=
(timestampDCFlightTimes +
timestampDCContactTimes)
- / timestampDCN;
+ / timestampDCn;
}
}
success = true;
@@ -287,7 +287,7 @@ Log.WriteLine("MANAGE(3)!!!!");
//change the automata state
loggedState = States.OFF;
- if(checkDoubleContact && timestampDCN > 0)
+ if(checkDoubleContact && timestampDCn > 0)
timestampDCContactTimes += timestamp;
else {
initializeTimer();
@@ -444,7 +444,8 @@ public class RunIntervalExecute : RunExecute
public RunIntervalExecute(int personID, int sessionID, string type, double distanceInterval, double limitAsDouble, bool tracksLimited,
Chronopic cp, Gtk.TextView event_execute_textview_message, Gtk.Window app, int pDN, bool metersSecondsPreferred,
bool volumeOn, RepetitiveConditionsWindow repetitiveConditionsWin,
- double progressbarLimit, ExecutingGraphData egd
+ double progressbarLimit, ExecutingGraphData egd ,
+ bool checkDoubleContact, int checkDoubleContactTime, Constants.DoubleContact checkDoubleContactMode
)
{
this.personID = personID;
@@ -479,6 +480,9 @@ public class RunIntervalExecute : RunExecute
this.repetitiveConditionsWin = repetitiveConditionsWin;
this.progressbarLimit = progressbarLimit;
this.egd = egd;
+ this.checkDoubleContact = checkDoubleContact;
+ this.checkDoubleContactTime = checkDoubleContactTime;
+ this.checkDoubleContactMode = checkDoubleContactMode;
fakeButtonUpdateGraph = new Gtk.Button();
fakeButtonEventEnded = new Gtk.Button();
@@ -502,20 +506,14 @@ public class RunIntervalExecute : RunExecute
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 {
@@ -554,7 +552,7 @@ public class RunIntervalExecute : RunExecute
if(limitAsDouble == -1) {
-
+ //has arrived, unlimited
if(simulated)
timestamp = simulatedTimeLast * 1000; //conversion to milliseconds
@@ -645,6 +643,9 @@ public class RunIntervalExecute : RunExecute
timestamp = simulatedTimeLast * 1000; //conversion to milliseconds
double myRaceTime = lastTc + timestamp/1000.0;
+
+ /*
+ success is never true here
if(success) {
//write();
//write only if there's a run at minimum
@@ -658,19 +659,19 @@ public class RunIntervalExecute : RunExecute
runPhase = runPhases.PLATFORM_END;
}
else {
- 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(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
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index fce9425..8b5d69b 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -147,7 +147,7 @@ public partial class ChronoJumpWindow
[Widget] Gtk.Box hbox_execute_test;
[Widget] Gtk.Button button_execute_test;
- //[Widget] Gtk.Label label_connected_chronopics;
+ [Widget] Gtk.Label label_connected_chronopics;
//[Widget] Gtk.TextView textview_message_connected_chronopics;
//[Widget] Gtk.Image image_connected_chronopics;
@@ -475,6 +475,7 @@ public partial class ChronoJumpWindow
//don't know why Glade is not doing this
spinbutton_runs_prevent_double_contact.Value=1000;
+ spinbutton_runs_i_prevent_double_contact.Value=1000;
//We have no session, mark some widgets as ".Sensitive = false"
sensitiveGuiNoSession();
@@ -3358,13 +3359,22 @@ Log.WriteLine("DDD 2");
* --------------------------------------------------------
*/
- private Constants.DoubleContact getDoubleContactModes() {
- if(radio_runs_prevent_double_contact_first.Active)
- return Constants.DoubleContact.FIRST;
- else if(radio_runs_prevent_double_contact_average.Active)
- return Constants.DoubleContact.AVERAGE;
- else
- return Constants.DoubleContact.LAST;
+ private Constants.DoubleContact getDoubleContactModes(bool runSimple) {
+ if(runSimple) {
+ if(radio_runs_prevent_double_contact_first.Active)
+ return Constants.DoubleContact.FIRST;
+ else if(radio_runs_prevent_double_contact_average.Active)
+ return Constants.DoubleContact.AVERAGE;
+ else
+ return Constants.DoubleContact.LAST;
+ } else { //runInterval
+ if(radio_runs_i_prevent_double_contact_first.Active)
+ return Constants.DoubleContact.FIRST;
+ else if(radio_runs_i_prevent_double_contact_average.Active)
+ return Constants.DoubleContact.AVERAGE;
+ else
+ return Constants.DoubleContact.LAST;
+ }
}
//suitable for all runs not repetitive
@@ -3412,13 +3422,15 @@ Log.WriteLine("DDD 2");
event_execute_ButtonUpdate.Clicked += new EventHandler(on_update_clicked);
- currentEventExecute = new RunExecute(currentPerson.UniqueID, currentSession.UniqueID,
+ currentEventExecute = new RunExecute(
+ currentPerson.UniqueID, currentSession.UniqueID,
currentRunType.Name, myDistance,
- chronopicWin.CP, event_execute_textview_message, app1, prefsDigitsNumber, metersSecondsPreferred, volumeOn,
+ chronopicWin.CP, event_execute_textview_message, app1,
+ prefsDigitsNumber, metersSecondsPreferred, volumeOn,
progressbarLimit, egd,
checkbutton_runs_prevent_double_contact.Active,
(int) spinbutton_runs_prevent_double_contact.Value,
- getDoubleContactModes()
+ getDoubleContactModes(true) //true: runSimple
);
if (!chronopicWin.Connected)
@@ -3531,10 +3543,16 @@ Log.WriteLine("DDD 2");
event_execute_ButtonUpdate.Clicked -= new EventHandler(on_update_clicked); //if we don't do this, on_update_clicked it's called 'n' times when 'n' events are done
event_execute_ButtonUpdate.Clicked += new EventHandler(on_update_clicked);
- currentEventExecute = new RunIntervalExecute(currentPerson.UniqueID, currentSession.UniqueID, currentRunIntervalType.Name,
+ currentEventExecute = new RunIntervalExecute(
+ currentPerson.UniqueID, currentSession.UniqueID, currentRunIntervalType.Name,
distanceInterval, progressbarLimit, currentRunIntervalType.TracksLimited,
- chronopicWin.CP, event_execute_textview_message, app1, prefsDigitsNumber, metersSecondsPreferred, volumeOn, repetitiveConditionsWin,
- progressbarLimit, egd);
+ chronopicWin.CP, event_execute_textview_message, app1,
+ prefsDigitsNumber, metersSecondsPreferred, volumeOn, repetitiveConditionsWin,
+ progressbarLimit, egd,
+ checkbutton_runs_i_prevent_double_contact.Active,
+ (int) spinbutton_runs_i_prevent_double_contact.Value,
+ getDoubleContactModes(false) //false: not runSimple
+ );
//suitable for limited by tracks and time
@@ -3871,10 +3889,10 @@ Log.WriteLine("DDD 2");
}
private void chronopicLabels(int cps) {
- /*
label_connected_chronopics.Text = "<b>" + cps.ToString() + "</b>";
label_connected_chronopics.UseMarkup = true;
-
+
+ /*
string myMessage = "";
if(cps == 0)
myMessage = Constants.SimulatedMessage;
diff --git a/src/gui/run.cs b/src/gui/run.cs
index 374f764..7c6e2bf 100644
--- a/src/gui/run.cs
+++ b/src/gui/run.cs
@@ -954,12 +954,18 @@ partial class ChronoJumpWindow
[Widget] Gtk.Label extra_window_runs_interval_label_distance;
[Widget] Gtk.SpinButton extra_window_runs_interval_spinbutton_distance;
[Widget] Gtk.Label extra_window_runs_interval_label_distance_units;
-
[Widget] Gtk.Label extra_window_runs_interval_label_limit;
[Widget] Gtk.SpinButton extra_window_runs_interval_spinbutton_limit;
[Widget] Gtk.Label extra_window_runs_interval_label_limit_units;
-
[Widget] Gtk.Label extra_window_label_runs_interval_no_options;
+
+ [Widget] Gtk.Box vbox_runs_i_prevent_double_contact;
+ [Widget] Gtk.CheckButton checkbutton_runs_i_prevent_double_contact;
+ [Widget] Gtk.SpinButton spinbutton_runs_i_prevent_double_contact;
+ [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;
+
//selected test labels
[Widget] Gtk.Label extra_window_runs_label_selected;
@@ -1262,6 +1268,9 @@ partial class ChronoJumpWindow
protected void on_checkbutton_runs_prevent_double_contact_toggled (object o, EventArgs args) {
vbox_runs_prevent_double_contact.Visible = checkbutton_runs_prevent_double_contact.Active;
}
+ protected void on_checkbutton_runs_i_prevent_double_contact_toggled (object o, EventArgs args) {
+ vbox_runs_i_prevent_double_contact.Visible = checkbutton_runs_i_prevent_double_contact.Active;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]