[chronojump] Organized networks compujump code



commit 843e2429127d323ed30a6411266511267a7c13ac
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Jan 30 12:05:36 2020 +0100

    Organized networks compujump code

 po/POTFILES.in                   |   1 +
 src/Makefile.am                  |   4 +
 src/json/compujump.cs            | 516 ---------------------------------------
 src/json/compujumpEncoder.cs     | 274 +++++++++++++++++++++
 src/json/compujumpForceSensor.cs | 114 +++++++++
 src/json/compujumpOther.cs       | 134 ++++++++++
 src/json/compujumpSprint.cs      |  93 +++++++
 7 files changed, 620 insertions(+), 516 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index e9c5e7b6..13643baa 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -114,6 +114,7 @@ src/gui/sprint.cs
 src/gui/stats.cs
 src/gui/webcam.cs
 src/json/compujump.cs
+src/json/compujumpOther.cs
 src/json/json.cs
 src/jumpsProfile.cs
 src/jumpType.cs
diff --git a/src/Makefile.am b/src/Makefile.am
index 1c925308..62587b89 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -182,6 +182,10 @@ SOURCES = \
        json/json.cs\
        json/utils.cs\
        json/compujump.cs\
+       json/compujumpEncoder.cs\
+       json/compujumpForceSensor.cs\
+       json/compujumpSprint.cs\
+       json/compujumpOther.cs\
        json/exhibitions.cs\
        jump.cs\
        jumpsProfile.cs\
diff --git a/src/json/compujump.cs b/src/json/compujump.cs
index 19bc2a2d..86e9a84c 100644
--- a/src/json/compujump.cs
+++ b/src/json/compujump.cs
@@ -739,519 +739,3 @@ public class JsonCompujump : Json
 
        ~JsonCompujump() {}
 }
