[chronojump] More code reorganization
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] More code reorganization
- Date: Fri, 24 Jan 2014 15:56:11 +0000 (UTC)
commit d74533236dc42146f65cff17633b2b42b8e09ad5
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Jan 24 16:55:51 2014 +0100
More code reorganization
src/constants.cs | 2 +-
src/encoder.cs | 117 +++++++++++++++----------
src/gui/encoder.cs | 181 +++++++++------------------------------
src/gui/encoderConfiguration.cs | 59 ++++++-------
src/sqlite/encoder.cs | 6 +-
src/sqlite/main.cs | 6 +-
src/utilEncoder.cs | 78 +++++++++--------
7 files changed, 184 insertions(+), 265 deletions(-)
---
diff --git a/src/constants.cs b/src/constants.cs
index a8e1695..2d9bee6 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -639,7 +639,7 @@ public class Constants
public static string FileNameEncoderAxisInertial = "encoder-axis-inertial.png";
public static string FileNameEncoderAxisWithMovPulley =
"encoder-rotary-axis-on-fixed-pulley-with-weighted-moving-pulley.png";
- public enum EncoderMode { //this names are used on graph.R change there also if needed
+ public enum EncoderConfigurationNames { //this names are used on graph.R change there also if needed
LINEAR, LINEARINVERTED, LINEARINERTIAL,
WEIGHTEDMOVPULLEYLINEARONPERSON1, WEIGHTEDMOVPULLEYLINEARONPERSON1INV,
WEIGHTEDMOVPULLEYLINEARONPERSON2, WEIGHTEDMOVPULLEYLINEARONPERSON2INV,
diff --git a/src/encoder.cs b/src/encoder.cs
index 41b9892..b860793 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -36,9 +36,9 @@ public class EncoderParams
private string analysisVariables;
private string analysisOptions; //p: propulsive
- //encoderMode conversions
+ //encoderConfiguration conversions
//in signals and curves, need to do conversions (invert, inertiaMomentum, diameter)
- private string encoderMode;
+ private string encoderConfigurationName;
private int inertiaMomentum;
private double diameter;
@@ -58,7 +58,7 @@ public class EncoderParams
private int peakPowerLowerCondition;
private string mainVariable;
private string decimalSeparator; //used in export data from R to csv
- private bool inverted; //used only in runEncoderCapturePython. In graph.R will be used encoderMode
+ private bool inverted; //used only in runEncoderCapturePython. In graph.R will be used
encoderConfigurationName
public EncoderParams()
{
@@ -119,7 +119,7 @@ public class EncoderParams
//to graph.R
public EncoderParams(int minHeight, int exercisePercentBodyWeight, string mass, string eccon,
string analysis, string analysisVariables, string analysisOptions,
- string encoderMode, int inertiaMomentum, double diameter,
+ string encoderConfigurationName, int inertiaMomentum, double diameter,
string smoothCon, int curve, int width, int height, string decimalSeparator)
{
this.minHeight = minHeight;
@@ -129,7 +129,7 @@ public class EncoderParams
this.analysis = analysis;
this.analysisVariables = analysisVariables;
this.analysisOptions = analysisOptions;
- this.encoderMode = encoderMode;
+ this.encoderConfigurationName = encoderConfigurationName;
this.inertiaMomentum = inertiaMomentum;
this.diameter = diameter;
this.smoothCon = smoothCon;
@@ -143,7 +143,7 @@ public class EncoderParams
{
return minHeight + sep + exercisePercentBodyWeight + sep + mass + sep + eccon +
sep + analysis + sep + analysisVariables + sep + analysisOptions +
- sep + encoderMode + sep + inertiaMomentum.ToString() + sep +
Util.ConvertToPoint(diameter) +
+ sep + encoderConfigurationName + sep + inertiaMomentum.ToString() + sep +
Util.ConvertToPoint(diameter) +
sep + smoothCon + sep + curve + sep + width + sep + height + sep + decimalSeparator;
}
@@ -282,9 +282,9 @@ public class EncoderSQL
public string status; //active or inactive curves
public string videoURL; //URL of video of signals
- //encoderMode conversions
+ //encoderConfiguration conversions
//in signals and curves, need to do conversions (invert, inertiaMomentum, diameter)
- public string encoderMode;
+ public string encoderConfigurationName;
public int inertiaMomentum; //kg*cm^2
public double diameter;
@@ -304,7 +304,7 @@ public class EncoderSQL
string eccon, string laterality, string extraWeight, string signalOrCurve,
string filename, string url, int time, int minHeight, double smooth,
string description, string status, string videoURL,
- string encoderMode, int inertiaMomentum, double diameter,
+ string encoderConfigurationName, int inertiaMomentum, double diameter,
string future1, string future2, string future3,
string exerciseName
)
@@ -325,7 +325,7 @@ public class EncoderSQL
this.description = description;
this.status = status;
this.videoURL = videoURL;
- this.encoderMode = encoderMode;
+ this.encoderConfigurationName = encoderConfigurationName;
this.inertiaMomentum = inertiaMomentum;
this.diameter = diameter;
this.future1 = future1;
@@ -592,53 +592,74 @@ public class EncoderCaptureCurveArray {
}
-public class EncoderModeSelection {
- public Constants.EncoderMode encoderMode;
+public class EncoderConfiguration {
+ public Constants.EncoderConfigurationNames name;
public Constants.EncoderType type;
public int position;
public string image;
public string code; //this code will be stored untranslated but will be translated just to be
shown
public string text;
- public bool d;
- public bool d2;
- public bool angle;
- public bool inertia;
-
+ public bool has_d;
+ public bool has_d2;
+ public bool has_angle;
+ public bool has_inertia;
+ public double d;
+ public double d2;
+ public int angle;
+ public int inertia;
+
+ //this is the default values
+ public EncoderConfiguration() {
+ name = Constants.EncoderConfigurationNames.LINEAR;
+ type = Constants.EncoderType.LINEAR;
+ position = 0;
+ image = Constants.FileNameEncoderLinearFreeWeight;
+ code = Constants.DefaultEncoderConfigurationCode;
+ text = "Linear encoder attached to a barbell.";
+ has_d = false;
+ has_d2 = false;
+ has_angle = false;
+ has_inertia = false;
+ d = -1;
+ d2 = -1;
+ angle = -1;
+ inertia = -1;
+ }
/* note: if this changes, change also in:
- * Constants.EncoderModeSelectionList(enum encoderType)
+ * UtilEncoder.EncoderConfigurationList(enum encoderType)
*/
- public EncoderModeSelection(Constants.EncoderMode encoderMode) {
- this.encoderMode = encoderMode;
- d = false;
- d2 = false;
- angle = false;
- inertia = false;
-
- if(encoderMode == Constants.EncoderMode.LINEAR) {
+ public EncoderConfiguration(Constants.EncoderConfigurationNames name) {
+ this.name = name;
+ has_d = false;
+ has_d2 = false;
+ has_angle = false;
+ has_inertia = false;
+
+ if(name == Constants.EncoderConfigurationNames.LINEAR) {
type = Constants.EncoderType.LINEAR;
position = 0;
image = Constants.FileNameEncoderLinearFreeWeight;
code = Constants.DefaultEncoderConfigurationCode;
text = "Linear encoder attached to a barbell.";
}
- else if(encoderMode == Constants.EncoderMode.LINEARINVERTED) {
+ else if(name == Constants.EncoderConfigurationNames.LINEARINVERTED) {
type = Constants.EncoderType.LINEAR;
position = 1;
image =Constants.FileNameEncoderLinearFreeWeightInv;
code = "Linear inv - barbell";
text = "Linear encoder inverted attached to a barbell.";
}
- else if(encoderMode == Constants.EncoderMode.LINEARINERTIAL) {
+ else if(name == Constants.EncoderConfigurationNames.LINEARINERTIAL) {
type = Constants.EncoderType.LINEAR;
position = 2;
image = Constants.FileNameEncoderLinearInertial;
code = "Linear - inertial machine";
text = "Linear encoder on inertia machine." + " " + "NOT Recommended!";
- inertia = true;
+ has_inertia = true;
}
- else if(encoderMode == Constants.EncoderMode.WEIGHTEDMOVPULLEYLINEARONPERSON1) {
+ else if(name == Constants.EncoderConfigurationNames.WEIGHTEDMOVPULLEYLINEARONPERSON1) {
type = Constants.EncoderType.LINEAR;
position = 3;
image = Constants.FileNameEncoderWeightedMovPulleyOnPerson1;
@@ -646,7 +667,7 @@ public class EncoderModeSelection {
text = "Linear encoder attached to a barbell." + " " +
"Barbell is connected to a weighted moving pulley.";
}
- else if(encoderMode == Constants.EncoderMode.WEIGHTEDMOVPULLEYLINEARONPERSON1INV) {
+ else if(name == Constants.EncoderConfigurationNames.WEIGHTEDMOVPULLEYLINEARONPERSON1INV) {
type = Constants.EncoderType.LINEAR;
position = 4;
image = Constants.FileNameEncoderWeightedMovPulleyOnPerson1Inv;
@@ -654,7 +675,7 @@ public class EncoderModeSelection {
text = "Linear encoder inverted attached to a barbell." + " " +
"Barbell is connected to a weighted moving pulley.";
}
- else if(encoderMode == Constants.EncoderMode.WEIGHTEDMOVPULLEYLINEARONPERSON2) {
+ else if(name == Constants.EncoderConfigurationNames.WEIGHTEDMOVPULLEYLINEARONPERSON2) {
type = Constants.EncoderType.LINEAR;
position = 5;
image = Constants.FileNameEncoderWeightedMovPulleyOnPerson2;
@@ -662,7 +683,7 @@ public class EncoderModeSelection {
text = "Linear encoder attached to a barbell." + " " +
"Barbell is connected to a fixed pulley that is connected to a weighted
moving pulley.";
}
- else if(encoderMode == Constants.EncoderMode.WEIGHTEDMOVPULLEYLINEARONPERSON2INV) {
+ else if(name == Constants.EncoderConfigurationNames.WEIGHTEDMOVPULLEYLINEARONPERSON2INV) {
type = Constants.EncoderType.LINEAR;
position = 6;
image = Constants.FileNameEncoderWeightedMovPulleyOnPerson2Inv;
@@ -670,74 +691,74 @@ public class EncoderModeSelection {
text = "Linear encoder inverted attached to a barbell." + " " +
"Barbell is connected to a fixed pulley that is connected to a weighted
moving pulley.";
}
- else if(encoderMode == Constants.EncoderMode.WEIGHTEDMOVPULLEYONLINEARENCODER) {
+ else if(name == Constants.EncoderConfigurationNames.WEIGHTEDMOVPULLEYONLINEARENCODER) {
type = Constants.EncoderType.LINEAR;
position = 7;
image = Constants.FileNameEncoderWeightedMovPulleyOnLinearEncoder;
code = "Linear - moving pulley";
text = "Linear encoder attached to a weighted moving pulley.";
}
- else if(encoderMode == Constants.EncoderMode.LINEARONPLANE) {
+ else if(name == Constants.EncoderConfigurationNames.LINEARONPLANE) {
type = Constants.EncoderType.LINEAR;
position = 8;
image = Constants.FileNameEncoderLinearOnPlane;
code = "Linear - inclinated plane";
text = "Linear encoder on a inclinated plane.";
- angle = true;
+ has_angle = true;
}
- else if(encoderMode == Constants.EncoderMode.ROTARYFRICTIONSIDE) {
+ else if(name == Constants.EncoderConfigurationNames.ROTARYFRICTIONSIDE) {
type = Constants.EncoderType.ROTARYFRICTION;
position = 0;
image = Constants.FileNameEncoderFrictionSide;
code = "Rotary friction - pulley";
text = "Rotary friction encoder on pulley.";
}
- else if(encoderMode == Constants.EncoderMode.ROTARYFRICTIONAXIS) {
+ else if(name == Constants.EncoderConfigurationNames.ROTARYFRICTIONAXIS) {
type = Constants.EncoderType.ROTARYFRICTION;
position = 1;
image = Constants.FileNameEncoderFrictionAxis;
code = "Rotary friction - pulley axis";
text = "Rotary friction encoder on pulley axis.";
- d = true;
- d2 = true;
+ has_d = true;
+ has_d2 = true;
}
- else if(encoderMode == Constants.EncoderMode.ROTARYFRICTIONINERTIAL) {
+ else if(name == Constants.EncoderConfigurationNames.ROTARYFRICTIONINERTIAL) {
type = Constants.EncoderType.ROTARYFRICTION;
position = 2;
image = Constants.FileNameEncoderFrictionInertial;
code = "Rotary friction - inertial machine";
text = "Rotary friction encoder on inertial machine.";
- inertia = true;
+ has_inertia = true;
}
- else if(encoderMode == Constants.EncoderMode.WEIGHTEDMOVPULLEYROTARYFRICTION) {
+ else if(name == Constants.EncoderConfigurationNames.WEIGHTEDMOVPULLEYROTARYFRICTION) {
type = Constants.EncoderType.ROTARYFRICTION;
position = 3;
image = Constants.FileNameEncoderFrictionWithMovPulley;
code = "Rotary friction - moving pulley";
text = "Rotary friction encoder on weighted moving pulley.";
}
- else if(encoderMode == Constants.EncoderMode.ROTARYAXIS) {
+ else if(name == Constants.EncoderConfigurationNames.ROTARYAXIS) {
type = Constants.EncoderType.ROTARYAXIS;
position = 0;
image = Constants.FileNameEncoderRotaryAxisOnAxis;
code = "Rotary axis - pulley axis";
text = "Rotary axis encoder on pulley axis.";
- d = true;
+ has_d = true;
}
- else if(encoderMode == Constants.EncoderMode.ROTARYAXISINERTIAL) {
+ else if(name == Constants.EncoderConfigurationNames.ROTARYAXISINERTIAL) {
type = Constants.EncoderType.ROTARYAXIS;
position = 1;
image = Constants.FileNameEncoderAxisInertial;
code = "Rotary axis - inertial machine";
text = "Rotary axis encoder on inertial machine.";
- inertia = true;
+ has_inertia = true;
}
- else if(encoderMode == Constants.EncoderMode.WEIGHTEDMOVPULLEYROTARYAXIS) {
+ else if(name == Constants.EncoderConfigurationNames.WEIGHTEDMOVPULLEYROTARYAXIS) {
type = Constants.EncoderType.ROTARYAXIS;
position = 2;
image = Constants.FileNameEncoderAxisWithMovPulley;
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 62ded85..b74878a 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -178,7 +178,7 @@ public partial class ChronoJumpWindow
EncoderCaptureOptionsWindow encoderCaptureOptionsWin;
EncoderConfigurationWindow encoder_configuration_win;
- EncoderModeSelection encoderModeSelectionCurrent;
+ EncoderConfiguration encoderConfigurationCurrent;
/*
* this contains last EncoderSQL captured, recalculated or loaded
@@ -228,9 +228,10 @@ public partial class ChronoJumpWindow
encoder_pulsebar_capture.Text = "";
encoder_pulsebar_analyze.Fraction = 1;
encoder_pulsebar_analyze.Text = "";
-
- encoderModeSelectionCurrent = new EncoderModeSelection(Constants.EncoderMode.LINEAR);
- label_encoder_selected.Text = encoderModeSelectionCurrent.code;
+
+ //default values
+ encoderConfigurationCurrent = new EncoderConfiguration();
+ label_encoder_selected.Text = encoderConfigurationCurrent.code;
encoderCaptureListStore = new Gtk.ListStore (typeof (EncoderCurve));
@@ -244,33 +245,18 @@ public partial class ChronoJumpWindow
encoderCaptureOptionsWin = EncoderCaptureOptionsWindow.Create();
encoderCaptureOptionsWin.FakeButtonClose.Clicked += new
EventHandler(on_encoder_capture_options_closed);
}
-
- double encoderConfigurationWindowDiameter = -1;
- double encoderConfigurationWindowDiameter2 = -1;
- int encoderConfigurationWindowAngle = -1;
- int encoderConfigurationWindowInertia = -1;
+
void on_button_encoder_select_clicked (object o, EventArgs args) {
- encoder_configuration_win = EncoderConfigurationWindow.View(
- encoderModeSelectionCurrent,
- encoderConfigurationWindowDiameter,
- encoderConfigurationWindowDiameter2,
- encoderConfigurationWindowAngle,
- encoderConfigurationWindowInertia
- );
+ encoder_configuration_win = EncoderConfigurationWindow.View(encoderConfigurationCurrent);
encoder_configuration_win.Button_accept.Clicked += new
EventHandler(on_encoder_configuration_win_accepted);
}
void on_encoder_configuration_win_accepted (object o, EventArgs args) {
encoder_configuration_win.Button_accept.Clicked -= new
EventHandler(on_encoder_configuration_win_accepted);
- encoderModeSelectionCurrent = encoder_configuration_win.GetSelected();
- label_encoder_selected.Text = encoderModeSelectionCurrent.code;
-
- encoderConfigurationWindowDiameter = encoder_configuration_win.GetDiameter();
- encoderConfigurationWindowDiameter2 = encoder_configuration_win.GetDiameter2();
- encoderConfigurationWindowAngle = encoder_configuration_win.GetAngle();
- encoderConfigurationWindowInertia = encoder_configuration_win.GetInertia();
+ encoderConfigurationCurrent = encoder_configuration_win.GetAcceptedValues();
+ label_encoder_selected.Text = encoderConfigurationCurrent.code;
}
void on_button_encoder_capture_options_clicked (object o, EventArgs args) {
@@ -610,85 +596,6 @@ public partial class ChronoJumpWindow
encoderAnalyzeListStore = new Gtk.ListStore (typeof (EncoderCurve));
}
- //arraylist with: encoderMode, inertial value (or zero), diameter value (or zero)
- private ArrayList getEncoderTypeByCombos() {
- ArrayList data = new ArrayList(3);
- if(radiobutton_encoder_capture_linear.Active) {
- if(checkbutton_encoder_capture_inverted.Active) {
- //if(checkbutton_encoder_capture_inertial.Active)
- //data.Add(Constants.EncoderMode.LINEARINVERTEDINERTIAL.ToString());
- //else
- data.Add(Constants.EncoderMode.LINEARINVERTED.ToString());
- } else {
- if(checkbutton_encoder_capture_inertial.Active)
- data.Add(Constants.EncoderMode.LINEARINERTIAL.ToString());
- else
- data.Add(Constants.EncoderMode.LINEAR.ToString());
- }
- }
- else { //(radiobutton_encoder_capture_rotary.Active)
- if(checkbutton_encoder_capture_inertial.Active)
- data.Add(Constants.EncoderMode.ROTARYFRICTIONINERTIAL.ToString());
- else {
- if(radiobutton_encoder_capture_rotary_friction.Active)
- data.Add(Constants.EncoderMode.ROTARYFRICTIONSIDE.ToString());
- else
- data.Add(Constants.EncoderMode.ROTARYAXIS.ToString());
- }
- }
-
- if(checkbutton_encoder_capture_inertial.Active)
- data.Add((int) spin_encoder_capture_inertial.Value);
- else
- data.Add(0);
-
- //diameter is always in m except in gui: there is in cm
- data.Add((double) spin_encoder_capture_diameter.Value / 100);
-
- return data;
- }
-
-
- private void setEncoderCombos(EncoderSQL eSQL) {
- //TODO diferentiate both rotary encoders
- if (
- eSQL.encoderMode == Constants.EncoderMode.LINEARINERTIAL.ToString() ||
- //eSQL.encoderMode == Constants.EncoderMode.LINEARINVERTEDINERTIAL.ToString()
||
- eSQL.encoderMode == Constants.EncoderMode.ROTARYFRICTIONINERTIAL.ToString() ||
- eSQL.encoderMode == Constants.EncoderMode.ROTARYAXISINERTIAL.ToString()
- ) {
- //inertial machines
- checkbutton_encoder_capture_inertial.Active = true;
- //TODO: check this is ok
- spin_encoder_capture_inertial.Value =
- Convert.ToInt32(eSQL.inertiaMomentum);
- } else
- checkbutton_encoder_capture_inertial.Active = false;
-
-
- if(eSQL.encoderMode == Constants.EncoderMode.LINEARINVERTED.ToString()) {
- radiobutton_encoder_capture_linear.Active = true;
- checkbutton_encoder_capture_inverted.Active = true;
- } else if(
- eSQL.encoderMode == Constants.EncoderMode.ROTARYFRICTIONSIDE.ToString() ||
- eSQL.encoderMode == Constants.EncoderMode.ROTARYAXIS.ToString() ) {
- radiobutton_encoder_capture_rotary.Active = true;
- checkbutton_encoder_capture_inverted.Active = false;
-
- if(eSQL.encoderMode == Constants.EncoderMode.ROTARYFRICTIONSIDE.ToString())
- radiobutton_encoder_capture_rotary_friction.Active = true;
- else
- radiobutton_encoder_capture_rotary_axis.Active = true;
-
- } else { //default to linear: (eSQL.encoderMode == Constants.EncoderMode.LINEAR.ToString())
- radiobutton_encoder_capture_linear.Active = true;
- checkbutton_encoder_capture_inverted.Active = false;
- }
-
- //diameter is always in m except in gui: there is in cm
- spin_encoder_capture_diameter.Value = Convert.ToDouble(eSQL.diameter) * 100;
- }
-
private string getEncoderAnalysisOptions(bool captureOrAnalyze) {
/*
@@ -706,7 +613,7 @@ public partial class ChronoJumpWindow
* p;ra;-;-;4
* -;li;-;-;-
*
- * TODO: not. Do this on getEncoderTypeByCombos();
+ * TODO: not.
* here only do the "p"
*
*/
@@ -740,8 +647,6 @@ public partial class ChronoJumpWindow
string analysisOptions = getEncoderAnalysisOptions(true);
- ArrayList encoderTypeArray = getEncoderTypeByCombos();
-
//see explanation on the top of this file
lastEncoderSQL = new EncoderSQL(
"-1",
@@ -759,9 +664,9 @@ public partial class ChronoJumpWindow
-1, //Since 1.3.7 smooth is not stored in curves
"", //desc,
"","", //status, videoURL
- encoderTypeArray[0].ToString(), //encoderMode
- Convert.ToInt32(encoderTypeArray[1]), //inertiaMomentum
- Convert.ToDouble(encoderTypeArray[2]), //diameter
+ encoderConfigurationCurrent.name.ToString(),
+ encoderConfigurationCurrent.inertia,
+ encoderConfigurationCurrent.d,
"","","", //future1, 2, 3
Util.FindOnArray(':', 2, 1, UtilGtk.ComboGetActive(combo_encoder_exercise),
encoderExercisesTranslationAndBodyPWeight) //exerciseName
(english)
@@ -776,9 +681,9 @@ public partial class ChronoJumpWindow
analysis,
"none", //analysisVariables (not needed in create
curves). Cannot be blank
analysisOptions,
- encoderTypeArray[0].ToString(), //encoderMode
- Convert.ToInt32(encoderTypeArray[1]), //inertiaMomentum
- Convert.ToDouble(encoderTypeArray[2]), //diameter
+ encoderConfigurationCurrent.name.ToString(),
+ encoderConfigurationCurrent.inertia,
+ encoderConfigurationCurrent.d,
Util.ConvertToPoint(encoderSmoothCon), //R decimal: '.'
0, //curve is not used here
image_encoder_width, image_encoder_height,
@@ -1261,7 +1166,12 @@ public partial class ChronoJumpWindow
encoderSignalUniqueID = eSQL.uniqueID;
button_video_play_this_test_encoder.Sensitive = (eSQL.videoURL != "");
- setEncoderCombos(eSQL);
+ encoderConfigurationCurrent = new EncoderConfiguration(
(Constants.EncoderConfigurationNames)
+ Enum.Parse(typeof(Constants.EncoderConfigurationNames),
eSQL.encoderConfigurationName) );
+ encoderConfigurationCurrent.d = eSQL.diameter;
+ encoderConfigurationCurrent.inertia = eSQL.inertiaMomentum;
+
+ label_encoder_selected.Text = encoderConfigurationCurrent.code;
}
}
@@ -1335,8 +1245,6 @@ public partial class ChronoJumpWindow
currentPersonSession.Weight
) );
- ArrayList encoderTypeArray = getEncoderTypeByCombos();
-
EncoderParams ep = new EncoderParams(
lastEncoderSQL.minHeight,
getExercisePercentBodyWeightFromName (lastEncoderSQL.exerciseName),
@@ -1345,9 +1253,9 @@ public partial class ChronoJumpWindow
"exportCSV",
"none", //analysisVariables (not
needed in create curves). Cannot be blank
analysisOptions,
- encoderTypeArray[0].ToString(), //encoderMode
- Convert.ToInt32(encoderTypeArray[1]), //inertiaMomentum
- Convert.ToDouble(encoderTypeArray[2]), //diameter
+ encoderConfigurationCurrent.name.ToString(),
+ encoderConfigurationCurrent.inertia,
+ encoderConfigurationCurrent.d,
Util.ConvertToPoint(encoderSmoothCon), //R decimal: '.'
-1,
image_encoder_width,
@@ -1686,10 +1594,9 @@ public partial class ChronoJumpWindow
eSQL.url = path;
eSQL.description = desc;
- ArrayList encoderTypeArray = getEncoderTypeByCombos();
- eSQL.encoderMode = encoderTypeArray[0].ToString();
- eSQL.inertiaMomentum = Convert.ToInt32(encoderTypeArray[1]);
- eSQL.diameter = Convert.ToDouble(encoderTypeArray[2]);
+ eSQL.encoderConfigurationName = encoderConfigurationCurrent.name.ToString();
+ eSQL.inertiaMomentum = encoderConfigurationCurrent.inertia;
+ eSQL.diameter = encoderConfigurationCurrent.d;
//if is a signal that we just loaded, then don't insert, do an update
@@ -1890,19 +1797,13 @@ public partial class ChronoJumpWindow
//this is what's readed from encoder, as it's linear (non-inverted, not inertial, ...)
//it's stored in file like this
int byteReadedRaw;
- //this it's converted applying encoderModeConversions: inverted, inertial, diameter, demult,
...
+ //this it's converted applying encoderConfigurationConversions: inverted, inertial, diameter,
demult, ...
double byteReaded;
//initialize
int [] encoderReadedRaw = new int[recordingTime]; //stored to file in this method
encoderReaded = new double[recordingTime]; //readed from drawing process:
updateEncoderCaptureGraphRCalc()
-
- ArrayList encoderTypeArray = getEncoderTypeByCombos();
- string encoderMode = encoderTypeArray[0].ToString();
- int inertiaMomentum = Convert.ToInt32(encoderTypeArray[1]);
- double diameter = Convert.ToDouble(encoderTypeArray[2]);
-
-
+
double sum = 0;
string dataString = "";
string sep = "";
@@ -1952,7 +1853,8 @@ public partial class ChronoJumpWindow
if(byteReadedRaw > 128)
byteReadedRaw = byteReadedRaw - 256;
- byteReaded = UtilEncoder.EncoderModeConversions(byteReadedRaw, encoderMode,
inertiaMomentum, diameter);
+ byteReaded = UtilEncoder.EncoderConfigurationConversions(
+ byteReadedRaw, encoderConfigurationCurrent);
i=i+1;
if(i >= 0) {
@@ -2058,7 +1960,7 @@ public partial class ChronoJumpWindow
sep = "";
for(int j=0; j < i ; j ++) {
- writer.Write(sep + encoderReadedRaw[j]); //store the raw file (before
encoderModeConversions)
+ writer.Write(sep + encoderReadedRaw[j]); //store the raw file (before
encoderConfigurationConversions)
sep = ", ";
}
@@ -2109,11 +2011,6 @@ public partial class ChronoJumpWindow
if(sendAnalysis == "powerBars" || sendAnalysis == "single" || sendAnalysis == "side")
analysisVariables = getAnalysisVariables(sendAnalysis);
- ArrayList encoderTypeArray = getEncoderTypeByCombos();
- string encoderMode = encoderTypeArray[0].ToString();
- int inertiaMomentum = Convert.ToInt32(encoderTypeArray[1]);
- double diameter = Convert.ToDouble(encoderTypeArray[2]);
-
if(radiobutton_encoder_analyze_data_user_curves.Active) {
string myEccon = "ec";
if(! check_encoder_analyze_eccon_together.Active)
@@ -2209,9 +2106,9 @@ public partial class ChronoJumpWindow
sendAnalysis,
analysisVariables,
analysisOptions,
- encoderTypeArray[0].ToString(), //encoderMode
- Convert.ToInt32(encoderTypeArray[1]), //inertiaMomentum
- Convert.ToDouble(encoderTypeArray[2]), //diameter
+ encoderConfigurationCurrent.name.ToString(),
+ encoderConfigurationCurrent.inertia,
+ encoderConfigurationCurrent.d,
Util.ConvertToPoint(encoderSmoothCon), //R decimal:
'.'
myCurveNum,
image_encoder_width,
@@ -2312,9 +2209,9 @@ Log.WriteLine(str);
sendAnalysis,
analysisVariables,
analysisOptions,
- encoderTypeArray[0].ToString(), //encoderMode
- Convert.ToInt32(encoderTypeArray[1]), //inertiaMomentum
- Convert.ToDouble(encoderTypeArray[2]), //diameter
+ encoderConfigurationCurrent.name.ToString(),
+ encoderConfigurationCurrent.inertia,
+ encoderConfigurationCurrent.d,
Util.ConvertToPoint(encoderSmoothCon), //R decimal:
'.'
Convert.ToInt32(UtilGtk.ComboGetActive(combo_encoder_analyze_curve_num_combo)),
image_encoder_width,
diff --git a/src/gui/encoderConfiguration.cs b/src/gui/encoderConfiguration.cs
index 7225635..a46d6d4 100644
--- a/src/gui/encoderConfiguration.cs
+++ b/src/gui/encoderConfiguration.cs
@@ -75,23 +75,23 @@ public class EncoderConfigurationWindow {
UtilGtk.IconWindow(encoder_configuration);
}
- static public EncoderConfigurationWindow View (EncoderModeSelection ems, double d, double d2, int
angle, int inertia) {
+ static public EncoderConfigurationWindow View (EncoderConfiguration ec) {
if (EncoderConfigurationWindowBox == null) {
EncoderConfigurationWindowBox = new EncoderConfigurationWindow ();
}
//activate default radiobutton
- if(ems.type == Constants.EncoderType.ROTARYFRICTION)
+ if(ec.type == Constants.EncoderType.ROTARYFRICTION)
EncoderConfigurationWindowBox.radio_rotary_friction.Active = true;
- else if(ems.type == Constants.EncoderType.ROTARYAXIS)
+ else if(ec.type == Constants.EncoderType.ROTARYAXIS)
EncoderConfigurationWindowBox.radio_rotary_axis.Active = true;
else //linear
EncoderConfigurationWindowBox.radio_linear.Active = true;
- EncoderConfigurationWindowBox.initializeList(ems.type, ems.position);
+ EncoderConfigurationWindowBox.initializeList(ec.type, ec.position);
- EncoderConfigurationWindowBox.putValuesStoredPreviously(d, d2, angle, inertia);
+ EncoderConfigurationWindowBox.putValuesStoredPreviously(ec.d, ec.d2, ec.angle, ec.inertia);
EncoderConfigurationWindowBox.encoder_configuration.Show ();
return EncoderConfigurationWindowBox;
@@ -111,7 +111,7 @@ public class EncoderConfigurationWindow {
}
private void initializeList(Constants.EncoderType type, int position) {
- list = UtilEncoder.EncoderModeSelectionList(type);
+ list = UtilEncoder.EncoderConfigurationList(type);
listCurrent = position; //current item on list
selectedModeChanged();
@@ -134,20 +134,20 @@ public class EncoderConfigurationWindow {
}
private void selectedModeChanged() {
- EncoderModeSelection sel = (EncoderModeSelection) list[listCurrent];
+ EncoderConfiguration ec = (EncoderConfiguration) list[listCurrent];
- pixbuf = new Pixbuf (null, Util.GetImagePath(false) + sel.image);
+ pixbuf = new Pixbuf (null, Util.GetImagePath(false) + ec.image);
image_encoder_configuration.Pixbuf = pixbuf;
TextBuffer tb1 = new TextBuffer (new TextTagTable());
- tb1.Text = "[" + sel.code + "]\n" + sel.text;
+ tb1.Text = "[" + ec.code + "]\n" + ec.text;
textview.Buffer = tb1;
- hbox_d.Visible = sel.d;
- hbox_d2.Visible = sel.d2;
- hbox_angle.Visible = sel.angle;
- hbox_inertia.Visible = sel.inertia;
- hbox_inertia2.Visible = sel.inertia;
+ hbox_d.Visible = ec.has_d;
+ hbox_d2.Visible = ec.has_d2;
+ hbox_angle.Visible = ec.has_angle;
+ hbox_inertia.Visible = ec.has_inertia;
+ hbox_inertia2.Visible = ec.has_inertia;
label_count.Text = (listCurrent + 1).ToString() + " / " + list.Count.ToString();
}
@@ -163,22 +163,21 @@ public class EncoderConfigurationWindow {
spin_inertia.Value = inertia;
}
- public EncoderModeSelection GetSelected() {
- EncoderModeSelection sel = (EncoderModeSelection) list[listCurrent];
- return sel;
- }
-
- public double GetDiameter() {
- return (double) spin_d.Value;
- }
- public double GetDiameter2() {
- return (double) spin_d2.Value;
- }
- public int GetAngle() {
- return (int) spin_angle.Value;
- }
- public int GetInertia() {
- return (int) spin_inertia.Value;
+ /*
+ * Use this to retrieve values after accept
+ * do not use to know current encoder configuration
+ * because that is stored in gui/encoder as
+ * encoderConfigurationCurrent
+ */
+ public EncoderConfiguration GetAcceptedValues()
+ {
+ EncoderConfiguration ec = (EncoderConfiguration) list[listCurrent];
+ ec.d = (double) spin_d.Value;
+ ec.d2 = (double) spin_d2.Value;
+ ec.angle = (int) spin_angle.Value;
+ ec.inertia = (int) spin_inertia.Value;
+
+ return ec;
}
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index 4e058ac..c248c19 100644
--- a/src/sqlite/encoder.cs
+++ b/src/sqlite/encoder.cs
@@ -110,7 +110,7 @@ class SqliteEncoder : Sqlite
es.signalOrCurve + "', '" + es.filename + "', '" +
es.url + "', " + es.time + ", " + es.minHeight + ", " +
Util.ConvertToPoint(es.smooth) + ", '" + es.description +
- "', 'active', '" + es.videoURL + "', '" + es.encoderMode + "', " +
+ "', 'active', '" + es.videoURL + "', '" + es.encoderConfigurationName + "', " +
es.inertiaMomentum + ", " + Util.ConvertToPoint(es.diameter) + ", '" +
es.future1 + "', '" + es.future2 + "', '" +
es.future3 + "')";
@@ -153,7 +153,7 @@ class SqliteEncoder : Sqlite
", description = '" + es.description +
"', status = '" + es.status +
"', videoURL = '" + es.videoURL +
- "', mode = '" + es.encoderMode +
+ "', mode = '" + es.encoderConfigurationName +
"', inertiaMomentum = " + es.inertiaMomentum +
", diameter = " + Util.ConvertToPoint(es.diameter) +
", future1 = '" + es.future1 +
@@ -242,7 +242,7 @@ class SqliteEncoder : Sqlite
reader[13].ToString(), //description
reader[14].ToString(), //status
reader[15].ToString(), //videoURL
- reader[16].ToString(), //encoderMode
+ reader[16].ToString(), //encoderConfigurationName
Convert.ToInt32(reader[17].ToString()), //inertiaMomentum
Convert.ToDouble(Util.ChangeDecimalSeparator(reader[18].ToString())),
//diameter
reader[19].ToString(), //future1
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index cdfb735..f95c61f 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -1291,11 +1291,11 @@ class Sqlite
if(currentVersion == "0.95") {
dbcon.Open();
- Update(true, Constants.EncoderTable, "future3", "",
Constants.EncoderMode.LINEAR.ToString(),
+ Update(true, Constants.EncoderTable, "future3", "",
Constants.EncoderConfigurationNames.LINEAR.ToString(),
"signalOrCurve", "signal");
- Update(true, Constants.EncoderTable, "future3", "0",
Constants.EncoderMode.LINEAR.ToString(),
+ Update(true, Constants.EncoderTable, "future3", "0",
Constants.EncoderConfigurationNames.LINEAR.ToString(),
"signalOrCurve", "signal");
- Update(true, Constants.EncoderTable, "future3", "1",
Constants.EncoderMode.LINEARINVERTED.ToString(),
+ Update(true, Constants.EncoderTable, "future3", "1",
Constants.EncoderConfigurationNames.LINEARINVERTED.ToString(),
"signalOrCurve", "signal");
Log.WriteLine("Encoder signal future3 three modes");
diff --git a/src/utilEncoder.cs b/src/utilEncoder.cs
index 30ba3be..7392573 100644
--- a/src/utilEncoder.cs
+++ b/src/utilEncoder.cs
@@ -115,7 +115,7 @@ public class UtilEncoder
}
-// public static void MoveTempToEncoderData(int sessionID, int uniqueID) {
+// public static void MoveTempToEncoderData(int sessionID, int uniqueID)
public static string CopyTempToEncoderData(int sessionID, int uniqueID, string personName, string
timeStamp)
{
string fileName="";
@@ -441,59 +441,61 @@ public class UtilEncoder
return fileCurve;
}
- public static double EncoderModeConversions(int byteReaded, string encoderMode, int inertiaMomentum,
double diameter) {
+ public static double EncoderConfigurationConversions(
+ //int byteReaded, string encoderMode, int inertiaMomentum, double diameter) {
+ int byteReaded, EncoderConfiguration ec) {
double byteConverted = byteReaded;
//invert sign if inverted is selected
- if(encoderMode == Constants.EncoderMode.LINEARINVERTED.ToString())
+ if(ec.name == Constants.EncoderConfigurationNames.LINEARINVERTED)
byteConverted *= -1;
- else if(encoderMode == "ROTARYAXIS") {
+ else if(ec.name == Constants.EncoderConfigurationNames.ROTARYAXIS) {
int ticksRotaryEncoder = 200; //our rotary axis encoder send 200 ticks by turn
//diameter m -> mm
- byteConverted = ( byteConverted / ticksRotaryEncoder ) * 2 * Math.PI * ( diameter *
1000 / 2 );
+ byteConverted = ( byteConverted / ticksRotaryEncoder ) * 2 * Math.PI * ( ec.d * 1000
/ 2 );
}
//Log.Write(" " + byteReaded + ":" + byteConverted);
return byteConverted;
}
- public static ArrayList EncoderModeSelectionList(Constants.EncoderType encoderType) {
+ public static ArrayList EncoderConfigurationList(Constants.EncoderType encoderType) {
ArrayList list = new ArrayList();
if(encoderType == Constants.EncoderType.LINEAR) {
- list.Add(new EncoderModeSelection(
- Constants.EncoderMode.LINEAR));
- list.Add(new EncoderModeSelection(
- Constants.EncoderMode.LINEARINVERTED));
- list.Add(new EncoderModeSelection(
- Constants.EncoderMode.LINEARINERTIAL));
- list.Add(new EncoderModeSelection(
- Constants.EncoderMode.WEIGHTEDMOVPULLEYLINEARONPERSON1));
- list.Add(new EncoderModeSelection(
- Constants.EncoderMode.WEIGHTEDMOVPULLEYLINEARONPERSON1INV));
- list.Add(new EncoderModeSelection(
- Constants.EncoderMode.WEIGHTEDMOVPULLEYLINEARONPERSON2));
- list.Add(new EncoderModeSelection(
- Constants.EncoderMode.WEIGHTEDMOVPULLEYLINEARONPERSON2INV));
- list.Add(new EncoderModeSelection(
- Constants.EncoderMode.WEIGHTEDMOVPULLEYONLINEARENCODER));
- list.Add(new EncoderModeSelection(
- Constants.EncoderMode.LINEARONPLANE));
+ list.Add(new EncoderConfiguration(
+ Constants.EncoderConfigurationNames.LINEAR));
+ list.Add(new EncoderConfiguration(
+ Constants.EncoderConfigurationNames.LINEARINVERTED));
+ list.Add(new EncoderConfiguration(
+ Constants.EncoderConfigurationNames.LINEARINERTIAL));
+ list.Add(new EncoderConfiguration(
+
Constants.EncoderConfigurationNames.WEIGHTEDMOVPULLEYLINEARONPERSON1));
+ list.Add(new EncoderConfiguration(
+
Constants.EncoderConfigurationNames.WEIGHTEDMOVPULLEYLINEARONPERSON1INV));
+ list.Add(new EncoderConfiguration(
+
Constants.EncoderConfigurationNames.WEIGHTEDMOVPULLEYLINEARONPERSON2));
+ list.Add(new EncoderConfiguration(
+
Constants.EncoderConfigurationNames.WEIGHTEDMOVPULLEYLINEARONPERSON2INV));
+ list.Add(new EncoderConfiguration(
+
Constants.EncoderConfigurationNames.WEIGHTEDMOVPULLEYONLINEARENCODER));
+ list.Add(new EncoderConfiguration(
+ Constants.EncoderConfigurationNames.LINEARONPLANE));
} else if(encoderType == Constants.EncoderType.ROTARYFRICTION) {
- list.Add(new EncoderModeSelection(
- Constants.EncoderMode.ROTARYFRICTIONSIDE));
- list.Add(new EncoderModeSelection(
- Constants.EncoderMode.ROTARYFRICTIONAXIS));
- list.Add(new EncoderModeSelection(
- Constants.EncoderMode.ROTARYFRICTIONINERTIAL));
- list.Add(new EncoderModeSelection(
- Constants.EncoderMode.WEIGHTEDMOVPULLEYROTARYFRICTION));
+ list.Add(new EncoderConfiguration(
+ Constants.EncoderConfigurationNames.ROTARYFRICTIONSIDE));
+ list.Add(new EncoderConfiguration(
+ Constants.EncoderConfigurationNames.ROTARYFRICTIONAXIS));
+ list.Add(new EncoderConfiguration(
+ Constants.EncoderConfigurationNames.ROTARYFRICTIONINERTIAL));
+ list.Add(new EncoderConfiguration(
+ Constants.EncoderConfigurationNames.WEIGHTEDMOVPULLEYROTARYFRICTION));
} else if(encoderType == Constants.EncoderType.ROTARYAXIS) {
- list.Add(new EncoderModeSelection(
- Constants.EncoderMode.ROTARYAXIS));
- list.Add(new EncoderModeSelection(
- Constants.EncoderMode.ROTARYAXISINERTIAL));
- list.Add(new EncoderModeSelection(
- Constants.EncoderMode.WEIGHTEDMOVPULLEYROTARYAXIS));
+ list.Add(new EncoderConfiguration(
+ Constants.EncoderConfigurationNames.ROTARYAXIS));
+ list.Add(new EncoderConfiguration(
+ Constants.EncoderConfigurationNames.ROTARYAXISINERTIAL));
+ list.Add(new EncoderConfiguration(
+ Constants.EncoderConfigurationNames.WEIGHTEDMOVPULLEYROTARYAXIS));
}
return list;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]