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