Example #1
0
 private static string ButtonStatus(EndPointActionArguments misc, object[] items)
 {
     lock (LockObject)
     {
        return "Button status is " + _buttonPushed + ", arguments: " + items.FormatAsCommaList();
     }
 }
Example #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";
 }
Example #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");
 }
Example #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;
        }
Example #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, EndPoinEventArgs 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;
            }
        }
Example #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, EndPoinEventArgs 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;
            }
        }
Example #7
0
 private string Test(EndPointActionArguments misc, object[] items)
 {
     return "<html><body><img height=120 width=160 src='liveCam.jpeg/mjpeg'/></body></html>";
 }