Beispiel #1
0
 private static string ButtonStatus(EndPointActionArguments misc, string[] items)
 {
     lock (LockObject)
     {
         return("Button status is " + _buttonPushed);
     }
 }
Beispiel #2
0
 private static string ButtonStatus(EndPointActionArguments misc, object[] items)
 {
     lock (LockObject)
     {
         return("Button status is " + _buttonPushed + ", arguments: " + items.FormatAsCommaList());
     }
 }
        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.");
        }
Beispiel #4
0
        private string TakePicture(EndPointActionArguments misc, object[] items)
        {
            lock (Lock)
            {
                if (_usingPort)
                {
                    return("Whoa whoa, someone is already reading from the camera. Wait a hot sec and try again later");
                }

                _usingPort = true;
            }

            try
            {
                var mjpeg = items != null && items.Length > 0 && items[0].ToString() == "mjpeg";

                if (mjpeg)
                {
                    misc.Connection.Send(WebUtils.StartMJPEGHeader());
                }

                var count = 0;
                do
                {
                    _led.Write(true);
                    var now = DateTime.Now;
                    _camera.TakePictureToSocket(misc.Connection, mjpeg);
                    LcdWriter.Instance.Write("pic taken #" + count + ": " + (DateTime.Now - now).Seconds + " s");
                    count++;
                } while (misc.Connection != null && mjpeg);

                return(null);
            }
            catch (Exception ex)
            {
            }
            finally
            {
                lock (Lock)
                {
                    _led.Write(false);
                    _usingPort = false;
                }
            }
            return(null);
        }
        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");
        }
Beispiel #6
0
        private string Echo(EndPointActionArguments misc, string[] items)
        {
            String text = "";

            if (items != null && items.Length > 0)
            {
                foreach (var item in items)
                {
                    text += item + " ";
                }
            }
            else
            {
                text = "No arguments!";
            }

            LcdWriter.Instance.Write(text);

            return("OK. Wrote out: " + (text.Length == 0 ? "n/a" : text));
        }
        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.");
        }
Beispiel #8
0
 private string Test(EndPointActionArguments misc, object[] items)
 {
     return("<html><body><img height=120 width=160 src='liveCam.jpeg/mjpeg'/></body></html>");
 }