[chronojump] Compujump: upload correctly sprint times on 4 columns



commit 6e8b4a01c58f63453043f2343976f6056693d2d7
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Sep 18 11:46:37 2017 +0200

    Compujump: upload correctly sprint times on 4 columns

 src/gui/chronojump.cs |    5 ++++-
 src/json.cs           |   30 ++++++++++++++++++++++++++++--
 src/sprint.cs         |   20 ++++++++++++++++++++
 3 files changed, 52 insertions(+), 3 deletions(-)
---
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 2c765b1..0afd830 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -4595,7 +4595,10 @@ public partial class ChronoJumpWindow
                double pmax = Convert.ToDouble(Util.ChangeDecimalSeparator(results[14])); //pmax.rel.fitted
 
                Json js = new Json();
-               js.UploadSprintData(currentPerson.UniqueID, sprint, k, vmax, amax, fmax, pmax);
+               js.UploadSprintData(
+                               currentPerson.UniqueID,
+                               sprint, sprint.GetSplitTimesAsList(),
+                               k, vmax, amax, fmax, pmax);
        }
 
        /* ---------------------------------------------------------
diff --git a/src/json.cs b/src/json.cs
index 9fd54a8..3b0b3a3 100644
--- a/src/json.cs
+++ b/src/json.cs
@@ -781,12 +781,20 @@ public class Json
        }
        */
 
-       public bool UploadSprintData(int personId, Sprint sprint, double k, double vmax, double amax, double 
fmax, double pmax )
+       public bool UploadSprintData(int personId, Sprint sprint, List<double> splitTimesL,
+                       double k, double vmax, double amax, double fmax, double pmax )
        {
                LogB.Information("calling upload sprint");
                // Create a request using a URL that can receive a post.
                WebRequest request = WebRequest.Create (serverUrl + "/uploadSprintData");
 
+
+               /*
+               LogB.Information("UploadSprintData doubles:");
+               foreach(double d in splitTimesL)
+                       LogB.Information(d.ToString());
+                       */
+
                // Set the Method property of the request to POST.
                request.Method = "POST";
 
@@ -799,7 +807,25 @@ public class Json
 
                json.Add("personId", personId);
                json.Add("distances", sprint.Positions);
-               json.Add("times", sprint.SplitTimes);
+               //json.Add("times", sprint.SplitTimes);
+               json.Add("t1", splitTimesL[1]);
+
+               //splitTimesL starts with a 0 that is not passed
+               if(splitTimesL.Count >= 3)
+                       json.Add("t2", splitTimesL[2] - splitTimesL[1]); //return lap (partial time) and not 
split (accumulated time)
+               else
+                       json.Add("t2", "");
+
+               if(splitTimesL.Count >= 4)
+                       json.Add("t3", splitTimesL[3] - splitTimesL[2]);
+               else
+                       json.Add("t3", "");
+
+               if(splitTimesL.Count >= 5)
+                       json.Add("t4", splitTimesL[4] - splitTimesL[3]);
+               else
+                       json.Add("t4", "");
+
                json.Add("k", k);
                json.Add("vmax", vmax);
                json.Add("amax", amax);
diff --git a/src/sprint.cs b/src/sprint.cs
index 3dc3676..0027274 100644
--- a/src/sprint.cs
+++ b/src/sprint.cs
@@ -119,6 +119,26 @@ public class Sprint
                ((IDisposable)writer).Dispose();
        }
 
+       public List<double> GetSplitTimesAsList()
+       {
+               string [] splitTimesArray = splitTimes.Split(new char[] {';'});
+
+               List<double> splitTimesList = new List<double>();
+               int count = 0;
+               foreach(string time in splitTimesArray)
+               {
+                       double timeD = Convert.ToDouble(time);
+
+                       //convert from milliseconds to seconds
+                       if(timeD > 0)
+                               timeD /= 1000;
+
+                       splitTimesList.Add(timeD);
+               }
+
+               return splitTimesList;
+       }
+
        public string Positions {
                get { return positions; }
        }


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