[chronojump] Speed optimization: on showOnlyBars don't use EncoderCapturePoints
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Speed optimization: on showOnlyBars don't use EncoderCapturePoints
- Date: Fri, 17 Feb 2017 11:11:40 +0000 (UTC)
commit 6134ae00b8c45785cb79e9da16c2837945999f2c
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Feb 17 12:10:49 2017 +0100
Speed optimization: on showOnlyBars don't use EncoderCapturePoints
src/encoderCapture.cs | 74 ++++++++++++++++++++++++++++++++----------------
src/gui/encoder.cs | 4 ++-
2 files changed, 52 insertions(+), 26 deletions(-)
---
diff --git a/src/encoderCapture.cs b/src/encoderCapture.cs
index 8433756..b347f13 100644
--- a/src/encoderCapture.cs
+++ b/src/encoderCapture.cs
@@ -33,6 +33,7 @@ public abstract class EncoderCapture
public int Countdown;
//stored to be realtime displayed
+ //this is unused if showOnlyBars (configChronojump.EncoderCaptureShowOnlyBars)
public List<Gdk.Point> EncoderCapturePoints;
public List<Gdk.Point> EncoderCapturePointsInertialDisc;
public int EncoderCapturePointsCaptured;
@@ -85,6 +86,7 @@ public abstract class EncoderCapture
protected static SerialPort sp;
protected bool finish;
protected bool capturingInertialBG;
+ protected bool showOnlyBars;
//get the moment where we cross 0 first time on inertial calibrated
//signal will be saved from here
@@ -102,13 +104,14 @@ public abstract class EncoderCapture
//if cont (continuous mode), then will not end when too much time passed before start
- public void InitGlobal (int widthG, int heightG, int time, int timeEnd, bool cont, string eccon,
string port, bool capturingInertialBG)
+ public void InitGlobal (int widthG, int heightG, int time, int timeEnd, bool cont, string eccon,
string port, bool capturingInertialBG, bool showOnlyBars)
{
this.widthG = widthG;
this.heightG = heightG;
this.cont = cont;
this.eccon = eccon;
this.capturingInertialBG = capturingInertialBG;
+ this.showOnlyBars = showOnlyBars;
//---- a) open port -----
if(! simulated && ! capturingInertialBG) {
@@ -132,10 +135,15 @@ public abstract class EncoderCapture
encoderReaded = new List<int>();
encoderReadedInertialDisc = new List<int>();
- EncoderCapturePoints = new List<Gdk.Point>();
- EncoderCapturePointsInertialDisc = new List<Gdk.Point>();
- EncoderCapturePointsCaptured = 0;
- EncoderCapturePointsPainted = 0; //-1 means delete screen
+
+ if(! showOnlyBars)
+ {
+ EncoderCapturePoints = new List<Gdk.Point>();
+ EncoderCapturePointsInertialDisc = new List<Gdk.Point>();
+ EncoderCapturePointsCaptured = 0;
+ EncoderCapturePointsPainted = 0; //-1 means delete screen
+ }
+
sum = 0;
i = -20; //delete first records because there's encoder bug
@@ -237,10 +245,14 @@ public abstract class EncoderCapture
consecutiveZeros = -1;
encoderReadedInertialDisc = new List<int>();
encoderReaded = new List<int>();
- EncoderCapturePoints = new List<Gdk.Point>();
- EncoderCapturePointsInertialDisc = new List<Gdk.Point>();
- EncoderCapturePointsCaptured = 0;
- EncoderCapturePointsPainted = 0; //-1 means delete
screen
+
+ if(! showOnlyBars)
+ {
+ EncoderCapturePoints = new List<Gdk.Point>();
+ EncoderCapturePointsInertialDisc = new
List<Gdk.Point>();
+ EncoderCapturePointsCaptured = 0;
+ EncoderCapturePointsPainted = 0; //-1 means
delete screen
+ }
i = -1; //will be 0 on next loop start
continue;
@@ -284,15 +296,19 @@ public abstract class EncoderCapture
sum += byteReaded;
encoderReaded.Add(byteReaded);
- assignEncoderCapturePoints();
-
- EncoderCapturePointsCaptured = i;
+ if(! showOnlyBars)
+ {
+ assignEncoderCapturePoints();
+
+ EncoderCapturePointsCaptured = i;
+ }
//this only applies to inertial subclass
if(inertialShouldCheckStartDirection)
inertialCheckIfInverted();
- encoderCapturePointsAdaptativeDisplay();
+ if(! showOnlyBars)
+ encoderCapturePointsAdaptativeDisplay();
// ---- prepare to send to R ----
@@ -722,7 +738,7 @@ public class EncoderCaptureInertial : EncoderCapture
directionLastMSecond *= -1;
sum *= -1;
sumInertialDisc *= -1;
-
+
int xWidth = recordingTime;
if(cont)
xWidth = recordedTimeCont;
@@ -734,18 +750,26 @@ public class EncoderCaptureInertial : EncoderCapture
double sum2=0;
for(int j=0; j <= i; j ++) {
sum2 += encoderReaded[j];
- EncoderCapturePoints[j] = new Gdk.Point(
- Convert.ToInt32(widthG * j / xWidth),
- Convert.ToInt32( (heightG/2) - ( sum2 * heightG /
realHeightG) )
- );
- //same for InertialDisc. Read comment 2 on the top of this method
- EncoderCapturePointsInertialDisc[j] = new Gdk.Point(
- Convert.ToInt32(widthG * j / xWidth),
- Convert.ToInt32( (heightG/2) - ( sum2 * heightG /
realHeightG) )
- );
+
+ if(! showOnlyBars)
+ {
+ EncoderCapturePoints[j] = new Gdk.Point(
+ Convert.ToInt32(widthG * j / xWidth),
+ Convert.ToInt32( (heightG/2) - ( sum2 *
heightG / realHeightG) )
+ );
+ //same for InertialDisc. Read comment 2 on the top of this
method
+ EncoderCapturePointsInertialDisc[j] = new Gdk.Point(
+ Convert.ToInt32(widthG * j / xWidth),
+ Convert.ToInt32( (heightG/2) - ( sum2 *
heightG / realHeightG) )
+ );
+ }
+ }
+
+ if(! showOnlyBars)
+ {
+ EncoderCapturePointsCaptured = i;
+ EncoderCapturePointsPainted = -1; //mark meaning screen should be
erased
}
- EncoderCapturePointsCaptured = i;
- EncoderCapturePointsPainted = -1; //mark meaning screen should be erased
}
}
}
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 0306ca9..49763ed 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -4691,7 +4691,8 @@ public partial class ChronoJumpWindow
radio_encoder_capture_cont.Active,
findEccon(true),
chronopicRegister.ConnectedOfType(ChronopicRegisterPort.Types.ENCODER).Port,
- (encoderConfigurationCurrent.has_inertia &&
eCaptureInertialBG != null)
+ (encoderConfigurationCurrent.has_inertia &&
eCaptureInertialBG != null),
+ configChronojump.EncoderCaptureShowOnlyBars
);
if(encoderConfigurationCurrent.has_inertia && eCaptureInertialBG != null)
@@ -4714,6 +4715,7 @@ public partial class ChronoJumpWindow
false,
findEccon(true),
chronopicRegister.ConnectedOfType(ChronopicRegisterPort.Types.ENCODER).Port,
+ false,
false
);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]