public static Boolean AddErgometerDataToSession(string username, ErgometerData data)
 {
     if (ActiveTrainSessions.ContainsKey(username))
     {
         ((TrainSession)ActiveTrainSessions[username]).AddData(data);
         return(true);
     }
     return(false);
 }
 public void AddData(ErgometerData ergometerData)
 {
     data.Add(ergometerData);
 }
Beispiel #3
0
 //Recieved data from patient
 #region
 public void DataRecieved(dynamic jsonObject)
 {
     try
     {
         string        session  = (string)jsonObject.session;
         int           power    = jsonObject.data.power;
         double        speed    = jsonObject.data.speed;
         int           time     = jsonObject.data.time;
         int           rpm      = jsonObject.data.RPM;
         double        distance = jsonObject.data.distance;
         int           pulse    = jsonObject.data.pulse;
         ErgometerData data     = new ErgometerData(pulse, rpm, speed, distance, time, 0, 0, power);
         Boolean       added    = Database.AddErgometerDataToSession(session, data);
         if (added)
         {
             dynamic answer = new
             {
                 id   = "data",
                 data = new
                 {
                     status = "OK"
                 }
             };
             Send(JsonConvert.SerializeObject(answer));
             dynamic answerToDoctor = new
             {
                 id        = "data",
                 sessionId = session,
                 data      = new
                 {
                     data = data
                 }
             };
             foreach (Session s in DoctorsToSendDataTo)
             {
                 s.Send(JsonConvert.SerializeObject(answerToDoctor));
             }
         }
         else
         {
             dynamic answer = new
             {
                 id   = "data",
                 data = new
                 {
                     status = "ERROR",
                     error  = "Geen sessie voor username bekend"
                 }
             };
             Send(JsonConvert.SerializeObject(answer));
         }
     }
     catch (Exception e)
     {
         dynamic answer = new
         {
             id     = "data",
             status = "Error",
             error  = e.Message
         };
         Send(JsonConvert.SerializeObject(answer));
     }
 }