/// <summary> /// Задать параметры метрики в файл /// </summary> /// <param name="s"></param> private static void MetricSet(string s = "max", string path = null) { path = path ?? Environment.CurrentDirectory; Expendator.WriteStringInFile(Path.Combine(path, "MetrixSumOrMax.txt"), s); Expendator.WriteStringInFile("MetrixSumOrMax.txt", s); }
/// <summary> /// Конструктор /// </summary> public PS5000ABlockForm(double w0_, double w1_, int l_, int Scount = 8) { InitializeComponent(); w0 = w0_; w1 = w1_; wcount = l_; sourcesCount = Scount; // comboRangeA.DataSource = System.Enum.GetValues(typeof(Imports.Range)); toolStripStatusLabel1.Text = "Готов к работе"; toolStripStatusLabel2.Text = ""; timer1.Interval = 300; timer1.Tick += new EventHandler(Timer1_Tick); SetDirects(); SetParams(); InfoGet(); this.FormClosing += (object o, FormClosingEventArgs aa) => { GetParams(); Expendator.WriteStringInFile(Path.Combine(globalbase, "Описание.txt"), textBox23.Text); }; this.FormClosed += new FormClosedEventHandler((object o, FormClosedEventArgs a) => { FurierTransformer.Dispose(); }); Hides(); }
private bool SetGlobalBase() { if (Directory.Exists(textBox12.Text)) { globalbase = textBox12.Text; Expendator.WriteStringInFile("LastDirectory.txt", globalbase); } else { MessageBox.Show("Указанной директории не существует!", "Ошибка в пути", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } return(true); }
/// <summary> /// Задание пределов по осям /// </summary> /// <param name="count"></param> /// <param name="path"></param> private void ZlimsCalculate(int count = 1, string path = null) { path = path ?? Environment.CurrentDirectory; if (высчитатьИИспользоватьНовыеЗначенияToolStripMenuItem.Checked) { toolStripStatusLabel1.Text = "Происходит пересчёт пределов по z"; if (Forms.UG.listBox1.SelectedIndex != 3) { Forms.UG.listBox1.SelectedIndex = 3; Forms.UG.listBox1_SelectedIndexChanged(new object(), new EventArgs()); Forms.UG.checkBox13.Checked = false; } Forms.UG.button1_Click(new object(), new EventArgs()); double min1, min2, max1, max2; using (StreamReader fs = new StreamReader(Path.Combine(path, "zlims.txt"))) { fs.ReadLine(); string[] st = fs.ReadLine().Split(' '); min1 = st[0].ToDouble(); min2 = st[1].ToDouble(); st = fs.ReadLine().Split(' '); max1 = st[0].ToDouble(); max2 = st[1].ToDouble(); } using (StreamWriter f = new StreamWriter(Path.Combine(path, "zlims.txt"))) { f.WriteLine($"ur uz"); f.WriteLine($"{min1 * count} {min2 * count}"); f.WriteLine($"{max1 * count} {max2 * count}"); } } if (автоопределениеToolStripMenuItem.Checked) { Expendator.WriteStringInFile(Path.Combine(path, "AutoLims.txt"), "yes"); } else { Expendator.WriteStringInFile(Path.Combine(path, "AutoLims.txt"), "no"); } }
private static void GraficTypeToFile(GraficType type) { string s = ""; switch (type) { case GraficType.Html: s = "html"; break; case GraficType.Pdf: s = "pdf"; break; case GraficType.Png: s = "png"; break; default: s = "all"; break; } Expendator.WriteStringInFile("GraficType.txt", s); }
/// <summary> /// Суммирование замеров, построение анимации и прочие заключительные действия /// </summary> /// <returns></returns> private async Task AfterLoopsActAsync() { label9.Show(); label9.Text = $"Суммирование{Environment.NewLine}по замерам"; toolStripStatusLabel1.Text = $"Запущено построение u-surfaces"; toolStripStatusLabel2.Text = $""; BegShow(); string gl = $"{Source.ToString(sourcesArray)}, (xmin, xmax, count, ymin, ymax) = ({xmin}, {xmax}, {count}dot{count2}, {ymin}, {ymax})"; await Task.Run(() => { StreamWriter ts = new StreamWriter("textnames.txt"); StreamWriter pds = new StreamWriter("pdfnames.txt"); Expendator.WriteStringInFile("SurfaceMain.txt", gl); double th = (tmax - tmin) / (tcount - 1); for (int i = 0; i < tcount; i++) { double t = tmin + i *th; if (t == 0) { continue; } string tit = $"{Source.ToString(sourcesArray)}, t = {t.ToString(4)}, (xmin, xmax, count, ymin, ymax) = ({xmin}, {xmax}, {count}dot{count2}, {ymin}, {ymax})"; ts.WriteLine(tit + ".txt"); pds.WriteLine($"3D ur, uz(title , {tit} ).pdf"); filenames[i] = "3D " + tit + " .png"; } FilenamesArrayToFile(); ts.Close(); pds.Close(); OtherMethods.PlaySound("ДанныеСуммируются"); Parallel.Invoke( () => SSum(), () => { if (Functions.ur.Lenght > 0) { Functions.ur.Dispose(); GC.Collect(); } }); Expendator.CopyFiles(Expendator.GetWordFromFile("WhereData.txt"), Environment.CurrentDirectory, "3D ur, uz(x).txt", "3D ur, uz(y).txt"); }); label9.Hide(); if (source.IsCancellationRequested) { return; } await Task.Run(() => StartProcess("OnlySurface.r", global : true)); //new Библиотека_графики.PdfOpen("Полученные u-surfaces", Path.Combine(Environment.CurrentDirectory, $"{gl} .pdf")).Show(); CopyImages(gl); ShowImages(gl); OtherMethods.PlaySound("ПоверхностиПостроены"); if (count == count2) { if (MessageBox.Show("Создавать анимацию? (может занять до 15 минут)", "Анимация", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { toolStripStatusLabel1.Text = $"Построены u-surface. Создаётся массив кадров"; await Task.Run(() => Expendator.StartProcessOnly("ReDraw3Duxt2.r", true)); if (source.IsCancellationRequested) { return; } OtherMethods.PlaySound("АнимацияГотова"); new Anima(filenames).ShowDialog(); } new Scheme(sourcesArray, new Point(xmin, ymin), xmax - xmin, ymax - ymin, gl + " (heatmap).png").Show(); OtherMethods.PlaySound("ВычисленияЗавершены"); } toolStripStatusLabel1.Text = $"Операции закончены"; }
public async Task ManyPZAsync(Source[] sources, string path) { ZlimsCalculate(sources.Length, path); groupBox2.Hide(); groupBox6.Hide(); GetFields(); Metrics(path); double th = (tmax - tmin) / (tcount - 1); all = tcount; timer1.Start(); IProgress <int> progress = new Progress <int>((p) => { save = p; }); toolStripStatusLabel1.Text = "Вычисления запущены"; System.Threading.CancellationToken token = source.Token; StreamWriter ts = new StreamWriter(Path.Combine(path, "textnames.txt")); StreamWriter pds = new StreamWriter(Path.Combine(path, "pdfnames.txt")); string gl = $"{Source.ToString(sources)}, (xmin, xmax, count, ymin, ymax) = ({xmin}, {xmax}, {count}dot{count2}, {ymin}, {ymax})"; Expendator.WriteStringInFile(Path.Combine(path, "SurfaceMain.txt"), gl); double[] xmas = Expendator.Seq(xmin, xmax, count); double[] ymas = Expendator.Seq(ymin, ymax, count2); Func <Point, bool> Filt = (Point point) => { for (int q = 0; q < sources.Length; q++) { if (sources[q].Filter(point)) { return(true); } } return(false); }; const string filename = "3D ur, uz.txt"; async Task SlowUxtAsync() { double[,] ur = new double[count, count2], uz = new double[count, count2]; for (int i = 0; i < tcount; i++) { double t = tmin + i * th; if (t == 0) { continue; } toolStripStatusLabel1.Text = $"Построение графика при t = {t.ToString(3)}"; string tit = $"{Source.ToString(sources)}, t = {t.ToString(4)}, (xmin, xmax, count, ymin, ymax) = ({xmin}, {xmax}, {count}dot{count2}, {ymin}, {ymax})"; ts.WriteLine(tit + ".txt"); pds.WriteLine($"3D ur, uz(title , {tit} ).pdf"); button2.Show(); await Task.Run(() => МатКлассы.Waves.Circle.FieldToFile(filename, path, (double x, double y) => Uxt(x, y, t, sources), xmas, ymas, ref ur, ref uz, token, Filt, tit, true) ); if (source.IsCancellationRequested) { return; } if (checkBox1.Checked) { await Task.Run(() => StartProcess("3Duxt.r", tit, false, path)); } filenames[i] = "3D " + tit + " .png"; save = i + 1; if (source.IsCancellationRequested) { return; } } ur = null; uz = null; } async Task FastUxtAsync() { save = 0; string[] tsmas = new string[tcount], pdsmas = new string[tcount]; toolStripStatusLabel1.Text = $"Построение u(x,t) с усиленным параллелизмом"; int[] kmas = new int[tcount]; await Task.Run(() => { OtherMethods.CalcUXT(xmas, ymas, sources); Parallel.For(0, tcount, (int i) => { double t = tmin + i *th; if (t != 0) { string tit = $"{Source.ToString(sources)}, t = {t.ToString(4)}, (xmin, xmax, count, ymin, ymax) = ({xmin}, {xmax}, {count}, {ymin}, {ymax})"; tsmas[i] = tit + ".txt"; pdsmas[i] = $"3D ur, uz(title , {tit} ).pdf"; filenames[i] = "3D " + tit + " .png"; МатКлассы.Waves.Circle.FieldToFile(path, (double x, double y) => Uxt(x, y, t, sources), xmas, ymas, token, Filt, tit); if (source.IsCancellationRequested) { return; } } kmas[i] = 1; save = kmas.Sum(); if (source.IsCancellationRequested) { return; } } ); }); tsmas = tsmas.Where(n => n != null).ToArray(); pdsmas = pdsmas.Where(n => n != null).ToArray(); for (int i = 0; i < tsmas.Length; i++) { ts.WriteLine(tsmas[i]); pds.WriteLine(pdsmas[i]); } } WriteXY(filename, path, xmas, ymas); //выбор параллельного или последовательного методов if (даToolStripMenuItem.Checked) { await FastUxtAsync(); } else { await SlowUxtAsync(); } Timer1_Tick(new object(), new EventArgs()); checkBox1.Hide(); timer1.Stop(); FilenamesArrayToFile(path); ts.Close(); pds.Close(); button2.Hide(); await AnimateAsync(gl, path); }
private void SetParamsInFile() => Expendator.WriteStringInFile("TrapeziParams.txt", $"{trackBar1.Value} {trackBar2.Value} {trackBar3.Value}");