[chronojump] new feature! DJ fall can be calculated using a prejump
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] new feature! DJ fall can be calculated using a prejump
- Date: Mon, 13 Oct 2014 16:44:28 +0000 (UTC)
commit b3a04396e82ab0b88fb98d1245cafef58076870e
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Oct 13 18:43:39 2014 +0200
new feature! DJ fall can be calculated using a prejump
glade/chronojump.glade | 162 +++++++++++++++++++++++++++++++++++++++++++++---
src/execute/jump.cs | 131 ++++++++++++++++++++++++++++----------
src/gui/chronojump.cs | 37 ++++++++---
src/gui/jump.cs | 10 +++-
src/jump.cs | 3 +-
src/jumpType.cs | 2 +-
6 files changed, 288 insertions(+), 57 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index ba3b838..add1f5f 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -3204,15 +3204,22 @@
<property name="can_focus">False</property>
<property name="spacing">4</property>
<child>
- <widget class="GtkLabel"
id="extra_window_jumps_label_fall">
+ <widget class="GtkHBox" id="hbox136">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label"
translatable="yes">Falling height</property>
+ <property name="spacing">8</property>
+ <child>
+ <widget class="GtkRadioButton"
id="extra_window_jumps_radio_dj_fall_predefined">
+ <property name="label" translatable="yes">Fall
from a predefined height</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property
name="receives_default">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="expand">False</property>
+ <property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
@@ -3220,6 +3227,7 @@
<widget class="GtkHBox" id="hbox23">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="spacing">4</property>
<child>
<widget class="GtkSpinButton"
id="extra_window_jumps_spinbutton_fall">
<property name="visible">True</property>
@@ -3238,7 +3246,6 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="padding">12</property>
<property name="position">0</property>
</packing>
</child>
@@ -3251,14 +3258,37 @@
</widget>
<packing>
<property name="expand">False</property>
- <property name="fill">True</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <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">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkRadioButton"
id="extra_window_jumps_radio_dj_fall_calculate">
+ <property name="label"
translatable="yes">Calculate falling height using a previous jump</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property
name="receives_default">False</property>
+ <property
name="xalign">0.40000000596046448</property>
+ <property name="draw_indicator">True</property>
+ <property
name="group">extra_window_jumps_radio_dj_fall_predefined</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
@@ -6275,6 +6305,12 @@ Second Chronopic to platforms.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">True</property>
@@ -6960,6 +6996,12 @@ Second Chronopic to platforms.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
<child>
@@ -7779,6 +7821,12 @@ Second Chronopic to platforms.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="position">2</property>
@@ -8357,6 +8405,12 @@ Second Chronopic to platforms.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="position">4</property>
@@ -18061,6 +18115,12 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -18547,6 +18607,12 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -19525,6 +19591,12 @@ by you</property>
<placeholder/>
</child>
<child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<widget class="GtkButton" id="button_video_url">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -19560,6 +19632,12 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">True</property>
@@ -28214,6 +28292,42 @@ options</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -30090,6 +30204,12 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -30635,6 +30755,12 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -33153,6 +33279,12 @@ show elevation as:</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="left_attach">2</property>
@@ -33303,6 +33435,12 @@ show elevation as:</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -33468,6 +33606,12 @@ show elevation as:</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
diff --git a/src/execute/jump.cs b/src/execute/jump.cs
index 5cdfa03..b3201ab 100644
--- a/src/execute/jump.cs
+++ b/src/execute/jump.cs
@@ -57,7 +57,7 @@ public class JumpExecute : EventExecute
this.personName = personName;
this.sessionID = sessionID;
this.type = type;
- this.fall = fall;
+ this.fall = fall; //-1 means has to be calculated with a previous jump
this.weight = weight;
this.cp = cp;
@@ -149,8 +149,8 @@ public class JumpExecute : EventExecute
}
else if (platformState==Chronopic.Plataforma.OFF) {
ConfirmWindow confirmWin;
- confirmWin = ConfirmWindow.Show(
- Catalog.GetString("You are OUT, come inside and press the 'accept'
button"), "", "");
+ confirmWin = ConfirmWindow.Show(Catalog.GetString(
+ "You are OUT, please enter the platform, prepare for jump and
press the 'accept' button"), "", "");
Util.PlaySound(Constants.SoundTypes.BAD, volumeOn);
@@ -170,18 +170,43 @@ public class JumpExecute : EventExecute
//boolean to know if chronopic has been disconnected
chronopicDisconnected = false;
- if (simulated)
- platformState = Chronopic.Plataforma.OFF;
+ if (simulated) {
+ if(fall != -1)
+ platformState = Chronopic.Plataforma.OFF;
+ else
+ platformState = Chronopic.Plataforma.ON;
+ }
else
platformState = chronopicInitialValue(cp);
+
+
+ if (platformState != Chronopic.Plataforma.OFF &&
+ platformState != Chronopic.Plataforma.ON)
+ {
+ //UNKNOW (Chronopic disconnected, port changed, ...)
+ chronopicHasBeenDisconnected();
+ return;
+ }
- if (platformState==Chronopic.Plataforma.OFF) {
- feedbackMessage = Catalog.GetString("You are OUT, JUMP when prepared!");
+ //if we are outside
+ //or we are inside, but with fall == -1 (calculate fall using a previous jump (start inside))
+ if (
+ ( platformState == Chronopic.Plataforma.OFF && fall != -1 ) ||
+ ( platformState == Chronopic.Plataforma.ON && fall == -1 )
+ )
+ {
+ if(fall != -1) {
+ feedbackMessage = Catalog.GetString("You are OUT, JUMP when prepared!");
+ loggedState = States.OFF;
+ } else {
+ feedbackMessage = Catalog.GetString("You are IN, JUMP when prepared!");
+ loggedState = States.ON;
+ }
+
needShowFeedbackMessage = true;
Util.PlaySound(Constants.SoundTypes.CAN_START, volumeOn);
- loggedState = States.OFF;
//useful also for tracking the jump phases
tc = 0;
@@ -191,19 +216,28 @@ public class JumpExecute : EventExecute
totallyCancelled = false;
//in simulated mode, make the jump start just when we arrive to waitEvent at the
first time
- //mark now that we have arrived:
- if (simulated)
- platformState = Chronopic.Plataforma.ON;
+ if (simulated) {
+ if(fall != -1)
+ platformState = Chronopic.Plataforma.ON; //mark now that we have
arrived:
+ else
+ platformState = Chronopic.Plataforma.OFF; //mark now that we have
jumped
+ }
//start thread
thread = new Thread(new ThreadStart(waitEvent));
GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
thread.Start();
}
- else if (platformState==Chronopic.Plataforma.ON) {
- ConfirmWindow confirmWin;
- confirmWin = ConfirmWindow.Show(
- Catalog.GetString("You are IN, please leave the platform, and press
the 'accept' button"), "", "");
+ else
+ {
+ ConfirmWindow confirmWin;
+
+ string message = Catalog.GetString("You are IN, please leave the platform, and press
the 'accept' button");
+ if(fall == -1)
+ message = Catalog.GetString("You are OUT, please enter the platform, prepare
for jump and press the 'accept' button");
+
+ confirmWin = ConfirmWindow.Show(message, "", "");
+
Util.PlaySound(Constants.SoundTypes.BAD, volumeOn);
//we call again this function
@@ -212,9 +246,6 @@ public class JumpExecute : EventExecute
//if confirmWin.Button_cancel is pressed return
confirmWin.Button_cancel.Clicked += new EventHandler(cancel_event_before_start);
}
- else { //UNKNOW (Chronopic disconnected, port changed, ...)
- chronopicHasBeenDisconnected();
- }
}
//for calling it again after a confirmWindow says that you have to be in or out the platform
@@ -231,19 +262,51 @@ public class JumpExecute : EventExecute
bool success = false;
bool ok;
+ int phase = 0;
do {
if(simulated)
ok = true;
else
ok = cp.Read_event(out timestamp, out platformState);
+
+
+ /*
+ * \()/ \()/
+ * \/ \/
+ * _()_ /\ _()_ /\ _()_
+ * \/ \/ \/
+ * ___/\______________/\______________/\___
+ *
+ * GraphA graphB graphC graphD graphE
+ * unused jumps lands jumps lands
+ *
+ * ______start_______ end
+ *
+ * DJ DJ SJ
+ * hasFall hasFall
+ * fall -1
+ *
+ */
//if (ok)
if (ok && !cancel) {
if (platformState == Chronopic.Plataforma.ON && loggedState == States.OFF)
{
//has landed
- if(hasFall && tc == 0) {
+ if(hasFall && tc == 0)
+ {
+ //**** graphC ****
+
+ if(fall == -1) {
+ if(simulated)
+ timestamp = simulatedTimeLast * 1000;
//conversion to milliseconds
+
+ //calculate the fall height using flight time
+ double tvPreJump = timestamp / 1000.0;
+ fall =
Convert.ToDouble(Util.GetHeightInCentimeters(tvPreJump.ToString()));
+ }
+
//jump with fall, landed first time
initializeTimer();
@@ -252,14 +315,15 @@ public class JumpExecute : EventExecute
updateProgressBar = new UpdateProgressBar (
true, //isEvent
true, //jumpsLimited: percentageMode
- 1 //it's a drop: phase 1/3
+ ++phase
);
needUpdateEventProgressBar = true;
feedbackMessage = "";
needShowFeedbackMessage = true;
+
} else {
- //jump with fall: second landed; or without fall first landing
+ //**** graphE **** jump with fall: second landed; or without
fall first landing
if(simulated)
timestamp = simulatedTimeLast * 1000; //conversion to
milliseconds
@@ -271,30 +335,25 @@ public class JumpExecute : EventExecute
success = true;
- //update event progressbar
- double percentageToPass = 2; //normal jump has two phases
- if(hasFall)
- percentageToPass = 3; //drop jump has three phases
-
//app1.ProgressBarEventOrTimePreExecution(
//don't do it, put a boolean value and let the PulseGTK do it
updateProgressBar = new UpdateProgressBar (
true, //isEvent
true, //percentageMode
- percentageToPass
+ ++phase
);
needUpdateEventProgressBar = true;
}
-
loggedState = States.ON;
}
else if (platformState == Chronopic.Plataforma.OFF && loggedState ==
States.ON)
{
-
//it's out, was inside (= has jumped)
-
- if(hasFall) {
-
+
+ //fall != -1 because if it was == -1, it will change once touching
floor for the first time
+ if(hasFall && fall != -1) {
+ //**** graphD ****
+
if(simulated)
timestamp = simulatedTimeLast * 1000; //conversion to
milliseconds
@@ -317,10 +376,13 @@ public class JumpExecute : EventExecute
updateProgressBar = new UpdateProgressBar (
true, //isEvent
true, //percentageMode
- 2 //it's a drop jump: phase 2/3
+ ++phase
);
needUpdateEventProgressBar = true;
} else {
+ //**** graphD (if normal jump) ****
+ //**** graphB (if hasFall and fall == -1) ****
+
initializeTimer();
//update event progressbar
@@ -329,7 +391,7 @@ public class JumpExecute : EventExecute
updateProgressBar = new UpdateProgressBar (
true, //isEvent
true, //percentageMode
- 1 //normal jump, phase 1/2
+ ++phase
);
needUpdateEventProgressBar = true;
@@ -339,7 +401,6 @@ public class JumpExecute : EventExecute
//change the automata state
loggedState = States.OFF;
-
}
}
//Log.WriteLine("PREEXIT");
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 6219063..46fce5b 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -894,38 +894,52 @@ public partial class ChronoJumpWindow
*/
public void on_radio_mode_jumps_small_toggled (object obj, EventArgs args) {
- if(radio_mode_jumps_small.Active)
+ if(radio_mode_jumps_small.Active) {
notebooks_change(0);
+ on_extra_window_jumps_test_changed(obj, args);
+ }
}
public void on_radio_mode_jumps_reactive_small_toggled (object obj, EventArgs args) {
- if(radio_mode_jumps_reactive_small.Active)
+ if(radio_mode_jumps_reactive_small.Active) {
notebooks_change(1);
+ on_extra_window_jumps_rj_test_changed(obj, args);
+ }
}
public void on_radio_mode_runs_small_toggled (object obj, EventArgs args) {
- if(radio_mode_runs_small.Active)
+ if(radio_mode_runs_small.Active) {
notebooks_change(2);
+ on_extra_window_runs_test_changed(obj, args);
+ }
}
public void on_radio_mode_runs_intervallic_small_toggled (object obj, EventArgs args) {
- if(radio_mode_runs_intervallic_small.Active)
+ if(radio_mode_runs_intervallic_small.Active) {
notebooks_change(3);
+ on_extra_window_runs_interval_test_changed(obj, args);
+ }
}
public void on_radio_mode_reaction_times_small_toggled (object obj, EventArgs args) {
- if(radio_mode_reaction_times_small.Active)
+ if(radio_mode_reaction_times_small.Active) {
notebooks_change(4);
+ on_extra_window_reaction_times_test_changed(obj, args);
+ }
}
public void on_radio_mode_pulses_small_toggled (object obj, EventArgs args) {
- if(radio_mode_pulses_small.Active)
+ if(radio_mode_pulses_small.Active) {
notebooks_change(5);
+ on_extra_window_pulses_test_changed(obj, args);
+ }
}
public void on_radio_mode_multi_chronopic_small_toggled (object obj, EventArgs args) {
- if(radio_mode_multi_chronopic_small.Active)
+ if(radio_mode_multi_chronopic_small.Active) {
notebooks_change(6);
+ on_extra_window_multichronopic_test_changed(obj, args);
+ }
}
public void on_radio_mode_encoder_capture_small_toggled (object obj, EventArgs args) {
@@ -3426,7 +3440,10 @@ Console.WriteLine("X");
}
double myFall = 0;
if(currentJumpType.HasFall) {
- myFall = (double) extra_window_jumps_spinbutton_fall.Value;
+ if(extra_window_jumps_radio_dj_fall_predefined.Active)
+ myFall = (double) extra_window_jumps_spinbutton_fall.Value;
+ else
+ myFall = -1;
}
string description = "";
@@ -3448,7 +3465,9 @@ Console.WriteLine("X");
//show the event doing window
double progressbarLimit = 3; //3 phases for show the Dj
- if( currentJumpType.StartIn ||
+ if(myFall == -1)
+ progressbarLimit = 4; //4 if there's a pre-jump
+ else if( currentJumpType.StartIn ||
currentJumpType.Name == Constants.TakeOffName ||
currentJumpType.Name == Constants.TakeOffWeightName)
progressbarLimit = 2; //2 for normal jump (or take off)
diff --git a/src/gui/jump.cs b/src/gui/jump.cs
index 62193d6..e7a61aa 100644
--- a/src/gui/jump.cs
+++ b/src/gui/jump.cs
@@ -998,11 +998,12 @@ partial class ChronoJumpWindow
{
//options jumps
[Widget] Gtk.SpinButton extra_window_jumps_spinbutton_weight;
+ [Widget] Gtk.RadioButton extra_window_jumps_radio_dj_fall_predefined;
+ [Widget] Gtk.RadioButton extra_window_jumps_radio_dj_fall_calculate;
[Widget] Gtk.SpinButton extra_window_jumps_spinbutton_fall;
[Widget] Gtk.RadioButton extra_window_jumps_radiobutton_kg;
[Widget] Gtk.RadioButton extra_window_jumps_radiobutton_weight;
[Widget] Gtk.Label extra_window_jumps_label_weight;
- [Widget] Gtk.Label extra_window_jumps_label_fall;
[Widget] Gtk.Label extra_window_jumps_label_cm;
[Widget] Gtk.Label extra_window_jumps_label_dj_arms;
[Widget] Gtk.CheckButton extra_window_jumps_check_dj_arms;
@@ -1323,8 +1324,13 @@ partial class ChronoJumpWindow
extra_window_jumps_rj_label_fall.Visible = show;
extra_window_jumps_rj_spinbutton_fall.Visible = show;
extra_window_jumps_rj_label_cm.Visible = show;
+
+ //only on simple jumps
+ extra_window_jumps_radio_dj_fall_predefined.Visible = false;
+ extra_window_jumps_radio_dj_fall_calculate.Visible = false;
} else {
- extra_window_jumps_label_fall.Visible = show;
+ extra_window_jumps_radio_dj_fall_predefined.Visible = show;
+ extra_window_jumps_radio_dj_fall_calculate.Visible = show;
extra_window_jumps_spinbutton_fall.Visible = show;
extra_window_jumps_label_cm.Visible = show;
}
diff --git a/src/jump.cs b/src/jump.cs
index bea6575..f4c24e2 100644
--- a/src/jump.cs
+++ b/src/jump.cs
@@ -28,7 +28,8 @@ public class Jump : Event
{
protected double tv;
protected double tc;
- protected double fall;
+ protected double fall; //-1 if start inside to detect the fall. This is a special case where there
are two flight times, but 1st is only used to detect fall-
+ //when jump finishes, fall is calculated and 2nd flight time is stored. It
becomes a jump with one TC and one TF
protected double weight; //always write in % (not kg or %) then sqlite can do avgs
//for not checking always in database
diff --git a/src/jumpType.cs b/src/jumpType.cs
index b315128..619539e 100644
--- a/src/jumpType.cs
+++ b/src/jumpType.cs
@@ -24,7 +24,7 @@ using Mono.Unix;
public class JumpType : EventType
{
- protected bool startIn;
+ protected bool startIn; //in the special case of Dj where falling height is calculated using a
previous jump, startIn is false (but starts in)
protected bool hasWeight;
protected bool isRepetitive;
protected bool jumpsLimited;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]