// 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 });
            }
        }