Ejemplo n.º 1
0
        /// <summary>
        /// Here is receives the messages from the arduino monitor
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void UpdateMonitorReading(object sender, NotifyContextMonitorListenersEventArgs e)
        {
            if (e.Type != typeof(BoardUpdate))
            return;

              BoardUpdate boardUpdate = (BoardUpdate)e.NewObject;
              if(boardUpdate.DeviceOnTopID == 0)
              {
            if(statusUpdate.Event == StackingEvent.PhyicalStacking)
            {
              statusUpdate.Event = StackingEvent.PhysicalSeparation;
              statusUpdate.When = DateTime.Now;
              NotifyContextServices(this, new NotifyContextMonitorListenersEventArgs(typeof(StackingUpdate), statusUpdate));
            }
            else if(statusUpdate.Event == StackingEvent.PhysicalSeparation)  {}
              }
              else
              {
            if(statusUpdate.Event == StackingEvent.PhysicalSeparation)
            {
              statusUpdate.Event = StackingEvent.PhyicalStacking;
              statusUpdate.When = DateTime.Now;
              statusUpdate.DeviceOnTopID = boardUpdate.DeviceOnTopID;
              NotifyContextServices(this, new NotifyContextMonitorListenersEventArgs(typeof(StackingUpdate), statusUpdate));
            }
              }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Here it receives the messages from the arduino sensor
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void UpdateMonitorReading(object sender, NotifyContextMonitorListenersEventArgs e)
        {
            if (e.Type != typeof(BoardUpdate))
            return;

              BoardUpdate boardInfo = (BoardUpdate)e.NewObject;
              NotifyContextServices(this, new NotifyContextMonitorListenersEventArgs(typeof(ButtonMonitor), boardInfo.ButtonEvent));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Here it receives the messages from the arduino sensor
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void UpdateMonitorReading(object sender, NotifyContextMonitorListenersEventArgs e)
        {
            if (e.Type != typeof(BoardUpdate))
            return;

              BoardUpdate boardInfo = (BoardUpdate)e.NewObject;
              if (boardInfo.FlippingSide == FlippingMode.Unknown)
              {
            //It's comming from the actual board and needs the processing
              }

              if (ActualFlippingMode == boardInfo.FlippingSide)
            return;

              ActualFlippingMode = boardInfo.FlippingSide;
              NotifyContextServices(this, new NotifyContextMonitorListenersEventArgs(typeof(FlippingMode), ActualFlippingMode));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// This method receives the image from the camera and finds the location of the device.
        /// Location defined as the page, the X and Y coordinates wihtin the page in cms, and the rotation angle
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void CustomUpdateMonitorReading(object sender, NotifyContextMonitorListenersEventArgs e)
        {
            if (e.Type != typeof(System.Drawing.Bitmap))
            return;
              if (isProcessStopped)
            return;
              if (Container == null || Controller == null)
            return;
              if (Device.State == StackingState.StackedOnTop)
            return;

              if (TPadCore.UseFeatureTracking)
              {
            if (sender is SimCameraMonitor)
            {
              if (Tracker == null)
            Tracker = (sender as SimCameraMonitor).Tracker;

              if (temp_SimCaptureToSourceImageRatio != Controller.SimCaptureToSourceImageRatio)
              {
            temp_SimCaptureToSourceImageRatio = Controller.SimCaptureToSourceImageRatio;
            Tracker.computeWarpMatrix(temp_SimCaptureToSourceImageRatio);
              }

              status = Tracker.detectLocation(false, status);
              GetLocationFromTracker();
            }
            else if (sender is CameraMonitor)
            {
              if (Tracker == null)
            Tracker = (sender as CameraMonitor).Tracker;

              if (Tracker == null)
            return;

              //start feature tracking
              //Stopwatch sw = new Stopwatch();
              //sw.Start();
              status = Tracker.detectLocation(true, status);
              //sw.Stop();
              //Console.WriteLine("Elapsed={0} ", sw.ElapsedMilliseconds);
              GetLocationFromTracker();
            }
              }
              else {
            location = new TPadLocation();
            location.Status = LocationStatus.Located;
            location.RotationAngle = ClampedAngle(Controller.RotationAngle);
            location.LocationCm = new Point(Controller.Location.X / Controller.WidthFactor, Controller.Location.Y / Controller.HeightFactor);
            location.Document = Controller.ActualDocument;
            location.PageIndex = Controller.ActualPage;
              }

              NotifyContextServiceListeners(this, new NotifyContextServiceListenersEventArgs(typeof(TPadLocation), location));
        }
Ejemplo n.º 5
0
 protected virtual void CustomUpdateMonitorReading(object sender, NotifyContextMonitorListenersEventArgs e)
 {
 }
Ejemplo n.º 6
0
 /// <summary>
 /// THe implementation of this method pushes the execution of the monitoring update on the dispatcher
 /// thread that created the service. In this way, as the services are created by the UI thread, we can 
 /// make sure that the observable collections can be updated and that the change will be reflected in the
 /// UI components to which they are bound.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void UpdateMonitorReading(object sender, NotifyContextMonitorListenersEventArgs e)
 {
     try
       {
     CustomUpdateMonitorReading(sender, e);
       }
       catch (Exception exception)
       {
     logger.Error("An error ocurred processing monitor reading", exception.InnerException);
       }
 }
Ejemplo n.º 7
0
 protected override void CustomUpdateMonitorReading(object sender, NotifyContextMonitorListenersEventArgs e)
 {
     Dispatcher.Invoke(DispatcherPriority.Render,
     (Action)delegate()
     {
       if (e.Type == typeof(StackingUpdate))
       {
     Device.ProcessStackingUpdate((StackingUpdate)e.NewObject);
       }
       else if (e.Type == typeof(TransportMessage))
       {
     Device.ProcessStackingUpdate((TransportMessage)e.NewObject);
       }
       else if (e.Type == typeof(FlippingMode))
       {
     Device.FlippingSide = (FlippingMode)e.NewObject;
       }
       else if (e.Type == typeof(ShakingMonitor))
       {
     Device.NotifyShake((DateTime)e.NewObject);
       }
       else if (e.Type == typeof(ButtonMonitor))
       {
     Device.NotifyHome((ButtonEvent)e.NewObject);
       }
     });
 }
Ejemplo n.º 8
0
 protected void NotifyContextServices(object sender, NotifyContextMonitorListenersEventArgs e)
 {
     if (OnNotifyContextServices != null)
     OnNotifyContextServices(sender, e);
 }