[chronojump] Improvements on Compujump communication



commit 763f00b1bcd51bca00372f3741f801291fb499bf
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Jun 26 19:45:25 2017 +0200

    Improvements on Compujump communication

 src/config.cs       |    6 +++---
 src/gui/encoder.cs  |    5 +++--
 src/gui/networks.cs |   15 ++++++++++++++-
 src/json.cs         |   13 ++++++++-----
 4 files changed, 28 insertions(+), 11 deletions(-)
---
diff --git a/src/config.cs b/src/config.cs
index 1b4061e..0cfec47 100644
--- a/src/config.cs
+++ b/src/config.cs
@@ -39,7 +39,7 @@ public class Config
        public SessionModeEnum SessionMode;
        public bool Compujump;
        public string CompujumpServerURL = "";
-       public int CompujumpStationNum = -1;
+       public int CompujumpStationID = -1;
        public Constants.Menuitem_modes CompujumpStationMode = Constants.Menuitem_modes.UNDEFINED;
        public string RunScriptOnExit;
 
@@ -85,8 +85,8 @@ public class Config
                                                Compujump = true;
                                        else if(parts[0] == "CompujumpServerURL" && parts[1] != "")
                                                CompujumpServerURL = parts[1];
-                                       else if(parts[0] == "CompujumpStationNum" && parts[1] != "" && 
Util.IsNumber(parts[1], false))
-                                               CompujumpStationNum = Convert.ToInt32(parts[1]);
+                                       else if(parts[0] == "CompujumpStationID" && parts[1] != "" && 
Util.IsNumber(parts[1], false))
+                                               CompujumpStationID = Convert.ToInt32(parts[1]);
                                        else if(parts[0] == "CompujumpStationMode" && 
Enum.IsDefined(typeof(Constants.Menuitem_modes), parts[1]))
                                                CompujumpStationMode = (Constants.Menuitem_modes)
                                                        Enum.Parse(typeof(Constants.Menuitem_modes), 
parts[1]);
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 0ca7559..3a3c0d8 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -6038,8 +6038,9 @@ public partial class ChronoJumpWindow
                                                        Json js = new Json();
                                                        bool success = js.UploadEncoderData(
                                                                        currentPerson.UniqueID,
-                                                                       1,
-                                                                       
UtilGtk.ComboGetActive(combo_encoder_exercise_capture),
+                                                                       configChronojump.CompujumpStationID,
+                                                                       
//UtilGtk.ComboGetActive(combo_encoder_exercise_capture),
+                                                                       1, //exerciseID
                                                                        
Util.ConvertToPoint(findMass(Constants.MassType.DISPLACED)), //this is only for gravitatory
                                                                        uo);
                                                        LogB.Information(js.ResultMessage);
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index 70394fb..b722b4d 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -406,7 +406,7 @@ public partial class ChronoJumpWindow
                                currentPerson = p;
                                currentPersonSession = new PersonSession (
                                                currentPerson.UniqueID, currentSession.UniqueID, 
-                                               0, json.LastPersonByRFIDWeight,
+                                               json.LastPersonByRFIDHeight, json.LastPersonByRFIDWeight,
                                                Constants.SportUndefinedID, 
                                                Constants.SpeciallityUndefinedID, 
                                                Constants.LevelUndefinedID,
@@ -429,6 +429,19 @@ public partial class ChronoJumpWindow
                else {
                        LogB.Information("RFID person exists!!");
                        currentPerson = p;
+
+                       PersonSession ps = SqlitePersonSession.Select(false, p.UniqueID, 
currentSession.UniqueID);
+                       if(ps == null)
+                               currentPersonSession = new PersonSession (
+                                               p.UniqueID, currentSession.UniqueID,
+                                               json.LastPersonByRFIDHeight, json.LastPersonByRFIDWeight,
+                                               Constants.SportUndefinedID,
+                                               Constants.SpeciallityUndefinedID,
+                                               Constants.LevelUndefinedID,
+                                               "", false); //comments, dbconOpened
+                       else
+                               currentPersonSession = ps;
+
                        personChanged(); //GTK
                        label_person_change();
                        pChanged = true;
diff --git a/src/json.cs b/src/json.cs
index f9de539..f762d11 100644
--- a/src/json.cs
+++ b/src/json.cs
@@ -337,6 +337,7 @@ public class Json
                return person;
 
        }
+       public double LastPersonByRFIDHeight = 0;
        public double LastPersonByRFIDWeight = 0;
        public string LastPersonByRFIDImageURL = "";
        private Person personDeserialize(string strPerson)
@@ -350,6 +351,7 @@ public class Json
                string rfid = jsonPerson ["rfid"];
                string image = jsonPerson ["imageName"];
 
+               LastPersonByRFIDHeight = height;
                LastPersonByRFIDWeight = weight;
                LastPersonByRFIDImageURL = image;
 
@@ -361,7 +363,7 @@ public class Json
        private string getImagesUrl()
        {
                int posOfLastColon = serverUrl.LastIndexOf(':');
-               return serverUrl.Substring(0, posOfLastColon) + ":5000/static/images/";
+               return serverUrl.Substring(0, posOfLastColon) + ":5000/static/images/photos/";
        }
 
        //imageHalfUrl is "jugadors/*.jpg"
@@ -577,7 +579,7 @@ public class Json
                return UploadEncoderData(1, 1, "40.2", "lateral", "8100.5", 8);
        }
        */
-       public bool UploadEncoderData(int personId, int machineId, string exerciseName, string resistance, 
UploadEncoderDataObject uo)
+       public bool UploadEncoderData(int personId, int stationId, int exerciseId, string resistance, 
UploadEncoderDataObject uo)
        {
                // Create a request using a URL that can receive a post.
                WebRequest request = WebRequest.Create (serverUrl + "/uploadEncoderData");
@@ -587,14 +589,15 @@ public class Json
 
                // Set the ContentType property of the WebRequest.
                request.ContentType = "application/json; Charset=UTF-8"; //but this is not enough, see this 
line:
-               exerciseName = Util.RemoveAccents(exerciseName);
+               //exerciseName = Util.RemoveAccents(exerciseName);
 
                // Creates the json object
                JsonObject json = new JsonObject();
 
                json.Add("personId", personId);
-               json.Add("machineId", machineId);
-               json.Add("exerciseName", exerciseName);
+               json.Add("stationId", stationId);
+               //json.Add("exerciseName", exerciseName);
+               json.Add("exerciseId", exerciseId);
                json.Add("resistance", resistance);
                json.Add("repetitions", uo.repetitions);
 


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