コード例 #1
0
ファイル: MainForm.cs プロジェクト: S1LV3Rman/State-machines
        private void SaveIcdfaPart()
        {
            var icdfa = CurrentIcdfaLogic;

            if (icdfa == null)
            {
                throw new NullReferenceException(nameof(CurrentIcdfaLogic));
            }

            if (!Directory.Exists("icdfa parts"))
            {
                Directory.CreateDirectory("icdfa parts");
            }

            if (!Directory.Exists($"icdfa parts/Prtcl{icdfa.N}x{icdfa.K}"))
            {
                Directory.CreateDirectory($"icdfa parts/Prtcl{icdfa.N}x{icdfa.K}");
            }

            var result = CurrentIcdfaLogic.GetTotalLenghts();
            //TODO "Remove Prtcl{icdfa.N}x{icdfa.K}"
            var stream = new StreamWriter(new FileStream($"icdfa parts/Prtcl{icdfa.N}x{icdfa.K}/Prtcl{icdfa.N}x{icdfa.K}_pts{icdfa.StartPart}-{icdfa.StartPart + icdfa.CountParts - 1}of{icdfa.TotalParts}.txt", FileMode.Create));

            foreach (var record in result)
            {
                stream.WriteLine(record);
            }
            stream.Close();
        }
コード例 #2
0
        /// <summary>
        /// Обновляет вывод связанный с Icdfa
        /// </summary>
        private void UpdateIcdfaOutput()
        {
            if (CurrentIcdfaLogic == null)
            {
                throw new InvalidProgramException();
            }

            StringBuilder.Clear();                                          //Юзам StringBuilder для экономии памяти и времени cpu
            var array = CurrentIcdfaLogic.GetTotalLenghts();                //Суммируем все части

            var deltaTime = DateTime.UtcNow - CurrentIcdfaLogic.LaunchTime; //Получаем время работы

            int?totalCount = GetTotalCount();

            StringBuilder.Append(GetDeltaTime(deltaTime));
            StringBuilder.Append("\n");

            if (totalCount.HasValue)
            {
                var totalParts = CurrentIcdfaLogic.TotalParts;
                var countParts = CurrentIcdfaLogic.CountParts;

                totalCount = (int)Math.Round(totalCount.Value * (countParts / (double)totalParts));

                var currentCount = CurrentIcdfaLogic.GetCurrentCount();
                var progress     = currentCount / (float)totalCount.Value;

                StringBuilder.Append(GetRemainedTime(deltaTime, totalCount.Value, progress));
                StringBuilder.Append("\n");

                StringBuilder.Append(GetCurrentCountOfTotalCount(currentCount, totalCount.Value));
                StringBuilder.Append("\n");

                StringBuilder.Append(GetProgress(progress));
                StringBuilder.Append("\n");

                //StringBuilder.Append(GetTransactionPerSecond(deltaTime,currentCount));
                //StringBuilder.Append("\n");

                StringBuilder.Append(GetGCCallsPerSecond(deltaTime, GC.CollectionCount(0), GC.CollectionCount(1), GC.CollectionCount(2)));
                StringBuilder.Append("\n");
            }
            else
            {
                StringBuilder.Append("<Calculating additional information...>");
                StringBuilder.Append("\n");
            }

            for (int i = 0; i < array.Length; i++)
            {
                StringBuilder.Append("\n");
                StringBuilder.Append(i.ToString("D2"));
                StringBuilder.Append(" - ");
                StringBuilder.Append(array[i].ToString());
            }

            richTextBoxIcdfaOutput.Text = StringBuilder.ToString();
        }