示例#1
0
        /// <summary>
        /// Starts or stops the adquisition
        /// Route: POST api/Adquisition/Adquisition?start=1
        /// </summary>
        /// <param name="start">Parameter with value=1 starts adquisition and value=0 stops it</param>
        /// <returns>Http 200 Ok when the action is completed</returns>
        public IHttpActionResult PostAdquisition([FromUri] int start)
        {
            try
            {
                if (start == 0)
                {
                    CommunicationMgr.GetInstance(Utilities.Log()).StopAdquisition();
                }
                else
                {
                    CommunicationMgr.GetInstance(Utilities.Log()).StartAdquisition();
                }

                return(Ok());
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#2
0
        public HttpResponseMessage GetOnlineData()
        {
            var response = Request.CreateResponse();

            response.Content = new PushStreamContent((stream, content, context) =>
            {
                foreach (var point in CommunicationMgr.GetInstance().AdquisitionMQueue.GetAllMessages())
                {
                    var serializer = new JsonSerializer();

                    using (var writer = new StreamWriter(stream))
                    {
                        serializer.Serialize(writer, ((Point)point.Body).ToValuePoint());
                        stream.Flush();
                    }
                }
            });

            return(response);
        }