public void waitForPatient() { _patient_found.WaitOne(); double weight = 60.0; double height = 160.0; System.Console.WriteLine(_patient.Remove(0,4)); IndivoExercisePlan plan = new IndivoExercisePlan(_patient.Remove(0,4)); if (plan == null) System.Console.WriteLine("{0} BOOO.", plan.Age); data.Add("Age", plan.Age); data.Add("Gender", plan.Gender); data.Add("AccountID", plan.AccountID); data.Add("Plan", plan.Plan); data.Add("RMR", calculateRMR(height, weight, plan.Age, plan.Gender)); }
public static void Main(string[] args) { if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["COMport"])) COMPort = Int32.Parse(ConfigurationManager.AppSettings["COMport"]); if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["targetHR"])) File_targetHR = Int32.Parse(ConfigurationManager.AppSettings["targetHR"]); Console.WriteLine ("ESOMA Data Processing Server"); allHRcalc=new List<int>(); allOXcalc=new List<int>(); allEAcalc=new List<double>(); HRtarget=new double[2]; StartPulseOX(); StartServer(); do{ if(!indivo_init){ if(serv.IsClientConnected("INDIVO")){ _indivoInit=new IndivoInitialization("rpoole","rpoole-dope75"); Console.WriteLine("INITIALIZE INDIVO:" +_indivoInit.ToString()); serv.SendToClient("INITIALIZE|"+_indivoInit.ToString()+"|","INDIVO"); indivo_init=true; } }else if(serv.IsClientConnected("UNITY") && !unity_init && sexercisePlan!=""){ unity_init=true; Console.WriteLine(sexercisePlan); _indivoPlan = new IndivoExercisePlan(sexercisePlan); // Console.WriteLine("hola"); SetHRtarget(); _indivoResults = new IndivoExerciseResult(new ExerciseResult(),_indivoPlan.AccountID); _indivoResults.Result.exerciseGroups = new System.Collections.Generic.List<ExerciseResultExerciseGroup>(); _indivoResults.Result.exerciseGroups.Add(new ExerciseResultExerciseGroup()); _indivoResults.Result.exerciseGroups[0].exercises = new System.Collections.Generic.List<ExerciseResultExerciseGroupExercise>(); ControlProgress(); } if(!serv.IsClientConnected("UNITY")){ unity_init=false; cen=-1; } }while(!exit); serv.SendToClient("ENDSESSION|"+_indivoResults.ToString()+"|","INDIVO"); Console.WriteLine("ENDSESSION|"+_indivoResults.ToString()+"|"); pulse.ClosePulseOX(); }
private static IndivoExercisePlan CreateIndivoExercisePlan(string accountId, ExercisePlan plan, Demographics demo) { // Default values in case we can't retrieve demographics int age = 0; string gender = string.Empty; if (demo != null) { age = GetAgeFromBirthDate(demo.dateOfBirth); gender = demo.gender; // dummy data in case indivo cant connect if (String.IsNullOrEmpty(gender)) gender = "Female"; } IndivoExercisePlan indivoPlan = new IndivoExercisePlan(plan, accountId, age, gender); return indivoPlan; }
public IndivoExercisePlan GetTodaysExercisePlan() { IndivoExercisePlan todaysPlan = new IndivoExercisePlan(); if (this.Plan != null) { todaysPlan.Age = this.Age; todaysPlan.AccountID = this.AccountID; todaysPlan.Gender = this.Gender; foreach (ExercisePlanExerciseGroup exGroup in this.Plan.exerciseGroups) { if (String.IsNullOrEmpty(exGroup.daysOfWeek) || GroupOccursToday(exGroup.daysOfWeek)) { todaysPlan.Plan = new ExercisePlan(); todaysPlan.Plan.exerciseGroups.Add(exGroup); } } } return todaysPlan; }
private static void SendExercisePlan(IndivoExercisePlan plan) { Console.WriteLine(plan.ToString()); string sentData = string.Format("I|I|{0}", plan.ToString()); _client.SendData(sentData); }