private async void ConvertImage(ImageStatsCollectingData srcData)
        {
            Interlocked.Increment(ref totalFilesProcessed);
            int perc = Convert.ToInt32(100.0d * (double)totalFilesProcessed / (double)totalFilesCountToProcess);

            Console.WriteLine(DateTime.Now.ToString("s") + " : " + perc + "% : started processing file " + Environment.NewLine + srcData.filename);

            Dictionary <string, object> taskParameters = new Dictionary <string, object>();

            foreach (string key in defaultProperties.Keys)
            {
                taskParameters.Add(key, defaultProperties[key]);
            }

            Stopwatch sw = new Stopwatch();

            sw.Start();
            taskParameters.Add("Stopwatch", sw);
            taskParameters.Add("logFileName", errorLogFilename);
            taskParameters.Add("currentFullFileName", srcData.filename);


            ImageStatsDataCalculationResult currImageConversionResult = await ConvertImageTask(taskParameters);


            #region process result

            currImageConversionResult.stopwatch.Stop();

            if (currImageConversionResult.calcResult)
            {
                string currentFullFileName = currImageConversionResult.imgFilename;
                string strPerfCountersData = currentFullFileName + ";" +
                                             currImageConversionResult.stopwatch.ElapsedMilliseconds + ";" +
                                             (currImageConversionResult.procTotalProcessorTimeEnd -
                                              currImageConversionResult.procTotalProcessorTimeStart).TotalMilliseconds +
                                             Environment.NewLine;
                ServiceTools.logToTextFile(strPerformanceCountersStatsFile, strPerfCountersData, true);


                ImageStatsCollectingData foundDataObj =
                    lStatsCalculation.Find(obj => obj.filename == currentFullFileName);
                foundDataObj.State = ImageStatsCollectingState.Finished;


                Console.WriteLine(DateTime.Now.ToString("s") + " : finished processing file " + Environment.NewLine + currentFullFileName);
            }
            else
            {
                string currentFullFileName            = currImageConversionResult.imgFilename;
                ImageStatsCollectingData foundDataObj =
                    lStatsCalculation.Find(obj => obj.filename == currentFullFileName);
                foundDataObj.State = ImageStatsCollectingState.Error;
                Console.WriteLine("ERROR processing file " + Path.GetFileName(currentFullFileName));
                try
                {
                    #region report error

                    ServiceTools.logToTextFile(errorLogFilename,
                                               "Error processing file: " + Environment.NewLine + currentFullFileName +
                                               Environment.NewLine + "message: " +
                                               ServiceTools.GetExceptionMessages(currImageConversionResult.exception) + Environment.NewLine +
                                               ServiceTools.CurrentCodeLineDescription() + Environment.NewLine + "Stack trace: " + Environment.NewLine +
                                               Environment.StackTrace + Environment.NewLine + Environment.NewLine, true, true);

                    #endregion report error
                }
                catch (Exception ex)
                {
                    return;
                }
            }

            #endregion process result
        }
