From 11d3cc69f932b44ec5b3bbf76339791f612bd067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B0=D0=B4=D0=B8=D0=BC=20=D0=91=D0=BE=D1=80=D0=B8?= =?UTF-8?q?=D1=81=D0=BE=D0=B2?= <98724575+Kirpitchnsk@users.noreply.github.com> Date: Fri, 12 May 2023 05:05:18 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B2=D1=8B=D0=B9=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D0=BD=D0=BE=D1=86=D0=B5=D0=BD=D0=BD=D1=8B=D0=B9=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BF=D0=BB=D0=B5=D0=BA=D1=81=D0=BD=D1=8B?= =?UTF-8?q?=D0=B9=20=D0=BF=D0=BE=D0=B4=D1=85=D0=BE=D0=B4!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LogicSimulator/Models/Simulator.cs | 27 ++++++++- .../ViewModels/MainWindowViewModel.cs | 2 + LogicSimulator/Views/MainWindow.axaml | 4 +- LogicSimulator/for_test.json | 1 + UITestsLogicSimulator/AllTestsInOnePlace.cs | 53 ++++++++++++++++-- UITestsLogicSimulator/TestLog.txt | 14 +---- UITestsLogicSimulator/tested | 56 ++++++++++++++++++- build.num | 2 +- 8 files changed, 136 insertions(+), 23 deletions(-) create mode 100644 LogicSimulator/for_test.json diff --git a/LogicSimulator/Models/Simulator.cs b/LogicSimulator/Models/Simulator.cs index 01b9476..a3c21ee 100644 --- a/LogicSimulator/Models/Simulator.cs +++ b/LogicSimulator/Models/Simulator.cs @@ -2,7 +2,6 @@ using LogicSimulator.Views.Shapes; using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using System.Threading.Tasks; @@ -112,6 +111,11 @@ private void Tick() { (outs2, outs) = (outs, outs2); // Магия здесь! // Log.Write("Выходы: " + Utils.Obj2json(outs)); + + if (comparative_test_mode) { + prev_state = cur_state; + cur_state = Export(); + } } public string Export() => string.Join("", outs.Select(x => x ? '1' : '0')); @@ -132,5 +136,26 @@ public void Clear() { */ public void TopSecretPublicTickMethod() => Tick(); + + // Для комплесного решения: + + public Switch[] GetSwitches() => items.Select(x => x.item).OfType().ToArray(); + public LightBulb[] GetLightBulbs() => items.Select(x => x.item).OfType().ToArray(); + + // Для УМНОГО комплесного решения XD: + + private bool comparative_test_mode = false; + private string prev_state; + private string cur_state; + + public bool ComparativeTestMode { + get => comparative_test_mode; + set { + comparative_test_mode = value; + if (value) prev_state = cur_state = Export(); + } + } + + public bool SomethingHasChanged => prev_state != cur_state; } } diff --git a/LogicSimulator/ViewModels/MainWindowViewModel.cs b/LogicSimulator/ViewModels/MainWindowViewModel.cs index 388bc62..227aaf1 100644 --- a/LogicSimulator/ViewModels/MainWindowViewModel.cs +++ b/LogicSimulator/ViewModels/MainWindowViewModel.cs @@ -181,6 +181,8 @@ public void FuncComm(string Comm) { break; case "Save": map.Export(); + // Для создания тестовых штучек: + File.WriteAllText("../../../for_test.json", Utils.Obj2json((map.current_scheme ?? throw new System.Exception("Чё?!")).Export())); break; case "SaveAs": map.Export(); diff --git a/LogicSimulator/Views/MainWindow.axaml b/LogicSimulator/Views/MainWindow.axaml index ec17f05..4dd310c 100644 --- a/LogicSimulator/Views/MainWindow.axaml +++ b/LogicSimulator/Views/MainWindow.axaml @@ -73,10 +73,10 @@ - -