Beispiel #1
0
        public virtual void MakeAlgorithm(ref Cl3DModel p_Model)
        {
            if (p_Model == null)
            {
                throw new Exception("NULL model");
            }

            ClInformationSender.SendInformation("-> In progress: " + m_sAlgorithmName + " for: " + p_Model.ModelFileName, ClInformationSender.eInformationType.eTextInternal);
            p_Model.ResetVisitedPoints();
            DateTime start = DateTime.Now;

            m_AlgorithmTime = TimeSpan.Zero;

            Algorithm(ref p_Model);

            DateTime stop = DateTime.Now;

            m_AlgorithmTime        = (stop - start);
            p_Model.IsModelChanged = true;
            ClInformationSender.SendInformation("-] Finished: " + m_sAlgorithmName + " for: " + p_Model.ModelFileName + " [time: " + m_AlgorithmTime.TotalSeconds + " sec.]", ClInformationSender.eInformationType.eTextInternal);

            string fullAlgorithmAdditionalData = GetAlgorithmFullPath() + "\n";

            foreach (KeyValuePair <string, string> prop in GetProperitis())
            {
                fullAlgorithmAdditionalData += "\t" + prop.Key + " -> " + prop.Value + "\n";
            }
            p_Model.AddDoneProcessingAlgorithm(fullAlgorithmAdditionalData);
        }
        static private void RunAlgorithmsForModel()
        {
            try
            {
                if (m_bIsRunning)
                {
                    return;
                }

                ClInformationSender.SendInformation(null, ClInformationSender.eInformationType.eStartProcessing);

                m_bIsRunning = true;
                DateTime start = DateTime.Now;
                foreach (IFaceAlgorithm alg in m_lAlgorithmsList)
                {
                    alg.MakeAlgorithm(ref m_sProcessedModel);
                }
                DateTime stop = DateTime.Now;

                ClInformationSender.SendInformation("DONE in: " + (stop - start).TotalSeconds + " Sec.", ClInformationSender.eInformationType.eTextInternal);

                string algTimes = "";
                foreach (IFaceAlgorithm alg in m_lAlgorithmsList)
                {
                    algTimes += alg.GetAlgorithmFullPath() + " time[ms]:\t" + alg.GetComputationTime().TotalMilliseconds + "\n";
                }

                ClInformationSender.SendInformation(algTimes, ClInformationSender.eInformationType.eDebugText);
                ClInformationSender.SendInformation(algTimes, ClInformationSender.eInformationType.eStopProcessing);
                m_bIsRunning = false;
            }
            catch (ThreadAbortException)
            {
                ClInformationSender.SendInformation("Processing Interrupted", ClInformationSender.eInformationType.eTextInternal);
                ClInformationSender.SendInformation(null, ClInformationSender.eInformationType.eStopProcessing);
                m_bIsRunning = false;
            }
            catch (Exception e)
            {
                ClInformationSender.SendInformation("ERROR:\n" + e.ToString(), ClInformationSender.eInformationType.eError);
                ClInformationSender.SendInformation(null, ClInformationSender.eInformationType.eStopProcessing);
                m_bIsRunning = false;
            }
        }
        static public void ResetFasade()
        {
            m_sProcessedModel = null;
            m_bIsRunning      = false;
            m_lAlgorithmsList = null;
            m_lFilesList.Clear();
            m_sTestDirectory = @"c:\";

            if (m_sProcessingThread != null)
            {
                if (m_sProcessingThread.IsAlive)
                {
                    m_sProcessingThread.Abort();
                }
                while (m_sProcessingThread.ThreadState != ThreadState.AbortRequested &&
                       m_sProcessingThread.ThreadState != ThreadState.Stopped)
                {
                }
                m_sProcessingThread = null;
                ClInformationSender.SendInformation(null, ClInformationSender.eInformationType.eStopProcessing);
            }
        }
        static private void RunAlgorithmsForFolder()
        {
            if (m_bIsRunning)
            {
                return;
            }

            m_bIsRunning = true;

            ClFileLogger FileLogger = new ClFileLogger(m_sTestDirectory + "log.txt", false);

            if (m_bLogging)
            {
                ClInformationSender.RegisterReceiver(FileLogger, ClInformationSender.eInformationType.eDebugText);
                ClInformationSender.RegisterReceiver(FileLogger, ClInformationSender.eInformationType.eTextExternal);
                ClInformationSender.RegisterReceiver(FileLogger, ClInformationSender.eInformationType.eTextInternal);
                ClInformationSender.RegisterReceiver(FileLogger, ClInformationSender.eInformationType.eError);
            }
            try
            {
                ClInformationSender.SendInformation(null, ClInformationSender.eInformationType.eStartProcessing);

                int current = 1;
                int howMany = m_lFilesList.Count;

                ClInformationSender.SendInformation(null, ClInformationSender.eInformationType.eStartProcessing);

                string fullAlgorithmAdditionalData = "";
                foreach (IFaceAlgorithm alg in m_lAlgorithmsList)
                {
                    fullAlgorithmAdditionalData += "\n- " + alg.GetAlgorithmFullPath();
                    fullAlgorithmAdditionalData += "\n";
                    foreach (KeyValuePair <string, string> prop in alg.GetProperitis())
                    {
                        fullAlgorithmAdditionalData += "\t" + prop.Key + " -> " + prop.Value + "\n";
                    }
                }
                fullAlgorithmAdditionalData += "\n------------------------------";
                ClInformationSender.SendInformation(fullAlgorithmAdditionalData, ClInformationSender.eInformationType.eDebugText);

                TimeSpan mean = TimeSpan.Zero;
                foreach (String file in m_lFilesList)
                {
                    DateTime start = DateTime.Now;
                    ClInformationSender.SendInformation(((current * 100) / howMany).ToString(), ClInformationSender.eInformationType.eProgress);
                    try
                    {
                        Cl3DModel newModel = new Cl3DModel();

                        newModel.LoadModel(file);

                        foreach (IFaceAlgorithm alg in m_lAlgorithmsList)
                        {
                            alg.MakeAlgorithm(ref newModel);
                        }
                    }
                    catch (ThreadAbortException)
                    {
                        ClInformationSender.SendInformation("Processing Interrupted", ClInformationSender.eInformationType.eTextInternal);
                        break;
                    }
                    catch (Exception ex)
                    {
                        ClInformationSender.SendInformation("ERROR:\n(" + file + ")\n" + ex.ToString(), ClInformationSender.eInformationType.eDebugText);
                    }
                    DateTime stop = DateTime.Now;
                    mean += (stop - start);
                    double MeanTotalHours = mean.TotalHours;
                    double MeanTotalMin   = mean.TotalMinutes;

                    int TotalTimeHours = (int)((MeanTotalHours / current) * (howMany - current));
                    int TotalTimeMin   = (int)((MeanTotalMin / current) * (howMany - current));

                    TotalTimeMin = TotalTimeMin - (TotalTimeHours * 60);

                    ClInformationSender.SendInformation("Time Remaining: " + TotalTimeHours.ToString() + "h" + TotalTimeMin.ToString("00") + "min [" + current.ToString() + "/" + howMany.ToString() + "]", ClInformationSender.eInformationType.eTextExternal);
                    current++;
                }
            }
            catch (Exception e)
            {
                ClInformationSender.SendInformation("ERROR:\n" + e.ToString(), ClInformationSender.eInformationType.eError);
            }

            m_bIsRunning = false;
            ClInformationSender.SendInformation(null, ClInformationSender.eInformationType.eStopProcessing);

            ClInformationSender.UnRegisterReceiver(FileLogger, ClInformationSender.eInformationType.eDebugText);
            ClInformationSender.UnRegisterReceiver(FileLogger, ClInformationSender.eInformationType.eTextExternal);
            ClInformationSender.UnRegisterReceiver(FileLogger, ClInformationSender.eInformationType.eTextInternal);
            ClInformationSender.UnRegisterReceiver(FileLogger, ClInformationSender.eInformationType.eError);
        }
        static public void RegisterNewAlgorithm(BuildAlgorithm p_Algorithm, string p_sAlgorithmName)
        {
            m_CreateMethodsDictionary.Add(p_sAlgorithmName, p_Algorithm);

            ClInformationSender.SendInformation(p_sAlgorithmName, ClInformationSender.eInformationType.eNewAlgorithm);
        }