public void HTTPRequestEventHandler(Object sender, OnHttpRequestArgs requestArgs) //requestArgs
        {
            //int bytesSent = 0;
            string QueryString = requestArgs.Request.Header.RequestPath;
            string EventType = "";
            string JoinType = "";
            ushort JoinID = 0;
            string JoinValue = "0";

            //ErrorLog.Notice(requestArgs.Request.Header.RequestType.ToString());
            //IP/get|set/Digital|Analog|Serial/JoinID/Value
            if (requestArgs.Request.Header.RequestType.ToString() == "GET")
            {
                string[] words = QueryString.Split('/');
                EventType = words[1];
                JoinType = words[2];               
                JoinID = (ushort)Convert.ToInt32(words[3]);
                if(words[4] != null || words[4] != "")
                    JoinValue = words[4];

                switch (JoinType.ToUpper())
                {
                    case ("DIGITAL"):
                        {
                            if (EventType.ToUpper() == "SET")
                            {
                                SignalChangeEvents.DigitalValueChange(JoinID, (ushort)Convert.ToInt32(JoinValue));                                
                                requestArgs.Response.ContentString = "OK";
                            }
                            else if (EventType.ToUpper() == "GET")
                            {
                                requestArgs.Response.ContentString = getDigitalSignal(JoinID).ToString();
                            }
                            break;
                        }
                    case ("ANALOG"):
                        {
                            if (EventType.ToUpper() == "SET")
                            {
                                SignalChangeEvents.AnalogValueChange(JoinID, (ushort)Convert.ToInt32(JoinValue));
                                requestArgs.Response.ContentString = "OK";
                            }
                            else if (EventType.ToUpper() == "GET")
                            {
                                requestArgs.Response.ContentString = getAnalogSignal(JoinID).ToString();
                            }
                            break;
                        }
                    case ("SERIAL"):
                        {
                            if (EventType.ToUpper() == "SET")
                            {
                                SignalChangeEvents.SerialValueChange(JoinID, JoinValue);
                                requestArgs.Response.ContentString = "OK";
                            }
                            else if (EventType.ToUpper() == "GET")
                            {
                                requestArgs.Response.ContentString = getSerialSignal(JoinID).ToString();
                            }
                            break;
                        }
                    default:
                        {
                            break;
                        }
                }
            }

            /*
            if (requestArgs.Request.Header.RequestType.ToString() == "POST")
            {
                string[] words = QueryString.Split('/');
                JoinType = words[1];
                JoinID = (ushort)Convert.ToInt32(words[2]);
                JoinValue = words[3];

                switch (JoinType)
                {
                    case ("Digital"):
                        {
                            SignalChangeEvents.DigitalValueChange(JoinID,(ushort)Convert.ToInt32(JoinValue));
                            break;
                        }
                    case ("Analog"):
                        {
                            SignalChangeEvents.AnalogValueChange(JoinID,(ushort)Convert.ToInt32(JoinValue));
                            break;
                        }
                    case ("Serial"):
                        {
                            SignalChangeEvents.SerialValueChange(JoinID, JoinValue);
                            break;
                        }
                    default:
                        {
                            break;
                        }
                }
            }
             */
            


            /*
            switch (requestArgs.Request.Header.RequestPath)
            {
                //"http://IP address of controller:port assigned to server" or
                //"http://IP address of controller:port assigned to server/home"
                case "/":
                case "/home":
                    {
                        var test = requestArgs.Request.QueryString.ToString();
                        ErrorLog.Notice(test + "\n");
                        //If request included data
                        if (requestArgs.Request.HasContentLength)
                        {
                            //Assign amount of bytes sent to bytesSent
                            bytesSent = requestArgs.Request.ContentLength;
                        }
                        if (bytesSent > 0)
                        {
                            String result = requestArgs.Request.ContentString;
                            CrestronConsole.Print("Data that was received from POST request: " + result + "\r\n");
                        }
                        //If the request contained no bytes
                        else
                        {
                            //Set the ContentString variable as the source of data to return
                            requestArgs.Response.ContentSource = ContentSource.ContentString;
                            //Return the homepage
                            requestArgs.Response.ContentString = MainPageHTML;
                            requestArgs.Response.Header.SetHeaderValue("Content-Type", "text/html");
                        }
                        break;
                    }
                //http://IP address of controller:port assigned to server/secondpage
                case "/secondpage":
                    {
                        requestArgs.Response.ContentSource = ContentSource.ContentString;
                        //Return the second page
                        requestArgs.Response.ContentString = SecondPageHTML;
                        requestArgs.Response.Header.SetHeaderValue("Content-Type", "text/html");
                        break;
                    }
                //http://IP address of controller:port assigned to server/anything else
                default:
                    {
                        requestArgs.Response.ContentSource = ContentSource.ContentString;
                        requestArgs.Response.ContentString = PageNotFoundHTML;
                        requestArgs.Response.Header.SetHeaderValue("Content-Type", "text/html");
                        break;
                    }
             
            }*/
        }
 public static void AnalogValueChange(ushort JoinID, ushort JoinValue)
 {
     SignalChangeEvents.onAnalogValueChange(new AnalogChangeEventArgs(JoinID, JoinValue));
 }
 public static void SerialValueChange(ushort JoinID, string JoinValue)
 {
     SignalChangeEvents.onSerialValueChange(new SerialChangeEventArgs(JoinID, JoinValue));
 }        
 public static void DigitalValueChange(ushort JoinID, ushort JoinValue)
 {
     SignalChangeEvents.onDigitalValueChange(new DigitalChangeEventArgs(JoinID, JoinValue));
 }