Пример #1
0
        private string StartSprinkler(EndPointActionArguments misc, string[] items)
        {
            String text = "";
            if (items != null && items.Length > 0)
            {
                foreach (var item in items)
                {
                    text += item + " ";
                }
            }
            else
            {
                text = "No arguments!";
            }

            
            this.sprinklerState = true;
            this.led.Write(this.sprinklerState);
            if (items != null && items.Length > 0)
            {
                var seconds = int.Parse(items[0]);
                Thread.Sleep(1000 * seconds);
                this.led.Write(false);
            }
            
            
            //LcdWriter.Instance.Write(text);

            return "OK. Sprinkler is now on.";
        }
Пример #2
0
 /// <summary>
 /// Execute this endpoint. We'll call the action with the supplied arguments and
 /// return whatever string the action returns.
 /// </summary>
 /// <returns></returns>
 public String Execute(EndPointActionArguments misc)
 {
     if (Action != null)
     {
         return Action(misc, _arguments);
     }
     return "Unknown action";
 }
Пример #3
0
 /// <summary>
 /// Execute this endpoint. We'll call the action with the supplied arguments and
 /// return whatever string the action returns.
 /// </summary>
 /// <returns></returns>
 public String Execute(EndPointActionArguments misc)
 {
     if (Action != null)
     {
         return(Action(misc, _arguments));
     }
     return("Unknown action");
 }
Пример #4
0
        private string GetSprinklerStatus(EndPointActionArguments arguments, string[] items)
        {
            //String text = "";
            //if (items != null && items.Length > 0)
            //{
            //    foreach (var item in items)
            //    {
            //        text += item + " ";
            //    }
            //}
            //else
            //{
            //    text = "No arguments!";
            //}

            return this.sprinklerState ? "On" : "Off";
        }
Пример #5
0
        /// <summary>
        /// We'll get an endpoint invokcation from the web server
        /// so we can execute the endpoint action and response based on its supplied arguments
        /// in a seperate thread, hence the event. we'll set the event return string
        /// so the web server can know how to respond back to the ui in a seperate thread
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        private static void EndPointHandler(object source, EndPointEventArgs e)
        {
            var misc = new EndPointActionArguments
            {
                Connection = e.Connection
            };

            e.ReturnString = e.Command.Execute(misc);

            // we can override the manual use of the socket if we returned a value other than null
            if (e.ReturnString != null && e.Command.UsesManualSocket)
            {
                e.ManualSent = false;
            }
            else
            {
                e.ManualSent = e.Command.UsesManualSocket;
            }
        }
Пример #6
0
        /// <summary>
        /// We'll get an endpoint invokcation from the web server
        /// so we can execute the endpoint action and response based on its supplied arguments
        /// in a seperate thread, hence the event. we'll set the event return string
        /// so the web server can know how to respond back to the ui in a seperate thread
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        private static void EndPointHandler(object source, EndPointEventArgs e)
        {
            var misc = new EndPointActionArguments
            {
                Connection = e.Connection
            };

            e.ReturnString = e.Command.Execute(misc);

            // we can override the manual use of the socket if we returned a value other than null
            if (e.ReturnString != null && e.Command.UsesManualSocket)
            {
                e.ManualSent = false;
            }
            else
            {
                e.ManualSent = e.Command.UsesManualSocket;
            }
        }
Пример #7
0
        private string StopSprinkler(EndPointActionArguments misc, string[] items)
        {
            String text = "";
            if (items != null && items.Length > 0)
            {
                foreach (var item in items)
                {
                    text += item + " ";
                }
            }
            else
            {
                text = "No arguments!";
            }

            this.sprinklerState = false;
            this.led.Write(this.sprinklerState);
            //LcdWriter.Instance.Write(text);

            return "OK. Sprinkler is now off.";
        }