[chronojump] ForceSensor AIgraph with position (needs debugging)
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] ForceSensor AIgraph with position (needs debugging)
- Date: Mon, 24 Feb 2020 17:44:33 +0000 (UTC)
commit 9ada09bdcdb109b0352ecd18d11e4392a0255d16
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Feb 24 18:41:56 2020 +0100
ForceSensor AIgraph with position (needs debugging)
src/forceSensor.cs | 108 +++++++++++++++++++++++++++++--------
src/gui/app1/forceSensor.cs | 42 ++++++++-------
src/gui/app1/forceSensorAnalyze.cs | 16 ++++++
3 files changed, 126 insertions(+), 40 deletions(-)
---
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index 8cc08006..1f6f198d 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -694,32 +694,33 @@ public class ForceSensorElasticBand
}
//struct with relevant data used on various functions and threads
+//for force, but can be also for position on elastic
public class ForceSensorValues
{
public int TimeLast; //store last time
- public int TimeForceMax; //store time of max force
- public double ForceLast; //store last force
- public double ForceMax; //store max force
- public double ForceMin; //store min force
+ public int TimeValueMax; //store time of max force (only used on force)
+ public double ValueLast; //store last force (or displ)
+ public double Max; //store max force (or displ)
+ public double Min; //store min force (or displ)
public ForceSensorValues()
{
TimeLast = 0;
- TimeForceMax = 0;
- ForceLast = 0;
- ForceMax = 0;
- ForceMin = 10000;
+ TimeValueMax = 0;
+ ValueLast = 0;
+ Max = 0;
+ Min = 10000;
}
- public void SetMaxMinIfNeeded(double force, int time)
+ public void SetMaxMinIfNeeded(double newValue, int time)
{
- if(force > ForceMax)
+ if(newValue > Max)
{
- ForceMax = force;
- TimeForceMax = time;
+ Max = newValue;
+ TimeValueMax = time;
}
- if(force < ForceMin)
- ForceMin = force;
+ if(newValue < Min)
+ Min = newValue;
}
}
/*
@@ -727,6 +728,7 @@ public class ForceSensorValues
* currently all the code relevant to force sensor actions is on gui/forcesensor.cs
* that code should be here and there only the gui stuff
*/
+//to manage force, but can also manage displ on elastic
public class ForceSensorCapturePoints
{
//ForceCapturePoints stored to be realtime displayed
@@ -734,6 +736,9 @@ public class ForceSensorCapturePoints
public int NumCaptured;
public int NumPainted;
+ public enum GraphTypes { FORCESIGNAL, FORCEAIFORCE, FORCEAIDISPL }
+ private GraphTypes graphType; //useful to debug
+
//used to redo all points if change RealWidthG or RealHeightG
private List<int> times;
private List<double> forces;
@@ -756,7 +761,7 @@ public class ForceSensorCapturePoints
private int marginBottom = 30; //px
//initialize
- public ForceSensorCapturePoints(int widthG, int heightG, int widthInSeconds)
+ public ForceSensorCapturePoints(GraphTypes graphType, int widthG, int heightG, int widthInSeconds)
{
Points = new List<Gdk.Point>();
NumCaptured = 0;
@@ -769,6 +774,7 @@ public class ForceSensorCapturePoints
InitRealWidthHeight(widthInSeconds);
+ this.graphType = graphType;
this.widthG = widthG;
this.heightG = heightG;
}
@@ -1024,6 +1030,7 @@ public class ForceSensorCapturePoints
public void Zoom(int lastTime) //on zoom adjust width
{
+ LogB.Information("At Zoom with graphType: " + graphType.ToString());
//X
RealWidthG = lastTime + GetTimeInPx(marginLeft) + GetTimeInPx(marginRight);
@@ -1420,42 +1427,78 @@ public class ForceSensorAnalyzeInstant
private ForceSensorCapturePoints fscAIPoints; //Analyze Instant
private ForceSensorValues forceSensorValues;
+
+ private ForceSensorCapturePoints fscAIPointsDispl; //Analyze Instant only on elastic
+ private ForceSensorValues forceSensorValuesDispl; //this class can be used for force, displ, or
whatever
+
private int graphWidth;
private int graphHeight;
+ private ForceSensorExercise fse;
- public ForceSensorAnalyzeInstant(string file, int graphWidth, int graphHeight, double start, double
end,
+ public ForceSensorAnalyzeInstant(
+ string file, int graphWidth, int graphHeight, double start, double end,
ForceSensorExercise fse, double personWeight, ForceSensor.CaptureOptions fsco, double
stiffness,
double eccMinDisplacement, double conMinDisplacement)
{
this.graphWidth = graphWidth;
this.graphHeight = graphHeight;
+ this.fse = fse;
- readFile(file, start, end, fse, personWeight, fsco, stiffness, eccMinDisplacement,
conMinDisplacement);
+ readFile(file, start, end, personWeight, fsco, stiffness, eccMinDisplacement,
conMinDisplacement);
//on zoom adjust width
if(start >= 0 || end >= 0)
{
fscAIPoints.Zoom(forceSensorValues.TimeLast);
+ LogB.Information("Redo normal at constructor");
fscAIPoints.Redo();
+
+ if(fse.ComputeAsElastic) {
+ fscAIPointsDispl.Zoom(forceSensorValuesDispl.TimeLast);
+ LogB.Information("Redo elastic at constructor");
+ fscAIPointsDispl.Redo();
+ }
}
//ensure points fit on display
- if(fscAIPoints.OutsideGraph(forceSensorValues.TimeLast, forceSensorValues.ForceMax,
forceSensorValues.ForceMin))
+ if(fscAIPoints.OutsideGraph(forceSensorValues.TimeLast, forceSensorValues.Max,
forceSensorValues.Min))
+ {
+ LogB.Information("Redo normal at constructor b");
fscAIPoints.Redo();
+ }
+
+ if(fse.ComputeAsElastic)
+ {
+ bool forcePointsWidthChanged = false;
+ if(fscAIPointsDispl.RealWidthG != fscAIPoints.RealWidthG) {
+ fscAIPointsDispl.RealWidthG = fscAIPoints.RealWidthG;
+ forcePointsWidthChanged = true;
+ }
+
+ if(forcePointsWidthChanged ||
fscAIPointsDispl.OutsideGraph(forceSensorValuesDispl.TimeLast, forceSensorValuesDispl.Max,
forceSensorValuesDispl.Min))
+ {
+ fscAIPointsDispl.Redo();
+ LogB.Information("Redo elastic at constructor b");
+ }
+ }
}
- private void readFile(string file, double start, double end, ForceSensorExercise fse,
+ private void readFile(string file, double start, double end,
double personWeight, ForceSensor.CaptureOptions fsco, double stiffness,
double eccMinDisplacement, double conMinDisplacement)
{
LogB.Information(string.Format("at readFile, start: {0}, end: {1}", start, end));
- fscAIPoints = new ForceSensorCapturePoints(graphWidth, graphHeight, -1);
+ fscAIPoints = new ForceSensorCapturePoints(ForceSensorCapturePoints.GraphTypes.FORCEAIFORCE,
graphWidth, graphHeight, -1);
+ if(fse.ComputeAsElastic)
+ fscAIPointsDispl = new
ForceSensorCapturePoints(ForceSensorCapturePoints.GraphTypes.FORCEAIDISPL, graphWidth, graphHeight, -1);
List<string> contents = Util.ReadFileAsStringList(file);
bool headersRow = true;
//initialize
forceSensorValues = new ForceSensorValues();
+ if(fse.ComputeAsElastic)
+ forceSensorValuesDispl = new ForceSensorValues();
if(contents == null)
return;
@@ -1535,9 +1578,19 @@ public class ForceSensorAnalyzeInstant
fscAIPoints.NumCaptured ++;
forceSensorValues.TimeLast = time;
- forceSensorValues.ForceLast = forces[i];
+ forceSensorValues.ValueLast = forces[i];
forceSensorValues.SetMaxMinIfNeeded(forces[i], time);
+ if(fse.ComputeAsElastic)
+ {
+ fscAIPointsDispl.Add(time, Position_l[i]);
+ fscAIPointsDispl.NumCaptured ++;
+
+ forceSensorValuesDispl.TimeLast = time;
+ forceSensorValuesDispl.ValueLast = Position_l[i];
+ forceSensorValuesDispl.SetMaxMinIfNeeded(Position_l[i], time);
+ }
+
i ++;
}
}
@@ -1550,7 +1603,15 @@ public class ForceSensorAnalyzeInstant
fscAIPoints.WidthG = graphWidth;
fscAIPoints.HeightG = graphHeight;
+ LogB.Information("RedoGraph normal at RedoGraph");
fscAIPoints.Redo();
+
+ if(fse.ComputeAsElastic) {
+ fscAIPointsDispl.WidthG = graphWidth;
+ fscAIPointsDispl.HeightG = graphHeight;
+ LogB.Information("RedoGraph displ elastic at RedoGraph");
+ fscAIPointsDispl.Redo();
+ }
}
//gets an instant value
@@ -1896,7 +1957,10 @@ public class ForceSensorAnalyzeInstant
{
get { return fscAIPoints; }
}
-
+ public ForceSensorCapturePoints FscAIPointsDispl
+ {
+ get { return fscAIPointsDispl; }
+ }
}
//we need this class because we started using forcesensor without database (only text files)
diff --git a/src/gui/app1/forceSensor.cs b/src/gui/app1/forceSensor.cs
index 011638da..8e3e459a 100644
--- a/src/gui/app1/forceSensor.cs
+++ b/src/gui/app1/forceSensor.cs
@@ -746,6 +746,7 @@ public partial class ChronoJumpWindow
UtilGtk.ErasePaint(force_capture_drawingarea, force_capture_pixmap);
fscPoints = new ForceSensorCapturePoints(
+ ForceSensorCapturePoints.GraphTypes.FORCESIGNAL,
force_capture_drawingarea.Allocation.Width,
force_capture_drawingarea.Allocation.Height,
preferences.forceSensorCaptureWidthSeconds
@@ -953,7 +954,7 @@ public partial class ChronoJumpWindow
writer.WriteLine(time.ToString() + ";" + force.ToString()); //on file force is stored
without flags
forceSensorValues.TimeLast = time;
- forceSensorValues.ForceLast = forceCalculated;
+ forceSensorValues.ValueLast = forceCalculated;
forceSensorValues.SetMaxMinIfNeeded(forceCalculated, time);
@@ -1097,7 +1098,7 @@ LogB.Information(" fs C ");
if( configChronojump.Exhibition &&
( configChronojump.ExhibitionStationType ==
ExhibitionTest.testTypes.FORCE_ROPE ||
configChronojump.ExhibitionStationType ==
ExhibitionTest.testTypes.FORCE_SHOT ) )
-
SqliteJson.UploadExhibitionTest(getExhibitionTestFromGui(configChronojump.ExhibitionStationType,
forceSensorValues.ForceMax));
+
SqliteJson.UploadExhibitionTest(getExhibitionTestFromGui(configChronojump.ExhibitionStationType,
forceSensorValues.Max));
}
} else if(forceProcessCancel || forceProcessError)
@@ -1162,9 +1163,9 @@ LogB.Information(" fs F ");
if(capturingForce == arduinoCaptureStatus.CAPTURING)
{
LogB.Information(" fs G ");
- label_force_sensor_value_max.Text = string.Format("{0:0.##} N",
forceSensorValues.ForceMax);
- label_force_sensor_value_min.Text = string.Format("{0:0.##} N",
forceSensorValues.ForceMin);
- label_force_sensor_value.Text = string.Format("{0:0.##} N",
forceSensorValues.ForceLast);
+ label_force_sensor_value_max.Text = string.Format("{0:0.##} N",
forceSensorValues.Max);
+ label_force_sensor_value_min.Text = string.Format("{0:0.##} N",
forceSensorValues.Min);
+ label_force_sensor_value.Text = string.Format("{0:0.##} N",
forceSensorValues.ValueLast);
LogB.Information(" fs H ");
@@ -1198,7 +1199,7 @@ LogB.Information(" fs I ");
UtilGtk.ErasePaint(force_capture_drawingarea, force_capture_pixmap);
fscPoints.NumPainted = 0;
- forcePaintHVLines(ForceSensorGraphs.CAPTURE, fscPoints.RealHeightG,
forceSensorValues.ForceMin * 2, fscPoints.RealWidthG, false);
+ forcePaintHVLines(ForceSensorGraphs.CAPTURE, fscPoints.RealHeightG,
forceSensorValues.Min * 2, fscPoints.RealWidthG, false);
//draw horizontal rectangle of feedback
if(preferences.forceSensorCaptureFeedbackActive)
forceSensorSignalPlotFeedbackRectangle(fscPoints,
@@ -1305,8 +1306,8 @@ LogB.Information(" fs R ");
force_capture_drawingarea, force_capture_pixmap,
pen_blue_light_force_capture);
forcePaintHVLines(ForceSensorGraphs.CAPTURE,
- getForceSensorMaxForceIncludingRectangle(forceSensorValues.ForceMax),
- forceSensorValues.ForceMin,
+ getForceSensorMaxForceIncludingRectangle(forceSensorValues.Max),
+ forceSensorValues.Min,
Convert.ToInt32(forceSensorValues.TimeLast),
true);
@@ -1832,6 +1833,7 @@ LogB.Information(" fs R ");
void forceSensorDoSignalGraphReadFile(ForceSensor.CaptureOptions fsco)
{
fscPoints = new ForceSensorCapturePoints(
+ ForceSensorCapturePoints.GraphTypes.FORCESIGNAL,
force_capture_drawingarea.Allocation.Width,
force_capture_drawingarea.Allocation.Height,
preferences.forceSensorCaptureWidthSeconds
@@ -1889,7 +1891,7 @@ LogB.Information(" fs R ");
fscPoints.NumCaptured ++;
forceSensorValues.TimeLast = time;
- forceSensorValues.ForceLast = forces[i];
+ forceSensorValues.ValueLast = forces[i];
forceSensorValues.SetMaxMinIfNeeded(forces[i], time);
i ++;
@@ -1910,13 +1912,13 @@ LogB.Information(" fs R ");
setForceSensorTopAtOperationStart();
if(fscPoints.OutsideGraph(forceSensorValues.TimeLast,
- getForceSensorMaxForceIncludingRectangle(forceSensorValues.ForceMax),
- forceSensorValues.ForceMin))
+ getForceSensorMaxForceIncludingRectangle(forceSensorValues.Max),
+ forceSensorValues.Min))
fscPoints.Redo();
forcePaintHVLines(ForceSensorGraphs.CAPTURE,
- getForceSensorMaxForceIncludingRectangle(forceSensorValues.ForceMax),
- forceSensorValues.ForceMin, forceSensorValues.TimeLast,
+ getForceSensorMaxForceIncludingRectangle(forceSensorValues.Max),
+ forceSensorValues.Min, forceSensorValues.TimeLast,
false);
//draw horizontal rectangle of feedback
@@ -1937,15 +1939,15 @@ LogB.Information(" fs R ");
//draw circle in maxForce
force_capture_pixmap.DrawArc(pen_red_force_capture, false,
- fscPoints.GetTimeInPx(forceSensorValues.TimeForceMax) -6,
- fscPoints.GetForceInPx(forceSensorValues.ForceMax) -6,
+ fscPoints.GetTimeInPx(forceSensorValues.TimeValueMax) -6,
+ fscPoints.GetForceInPx(forceSensorValues.Max) -6,
12, 12, 90 * 64, 360 * 64);
force_capture_drawingarea.QueueDraw(); // -- refresh
- label_force_sensor_value.Text = string.Format("{0:0.##} N", forceSensorValues.ForceLast);
- label_force_sensor_value_max.Text = string.Format("{0:0.##} N", forceSensorValues.ForceMax);
- label_force_sensor_value_min.Text = string.Format("{0:0.##} N", forceSensorValues.ForceMin);
+ label_force_sensor_value.Text = string.Format("{0:0.##} N", forceSensorValues.ValueLast);
+ label_force_sensor_value_max.Text = string.Format("{0:0.##} N", forceSensorValues.Max);
+ label_force_sensor_value_min.Text = string.Format("{0:0.##} N", forceSensorValues.Min);
button_force_sensor_image_save_signal.Sensitive = true;
button_force_sensor_analyze_analyze.Sensitive = true;
}
@@ -2430,7 +2432,11 @@ LogB.Information(" fs R ");
if(forceSensorExerciseWin.Success)
fillForceSensorExerciseCombo(forceSensorExerciseWin.Exercise.Name);
+ currentForceSensorExercise = forceSensorExerciseWin.Exercise;
+
forceSensorExerciseWin.HideAndNull();
+
+ forceSensorDoGraphAI();
}
//based on: on_button_encoder_exercise_delete
diff --git a/src/gui/app1/forceSensorAnalyze.cs b/src/gui/app1/forceSensorAnalyze.cs
index b62addb9..86e74ac3 100644
--- a/src/gui/app1/forceSensorAnalyze.cs
+++ b/src/gui/app1/forceSensorAnalyze.cs
@@ -1041,6 +1041,22 @@ public partial class ChronoJumpWindow
else
force_sensor_ai_pixmap.DrawLines(pen_black_force_ai, paintPoints);
+ // 3b) create and paint points displ on elastic
+ if(fsAI.CalculedElasticPSAP)
+ {
+ Gdk.Point [] paintPointsDispl = new Gdk.Point[fsAI.FscAIPointsDispl.Points.Count];
+ for(int i = 0; i < fsAI.FscAIPointsDispl.Points.Count; i ++)
+ paintPointsDispl[i] = fsAI.FscAIPointsDispl.Points[i];
+
+ if(debug)
+ force_sensor_ai_pixmap.DrawPoints(pen_green_force_ai, paintPointsDispl);
+ else
+ force_sensor_ai_pixmap.DrawLines(pen_green_force_ai, paintPointsDispl);
+
+ LogB.Information(string.Format("fsAI.FscAIPoints.Points.Count: {0},
fsAI.FscAIPointsDispl.Points.Count: {1}",
+ fsAI.FscAIPoints.Points.Count,
fsAI.FscAIPointsDispl.Points.Count));
+ }
+
// 4) create hscaleLower and higher values (A, B at the moment)
int hscaleLower = Convert.ToInt32(hscale_force_sensor_ai_a.Value);
int hscaleHigher = Convert.ToInt32(hscale_force_sensor_ai_b.Value);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]