// GET api/values public IEnumerable <string> Get() { // Instantiate Model LaerdalServerModel lsModelObj = new LaerdalServerModel(); // Initialize parameters System.Threading.Thread.Sleep(300); lsModelObj.SetupParameters(); //Boolean check = lsModelObj.Check(); // System.Diagnostics.Debug.Write(check, "check"); //TODO: GET FROM SESSION, DON'T MAKE NEW CONNECTION string error; string address = "192.168.0.134"; Boolean connected = lsModelObj.Connect(address, out error); if (connected) { System.Diagnostics.Debug.Write(connected, "note"); lsModelObj.PulseOximeter.Value = 1; } System.Diagnostics.Debug.Write(lsModelObj.PulseOximeter.Value, "PulseOximeter"); return(new string[] { "Sucessfully invoked Laerdal simulator" }); }
// GET: api/set_respiratory_rate/5 public string Get(int id) { LaerdalServerModel lsModelObj = new LaerdalServerModel(); int goalHR = id; lsModelObj.UpdateHeartRate(goalHR); System.Threading.Thread.Sleep(500); while (lsModelObj.HeartRate < goalHR) { lsModelObj.UpdateHeartRate(goalHR); System.Threading.Thread.Sleep(500); } lsModelObj.PauseEvent.Value = false; return(lsModelObj.HeartRate.ToString()); }
// POST: api/set_blood_pressure public async Task <string> Post(HttpRequestMessage request) { HttpResponseMessage response = new HttpResponseMessage(); LaerdalServerModel lsModelObj = new LaerdalServerModel(); Boolean isConnected = lsModelObj.Check(); JObject postData = JObject.Parse(request.Content.ReadAsStringAsync().Result); var pressure_sys = postData["pressure_sys"].ToString(); var pressure_dia = postData["pressure_dia"].ToString(); int sys = Int32.Parse(pressure_sys); int dia = Int32.Parse(pressure_dia); if (isConnected) { bool bp = lsModelObj.UpdateBP(dia, sys); if (bp) { return("Blood pressure updated"); } else { return("Was not able to set blood pressure to: " + "sys: " + sys + "dia:" + dia); } } else { string error; string address = "10.100.2.166"; Boolean connected = lsModelObj.Connect(address, out error); System.Threading.Thread.Sleep(500); lsModelObj.SetupParameters(); System.Diagnostics.Debug.Write(connected, "connected"); System.Threading.Thread.Sleep(500); bool bp = lsModelObj.UpdateBP(dia, sys); if (bp) { return("Blood pressure updated"); } else { return("Was not able to set blood pressure to: " + "sys: " + sys + "dia:" + dia); } } }
// POST: api/set_heart_rate public async Task <string> Post(HttpRequestMessage request) { HttpResponseMessage response = new HttpResponseMessage(); LaerdalServerModel lsModelObj = new LaerdalServerModel(); Boolean isConnected = lsModelObj.Check(); JObject postData = JObject.Parse(request.Content.ReadAsStringAsync().Result); var rate = postData["rate"].ToString(); var pressure_dia = postData["rate"].ToString(); int hrRate = Int32.Parse(rate); if (isConnected) { bool hr = lsModelObj.UpdateHeartRate(hrRate); if (hr) { return("Heart Rate updated"); } else { return("Was not able to set hr to: " + hr); } } else { string error; string address = "10.100.2.166"; Boolean connected = lsModelObj.Connect(address, out error); System.Threading.Thread.Sleep(500); lsModelObj.SetupParameters(); System.Diagnostics.Debug.Write(connected, "connected"); System.Threading.Thread.Sleep(500); bool hr = lsModelObj.UpdateHeartRate(hrRate); if (hr) { return("Heart Rate updated"); } else { return("Was not able to set hr to: " + hr); } } }
// POST: api/set_open_eyes public async Task <string> Post(HttpRequestMessage request) { HttpResponseMessage response = new HttpResponseMessage(); LaerdalServerModel lsModelObj = new LaerdalServerModel(); Boolean isConnected = lsModelObj.Check(); JObject postData = JObject.Parse(request.Content.ReadAsStringAsync().Result); var eye_status = postData["open"].ToString(); if (isConnected) { bool eye = lsModelObj.UpdateEyeStatus(eye_status == "true"); if (eye) { return("Eye lid status updated"); } else { return("Was not able to update eye lid status"); } } else { string error; string address = "10.100.2.166"; Boolean connected = lsModelObj.Connect(address, out error); System.Threading.Thread.Sleep(500); lsModelObj.SetupParameters(); System.Diagnostics.Debug.Write(connected, "connected"); System.Threading.Thread.Sleep(500); bool eye = lsModelObj.UpdateEyeStatus(eye_status == "true"); if (eye) { return("Eye lid status updated"); } else { return("Was not able to update eye lid status"); } } }
// GET: api/Scenario public IEnumerable <string> Get() { LaerdalServerModel lsModelObj = new LaerdalServerModel(); Boolean isConnected = lsModelObj.Check(); //TODO: GET FROM SESSION, DON'T MAKE NEW CONNECTION if (!isConnected) { string error; string address = "10.100.2.166"; Boolean connected = lsModelObj.Connect(address, out error); System.Threading.Thread.Sleep(500); lsModelObj.SetupParameters(); System.Diagnostics.Debug.Write(connected, "connected"); System.Threading.Thread.Sleep(500); lsModelObj.trigger_state_severe_asthma(); System.Threading.Thread.Sleep(500); lsModelObj.PauseEvent.Value = false; var result = "Scenario has been Activated"; System.Diagnostics.Debug.Write(result, "phase 1 initiated"); return(new string[] { result }); } else { System.Threading.Thread.Sleep(500); lsModelObj.trigger_state_severe_asthma(); System.Threading.Thread.Sleep(500); lsModelObj.PauseEvent.Value = false; var result = "Scenario has been Activated"; System.Diagnostics.Debug.Write(result, "phase 1 initiated"); return(new string[] { result }); } }
// POST: api/trigger_state public async Task <string> Post(HttpRequestMessage request) { HttpResponseMessage response = new HttpResponseMessage(); LaerdalServerModel lsModelObj = new LaerdalServerModel(); Boolean isConnected = lsModelObj.Check(); JObject postData = JObject.Parse(request.Content.ReadAsStringAsync().Result); var intensity = postData["intensity"].ToString(); if (isConnected) { if (intensity == "healthy") { //lsModelObj.trigger_healthy_state(); return("triggered healthy"); } return("Was not able to find command: " + intensity); } else { string error; string address = "10.100.2.166"; Boolean connected = lsModelObj.Connect(address, out error); System.Threading.Thread.Sleep(500); lsModelObj.SetupParameters(); System.Diagnostics.Debug.Write(connected, "connected"); System.Threading.Thread.Sleep(500); if (intensity == "healthy") { //lsModelObj.trigger_healthy_state(); return("triggered healthy"); } return("Was not able to find command: " + intensity); } }
// POST: api/trigger_asthma public async Task <string> Post(HttpRequestMessage request) { String[] scenarios = { "worsen", "severe", "albuterol_intervention", "mild" }; HttpResponseMessage response = new HttpResponseMessage(); LaerdalServerModel lsModelObj = new LaerdalServerModel(); Boolean isConnected = lsModelObj.Check(); JObject postData = JObject.Parse(request.Content.ReadAsStringAsync().Result); var intensity = postData["intensity"].ToString(); if (isConnected) { if (intensity == scenarios[0]) { lsModelObj.trigger_state_asthma_worsen(); return("triggered worsen"); } if (intensity == scenarios[1]) { lsModelObj.trigger_state_severe_asthma(); return("triggered severe"); } if (intensity == scenarios[2]) { lsModelObj.trigger_intervention(); return("triggered intervention"); } if (intensity == scenarios[3]) { lsModelObj.trigger_mild_asthma(); return("trigger mild"); } return("Was not able to find command: " + intensity); } else { string error; string address = "10.100.2.166"; Boolean connected = lsModelObj.Connect(address, out error); System.Threading.Thread.Sleep(500); lsModelObj.SetupParameters(); System.Diagnostics.Debug.Write(connected, "connected"); System.Threading.Thread.Sleep(500); if (intensity == scenarios[0]) { lsModelObj.trigger_state_asthma_worsen(); return("triggered worsen"); } if (intensity == scenarios[1]) { lsModelObj.trigger_state_severe_asthma(); return("triggered severe"); } if (intensity == scenarios[2]) { lsModelObj.trigger_intervention(); return("triggered intervention"); } if (intensity == scenarios[3]) { lsModelObj.trigger_mild_asthma(); return("trigger mild"); } return("Was not able to find command: " + intensity); } }
// GET: api/Scenario/5 public IEnumerable <string> Get(int id) { string[] scenarios = new string[] { "trigger_state_severe_asthma", "trigger_state_asthma_worsen", "trigger_intervention", "trigger_mild_asthma", "trigger_healthy_state" }; LaerdalServerModel lsModelObj = new LaerdalServerModel(); Boolean isConnected = lsModelObj.Check(); //TODO: GET FROM SESSION, DON'T MAKE NEW CONNECTION if (!isConnected) { string error; string address = "10.100.2.166"; Boolean connected = lsModelObj.Connect(address, out error); System.Threading.Thread.Sleep(500); lsModelObj.SetupParameters(); System.Diagnostics.Debug.Write(connected, "connected"); System.Threading.Thread.Sleep(500); if (id == 1) { lsModelObj.trigger_state_severe_asthma(); } if (id == 2) { lsModelObj.trigger_state_asthma_worsen(); } if (id == 3) { lsModelObj.trigger_intervention(); } if (id == 4) { lsModelObj.trigger_mild_asthma(); } if (id == 5) { lsModelObj.trigger_healthy_state(); } System.Threading.Thread.Sleep(500); lsModelObj.PauseEvent.Value = false; var result = "Scenario function " + scenarios[id - 1] + " been Activated"; System.Diagnostics.Debug.Write(result, "result"); return(new string[] { result }); } else { System.Threading.Thread.Sleep(500); if (id == 1) { lsModelObj.trigger_state_severe_asthma(); } if (id == 2) { lsModelObj.trigger_state_asthma_worsen(); } if (id == 3) { lsModelObj.trigger_intervention(); } if (id == 4) { lsModelObj.trigger_mild_asthma(); } if (id == 5) { lsModelObj.trigger_healthy_state(); } System.Threading.Thread.Sleep(500); var result = "Scenario function " + scenarios[id - 1] + " been Activated"; System.Diagnostics.Debug.Write(result, "result"); return(new string[] { result }); } }