Пример #1
0
        public void StartSimulationTimer(int interval)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            LoadSimulationConfiguration();

            int hBinning = 1, vBinning = 1;

            ChartArray.BuildChartArray(m_mask.Rows, m_mask.Cols, hBinning, vBinning, m_indicatorList);

            ////////////////////////////////////////////////////
            //m_uiTask = TaskScheduler.FromCurrentSynchronizationContext();
            Dictionary <int, ImageDisplay> idDictionary = ChartArray.GetImageDisplayDictionary();

            m_displayPipeline = m_imager.CreateDisplayPipeline(m_uiTask, idDictionary);


            m_storagePipeline = m_imager.CreateImageStoragePipeline(GlobalVars.CompressionAlgorithm, m_iParams.imageWidth, m_iParams.imageHeight);

            if (ChartArray != null)
            {
                m_analysisPipeline = m_imager.CreateAnalysisPipeline(ChartArray, m_mask, m_iParams.imageWidth,
                                                                     m_iParams.imageHeight, m_iParams.HorzBinning, m_iParams.VertBinning,
                                                                     m_iParams.ExperimentIndicatorID, m_controlSubtractionWellList, m_numFoFrames,
                                                                     m_dynamicRatioNumerator.ExperimentIndicatorID,
                                                                     m_dynamicRatioDenominator.ExperimentIndicatorID);
            }

            if (m_histogram != null)
            {
                m_histogramPipeline = m_imager.CreateHistogramPipeline(m_uiTask, m_histogram);
            }



            /////////////////////////////////////////////////////////
            // use reference images as simulated images from camera
            bool success = m_wgDB.GetAllReferenceImages();

            m_simulationImageList = new List <ushort[]>();
            foreach (ReferenceImageContainer image in m_wgDB.m_refImageList)
            {
                ushort[] img = new ushort[image.Width * image.Height];
                Buffer.BlockCopy(image.ImageData, 0, img, 0, image.NumBytes);
                m_simulationImageList.Add(img);
            }

            m_simulationTimer          = new DispatcherTimer();
            m_simulationTimer.Tick    += m_simulationTimer_Tick;
            m_simulationTimer.Interval = TimeSpan.FromMilliseconds(interval);
            m_simulationTime           = 0;
            m_timerStartDateTime       = DateTime.Now;
            m_simulationTimer.Start();

            stopwatch.Stop();
            PostMessage("startup time = " + stopwatch.ElapsedMilliseconds.ToString());
        }
Пример #2
0
        public void Configure(ImagingParameters iParams, ProjectContainer project, PlateContainer plate, ExperimentContainer experiment,
                              MethodContainer method,
                              MaskContainer mask, PlateTypeContainer plateType,
                              ObservableCollection <ExperimentIndicatorContainer> indicatorList,
                              ObservableCollection <ExperimentCompoundPlateContainer> compoundPlateList,
                              ObservableCollection <Tuple <int, int> > controlSubtractionWellList,
                              int numFoFrames,
                              ExperimentIndicatorContainer dynamicRatioNumerator,
                              ExperimentIndicatorContainer dynamicRatioDenominator)
        {
            m_iParams                    = iParams;
            m_project                    = project;
            m_experimentPlate            = plate;
            m_experiment                 = experiment;
            m_method                     = method;
            m_mask                       = mask;
            m_plateType                  = plateType;
            m_indicatorList              = indicatorList;
            m_compoundPlateList          = compoundPlateList;
            m_controlSubtractionWellList = controlSubtractionWellList;
            m_numFoFrames                = numFoFrames;
            m_dynamicRatioNumerator      = dynamicRatioNumerator;
            m_dynamicRatioDenominator    = dynamicRatioDenominator;


            m_vworksProtocolFilename = m_method.BravoMethodFile;

            ChartArray.BuildChartArray(mask.Rows, mask.Cols, m_iParams.HorzBinning, m_iParams.VertBinning, m_indicatorList);

            Dictionary <int, ImageDisplay> idDictionary = ChartArray.GetImageDisplayDictionary();

            m_displayPipeline = m_imager.CreateDisplayPipeline(m_uiTask, idDictionary);


            m_storagePipeline = m_imager.CreateImageStoragePipeline(GlobalVars.CompressionAlgorithm, m_iParams.imageWidth, m_iParams.imageHeight);

            int numerID = 0;
            int denomID = 0;

            if (m_dynamicRatioNumerator != null)
            {
                numerID = m_dynamicRatioNumerator.ExperimentIndicatorID;
            }
            if (m_dynamicRatioDenominator != null)
            {
                denomID = m_dynamicRatioDenominator.ExperimentIndicatorID;
            }

            m_analysisPipeline = m_imager.CreateAnalysisPipeline(ChartArray, m_mask, m_iParams.imageWidth,
                                                                 m_iParams.imageHeight, m_iParams.HorzBinning, m_iParams.VertBinning,
                                                                 m_iParams.ExperimentIndicatorID, m_controlSubtractionWellList, m_numFoFrames,
                                                                 numerID, denomID);


            if (m_histogram != null)
            {
                m_histogramPipeline = m_imager.CreateHistogramPipeline(m_uiTask, m_histogram);
            }
        }
Пример #3
0
        //////////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////////////////////



        public async void StartVideo(ImagingParameters iParams)
        {
            if (m_imager == null)
            {
                return;
            }

            //m_uiTask = TaskScheduler.FromCurrentSynchronizationContext();

            m_tokenSource = new CancellationTokenSource();
            m_cancelToken = m_tokenSource.Token;

            Progress <int> progress = new Progress <int>();

            progress.ProgressChanged += (sender1, num) =>
            {
                VM.MessageText = num.ToString() + " images";
            };

            Dictionary <int, ImageDisplay> imageDisplayDictionary = ChartArray.GetImageDisplayDictionary();

            foreach (KeyValuePair <int, ImageDisplay> entry in imageDisplayDictionary)
            {
                ImageDisplay imageDisplay = entry.Value;
                imageDisplay.SetImageSize(iParams.imageWidth, m_iParams.imageHeight, m_iParams.maxPixelValue);
            }


            Task ImagingTask = Task.Factory.StartNew(() => m_imager.StartImaging(m_iParams,
                                                                                 Tuple.Create(m_mask, m_controlSubtractionWellList, m_numFoFrames,
                                                                                              m_dynamicRatioNumerator.ExperimentIndicatorID,
                                                                                              m_dynamicRatioDenominator.ExperimentIndicatorID),
                                                                                 m_cancelToken, m_uiTask, progress,
                                                                                 null, m_colorModel.m_colorMap, m_histogram, ChartArray), m_cancelToken);


            try
            {
                await ImagingTask;
            }
            catch (AggregateException aggEx)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("Exception(s) occurred: ");
                foreach (Exception ex in aggEx.InnerExceptions)
                {
                    sb.Append(ex.Message);
                    sb.Append(", ");
                }
                MessageBoxResult result = MessageBox.Show(sb.ToString(), "Exception(s) Occurred", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (OperationCanceledException)
            {
            }
            catch (Exception ex)
            {
                MessageBoxResult result = MessageBox.Show(ex.Message, "Unknown Exception Occurred", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                ImagingTask.Dispose();
            }
        }