public static void savePatientJson(string path, Patient patient) { string json = JsonConvert.SerializeObject(patient); File.WriteAllText(path, json); }
private void startTraject() { patient = new Patient(naam); meetsessie = new Meetsessie(leeftijd, gewicht); patient.meetsessies.Add(meetsessie); int amount_of_seconds = (minutes * 60) + seconds; int sec_per_stap = amount_of_seconds / 10; int amount_per_stap = (maxPower - 25) / 10; int currentPower = 25; int tick = sec_per_stap; bicycle.sendData("CM"); bicycle.sendData("PW " + currentPower); bicycle.sendData("CM"); bicycle.sendData("PT " + Math.Floor(Convert.ToDecimal(amount_of_seconds / 60)) + ":" + Convert.ToDecimal(amount_of_seconds % 60)); while (amount_of_seconds != 0) { bicycle.sendData(ConnectionToBicycle.STATUS); if (tick == 0) { tick = sec_per_stap; currentPower += amount_per_stap; bicycle.sendData("CM"); bicycle.sendData("PW " + currentPower); bicycle.sendData("CM"); bicycle.sendData("PT " + Math.Floor(Convert.ToDecimal(amount_of_seconds / 60)) + ":" + Convert.ToDecimal(amount_of_seconds % 60)); } else tick--; Thread.Sleep(1000); amount_of_seconds--; Action min = () => patientScherm.Minutes.Value = Math.Floor(Convert.ToDecimal(amount_of_seconds / 60)); patientScherm.WaarschuwingLabel.Invoke(min); Action sec = () => patientScherm.Seconds.Value = Convert.ToDecimal(amount_of_seconds % 60); patientScherm.WaarschuwingLabel.Invoke(sec); } Action pre = () => patientScherm.Stop_button.PerformClick(); patientScherm.WaarschuwingLabel.Invoke(pre); }
//sending patient public static void SendPatient(TcpClient client, Patient patient) { string json = JsonConvert.SerializeObject(patient); WriteMessage(client, "1|" + json); }