Exemplo n.º 2
0
        private void ProcessImage(ImageStatsCollectingData srcData)
        {
            Interlocked.Increment(ref totalFilesProcessed);
            int perc = Convert.ToInt32(100.0d * (double)totalFilesProcessed / (double)totalFilesCountToProcess);

            Console.WriteLine(DateTime.Now.ToString("s") + " : " + perc + "% : started processing file " + Environment.NewLine + srcData.filename);

            Dictionary <string, object> optionalParameters = new Dictionary <string, object>();

            optionalParameters.Add("ImagesRoundMasksXMLfilesMappingList", ImagesRoundMasksXMLfilesMappingList);
            Stopwatch sw = new Stopwatch();

            sw.Start();
            optionalParameters.Add("Stopwatch", sw);
            optionalParameters.Add("logFileName", errorLogFilename);

            ImageStatsDataCalculationResult currImageProcessingResult =
                ImageProcessing.CalculateImageStatsData(srcData.filename, optionalParameters);

            currImageProcessingResult.stopwatch.Stop();
            if (currImageProcessingResult.calcResult)
            {
                string currentFullFileName = currImageProcessingResult.imgFilename;
                string strPerfCountersData = currentFullFileName + ";" +
                                             currImageProcessingResult.stopwatch.ElapsedMilliseconds + ";" +
                                             (currImageProcessingResult.procTotalProcessorTimeEnd -
                                              currImageProcessingResult.procTotalProcessorTimeStart).TotalMilliseconds +
                                             Environment.NewLine;
                ServiceTools.logToTextFile(strPerformanceCountersStatsFile, strPerfCountersData, true);



                //string strImageGrIxMedianP5DataFileName =
                //    ConventionalTransitions.ImageGrIxMedianP5DataFileName(currentFullFileName, imageMP5statsXMLdataFilesDirectory);
                //ServiceTools.WriteObjectToXML(currImageProcessingResult.mp5Result, strImageGrIxMedianP5DataFileName);
                string strImageGrIxYRGBDataFileName =
                    ConventionalTransitions.ImageGrIxYRGBstatsDataFileName(currentFullFileName, imageYRGBstatsXMLdataFilesDirectory, true, currPath2Process);
                ServiceTools.WriteObjectToXML(currImageProcessingResult.grixyrgbStatsData, strImageGrIxYRGBDataFileName);


                ImageStatsCollectingData foundDataObj =
                    lStatsCalculation.Find(obj => obj.filename == currentFullFileName);
                foundDataObj.State           = ImageStatsCollectingState.Finished;
                foundDataObj.GrIxMedianValue = currImageProcessingResult.mp5Result.GrIxStatsMedian;
                foundDataObj.GrIxPerc5Value  = currImageProcessingResult.mp5Result.GrIxStatsPerc5;


                Console.WriteLine(DateTime.Now.ToString("s") + " : finished processing file " + Environment.NewLine + currentFullFileName);
            }
            else
            {
                string currentFullFileName            = currImageProcessingResult.imgFilename;
                ImageStatsCollectingData foundDataObj =
                    lStatsCalculation.Find(obj => obj.filename == currentFullFileName);
                foundDataObj.State = ImageStatsCollectingState.Error;
                Console.WriteLine("ERROR processing file " + Path.GetFileName(currentFullFileName));
                try
                {
                    //report full error to error log file
                    #region report error
#if (DEBUG && MONO)
                    ServiceTools.logToTextFile(errorLogFilename,
                                               "Error processing file: " + Environment.NewLine + currentFullFileName +
                                               Environment.NewLine + "messages: " +
                                               ServiceTools.GetExceptionMessages(currImageProcessingResult.exception) + Environment.NewLine +
                                               "Stack trace: " + Environment.NewLine +
                                               Environment.StackTrace + Environment.NewLine + Environment.NewLine, true, true);
#else
#if MONO
                    ServiceTools.logToTextFile(errorLogFilename,
                                               "Error processing file: " + Environment.NewLine + currentFullFileName +
                                               Environment.NewLine + "messages: " +
                                               ServiceTools.GetExceptionMessages(currImageProcessingResult.exception) + Environment.NewLine +
                                               "Stack trace: " + Environment.NewLine +
                                               Environment.StackTrace + Environment.NewLine + Environment.NewLine, true, true);
#else
                    ServiceTools.logToTextFile(errorLogFilename,
                                               "Error processing file: " + Environment.NewLine + currentFullFileName +
                                               Environment.NewLine + "message: " +
                                               ServiceTools.GetExceptionMessages(currImageProcessingResult.exception) + Environment.NewLine +
                                               ServiceTools.CurrentCodeLineDescription() + Environment.NewLine + "Stack trace: " + Environment.NewLine +
                                               Environment.StackTrace + Environment.NewLine + Environment.NewLine, true, true);
#endif
#endif
                    #endregion report error
                }
                catch (Exception ex)
                {
                    return;
                }
            }
        }
