[chronojump/michrolab] CairoGraphRaceAnalyzer will start on 1st trigger or a >= minAccel (whatever is first) if trigger is
- From: Xavier Padullés <xpadulles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump/michrolab] CairoGraphRaceAnalyzer will start on 1st trigger or a >= minAccel (whatever is first) if trigger is
- Date: Thu, 14 Jul 2022 16:37:49 +0000 (UTC)
commit 66164e5b2bc8861352ed0472e50caaa9acbe1efa
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed May 25 10:57:40 2022 +0200
CairoGraphRaceAnalyzer will start on 1st trigger or a >= minAccel (whatever is first)
if trigger is first, then will display a>minAccel and shift accordingly
src/gui/app1/runEncoder.cs | 108 ++++++++++++++++++++++++++++++++----------
src/gui/cairo/raceAnalyzer.cs | 26 ++++++++--
src/runEncoder.cs | 31 ++++++------
src/trigger.cs | 5 ++
4 files changed, 127 insertions(+), 43 deletions(-)
---
diff --git a/src/gui/app1/runEncoder.cs b/src/gui/app1/runEncoder.cs
index ce907bb71..a3c2bcbb5 100644
--- a/src/gui/app1/runEncoder.cs
+++ b/src/gui/app1/runEncoder.cs
@@ -1102,6 +1102,7 @@ public partial class ChronoJumpWindow
double timePre = -1;
double accel = -1;
bool enoughAccel = false; //accel has been > preferences.runEncoderMinAccel (default 10ms^2)
+ bool signalShifted = false; //shifted on trigger0 or accel >= minAccel, whatever is first
string rowPre = "";
//store data on cairoGraphRaceAnalyzerPoints_dt_l, ...st_l, ...at_l
@@ -1127,28 +1128,72 @@ public partial class ChronoJumpWindow
accel = UtilAll.DivideSafe(reCGSD.RunEncoderCaptureSpeed - speedPre2,
UtilAll.DivideSafe(reCGSD.Time, 1000000) -
timePre2);
- if (accel >= preferences.runEncoderMinAccel && ! enoughAccel)
+ int timeNow = 0;
+ string [] cells = row.Split(new char[] {';'});
+ timeNow = Convert.ToInt32(cells[1]);
+
+ if (! signalShifted)
{
- //recreate rcCGSD object since now
- reCGSD = new RunEncoderCaptureGetSpeedAndDisplacement(
- currentRunEncoderExercise.SegmentCm,
currentRunEncoderExercise.SegmentVariableCm,
- currentPersonSession.Weight, //but note if person
changes (but graph will be hopefully erased), this will change also take care on exports
- currentRunEncoder.Angle);
-
- //to shift times to the left
- reCGSD.SetTimeAtEnoughAccel (row);
-
- //pass previous row and this one
- if(reCGSD.PassLoadedRow (rowPre))
- reCGSD.Calcule();
- if(reCGSD.PassLoadedRow (row))
- reCGSD.Calcule();
-
- enoughAccel = true;
+ /*
+ pass when the first trigger is done,
+ because first time will be on first trigger or when accel >=
minAccel
+ whatever is first.
+ We need timeAtTrigger0 and timeAtEnoughAccel,
+ because if timeAtTrigger0 is first, display also timeAtEnougAccel
+ */
+ bool shiftNow = false;
+ int shiftTo = 0;
+
+ if (triggerListRunEncoder != null && triggerListRunEncoder.Count() >
0 &&
+ triggerListRunEncoder.GetList()[0].Us < timeNow)
+ {
+ //reCGSD.SetTimeAtTrigger0
(triggerListRunEncoder.GetList()[0].Us);
+ shiftTo = triggerListRunEncoder.GetList()[0].Us;
+ shiftNow = true;
+ }
+
+ if (accel >= preferences.runEncoderMinAccel && ! enoughAccel)
+ {
+ if (cells.Length == 3 && Util.IsNumber(cells[0], false) &&
Util.IsNumber(cells[1], false))
+ {
+ shiftTo = timeNow;
+ shiftNow = true;
+ enoughAccel = true;
+ }
+ }
+
+ if (shiftNow)
+ {
+ //recreate rcCGSD object since now
+ reCGSD = new RunEncoderCaptureGetSpeedAndDisplacement(
+ currentRunEncoderExercise.SegmentCm,
currentRunEncoderExercise.SegmentVariableCm,
+ currentPersonSession.Weight, //but note if
person changes (but graph will be hopefully erased), this will change also take care on exports
+ currentRunEncoder.Angle);
+
+ reCGSD.SetTimeAtEnoughAccelOrTrigger0 (shiftTo);
+
+ //pass previous row and this one
+ if(reCGSD.PassLoadedRow (rowPre))
+ reCGSD.Calcule();
+ if(reCGSD.PassLoadedRow (row))
+ reCGSD.Calcule();
+
+ signalShifted = true;
+ }
+ } else {
+ /*
+ if first was trigger then accel >= minAccel,
+ we need to use the reCGSD.SetTimeAtEnoughAccelMark () to show a
line
+ */
+ if (accel >= preferences.runEncoderMinAccel && ! enoughAccel)
+ {
+ reCGSD.SetTimeAtEnoughAccelMark (timeNow);
+ enoughAccel = true;
+ }
}
}
- if(enoughAccel)
+ if(signalShifted)
{
cairoGraphRaceAnalyzerPoints_dt_l.Add(new PointF(
UtilAll.DivideSafe(reCGSD.Time, 1000000),
@@ -2320,9 +2365,13 @@ public partial class ChronoJumpWindow
reCGSD != null && reCGSD.SegmentCalcs != null)
segmentCalcs = reCGSD.SegmentCalcs;
+ int timeAtEnoughAccel = 0;
int timeAtEnoughAccelMark = 0;
if (reCGSD != null)
- timeAtEnoughAccelMark = reCGSD.TimeAtEnoughAccelMark;
+ {
+ timeAtEnoughAccel = reCGSD.TimeAtEnoughAccelOrTrigger0; //to shift time at load, sent
here to sync/delete triggers
+ timeAtEnoughAccelMark = reCGSD.TimeAtEnoughAccelMark; //to show mark at capture
+ }
if(cairoGraphRaceAnalyzer_dt == null || forceRedraw)
cairoGraphRaceAnalyzer_dt = new CairoGraphRaceAnalyzer(
@@ -2334,9 +2383,10 @@ public partial class ChronoJumpWindow
true);
cairoGraphRaceAnalyzer_dt.DoSendingList (preferences.fontType.ToString(),
- cairoGraphRaceAnalyzerPoints_dt_l, triggerListRunEncoder,
+ cairoGraphRaceAnalyzerPoints_dt_l,
forceRedraw, CairoXY.PlotTypes.LINES, true,
getSmoothFrom_gui_at_race_analyzer_capture_smooth_graphs (),
+ triggerListRunEncoder, timeAtEnoughAccel,
timeAtEnoughAccelMark, preferences.runEncoderMinAccel);
}
private void updateRaceAnalyzerCaptureSpeedTime(bool forceRedraw)
@@ -2350,9 +2400,13 @@ public partial class ChronoJumpWindow
reCGSD != null && reCGSD.SegmentCalcs != null)
segmentCalcs = reCGSD.SegmentCalcs;
+ int timeAtEnoughAccel = 0;
int timeAtEnoughAccelMark = 0;
if (reCGSD != null)
- timeAtEnoughAccelMark = reCGSD.TimeAtEnoughAccelMark;
+ {
+ timeAtEnoughAccel = reCGSD.TimeAtEnoughAccelOrTrigger0; //to shift time at load, sent
here to sync/delete triggers
+ timeAtEnoughAccelMark = reCGSD.TimeAtEnoughAccelMark; //to show mark at capture
+ }
if(cairoGraphRaceAnalyzer_st == null || forceRedraw)
cairoGraphRaceAnalyzer_st = new CairoGraphRaceAnalyzer(
@@ -2364,9 +2418,10 @@ public partial class ChronoJumpWindow
false);
cairoGraphRaceAnalyzer_st.DoSendingList (preferences.fontType.ToString(),
- cairoGraphRaceAnalyzerPoints_st_l, triggerListRunEncoder,
+ cairoGraphRaceAnalyzerPoints_st_l,
forceRedraw, CairoXY.PlotTypes.LINES, true,
getSmoothFrom_gui_at_race_analyzer_capture_smooth_graphs (),
+ triggerListRunEncoder, timeAtEnoughAccel,
timeAtEnoughAccelMark, preferences.runEncoderMinAccel);
}
private void updateRaceAnalyzerCaptureAccelTime(bool forceRedraw)
@@ -2383,9 +2438,13 @@ public partial class ChronoJumpWindow
reCGSD != null && reCGSD.SegmentCalcs != null)
segmentCalcs = reCGSD.SegmentCalcs;
+ int timeAtEnoughAccel = 0;
int timeAtEnoughAccelMark = 0;
if (reCGSD != null)
- timeAtEnoughAccelMark = reCGSD.TimeAtEnoughAccelMark;
+ {
+ timeAtEnoughAccel = reCGSD.TimeAtEnoughAccelOrTrigger0; //to shift time at load, sent
here to sync/delete triggers
+ timeAtEnoughAccelMark = reCGSD.TimeAtEnoughAccelMark; //to show mark at capture
+ }
if(cairoGraphRaceAnalyzer_at == null || forceRedraw)
cairoGraphRaceAnalyzer_at = new CairoGraphRaceAnalyzer(
@@ -2397,9 +2456,10 @@ public partial class ChronoJumpWindow
false);
cairoGraphRaceAnalyzer_at.DoSendingList (preferences.fontType.ToString(),
- cairoGraphRaceAnalyzerPoints_at_l, triggerListRunEncoder,
+ cairoGraphRaceAnalyzerPoints_at_l,
forceRedraw, CairoXY.PlotTypes.LINES, false,
getSmoothFrom_gui_at_race_analyzer_capture_smooth_graphs (),
+ triggerListRunEncoder, timeAtEnoughAccel,
timeAtEnoughAccelMark, preferences.runEncoderMinAccel);
}
diff --git a/src/gui/cairo/raceAnalyzer.cs b/src/gui/cairo/raceAnalyzer.cs
index c6f09c514..2c5610209 100644
--- a/src/gui/cairo/raceAnalyzer.cs
+++ b/src/gui/cairo/raceAnalyzer.cs
@@ -82,17 +82,20 @@ public class CairoGraphRaceAnalyzer : CairoXY
}
//separated in two methods to ensure endGraphDisposing on any return of the other method
- public void DoSendingList (string font, List<PointF> points_list, TriggerList triggerList, bool
forceRedraw,
+ public void DoSendingList (string font, List<PointF> points_list, bool forceRedraw,
PlotTypes plotType, bool blackLine, int smoothLineWindow,
+ TriggerList triggerList, int timeAtEnoughAccelOrTrigger0,
int timeAtEnoughAccelMark, double minAccel)
{
- if(doSendingList (font, points_list, triggerList, forceRedraw, plotType, blackLine,
smoothLineWindow, timeAtEnoughAccelMark, minAccel))
+ if(doSendingList (font, points_list, forceRedraw, plotType, blackLine, smoothLineWindow,
+ triggerList, timeAtEnoughAccelOrTrigger0, timeAtEnoughAccelMark,
minAccel))
endGraphDisposing(g, surface, area.GdkWindow);
}
//return true if graph is inited (to dispose it)
- private bool doSendingList (string font, List<PointF> points_list, TriggerList triggerList, bool
forceRedraw,
+ private bool doSendingList (string font, List<PointF> points_list, bool forceRedraw,
PlotTypes plotType, bool blackLine, int smoothLineWindow,
+ TriggerList triggerList, int timeAtEnoughAccelOrTrigger0,
int timeAtEnoughAccelMark, double minAccel) //timeAtEnoughAccelMark: only for capture
(just to display mark), minAccel is the value at preferences
{
// 1) init graph
@@ -321,6 +324,10 @@ public class CairoGraphRaceAnalyzer : CairoXY
if (timeAtEnoughAccelMark > 0)
{
+ //on load we have to shift if trigger0 has been first
+ if (timeAtEnoughAccelOrTrigger0 > 0)
+ timeAtEnoughAccelMark -= timeAtEnoughAccelOrTrigger0;
+
double xTimeAtEnoughAccelMark = calculatePaintX
(timeAtEnoughAccelMark/1000000.0);
g.LineWidth = 1;
@@ -349,7 +356,18 @@ public class CairoGraphRaceAnalyzer : CairoXY
g.LineWidth = 1;
foreach(Trigger trigger in triggerList.GetList())
{
- paintVerticalTriggerLine(g, trigger, textHeight -3);
+ //create a new trigger to not modify the original list that will be used for
pos/time, speed/time, accel/time
+ Trigger triggerModified = new Trigger (trigger.Mode, trigger.Us,
trigger.InOut);
+
+ LogB.Information("trigger.Us: " + trigger.Us.ToString());
+ LogB.Information("timeAtEnoughAccelOrTrigger0: " +
timeAtEnoughAccelOrTrigger0.ToString());
+
+ if (timeAtEnoughAccelOrTrigger0 > 0)
+ triggerModified.Us -= timeAtEnoughAccelOrTrigger0;
+
+ LogB.Information("triggerModified.Us fixed: " +
triggerModified.Us.ToString());
+
+ paintVerticalTriggerLine(g, triggerModified, textHeight -3);
}
}
diff --git a/src/runEncoder.cs b/src/runEncoder.cs
index db55a0352..4a4ca46c2 100644
--- a/src/runEncoder.cs
+++ b/src/runEncoder.cs
@@ -290,7 +290,7 @@ public class RunEncoderCaptureGetSpeedAndDisplacement
private int encoderOrRCA;
private int timePre;
- private int timeAtEnoughAccel; //load (discard previous and shift time)
+ private int timeAtEnoughAccelOrTrigger0; //load (discard previous and shift time)
private int timeAtEnoughAccelMark; //capture (just draw a vertical line, to not erase previous points
while capture)
private double runEncoderCaptureSpeed;
@@ -305,7 +305,7 @@ public class RunEncoderCaptureGetSpeedAndDisplacement
segmentCalcs = new RunEncoderSegmentCalcs (massKg, angle);
timePre = 0;
- timeAtEnoughAccel = 0;
+ timeAtEnoughAccelOrTrigger0 = 0;
timeAtEnoughAccelMark = 0;
}
@@ -330,29 +330,27 @@ public class RunEncoderCaptureGetSpeedAndDisplacement
this.time = Convert.ToInt32(cells[1]);
//after enoughAccel, time has to be shifted to left
- if(timeAtEnoughAccel > 0)
- time -= timeAtEnoughAccel;
+ if(timeAtEnoughAccelOrTrigger0 > 0)
+ time -= timeAtEnoughAccelOrTrigger0;
return true;
}
- //to show a vertical line at capture capture (meaning: passed the min accel)
+ //to show a vertical line at capture (meaning: passed the min accel)
public void SetTimeAtEnoughAccelMark (List<int> binaryReaded)
{
timeAtEnoughAccelMark = binaryReaded[1];
}
-
- //to sync time at load
- public void SetTimeAtEnoughAccel (string row)
+ //to show a vertical line at load (if a trigger marks previously the beginning of the set) (meaning:
passed the min accel)
+ public void SetTimeAtEnoughAccelMark (int t)
{
- string [] cells = row.Split(new char[] {';'});
- if(cells.Length != 3)
- return;
-
- if(! Util.IsNumber(cells[0], false) || ! Util.IsNumber(cells[1], false))
- return;
+ timeAtEnoughAccelMark = t;
+ }
- timeAtEnoughAccel = Convert.ToInt32(cells[1]);
+ //to sync time at load, also used to sync triggers at load
+ public void SetTimeAtEnoughAccelOrTrigger0 (int time)
+ {
+ timeAtEnoughAccelOrTrigger0 = time;
}
public bool Calcule ()
@@ -427,6 +425,9 @@ public class RunEncoderCaptureGetSpeedAndDisplacement
get { return segmentCalcs; }
}
+ public int TimeAtEnoughAccelOrTrigger0 {
+ get { return timeAtEnoughAccelOrTrigger0; }
+ }
public int TimeAtEnoughAccelMark {
get { return timeAtEnoughAccelMark; }
}
diff --git a/src/trigger.cs b/src/trigger.cs
index cf100c761..d0fc0a5a3 100644
--- a/src/trigger.cs
+++ b/src/trigger.cs
@@ -95,6 +95,7 @@ public class Trigger
public int Us {
get { return us; }
+ set { us = value; }
}
public double Ms {
get {
@@ -113,6 +114,10 @@ public class Trigger
get { return inOut; }
}
+ public Modes Mode {
+ get { return mode; }
+ }
+
public int ModeID {
set { modeID = value; }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]