[chronojump] Networks allow to download encoder exercises with 3.1 code
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Networks allow to download encoder exercises with 3.1 code
- Date: Tue, 8 Feb 2022 16:26:35 +0000 (UTC)
commit 4523aaf40a892511fe89c3b04de0f817cd2cdd78
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Feb 8 17:26:13 2022 +0100
Networks allow to download encoder exercises with 3.1 code
src/gui/networks.cs | 5 +----
src/json/compujump.cs | 38 +++++++++++++++++++++++++++++---------
2 files changed, 30 insertions(+), 13 deletions(-)
---
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index 4b928643d..bf1caa70a 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -985,8 +985,6 @@ public partial class ChronoJumpWindow
tasks = new TaskDeserialize().DeserializeTaskEncoder(tasksStr);
}
- /*
- TODO: disabled temporarily
//3) get exercises and insert if needed (only on encoder)
if(configChronojump.CompujumpStationMode == Constants.Modes.POWERGRAVITATORY ||
configChronojump.CompujumpStationMode == Constants.Modes.POWERINERTIAL)
@@ -1012,12 +1010,11 @@ public partial class ChronoJumpWindow
{
SqliteEncoder.InsertExercise(
false, exRemote.uniqueID, exRemote.name,
exRemote.percentBodyWeight,
- "", "", "", type); //ressitance, description,
speed1RM, type (encoderGI)
+ "", "", "", type);
updateEncoderExercisesGui(exRemote.name);
}
}
}
- */
//4) get other stationsCount
List<StationCount> stationsCount =
json.GetOtherStationsWithPendingTasks(currentPerson.UniqueID, configChronojump.CompujumpStationID);
diff --git a/src/json/compujump.cs b/src/json/compujump.cs
index 4a7def29f..4ff3845e9 100644
--- a/src/json/compujump.cs
+++ b/src/json/compujump.cs
@@ -339,26 +339,46 @@ public class JsonCompujump : Json
else if(responseFromServer == "[]")
LogB.Information(" Empty2 "); //when rfid is not on server
else {
- ex_list = stationExercisesDeserialize(responseFromServer, stationType);
+ ex_list = stationExercisesDeserialize(responseFromServer, stationId, stationType);
}
return ex_list;
}
- private List<EncoderExercise> stationExercisesDeserialize(string str, Constants.EncoderGI stationType)
+ private List<EncoderExercise> stationExercisesDeserialize(string str, int stationId,
Constants.EncoderGI stationType)
{
List<EncoderExercise> ex_list = new List<EncoderExercise>();
-
JsonValue jsonStationExercises = JsonValue.Parse (str);
foreach (JsonValue jsonSE in jsonStationExercises)
{
- Int32 id = jsonSE ["id"];
- string name = jsonSE ["name"];
- //Int32 stationId = jsonSE ["station_id"];
- int percentBodyMassDisplaced = jsonSE ["percent_body_mass_displaced"];
+ // 1) discard exercise if is not for this station
+ JsonValue jsonSEStations = JsonValue.Parse (jsonSE["stations"].ToString());
+ bool exerciseForThisStation = false;
+ foreach (JsonValue jsonSEStation in jsonSEStations)
+ {
+ Int32 stations_id = jsonSEStation ["id"];
+ if(stations_id == stationId)
+ exerciseForThisStation = true;
+ }
+
+ if(! exerciseForThisStation)
+ continue;
+
+ // 2) discard if is not for this station type
+ string type = jsonSE ["measurable"];
+ Constants.EncoderGI newExEncoderGi = Constants.EncoderGI.GRAVITATORY;
+ if(type == "I")
+ newExEncoderGi = Constants.EncoderGI.INERTIAL;
+
+ if(stationType != newExEncoderGi)
+ continue;
- ex_list.Add(new EncoderExercise(id, name, percentBodyMassDisplaced,
- "", "", 0, stationType)); //resistance, description, speed1RM,
stationType
+ // 3) add exercise to the list
+ Int32 newExId = jsonSE ["id"];
+ string newExName = jsonSE ["name"];
+ int newExPercentBodyMassDisplaced = jsonSE
["measurable_info"]["percent_body_mass_displaced"];
+ ex_list.Add(new EncoderExercise(newExId, newExName, newExPercentBodyMassDisplaced,
+ "", "", 0, newExEncoderGi));
}
return ex_list;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]