Exemplo n.º 3
0
        private Image <Bgr, byte> FillGraphImage(Size imgSize)
        {
            string curDirPath = Directory.GetCurrentDirectory() + "\\logs\\";

            DirectoryInfo dirInfo = new DirectoryInfo(curDirPath);

            List <Dictionary <string, object> > lReadData = new List <Dictionary <string, object> >();

            if (defaultGraphsTimeSpan)
            {
                graphsTimeSpan = new Tuple <DateTime, DateTime>(DateTime.UtcNow.AddDays(-1), DateTime.UtcNow);
            }

            GraphVariablesTypes currVarType = GraphVariablesTypes.none;

            if (rbtnPressureGraph.Checked)
            {
                currVarType = GraphVariablesTypes.Pressure;
            }
            if (rbtnAirTempGraph.Checked)
            {
                currVarType = GraphVariablesTypes.AirTemp;
            }
            if (rbtnWaterTempGraph.Checked)
            {
                currVarType = GraphVariablesTypes.WaterTemp;
            }
            if (rbtnWindSpeedGraph.Checked)
            {
                currVarType = GraphVariablesTypes.WindSpeed;
            }


            if ((fRenderer == null) || (!prevGraphsTimeSpan.Equals(graphsTimeSpan) || currVarType != prevGraphVariable))
            {
                fRenderer = new MultipleScatterAndFunctionsRepresentation(imgSize);
                switch (currVarType)
                {
                case GraphVariablesTypes.Pressure:
                {
                    currValueColor = new Bgr(Color.Blue);
                    break;
                }

                case GraphVariablesTypes.AirTemp:
                {
                    currValueColor = new Bgr(Color.Red);
                    break;
                }

                case GraphVariablesTypes.WaterTemp:
                {
                    currValueColor = new Bgr(Color.RoyalBlue);
                    break;
                }

                case GraphVariablesTypes.WindSpeed:
                {
                    currValueColor = new Bgr(Color.Gray);
                    break;
                }

                default:
                {
                    currValueColor = new Bgr(Color.Blue);
                    break;
                }
                }
            }
            else if (fRenderer != null)
            {
                if (fRenderer.TheImage.Size != imgSize)
                {
                    fRenderer.ResizeCanvas(imgSize);
                }
            }



            if (!prevGraphsTimeSpan.Equals(graphsTimeSpan))
            {
                IEnumerable <string> ncFileNames = Directory.EnumerateFiles(curDirPath,
                                                                            "IoffeVesselInfoStream-MeteoDataLog-*.nc",
                                                                            SearchOption.TopDirectoryOnly);
                foreach (string ncFileName in ncFileNames)
                {
                    Tuple <DateTime, DateTime> currFileDateTimeRange = null;
                    try
                    {
                        currFileDateTimeRange = ServiceTools.GetNetCDFfileTimeStampsRange(ncFileName);
                    }
                    catch (Exception ex)
                    {
                        #region report

#if DEBUG
                        ServiceTools.ExecMethodInSeparateThread(this, () =>
                        {
                            theLogWindow = ServiceTools.LogAText(theLogWindow,
                                                                 "an exception has been thrown during file reading: " + Environment.NewLine + ncFileName +
                                                                 Environment.NewLine + "message: " + ex.Message + Environment.NewLine +
                                                                 ServiceTools.CurrentCodeLineDescription());
                        });
#else
                        ServiceTools.ExecMethodInSeparateThread(this, () =>
                        {
                            ServiceTools.logToTextFile(errorLogFilename,
                                                       "an exception has been thrown during file reading: " + Environment.NewLine + ncFileName +
                                                       Environment.NewLine + "message: " + ex.Message + Environment.NewLine +
                                                       ServiceTools.CurrentCodeLineDescription(), true, true);
                        });
#endif

                        #endregion report
                    }

                    if (currFileDateTimeRange == null)
                    {
                        continue;
                    }

                    if ((currFileDateTimeRange.Item1 >= graphsTimeSpan.Item1) &&
                        (currFileDateTimeRange.Item1 <= graphsTimeSpan.Item2) ||
                        (currFileDateTimeRange.Item2 >= graphsTimeSpan.Item1) &&
                        (currFileDateTimeRange.Item2 <= graphsTimeSpan.Item2))
                    {
                        Dictionary <string, object> dictFileData = null;
                        try
                        {
                            dictFileData = NetCDFoperations.ReadDataFromFile(ncFileName);
                        }
                        catch (Exception ex)
                        {
                            #region report

#if DEBUG
                            ServiceTools.ExecMethodInSeparateThread(this, () =>
                            {
                                theLogWindow = ServiceTools.LogAText(theLogWindow,
                                                                     "an exception has been thrown during file reading: " + Environment.NewLine +
                                                                     ncFileName +
                                                                     Environment.NewLine + "message: " + ex.Message + Environment.NewLine +
                                                                     ServiceTools.CurrentCodeLineDescription());
                            });
#else
                            ServiceTools.ExecMethodInSeparateThread(this, () =>
                            {
                                ServiceTools.logToTextFile(errorLogFilename,
                                                           "an exception has been thrown during file reading: " + Environment.NewLine + ncFileName +
                                                           Environment.NewLine + "message: " + ex.Message + Environment.NewLine +
                                                           ServiceTools.CurrentCodeLineDescription(), true, true);
                            });
#endif

                            #endregion report
                        }

                        if (dictFileData != null)
                        {
                            lReadData.Add(dictFileData);
                        }
                    }
                }


                foreach (Dictionary <string, object> currFileDataDict in lReadData)
                {
                    if (currFileDataDict == null)
                    {
                        continue;
                    }

                    string varNameDateTime = "DateTime";

                    List <long> currFileDateTimeLongTicksList =
                        new List <long>((currFileDataDict[varNameDateTime] as long[]));
                    List <DateTime> currFileDateTimeList =
                        currFileDateTimeLongTicksList.ConvertAll(longVal => new DateTime(longVal));

                    string           varNameMeteoData      = "MeteoData";
                    List <MeteoData> currFileMeteoDataList =
                        MeteoData.OfDenseMatrix(currFileDataDict[varNameMeteoData] as DenseMatrix);

                    if (tsMeteoDataForGraphs == null)
                    {
                        try
                        {
                            tsMeteoDataForGraphs = new TimeSeries <MeteoData>(currFileMeteoDataList, currFileDateTimeList,
                                                                              true);
                        }
                        catch (Exception ex)
                        {
                            #region report

#if DEBUG
                            ServiceTools.ExecMethodInSeparateThread(this, () =>
                            {
                                theLogWindow = ServiceTools.LogAText(theLogWindow,
                                                                     "couldn`t create timeseries: exception has been thrown" + Environment.NewLine +
                                                                     ServiceTools.CurrentCodeLineDescription() + Environment.NewLine + "message: " +
                                                                     ex.Message);
                            });
#else
                            ServiceTools.ExecMethodInSeparateThread(this, () =>
                            {
                                ServiceTools.logToTextFile(errorLogFilename,
                                                           "couldn`t create timeseries: exception has been thrown" + Environment.NewLine +
                                                           ServiceTools.CurrentCodeLineDescription() + Environment.NewLine + "message: " +
                                                           ex.Message, true, true);
                            });
#endif

                            #endregion report
                        }
                    }
                    else
                    {
                        try
                        {
                            tsMeteoDataForGraphs.AddSubseriaData(currFileMeteoDataList, currFileDateTimeList, true);
                        }
                        catch (Exception ex)
                        {
                            #region report

#if DEBUG
                            ServiceTools.ExecMethodInSeparateThread(this, () =>
                            {
                                theLogWindow = ServiceTools.LogAText(theLogWindow,
                                                                     "couldn`t create timeseries: exception has been thrown" + Environment.NewLine +
                                                                     ServiceTools.CurrentCodeLineDescription() + Environment.NewLine + "message: " +
                                                                     ex.Message);
                            });
#else
                            ServiceTools.ExecMethodInSeparateThread(this, () =>
                            {
                                ServiceTools.logToTextFile(errorLogFilename,
                                                           "couldn`t create timeseries: exception has been thrown" + Environment.NewLine +
                                                           ServiceTools.CurrentCodeLineDescription() + Environment.NewLine + "message: " +
                                                           ex.Message, true, true);
                            });
#endif

                            #endregion report
                        }
                    }
                }



                if (tsMeteoDataForGraphs == null)
                {
                    return(null);
                }

                tsMeteoDataForGraphs.SortByTimeStamps();
                tsMeteoDataForGraphs.RemoveDuplicatedTimeStamps();

                DateTime utcNow = DateTime.UtcNow;
                if (defaultGraphsTimeSpan)
                {
                    tsMeteoDataForGraphs.RemoveValues(dt => (utcNow - dt).TotalSeconds > 86400);
                }
                else
                {
                    tsMeteoDataForGraphs.RemoveValues(
                        dt => !((dt >= graphsTimeSpan.Item1) && (dt <= graphsTimeSpan.Item2)));
                }


                List <TimeSeries <MeteoData> > subSeriesBy1Minute =
                    tsMeteoDataForGraphs.SplitByTimeSpan(new TimeSpan(0, 1, 0));
                List <double>         lSubSeriesEntriesCount = subSeriesBy1Minute.ConvertAll(subs => (double)subs.Count);
                DescriptiveStatistics statsCounts            = new DescriptiveStatistics(lSubSeriesEntriesCount);
                aveMinuteEntriesCount = Convert.ToInt32(statsCounts.Mean);


                // = tsMeteoData.TimeStamps.ConvertAll(dt => (dt - maxDateTime).TotalSeconds);
            }



            List <MeteoData> meteoDataList = tsMeteoDataForGraphs.DataValues;
            DateTime         maxDateTime   = tsMeteoDataForGraphs.TimeStamps.Max();



            if ((currVarType != prevGraphVariable) || !prevGraphsTimeSpan.Equals(graphsTimeSpan))
            {
                double        minVarValue         = 0.0d;
                double        maxVarValue         = 1.0d;
                List <double> currVarToShowValues = new List <double>();
                switch (currVarType)
                {
                case GraphVariablesTypes.Pressure:
                {
                    currVarToShowValues = meteoDataList.ConvertAll(mdt => mdt.pressure);

                    TimeSeries <double> currVarTS = new TimeSeries <double>(currVarToShowValues,
                                                                            tsMeteoDataForGraphs.TimeStamps);
                    currVarTS.RemoveValues(dVal => dVal <= 900.0d);

                    currVarToShowValues = new List <double>(currVarTS.DataValues);
                    currFileSecondsList = currVarTS.TimeStamps.ConvertAll(dt => (dt - maxDateTime).TotalSeconds);

                    fRenderer.yAxisValuesConversionToRepresentTicksValues =
                        new Func <double, string>(dVal => dVal.ToString("F1"));
                    break;
                }

                case GraphVariablesTypes.AirTemp:
                {
                    currVarToShowValues = meteoDataList.ConvertAll(mdt => mdt.airTemperature);

                    TimeSeries <double> currVarTS = new TimeSeries <double>(currVarToShowValues,
                                                                            tsMeteoDataForGraphs.TimeStamps);
                    currVarTS.RemoveValues(dVal => ((dVal < -20.0d) || (dVal > 50.0d)));

                    currVarToShowValues = new List <double>(currVarTS.DataValues);
                    currFileSecondsList = currVarTS.TimeStamps.ConvertAll(dt => (dt - maxDateTime).TotalSeconds);

                    fRenderer.yAxisValuesConversionToRepresentTicksValues =
                        new Func <double, string>(dVal => dVal.ToString("F2"));
                    break;
                }

                case GraphVariablesTypes.WaterTemp:
                {
                    currVarToShowValues = meteoDataList.ConvertAll(mdt => mdt.waterTemperature);

                    TimeSeries <double> currVarTS = new TimeSeries <double>(currVarToShowValues,
                                                                            tsMeteoDataForGraphs.TimeStamps);
                    currVarTS.RemoveValues(dVal => ((dVal < -20.0d) || (dVal > 50.0d)));

                    currVarToShowValues = new List <double>(currVarTS.DataValues);
                    currFileSecondsList = currVarTS.TimeStamps.ConvertAll(dt => (dt - maxDateTime).TotalSeconds);



                    fRenderer.yAxisValuesConversionToRepresentTicksValues =
                        new Func <double, string>(dVal => dVal.ToString("F2"));
                    break;
                }

                case GraphVariablesTypes.WindSpeed:
                {
                    currVarToShowValues = meteoDataList.ConvertAll(mdt => mdt.windSpeed);

                    TimeSeries <double> currVarTS = new TimeSeries <double>(currVarToShowValues,
                                                                            tsMeteoDataForGraphs.TimeStamps);
                    currVarTS.RemoveValues(dVal => ((dVal < 0.0d) || (dVal > 50.0d)));

                    currVarToShowValues = new List <double>(currVarTS.DataValues);
                    currFileSecondsList = currVarTS.TimeStamps.ConvertAll(dt => (dt - maxDateTime).TotalSeconds);

                    fRenderer.yAxisValuesConversionToRepresentTicksValues =
                        new Func <double, string>(dVal => dVal.ToString("F1"));
                    break;
                }

                default:
                    return(null);
                }

                dvVarValues = DenseVector.OfEnumerable(currVarToShowValues);
                dvVarValues = dvVarValues.Conv(Extensions.StandardConvolutionKernels.gauss, aveMinuteEntriesCount * 10);
            }



            fRenderer.dvScatterFuncValues.Add(dvVarValues);
            fRenderer.dvScatterXSpace.Add(DenseVector.OfEnumerable(currFileSecondsList));

            fRenderer.xAxisValuesConversionToRepresentTicksValues = (dValSec) =>
            {
                DateTime currDT = tsMeteoDataForGraphs.TimeStamps.Max().AddSeconds(dValSec);
                return(currDT.ToString("yyyy-MM-dd" + Environment.NewLine + "HH:mm"));
            };

            fRenderer.scatterLineColors.Add(currValueColor);
            fRenderer.scatterDrawingVariants.Add(SequencesDrawingVariants.polyline);
            fRenderer.xSpaceMin           = currFileSecondsList.Min();
            fRenderer.xSpaceMax           = currFileSecondsList.Max();
            fRenderer.overallFuncMin      = dvVarValues.Min();
            fRenderer.overallFuncMax      = dvVarValues.Max();
            fRenderer.fixSpecifiedMargins = true;

            fRenderer.Represent();

            Image <Bgr, byte> retImg = fRenderer.TheImage;

            // расположим надпись
            string strSign = "current value: " + dvVarValues.Last().ToString("F2");

            List <TextBarImage> textBarsCases = new List <TextBarImage>();

            TextBarImage tbimTopLeftSign = new TextBarImage(strSign, retImg);
            tbimTopLeftSign.PtSurroundingBarStart =
                new Point(fRenderer.LeftServiceSpaceGapX + tbimTopLeftSign.textHalfHeight,
                          fRenderer.TopServiceSpaceGapY + tbimTopLeftSign.textHalfHeight);
            textBarsCases.Add(tbimTopLeftSign);

            TextBarImage tbimBtmLeftSign = new TextBarImage(strSign, retImg);
            tbimBtmLeftSign.PtSurroundingBarStart = new Point(fRenderer.LeftServiceSpaceGapX + tbimBtmLeftSign.textHalfHeight,
                                                              retImg.Height - fRenderer.BtmServiceSpaceGapY - tbimBtmLeftSign.textHalfHeight - tbimBtmLeftSign.textHeight * 2);
            textBarsCases.Add(tbimBtmLeftSign);

            TextBarImage tbimTopRightSign = new TextBarImage(strSign, retImg);
            tbimTopRightSign.PtSurroundingBarStart =
                new Point(
                    retImg.Width - fRenderer.RightServiceSpaceGapX - tbimTopRightSign.textHalfHeight -
                    tbimTopRightSign.textBarSize.Width, fRenderer.TopServiceSpaceGapY + tbimTopLeftSign.textHalfHeight);
            textBarsCases.Add(tbimTopRightSign);

            TextBarImage tbimBtmRightSign = new TextBarImage(strSign, retImg);
            tbimBtmRightSign.PtSurroundingBarStart =
                new Point(
                    retImg.Width - fRenderer.RightServiceSpaceGapX - tbimBtmRightSign.textHalfHeight -
                    tbimBtmRightSign.textBarSize.Width,
                    retImg.Height - fRenderer.BtmServiceSpaceGapY - tbimBtmRightSign.textHalfHeight -
                    tbimBtmRightSign.textHeight * 2);
            textBarsCases.Add(tbimBtmRightSign);

            textBarsCases.Sort((case1, case2) => (case1.SubImageInTextRect.CountNonzero().Sum() > case2.SubImageInTextRect.CountNonzero().Sum()) ? 1 : -1);

            MCvFont theFont = new MCvFont(Emgu.CV.CvEnum.FONT.CV_FONT_HERSHEY_PLAIN, 2.0d, 2.0d)
            {
                thickness = 2,
            };
            // retImg.Draw(strSign, textBarsCases[0].ptTextBaselineStart, Emgu.CV.CvEnum.FontFace.HersheyPlain, 2.0d, new Bgr(Color.Green), 2);
            retImg.Draw(strSign, ref theFont, textBarsCases[0].ptTextBaselineStart, new Bgr(Color.Green));
            retImg.Draw(textBarsCases[0].rectSurroundingBar, new Bgr(Color.Green), 2);

            prevGraphsTimeSpan = graphsTimeSpan;
            prevGraphVariable  = currVarType;

            return(retImg);
        }
        private void CurrFileProcessing(ImagesConvertingData dat)
        {
            string currentFullFileName = dat.filename;

            try
            {
                List <List <string> > csvFileContents = ServiceTools.ReadDataFromCSV(currentFullFileName, 3, true, ";", Environment.NewLine);

                List <double> lCenterXValues = csvFileContents.ConvertAll <double>(lStr => Convert.ToDouble(lStr[1]));
                List <double> lCenterYValues = csvFileContents.ConvertAll <double>(lStr => Convert.ToDouble(lStr[2]));
                List <double> lRadiiValues   = csvFileContents.ConvertAll <double>(lStr => Convert.ToDouble(lStr[3]));

                // filter default values
                // filteringMarks = "те, которые оставляем"
                List <bool> filteringMarks = csvFileContents.ConvertAll <bool>(lStr => true);
                if (filterDefaultDoubleValueCenterX > 0.0d)
                {
                    List <bool> filteringMarksAdd = lCenterXValues.ConvertAll <bool>(dVal => dVal != filterDefaultDoubleValueCenterX);
                    filteringMarks =
                        (filteringMarks.Zip <bool, bool, bool>(filteringMarksAdd, (bVal1, bVal2) => bVal1 && bVal2))
                        .ToList();
                }

                if (filterDefaultDoubleValueCenterY > 0.0d)
                {
                    List <bool> filteringMarksAdd = lCenterYValues.ConvertAll <bool>(dVal => dVal != filterDefaultDoubleValueCenterY);
                    filteringMarks =
                        (filteringMarks.Zip <bool, bool, bool>(filteringMarksAdd, (bVal1, bVal2) => bVal1 && bVal2))
                        .ToList();
                }

                if (filterDefaultDoubleValueRadius > 0.0d)
                {
                    List <bool> filteringMarksAdd = lRadiiValues.ConvertAll <bool>(dVal => dVal != filterDefaultDoubleValueRadius);
                    filteringMarks =
                        (filteringMarks.Zip <bool, bool, bool>(filteringMarksAdd, (bVal1, bVal2) => bVal1 && bVal2))
                        .ToList();
                }

                List <int> indexes =
                    filteringMarks
                    .Select((val, idx) => new { val, idx })
                    .Where(x => x.val)
                    .Select(x => x.idx)
                    .ToList();
                lCenterXValues = lCenterXValues
                                 .Select((dVal, idx) => new { dVal, idx })
                                 .Where(x => indexes.Contains(x.idx))
                                 .Select(x => x.dVal).ToList();
                lCenterYValues = lCenterYValues
                                 .Select((dVal, idx) => new { dVal, idx })
                                 .Where(x => indexes.Contains(x.idx))
                                 .Select(x => x.dVal).ToList();
                lRadiiValues = lRadiiValues
                               .Select((dVal, idx) => new { dVal, idx })
                               .Where(x => indexes.Contains(x.idx))
                               .Select(x => x.dVal).ToList();

                DescriptiveStatistics stats = new DescriptiveStatistics(lCenterXValues, true);
                double dCenterXvalue        = stats.Mean;
                stats = new DescriptiveStatistics(lCenterYValues, true);
                double dCenterYvalue = stats.Mean;
                stats = new DescriptiveStatistics(lRadiiValues, true);
                double    dRadiusvalue = stats.Mean;
                RoundData rd           = new RoundData(dCenterXvalue, dCenterYvalue, dRadiusvalue);

                string xmlFilename = Path.GetDirectoryName(currentFullFileName);
                xmlFilename += (xmlFilename.Last() == Path.DirectorySeparatorChar)
                    ? ("")
                    : (Path.DirectorySeparatorChar.ToString());
                xmlFilename += Path.GetFileNameWithoutExtension(currentFullFileName) + "-RoundImagemask.xml";


                ServiceTools.WriteObjectToXML(rd, xmlFilename);

                Console.WriteLine("finished processing file " + Environment.NewLine + currentFullFileName);
            }
            catch (Exception ex)
            {
                #region report
#if DEBUG
                Console.WriteLine("exception has been thrown: " + ex.Message + Environment.NewLine +
                                  ServiceTools.CurrentCodeLineDescription());
#else
                ServiceTools.logToTextFile(errorLogFilename,
                                           "exception has been thrown: " + ex.Message + Environment.NewLine +
                                           ServiceTools.CurrentCodeLineDescription(), true, true);
#endif

                #endregion report
            }
        }