-
-public class UploadSprintDataObject
-{
-       public int uniqueId; //used for SQL load and delete
-       public int personId;
-       public string sprintPositions;
-       public List<double> splitTimesL;
-       public double k;
-       public double vmax;
-       public double amax;
-       public double fmax;
-       public double pmax;
-
-       public UploadSprintDataObject (int uniqueId, int personId, string sprintPositions, List<double> 
splitTimesL,
-                       double k, double vmax, double amax, double fmax, double pmax)
-       {
-               this.uniqueId = uniqueId;
-               this.personId = personId;
-               this.sprintPositions = sprintPositions;
-               this.splitTimesL = splitTimesL;
-               this.k = k;
-               this.vmax = vmax;
-               this.amax = amax;
-               this.fmax = fmax;
-               this.pmax = pmax;
-       }
-
-       public string ToSQLInsertString ()
-       {
-               return
-                       "NULL, " +
-                       personId.ToString() + ", " +
-                       "\"" + sprintPositions + "\", " +
-                       "\"" + splitTimesLToString() + "\", " +
-                       Util.ConvertToPoint(k) + ", " +
-                       Util.ConvertToPoint(vmax) + ", " +
-                       Util.ConvertToPoint(amax) + ", " +
-                       Util.ConvertToPoint(fmax) + ", " +
-                       Util.ConvertToPoint(pmax) + ")";
-       }
-
-       public static List<double> SplitTimesStringToList(string sqlSelectSplitTimes)
-       {
-               List<double> l = new List<double>();
-               if(sqlSelectSplitTimes == null || sqlSelectSplitTimes == "")
-                       return l;
-
-               string [] myStringFull = sqlSelectSplitTimes.Split(new char[] {';'});
-               foreach (string time in myStringFull)
-                       l.Add(Convert.ToDouble(Util.ChangeDecimalSeparator(time)));
-
-               return l;
-       }
-
-       private string splitTimesLToString()
-       {
-               string str = "";
-               string sep = "";
-               foreach(double d in splitTimesL)
-               {
-                       str += sep + Util.ConvertToPoint(d);
-                       sep = ";";
-               }
-
-               return str;
-       }
-}
-
-public class UploadEncoderDataFullObject
-{
-       public int uniqueId; //used for SQL load and delete
-       public int personId;
-       public int stationId;
-       public int exerciseId;
-       public string laterality;
-       public string resistance;
-       public UploadEncoderDataObject uo;
-
-       public UploadEncoderDataFullObject(int uniqueId, int personId, int stationId, int exerciseId,
-                       string laterality, string resistance, UploadEncoderDataObject uo)
-       {
-               this.uniqueId = uniqueId;
-               this.personId = personId;
-               this.stationId = stationId;
-               this.exerciseId = exerciseId;
-               this.laterality = laterality;
-               this.resistance = resistance;
-               this.uo = uo;
-       }
-
-       public string ToSQLInsertString ()
-       {
-               return
-                       "NULL, " +
-                       personId.ToString() + ", " +
-                       stationId.ToString() + ", " +
-                       exerciseId.ToString() + ", " +
-                       "\"" + laterality + "\", " +
-                       "\"" + resistance + "\", " +
-                       uo.repetitions.ToString() + ", " +
-                       uo.numBySpeed.ToString() + ", " +
-                       uo.lossBySpeed.ToString() + ", " +
-                       "\"" + uo.rangeBySpeed.ToString() + "\", " +
-                       "\"" + uo.vmeanBySpeed.ToString() + "\"," +
-                       "\"" + uo.vmaxBySpeed.ToString() + "\"," +
-                       "\"" + uo.pmeanBySpeed.ToString() + "\"," +
-                       "\"" + uo.pmaxBySpeed.ToString() + "\"," +
-                       uo.numByPower.ToString() + ", " +
-                       uo.lossByPower.ToString() + ", " +
-                       "\"" + uo.rangeByPower.ToString() + "\", " +
-                       "\"" + uo.vmeanByPower.ToString() + "\"," +
-                       "\"" + uo.vmaxByPower.ToString() + "\"," +
-                       "\"" + uo.pmeanByPower.ToString() + "\"," +
-                       "\"" + uo.pmaxByPower.ToString() + "\")";
-       }
-
-}
-
-public class UploadEncoderDataObject
-{
-       private enum byTypes { SPEED, POWER }
-
-       public int repetitions;
-
-       //variables calculated BySpeed (by best mean speed)
-       public int numBySpeed;
-       public int lossBySpeed;
-       public string rangeBySpeed; //strings with . as decimal point
-       public string vmeanBySpeed;
-       public string vmaxBySpeed;
-       public string pmeanBySpeed;
-       public string pmaxBySpeed;
-
-       //variables calculated ByPower (by best mean power)
-       public int numByPower;
-       public int lossByPower;
-       public string rangeByPower; //strings with . as decimal point
-       public string vmeanByPower;
-       public string vmaxByPower;
-       public string pmeanByPower;
-       public string pmaxByPower;
-
-       public double  pmeanByPowerAsDouble;
-
-       private ArrayList curves;
-       private string eccon;
-
-       //constructor called after capture
-       public UploadEncoderDataObject(ArrayList curves, string eccon)
-       {
-               this.curves = curves;
-               this.eccon = eccon;
-       }
-
-       //returns false if on discarding, there are no curves
-       public bool InertialDiscardFirstN(int inertialDiscardFirstN)
-       {
-               if(eccon == "c")
-               {
-                       if(curves.Count > inertialDiscardFirstN)
-                               curves.RemoveRange(0, inertialDiscardFirstN);
-                       else
-                               return false;
-               } else {
-                       if(curves.Count > inertialDiscardFirstN *2)
-                               curves.RemoveRange(0, inertialDiscardFirstN *2);
-                       else
-                               return false;
-               }
-
-               return true;
-       }
-
-       public void Calcule()
-       {
-               if(eccon == "c")
-                       calculeObjectCon (curves);
-               else
-                       calculeObjectEccCon (curves);
-       }
-
-
-       private void calculeObjectCon (ArrayList curves)
-       {
-               repetitions = curves.Count;
-
-               int nSpeed = getBestRep(curves, byTypes.SPEED);
-               int nPower = getBestRep(curves, byTypes.POWER);
-
-               EncoderCurve curveBySpeed = (EncoderCurve) curves[nSpeed];
-               EncoderCurve curveByPower = (EncoderCurve) curves[nPower];
-
-               rangeBySpeed = Util.ConvertToPoint(curveBySpeed.Height);
-               rangeByPower = Util.ConvertToPoint(curveByPower.Height);
-
-               vmeanBySpeed = Util.ConvertToPoint(curveBySpeed.MeanSpeed);
-               vmeanByPower = Util.ConvertToPoint(curveByPower.MeanSpeed);
-               vmaxBySpeed = Util.ConvertToPoint(curveBySpeed.MaxSpeed);
-               vmaxByPower = Util.ConvertToPoint(curveByPower.MaxSpeed);
-
-               pmeanBySpeed = Util.ConvertToPoint(curveBySpeed.MeanPower);
-               pmeanByPower = Util.ConvertToPoint(curveByPower.MeanPower);
-               pmaxBySpeed = Util.ConvertToPoint(curveBySpeed.PeakPower);
-               pmaxByPower = Util.ConvertToPoint(curveByPower.PeakPower);
-
-               pmeanByPowerAsDouble = Convert.ToDouble(curveByPower.MeanPower);
-
-               //add +1 to show to user
-               numBySpeed = nSpeed + 1;
-               numByPower = nPower + 1;
-
-               lossBySpeed = getConLoss(curves, byTypes.SPEED);
-               lossByPower = getConLoss(curves, byTypes.POWER);
-       }
-
-       private void calculeObjectEccCon (ArrayList curves)
-       {
-               repetitions = curves.Count / 2;
-               EncoderSignal eSignal = new EncoderSignal(curves);
-
-               //this n is the n of the ecc curve
-               int nSpeed = eSignal.FindPosOfBestEccCon(0, Constants.MeanSpeed);
-               int nPower = eSignal.FindPosOfBestEccCon(0, Constants.MeanPower);
-
-               rangeBySpeed = Util.ConvertToPoint( eSignal.GetEccConMax(nSpeed, Constants.Range) );
-               rangeByPower = Util.ConvertToPoint( eSignal.GetEccConMax(nPower, Constants.Range) );
-
-               vmeanBySpeed = Util.ConvertToPoint( eSignal.GetEccConMean(nSpeed, Constants.MeanSpeed) );
-               vmeanByPower = Util.ConvertToPoint( eSignal.GetEccConMean(nPower, Constants.MeanSpeed) );
-               vmaxBySpeed = Util.ConvertToPoint( eSignal.GetEccConMax(nSpeed, Constants.MaxSpeed) );
-               vmaxByPower = Util.ConvertToPoint( eSignal.GetEccConMax(nPower, Constants.MaxSpeed) );
-
-               pmeanBySpeed = Util.ConvertToPoint( eSignal.GetEccConMean(nSpeed, Constants.MeanPower) );
-               pmeanByPower = Util.ConvertToPoint( eSignal.GetEccConMean(nPower, Constants.MeanPower) );
-               pmaxBySpeed = Util.ConvertToPoint( eSignal.GetEccConMax(nSpeed, Constants.PeakPower) );
-               pmaxByPower = Util.ConvertToPoint( eSignal.GetEccConMax(nPower, Constants.PeakPower) );
-
-               pmeanByPowerAsDouble = Convert.ToDouble( eSignal.GetEccConMean(nPower, Constants.MeanPower) );
-
-               //add +1 to show to user
-               numBySpeed = (nSpeed /2) + 1;
-               numByPower = (nPower /2) + 1;
-
-               //lossBySpeed = eSignal.GetEccConLoss(Constants.MeanSpeed);
-               //lossByPower = eSignal.GetEccConLoss(Constants.MeanPower);
-               lossBySpeed = eSignal.GetEccConLossByOnlyConPhase(Constants.MeanSpeed);
-               lossByPower = eSignal.GetEccConLossByOnlyConPhase(Constants.MeanPower);
-       }
-
-       //constructor called on SQL load SqliteJson.SelectTempEncoder()
-       public UploadEncoderDataObject(int repetitions,
-                       int numBySpeed, int lossBySpeed, string rangeBySpeed,
-                       string vmeanBySpeed, string vmaxBySpeed, string pmeanBySpeed, string pmaxBySpeed,
-                       int numByPower, int lossByPower, string rangeByPower,
-                       string vmeanByPower, string vmaxByPower, string pmeanByPower, string pmaxByPower)
-       {
-               this.repetitions = repetitions;
-               this.numBySpeed = numBySpeed;
-               this.lossBySpeed = lossBySpeed;
-               this.rangeBySpeed = rangeBySpeed;
-               this.vmeanBySpeed = vmeanBySpeed;
-               this.vmaxBySpeed = vmaxBySpeed;
-               this.pmeanBySpeed = pmeanBySpeed;
-               this.pmaxBySpeed = pmaxBySpeed;
-               this.numByPower = numByPower;
-               this.lossByPower = lossByPower;
-               this.rangeByPower = rangeByPower;
-               this.vmeanByPower = vmeanByPower;
-               this.vmaxByPower = vmaxByPower;
-               this.pmeanByPower = pmeanByPower;
-               this.pmaxByPower = pmaxByPower;
-       }
-
-       private int getBestRep(ArrayList curves, byTypes by)
-       {
-               int curveNum = 0;
-               int i = 0;
-               double highest = 0;
-
-               foreach (EncoderCurve curve in curves)
-               {
-                       double compareTo = curve.MeanSpeedD;
-                       if(by == byTypes.POWER)
-                               compareTo = curve.MeanPowerD;
-
-                       if(compareTo > highest)
-                       {
-                               highest = compareTo;
-                               curveNum = i;
-                       }
-                       i ++;
-               }
-               return curveNum;
-       }
-
-       private int getConLoss(ArrayList curves, byTypes by)
-       {
-               double lowest = 100000;
-               double highest = 0;
-
-               //int i=0;
-               foreach (EncoderCurve curve in curves)
-               {
-                       double compareTo = curve.MeanSpeedD;
-                       if(by == byTypes.POWER)
-                               compareTo = curve.MeanPowerD;
-
-                       if(compareTo < lowest)
-                               lowest = compareTo;
-                       if(compareTo > highest)
-                               highest = compareTo;
-
-                       //LogB.Information(string.Format("Loss (con) of {0}; i: {1} is: {2}", by.ToString(), 
i++, Convert.ToInt32(UtilAll.DivideSafe(100.0 * (highest - lowest), highest))));
-               }
-               return Convert.ToInt32(UtilAll.DivideSafe(100.0 * (highest - lowest), highest));
-       }
-}
-
-public class UploadForceSensorDataFullObject
-{
-       public int uniqueId; //used for SQL load and delete
-       public int personId;
-       public int stationId;
-       public int exerciseId;
-       public string laterality;
-       public string resistance; //stiffness
-       public UploadForceSensorDataObject uo;
-
-       public UploadForceSensorDataFullObject(int uniqueId, int personId, int stationId, int exerciseId,
-                       string laterality, string resistance, UploadForceSensorDataObject uo)
-       {
-               this.uniqueId = uniqueId;
-               this.personId = personId;
-               this.stationId = stationId;
-               this.exerciseId = exerciseId;
-               this.laterality = laterality;
-               this.resistance = resistance;
-               this.uo = uo;
-       }
-
-       public string ToSQLInsertString ()
-       {
-               return
-                       "NULL, " +
-                       personId.ToString() + ", " +
-                       stationId.ToString() + ", " +
-                       exerciseId.ToString() + ", " +
-                       "\"" + laterality + "\", " +
-                       "\"" + resistance + "\", " +
-                       uo.ToString();
-       }
-}
-
-public class UploadForceSensorDataObject
-{
-       public string variability;
-       public string timeTotal;
-       public string impulse;
-       public string workJ;
-       public int repetitions;
-       public int numRep;
-       public string repCriteria;
-       public string time;  //duration?
-       public string range;
-       public string fmaxRaw;
-       public string rfdmeanRaw;
-       public string rfdmaxRaw;
-       public string fmaxModel;
-       public string rfdmaxModel;
-       //only on elastic
-       public string vmean;
-       public string vmax;
-       public string amean;
-       public string amax;
-       public string pmean;
-       public string pmax;
-
-       //constructor called after capture
-       public UploadForceSensorDataObject()
-       {
-       }
-
-       public override string ToString()
-       {
-               return
-                       "\"" + variability.ToString() + "\", " +
-                       "\"" + timeTotal.ToString() + "\"," +
-                       "\"" + impulse.ToString() + "\"," +
-                       "\"" + workJ.ToString() + "\"," +
-                       repetitions.ToString() + "," +
-                       numRep.ToString() + "," +
-                       "\"" + repCriteria.ToString() + "\", " +
-                       "\"" + time.ToString() + "\"," +
-                       "\"" + range.ToString() + "\"," +
-                       "\"" + fmaxRaw.ToString() + "\"," +
-                       "\"" + rfdmeanRaw.ToString() + "\"," +
-                       "\"" + rfdmaxRaw.ToString() + "\"," +
-                       "\"" + fmaxModel.ToString() + "\"," +
-                       "\"" + rfdmaxModel.ToString() + "\"," +
-                       "\"" + vmean.ToString() + "\"," +
-                       "\"" + vmax.ToString() + "\"," +
-                       "\"" + amean.ToString() + "\"," +
-                       "\"" + amax.ToString() + "\"," +
-                       "\"" + pmean.ToString() + "\"," +
-                       "\"" + pmax.ToString() + "\")";
-       }
-}
-
-public class Task
-{
-       public int Id;
-       public char Type; //initially 'P'arametrized or 'F'ree. Now all are 'P'
-       public int PersonId;
-       public int StationId;
-       public int ExerciseId;
-       public string ExerciseName;
-       public int Sets;
-       public int Nreps;
-       public float Load;
-       public float Speed;
-       public float PercentMaxSpeed;
-       public string Laterality;
-       public string Comment;
-
-       public Task()
-       {
-               Id = -1;
-               Comment = "";
-       }
-
-       public Task(int id, int personId, int stationId, int exerciseId, string exerciseName,
-                       int sets, int nreps, float load, float speed, float percentMaxSpeed,
-                       string laterality, string comment)
-       {
-               Type = 'P'; //parametrized
-
-               Id = id;
-               PersonId = personId;
-               StationId = stationId;
-               ExerciseId = exerciseId;
-               ExerciseName = exerciseName;
-               Sets = sets;
-               Nreps = nreps;
-               Load = load;
-               Speed = speed;
-               PercentMaxSpeed = percentMaxSpeed;
-               Laterality = laterality;
-               Comment = comment;
-       }
-
-       public override string ToString()
-       {
-               string sep = "";
-               string str = "";
-               if (Laterality == "R" || Laterality == "L")
-               {
-                       string lateralityStr = Catalog.GetString("Right");
-                       if (Laterality == "L")
-                               lateralityStr = Catalog.GetString("Left");
-
-                       str += sep + lateralityStr;
-                       sep = "; ";
-               }
-               if (Load != -1)
-               {
-                       str += sep + "Càrrega = " + Load.ToString() + " Kg";
-                       sep = "; ";
-               }
-               if (Sets != -1)
-               {
-                       str += sep + "Series = " + Sets.ToString();
-                       sep = "; ";
-               }
-               if (Nreps != -1)
-               {
-                       str += sep + "Repeticions = " + Nreps.ToString();
-                       sep = "; ";
-               }
-               if (Speed != -1)
-               {
-                       str += sep + "Velocitat = " + Speed.ToString() + " m/s";
-                       sep = "; ";
-               }
-               if (PercentMaxSpeed != -1)
-               {
-                       str += sep + "Velocitat = " + PercentMaxSpeed.ToString() + " %";
-                       sep = "; ";
-               }
-               if (Comment != "")
-               {
-                       str += "\n" + Comment;
-               }
-               return ExerciseName + ": " + str;
-       }
-}
-
-public class StationCount
-{
-       private string stationName;
-       private int tasksCount;
-
-       public StationCount()
-       {
-       }
-
-       public StationCount(string name, int count)
-       {
-               stationName = name;
-               tasksCount = count;
-       }
-
-       public override string ToString()
-       {
-               return stationName + " (" + tasksCount.ToString() + ")";
-       }
-}
diff --git a/src/json/compujumpEncoder.cs b/src/json/compujumpEncoder.cs
new file mode 100644
index 00000000..8443801d
--- /dev/null
+++ b/src/json/compujumpEncoder.cs
@@ -0,0 +1,274 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * ChronoJump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Copyright (C) 2016-2017 Carles Pina & Xavier de Blas
+ */
+
+using System;
+using System.Text;
+using System.Collections;
+
+
+public class UploadEncoderDataFullObject
+{
+       public int uniqueId; //used for SQL load and delete
+       public int personId;
+       public int stationId;
+       public int exerciseId;
+       public string laterality;
+       public string resistance;
+       public UploadEncoderDataObject uo;
+
+       public UploadEncoderDataFullObject(int uniqueId, int personId, int stationId, int exerciseId,
+                       string laterality, string resistance, UploadEncoderDataObject uo)
+       {
+               this.uniqueId = uniqueId;
+               this.personId = personId;
+               this.stationId = stationId;
+               this.exerciseId = exerciseId;
+               this.laterality = laterality;
+               this.resistance = resistance;
+               this.uo = uo;
+       }
+
+       public string ToSQLInsertString ()
+       {
+               return
+                       "NULL, " +
+                       personId.ToString() + ", " +
+                       stationId.ToString() + ", " +
+                       exerciseId.ToString() + ", " +
+                       "\"" + laterality + "\", " +
+                       "\"" + resistance + "\", " +
+                       uo.repetitions.ToString() + ", " +
+                       uo.numBySpeed.ToString() + ", " +
+                       uo.lossBySpeed.ToString() + ", " +
+                       "\"" + uo.rangeBySpeed.ToString() + "\", " +
+                       "\"" + uo.vmeanBySpeed.ToString() + "\"," +
+                       "\"" + uo.vmaxBySpeed.ToString() + "\"," +
+                       "\"" + uo.pmeanBySpeed.ToString() + "\"," +
+                       "\"" + uo.pmaxBySpeed.ToString() + "\"," +
+                       uo.numByPower.ToString() + ", " +
+                       uo.lossByPower.ToString() + ", " +
+                       "\"" + uo.rangeByPower.ToString() + "\", " +
+                       "\"" + uo.vmeanByPower.ToString() + "\"," +
+                       "\"" + uo.vmaxByPower.ToString() + "\"," +
+                       "\"" + uo.pmeanByPower.ToString() + "\"," +
+                       "\"" + uo.pmaxByPower.ToString() + "\")";
+       }
+
+}
+
+public class UploadEncoderDataObject
+{
+       private enum byTypes { SPEED, POWER }
+
+       public int repetitions;
+
+       //variables calculated BySpeed (by best mean speed)
+       public int numBySpeed;
+       public int lossBySpeed;
+       public string rangeBySpeed; //strings with . as decimal point
+       public string vmeanBySpeed;
+       public string vmaxBySpeed;
+       public string pmeanBySpeed;
+       public string pmaxBySpeed;
+
+       //variables calculated ByPower (by best mean power)
+       public int numByPower;
+       public int lossByPower;
+       public string rangeByPower; //strings with . as decimal point
+       public string vmeanByPower;
+       public string vmaxByPower;
+       public string pmeanByPower;
+       public string pmaxByPower;
+
+       public double  pmeanByPowerAsDouble;
+
+       private ArrayList curves;
+       private string eccon;
+
+       //constructor called after capture
+       public UploadEncoderDataObject(ArrayList curves, string eccon)
+       {
+               this.curves = curves;
+               this.eccon = eccon;
+       }
+
+       //returns false if on discarding, there are no curves
+       public bool InertialDiscardFirstN(int inertialDiscardFirstN)
+       {
+               if(eccon == "c")
+               {
+                       if(curves.Count > inertialDiscardFirstN)
+                               curves.RemoveRange(0, inertialDiscardFirstN);
+                       else
+                               return false;
+               } else {
+                       if(curves.Count > inertialDiscardFirstN *2)
+                               curves.RemoveRange(0, inertialDiscardFirstN *2);
+                       else
+                               return false;
+               }
+
+               return true;
+       }
+
+       public void Calcule()
+       {
+               if(eccon == "c")
+                       calculeObjectCon (curves);
+               else
+                       calculeObjectEccCon (curves);
+       }
+
+
+       private void calculeObjectCon (ArrayList curves)
+       {
+               repetitions = curves.Count;
+
+               int nSpeed = getBestRep(curves, byTypes.SPEED);
+               int nPower = getBestRep(curves, byTypes.POWER);
+
+               EncoderCurve curveBySpeed = (EncoderCurve) curves[nSpeed];
+               EncoderCurve curveByPower = (EncoderCurve) curves[nPower];
+
+               rangeBySpeed = Util.ConvertToPoint(curveBySpeed.Height);
+               rangeByPower = Util.ConvertToPoint(curveByPower.Height);
+
+               vmeanBySpeed = Util.ConvertToPoint(curveBySpeed.MeanSpeed);
+               vmeanByPower = Util.ConvertToPoint(curveByPower.MeanSpeed);
+               vmaxBySpeed = Util.ConvertToPoint(curveBySpeed.MaxSpeed);
+               vmaxByPower = Util.ConvertToPoint(curveByPower.MaxSpeed);
+
+               pmeanBySpeed = Util.ConvertToPoint(curveBySpeed.MeanPower);
+               pmeanByPower = Util.ConvertToPoint(curveByPower.MeanPower);
+               pmaxBySpeed = Util.ConvertToPoint(curveBySpeed.PeakPower);
+               pmaxByPower = Util.ConvertToPoint(curveByPower.PeakPower);
+
+               pmeanByPowerAsDouble = Convert.ToDouble(curveByPower.MeanPower);
+
+               //add +1 to show to user
+               numBySpeed = nSpeed + 1;
+               numByPower = nPower + 1;
+
+               lossBySpeed = getConLoss(curves, byTypes.SPEED);
+               lossByPower = getConLoss(curves, byTypes.POWER);
+       }
+
+       private void calculeObjectEccCon (ArrayList curves)
+       {
+               repetitions = curves.Count / 2;
+               EncoderSignal eSignal = new EncoderSignal(curves);
+
+               //this n is the n of the ecc curve
+               int nSpeed = eSignal.FindPosOfBestEccCon(0, Constants.MeanSpeed);
+               int nPower = eSignal.FindPosOfBestEccCon(0, Constants.MeanPower);
+
+               rangeBySpeed = Util.ConvertToPoint( eSignal.GetEccConMax(nSpeed, Constants.Range) );
+               rangeByPower = Util.ConvertToPoint( eSignal.GetEccConMax(nPower, Constants.Range) );
+
+               vmeanBySpeed = Util.ConvertToPoint( eSignal.GetEccConMean(nSpeed, Constants.MeanSpeed) );
+               vmeanByPower = Util.ConvertToPoint( eSignal.GetEccConMean(nPower, Constants.MeanSpeed) );
+               vmaxBySpeed = Util.ConvertToPoint( eSignal.GetEccConMax(nSpeed, Constants.MaxSpeed) );
+               vmaxByPower = Util.ConvertToPoint( eSignal.GetEccConMax(nPower, Constants.MaxSpeed) );
+
+               pmeanBySpeed = Util.ConvertToPoint( eSignal.GetEccConMean(nSpeed, Constants.MeanPower) );
+               pmeanByPower = Util.ConvertToPoint( eSignal.GetEccConMean(nPower, Constants.MeanPower) );
+               pmaxBySpeed = Util.ConvertToPoint( eSignal.GetEccConMax(nSpeed, Constants.PeakPower) );
+               pmaxByPower = Util.ConvertToPoint( eSignal.GetEccConMax(nPower, Constants.PeakPower) );
+
+               pmeanByPowerAsDouble = Convert.ToDouble( eSignal.GetEccConMean(nPower, Constants.MeanPower) );
+
+               //add +1 to show to user
+               numBySpeed = (nSpeed /2) + 1;
+               numByPower = (nPower /2) + 1;
+
+               //lossBySpeed = eSignal.GetEccConLoss(Constants.MeanSpeed);
+               //lossByPower = eSignal.GetEccConLoss(Constants.MeanPower);
+               lossBySpeed = eSignal.GetEccConLossByOnlyConPhase(Constants.MeanSpeed);
+               lossByPower = eSignal.GetEccConLossByOnlyConPhase(Constants.MeanPower);
+       }
+
+       //constructor called on SQL load SqliteJson.SelectTempEncoder()
+       public UploadEncoderDataObject(int repetitions,
+                       int numBySpeed, int lossBySpeed, string rangeBySpeed,
+                       string vmeanBySpeed, string vmaxBySpeed, string pmeanBySpeed, string pmaxBySpeed,
+                       int numByPower, int lossByPower, string rangeByPower,
+                       string vmeanByPower, string vmaxByPower, string pmeanByPower, string pmaxByPower)
+       {
+               this.repetitions = repetitions;
+               this.numBySpeed = numBySpeed;
+               this.lossBySpeed = lossBySpeed;
+               this.rangeBySpeed = rangeBySpeed;
+               this.vmeanBySpeed = vmeanBySpeed;
+               this.vmaxBySpeed = vmaxBySpeed;
+               this.pmeanBySpeed = pmeanBySpeed;
+               this.pmaxBySpeed = pmaxBySpeed;
+               this.numByPower = numByPower;
+               this.lossByPower = lossByPower;
+               this.rangeByPower = rangeByPower;
+               this.vmeanByPower = vmeanByPower;
+               this.vmaxByPower = vmaxByPower;
+               this.pmeanByPower = pmeanByPower;
+               this.pmaxByPower = pmaxByPower;
+       }
+
+       private int getBestRep(ArrayList curves, byTypes by)
+       {
+               int curveNum = 0;
+               int i = 0;
+               double highest = 0;
+
+               foreach (EncoderCurve curve in curves)
+               {
+                       double compareTo = curve.MeanSpeedD;
+                       if(by == byTypes.POWER)
+                               compareTo = curve.MeanPowerD;
+
+                       if(compareTo > highest)
+                       {
+                               highest = compareTo;
+                               curveNum = i;
+                       }
+                       i ++;
+               }
+               return curveNum;
+       }
+
+       private int getConLoss(ArrayList curves, byTypes by)
+       {
+               double lowest = 100000;
+               double highest = 0;
+
+               //int i=0;
+               foreach (EncoderCurve curve in curves)
+               {
+                       double compareTo = curve.MeanSpeedD;
+                       if(by == byTypes.POWER)
+                               compareTo = curve.MeanPowerD;
+
+                       if(compareTo < lowest)
+                               lowest = compareTo;
+                       if(compareTo > highest)
+                               highest = compareTo;
+
+                       //LogB.Information(string.Format("Loss (con) of {0}; i: {1} is: {2}", by.ToString(), 
i++, Convert.ToInt32(UtilAll.DivideSafe(100.0 * (highest - lowest), highest))));
+               }
+               return Convert.ToInt32(UtilAll.DivideSafe(100.0 * (highest - lowest), highest));
+       }
+}
diff --git a/src/json/compujumpForceSensor.cs b/src/json/compujumpForceSensor.cs
new file mode 100644
index 00000000..a0a260cd
--- /dev/null
+++ b/src/json/compujumpForceSensor.cs
@@ -0,0 +1,114 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * ChronoJump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Copyright (C) 2016-2017 Carles Pina & Xavier de Blas
+ */
+
+using System;
+using System.Text;
+using System.Collections;
+
+
+public class UploadForceSensorDataFullObject
+{
+       public int uniqueId; //used for SQL load and delete
+       public int personId;
+       public int stationId;
+       public int exerciseId;
+       public string laterality;
+       public string resistance; //stiffness
+       public UploadForceSensorDataObject uo;
+
+       public UploadForceSensorDataFullObject(int uniqueId, int personId, int stationId, int exerciseId,
+                       string laterality, string resistance, UploadForceSensorDataObject uo)
+       {
+               this.uniqueId = uniqueId;
+               this.personId = personId;
+               this.stationId = stationId;
+               this.exerciseId = exerciseId;
+               this.laterality = laterality;
+               this.resistance = resistance;
+               this.uo = uo;
+       }
+
+       public string ToSQLInsertString ()
+       {
+               return
+                       "NULL, " +
+                       personId.ToString() + ", " +
+                       stationId.ToString() + ", " +
+                       exerciseId.ToString() + ", " +
+                       "\"" + laterality + "\", " +
+                       "\"" + resistance + "\", " +
+                       uo.ToString();
+       }
+}
+
+public class UploadForceSensorDataObject
+{
+       public string variability;
+       public string timeTotal;
+       public string impulse;
+       public string workJ;
+       public int repetitions;
+       public int numRep;
+       public string repCriteria;
+       public string time;  //duration?
+       public string range;
+       public string fmaxRaw;
+       public string rfdmeanRaw;
+       public string rfdmaxRaw;
+       public string fmaxModel;
+       public string rfdmaxModel;
+       //only on elastic
+       public string vmean;
+       public string vmax;
+       public string amean;
+       public string amax;
+       public string pmean;
+       public string pmax;
+
+       //constructor called after capture
+       public UploadForceSensorDataObject()
+       {
+       }
+
+       public override string ToString()
+       {
+               return
+                       "\"" + variability.ToString() + "\", " +
+                       "\"" + timeTotal.ToString() + "\"," +
+                       "\"" + impulse.ToString() + "\"," +
+                       "\"" + workJ.ToString() + "\"," +
+                       repetitions.ToString() + "," +
+                       numRep.ToString() + "," +
+                       "\"" + repCriteria.ToString() + "\", " +
+                       "\"" + time.ToString() + "\"," +
+                       "\"" + range.ToString() + "\"," +
+                       "\"" + fmaxRaw.ToString() + "\"," +
+                       "\"" + rfdmeanRaw.ToString() + "\"," +
+                       "\"" + rfdmaxRaw.ToString() + "\"," +
+                       "\"" + fmaxModel.ToString() + "\"," +
+                       "\"" + rfdmaxModel.ToString() + "\"," +
+                       "\"" + vmean.ToString() + "\"," +
+                       "\"" + vmax.ToString() + "\"," +
+                       "\"" + amean.ToString() + "\"," +
+                       "\"" + amax.ToString() + "\"," +
+                       "\"" + pmean.ToString() + "\"," +
+                       "\"" + pmax.ToString() + "\")";
+       }
+}
diff --git a/src/json/compujumpOther.cs b/src/json/compujumpOther.cs
new file mode 100644
index 00000000..32251b7e
--- /dev/null
+++ b/src/json/compujumpOther.cs
@@ -0,0 +1,134 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * ChronoJump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Copyright (C) 2016-2017 Carles Pina & Xavier de Blas
+ */
+
+using System;
+using System.Text;
+using System.Collections;
+using Mono.Unix;
+
+
+public class Task
+{
+       public int Id;
+       public char Type; //initially 'P'arametrized or 'F'ree. Now all are 'P'
+       public int PersonId;
+       public int StationId;
+       public int ExerciseId;
+       public string ExerciseName;
+       public int Sets;
+       public int Nreps;
+       public float Load;
+       public float Speed;
+       public float PercentMaxSpeed;
+       public string Laterality;
+       public string Comment;
+
+       public Task()
+       {
+               Id = -1;
+               Comment = "";
+       }
+
+       public Task(int id, int personId, int stationId, int exerciseId, string exerciseName,
+                       int sets, int nreps, float load, float speed, float percentMaxSpeed,
+                       string laterality, string comment)
+       {
+               Type = 'P'; //parametrized
+
+               Id = id;
+               PersonId = personId;
+               StationId = stationId;
+               ExerciseId = exerciseId;
+               ExerciseName = exerciseName;
+               Sets = sets;
+               Nreps = nreps;
+               Load = load;
+               Speed = speed;
+               PercentMaxSpeed = percentMaxSpeed;
+               Laterality = laterality;
+               Comment = comment;
+       }
+
+       public override string ToString()
+       {
+               string sep = "";
+               string str = "";
+               if (Laterality == "R" || Laterality == "L")
+               {
+                       string lateralityStr = Catalog.GetString("Right");
+                       if (Laterality == "L")
+                               lateralityStr = Catalog.GetString("Left");
+
+                       str += sep + lateralityStr;
+                       sep = "; ";
+               }
+               if (Load != -1)
+               {
+                       str += sep + "Càrrega = " + Load.ToString() + " Kg";
+                       sep = "; ";
+               }
+               if (Sets != -1)
+               {
+                       str += sep + "Series = " + Sets.ToString();
+                       sep = "; ";
+               }
+               if (Nreps != -1)
+               {
+                       str += sep + "Repeticions = " + Nreps.ToString();
+                       sep = "; ";
+               }
+               if (Speed != -1)
+               {
+                       str += sep + "Velocitat = " + Speed.ToString() + " m/s";
+                       sep = "; ";
+               }
+               if (PercentMaxSpeed != -1)
+               {
+                       str += sep + "Velocitat = " + PercentMaxSpeed.ToString() + " %";
+                       sep = "; ";
+               }
+               if (Comment != "")
+               {
+                       str += "\n" + Comment;
+               }
+               return ExerciseName + ": " + str;
+       }
+}
+
+public class StationCount
+{
+       private string stationName;
+       private int tasksCount;
+
+       public StationCount()
+       {
+       }
+
+       public StationCount(string name, int count)
+       {
+               stationName = name;
+               tasksCount = count;
+       }
+
+       public override string ToString()
+       {
+               return stationName + " (" + tasksCount.ToString() + ")";
+       }
+}
diff --git a/src/json/compujumpSprint.cs b/src/json/compujumpSprint.cs
new file mode 100644
index 00000000..45248728
--- /dev/null
+++ b/src/json/compujumpSprint.cs
@@ -0,0 +1,93 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * ChronoJump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Copyright (C) 2016-2017 Carles Pina & Xavier de Blas
+ */
+
+using System;
+using System.Text;
+using System.Collections;
+using System.Collections.Generic; //List<T>
+
+
+public class UploadSprintDataObject
+{
+       public int uniqueId; //used for SQL load and delete
+       public int personId;
+       public string sprintPositions;
+       public List<double> splitTimesL;
+       public double k;
+       public double vmax;
+       public double amax;
+       public double fmax;
+       public double pmax;
+
+       public UploadSprintDataObject (int uniqueId, int personId, string sprintPositions, List<double> 
splitTimesL,
+                       double k, double vmax, double amax, double fmax, double pmax)
+       {
+               this.uniqueId = uniqueId;
+               this.personId = personId;
+               this.sprintPositions = sprintPositions;
+               this.splitTimesL = splitTimesL;
+               this.k = k;
+               this.vmax = vmax;
+               this.amax = amax;
+               this.fmax = fmax;
+               this.pmax = pmax;
+       }
+
+       public string ToSQLInsertString ()
+       {
+               return
+                       "NULL, " +
+                       personId.ToString() + ", " +
+                       "\"" + sprintPositions + "\", " +
+                       "\"" + splitTimesLToString() + "\", " +
+                       Util.ConvertToPoint(k) + ", " +
+                       Util.ConvertToPoint(vmax) + ", " +
+                       Util.ConvertToPoint(amax) + ", " +
+                       Util.ConvertToPoint(fmax) + ", " +
+                       Util.ConvertToPoint(pmax) + ")";
+       }
+
+       public static List<double> SplitTimesStringToList(string sqlSelectSplitTimes)
+       {
+               List<double> l = new List<double>();
+               if(sqlSelectSplitTimes == null || sqlSelectSplitTimes == "")
+                       return l;
+
+               string [] myStringFull = sqlSelectSplitTimes.Split(new char[] {';'});
+               foreach (string time in myStringFull)
+                       l.Add(Convert.ToDouble(Util.ChangeDecimalSeparator(time)));
+
+               return l;
+       }
+
+       private string splitTimesLToString()
+       {
+               string str = "";
+               string sep = "";
+               foreach(double d in splitTimesL)
+               {
+                       str += sep + Util.ConvertToPoint(d);
+                       sep = ";";
+               }
+
+               return str;
+       }
+}
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]