private void AssignImageToTool(ICogTool cogTool, ICogImage image)
        {
            Type         ty = null;
            PropertyInfo pi = null;

            try
            {
                ty = cogTool.GetType();
                pi = ty.GetProperty("InputImage");
            }
            catch { }
            if (pi == null)
            {
                U.LogPopup("Could not get the Input Image property from tool '{0}'.", cogTool.Name);
            }
            else
            {
                try
                {
                    pi.SetValue(cogTool, image, null);
                }
                catch (Exception ex)
                {
                    U.LogPopup(ex, "Could not set Input Image to '{0}'. The type expected is '{1}' and the type we have is '{2}'",
                               cogTool.Name,
                               pi.PropertyType.Name,
                               image.GetType().Name);
                }
            }
        }
        /// <summary>
        /// Wait for an expected image
        /// </summary>
        /// <param name="acqTicket">Use -1 if Auto-triggering</param>
        /// <returns></returns>
        private ICogImage WaitForImage(int acqTicket)
        {
            long      startTime0 = U.DateTimeNow;
            ICogImage cogImage = null;
            int       completeTicket, triggerNumber, numPending, numReady = 0;
            bool      busy;

            do
            {
                lock (_lockAcqFifo)
                {
                    try
                    {
                        _cogAcqFifo.GetFifoState(out numPending, out numReady, out busy);
                        //System.Diagnostics.Debug.WriteLine(string.Format("{0} Acquire numPending={1} numReady={2} busy={3}", Name, numPending, numReady, busy));

                        if (numReady > 0)
                        {
                            long startTime1 = U.DateTimeNow;
                            cogImage = _cogAcqFifo.CompleteAcquire(acqTicket, out completeTicket, out triggerNumber);
                            long startTime2 = U.DateTimeNow;
                            if (cogImage == null)
                            {
                                U.LogPopup("Unexpected CogImage type = {0}", cogImage.GetType().Name);
                                return(null);
                            }
                            if (cogImage is CogImage8Grey)
                            {
                                CogImage8Grey cogImage8Grey = cogImage as CogImage8Grey;

                                _mConGrey.InputImage = cogImage8Grey;
                                _mConGrey.Run();
                                _mConGrey.InputImage = null;
                                (cogImage as IDisposable).Dispose();
                                return(_mConGrey.OutputImage as CogImage8Grey);
                            }
                            else if (cogImage is CogImage24PlanarColor)
                            {
                                CogImage24PlanarColor copyColorImage = null;
                                if (RotateImage == 0)
                                {
                                    copyColorImage = new CogImage24PlanarColor((cogImage as CogImage24PlanarColor).ToBitmap());
                                }
                                else
                                {
                                    if (_mOneImageTool.Operators.Count == 0)
                                    {
                                        switch (RotateImage)
                                        {
                                        case 90:
                                            _ImageRotate.OperationInPixelSpace = CogIPOneImageFlipRotateOperationConstants.Rotate270Deg;
                                            break;

                                        case -90:
                                        case 270:
                                            _ImageRotate.OperationInPixelSpace = CogIPOneImageFlipRotateOperationConstants.Rotate270Deg;
                                            break;

                                        case 180:
                                            _ImageRotate.OperationInPixelSpace = CogIPOneImageFlipRotateOperationConstants.Rotate180Deg;
                                            break;

                                        default:
                                            U.LogPopup("Unexpected rotate value ({0}) for camera {1}", RotateImage, Nickname);
                                            break;
                                        }
                                        _mOneImageTool.Operators.Add(_ImageRotate);
                                    }
                                    _mOneImageTool.InputImage = cogImage;
                                    _mOneImageTool.Run();
                                    _mOneImageTool.InputImage = null;
                                    copyColorImage            = _mOneImageTool.OutputImage as CogImage24PlanarColor;
                                }
                                long   startTime3 = U.DateTimeNow;
                                double ms10       = U.TicksToMS(startTime1 - startTime0);
                                double ms21       = U.TicksToMS(startTime2 - startTime1);
                                double ms32       = U.TicksToMS(startTime3 - startTime2);
                                Debug.WriteLine(string.Format("GotImage={0}  Complete={1}  Rotate={2}", ms10, ms21, ms32));
                                (cogImage as IDisposable).Dispose();
                                return(copyColorImage);
                            }
                            else
                            {
                                U.LogPopup("Unexpected CogImage type = {0}", cogImage.GetType().Name);
                            }
                            (cogImage as IDisposable).Dispose();
                            return(null);
                        }
                        U.SleepWithEvents(10);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(string.Format("{0} WaitForImage Exception={1}", Name, ex.ToString()));
                        _cogAcqFifo.Flush();
                        U.LogError(ex, "Error in CompleteAcquire");
                        System.Threading.Thread.Sleep(100);
                    }
                }
            } while (numReady <= 0 && acqTicket >= 0);

            return(null);
        }