From 108e6850e6e99e3287bb7490b30ebf5ba7deeb87 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=92=D0=B0=D0=BD=D1=8F=20=D0=A3=D1=88=D0=B0=D0=BA=D0=BE?=
=?UTF-8?q?=D0=B2?= <98807407+Ivann03@users.noreply.github.com>
Date: Fri, 12 May 2023 06:13:07 +0700
Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20OR?=
=?UTF-8?q?=5F8=20=D0=B8=20AND=5F8=20=D0=B2=D0=B5=D0=BD=D1=82=D0=B8=D0=BB?=
=?UTF-8?q?=D0=B8.=20=D0=A1=D0=B8=D0=BB=D1=8C=D0=BD=D0=BE=20=D0=BF=D0=B5?=
=?UTF-8?q?=D1=80=D0=B5=D0=BF=D0=B8=D1=81=D0=B0=D0=BB=20=D0=BE=D0=BF=D1=80?=
=?UTF-8?q?=D0=B5=D0=B4=D0=B5=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=B8?=
=?UTF-8?q?=D0=BD=D0=B8=D0=BC=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B=D1=85=20=D1=80?=
=?UTF-8?q?=D0=B0=D0=B7=D0=BC=D0=B5=D1=80=D0=BE=D0=B2=20=D1=8D=D0=BB=D0=B5?=
=?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20=D1=81=D1=85=D0=B5=D0=BC?=
=?UTF-8?q?=D1=8B.=20=D0=94=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D0=BB=20Virtuali?=
=?UTF-8?q?zationMode=3D"None"=20=D0=BA=20=D0=BA=D0=B0=D0=B6=D0=B4=D0=BE?=
=?UTF-8?q?=D0=BC=D1=83=20ListBox'=D1=83=20=D0=B2=20=D0=BA=D0=B0=D1=87?=
=?UTF-8?q?=D0=B5=D1=81=D1=82=D0=B2=D0=B5=20=D0=B1=D0=B0=D0=B3=D0=BE=D1=84?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=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
LogicSimulator/LogicSimulator.csproj | 6 ++++++
LogicSimulator/Models/Mapper.cs | 4 +++-
LogicSimulator/Views/MainWindow.axaml | 4 ++--
LogicSimulator/Views/Shapes/AND_8.axaml | 18 ++++++++++++++++
LogicSimulator/Views/Shapes/AND_8.axaml.cs | 25 ++++++++++++++++++++++
LogicSimulator/Views/Shapes/GateBase.cs | 14 +++++++-----
LogicSimulator/Views/Shapes/OR_8.axaml | 18 ++++++++++++++++
LogicSimulator/Views/Shapes/OR_8.axaml.cs | 25 ++++++++++++++++++++++
LogicSimulator/for_test.json | 2 +-
build.num | 2 +-
10 files changed, 108 insertions(+), 10 deletions(-)
create mode 100644 LogicSimulator/Views/Shapes/AND_8.axaml
create mode 100644 LogicSimulator/Views/Shapes/AND_8.axaml.cs
create mode 100644 LogicSimulator/Views/Shapes/OR_8.axaml
create mode 100644 LogicSimulator/Views/Shapes/OR_8.axaml.cs
diff --git a/LogicSimulator/LogicSimulator.csproj b/LogicSimulator/LogicSimulator.csproj
index ac5aa45..20f7da8 100644
--- a/LogicSimulator/LogicSimulator.csproj
+++ b/LogicSimulator/LogicSimulator.csproj
@@ -35,6 +35,9 @@
LauncherWindow.axaml
+
+ AND_8.axaml
+
NAND_2.axaml
@@ -44,6 +47,9 @@
LightBulb.axaml
+
+ OR_8.axaml
+
Switch.axaml
diff --git a/LogicSimulator/Models/Mapper.cs b/LogicSimulator/Models/Mapper.cs
index d60c6de..0707a37 100644
--- a/LogicSimulator/Models/Mapper.cs
+++ b/LogicSimulator/Models/Mapper.cs
@@ -71,11 +71,13 @@ private static IGate CreateItem(int n) {
7 => new LightBulb(),
8 => new NAND_2(),
9 => new FlipFlop(),
+ 10 => new OR_8(),
+ 11 => new AND_8(),
_ => new AND_2(),
};
}
- public IGate[] item_types = Enumerable.Range(0, 10).Select(CreateItem).ToArray();
+ public IGate[] item_types = Enumerable.Range(0, 12).Select(CreateItem).ToArray();
public IGate GenSelectedItem() => CreateItem(selected_item);
diff --git a/LogicSimulator/Views/MainWindow.axaml b/LogicSimulator/Views/MainWindow.axaml
index f5e9fdd..f3c820a 100644
--- a/LogicSimulator/Views/MainWindow.axaml
+++ b/LogicSimulator/Views/MainWindow.axaml
@@ -51,7 +51,7 @@
-
+
@@ -67,7 +67,7 @@
-
+
diff --git a/LogicSimulator/Views/Shapes/AND_8.axaml b/LogicSimulator/Views/Shapes/AND_8.axaml
new file mode 100644
index 0000000..474bbd6
--- /dev/null
+++ b/LogicSimulator/Views/Shapes/AND_8.axaml
@@ -0,0 +1,18 @@
+
+
+
+
diff --git a/LogicSimulator/Views/Shapes/AND_8.axaml.cs b/LogicSimulator/Views/Shapes/AND_8.axaml.cs
new file mode 100644
index 0000000..a230489
--- /dev/null
+++ b/LogicSimulator/Views/Shapes/AND_8.axaml.cs
@@ -0,0 +1,25 @@
+using Avalonia.Controls;
+using System.ComponentModel;
+
+namespace LogicSimulator.Views.Shapes {
+ public partial class AND_8: GateBase, IGate, INotifyPropertyChanged {
+ public override int TypeId => 11;
+
+ public override UserControl GetSelf() => this;
+ protected override IGate GetSelfI => this;
+ protected override int[][] Sides => new int[][] {
+ System.Array.Empty(),
+ new int[] { 0, 0, 0, 0, 0, 0, 0, 0 },
+ new int[] { 1 },
+ System.Array.Empty()
+ };
+
+ protected override void Init() => InitializeComponent();
+
+ /*
+ * Мозги
+ */
+
+ public void Brain(ref bool[] ins, ref bool[] outs) => outs[0] = ins[0] && ins[1] && ins[2] && ins[3] && ins[3] && ins[5] && ins[6] && ins[7];
+ }
+}
diff --git a/LogicSimulator/Views/Shapes/GateBase.cs b/LogicSimulator/Views/Shapes/GateBase.cs
index bd92b8a..6664273 100644
--- a/LogicSimulator/Views/Shapes/GateBase.cs
+++ b/LogicSimulator/Views/Shapes/GateBase.cs
@@ -45,8 +45,11 @@ public GateBase() {
CountIns = ins;
CountOuts = outs + ios;
- double sizer = sides.Select(x => x.Length).Max();
- width = height = 30 * (2 + sizer / 2);
+ /* double sizer = sides.Select(x => x.Length).Max();
+ double vert_sizer = Math.Max(Math.Max(sides[0].Length, sides[3].Length), 3);
+ width = 30 * (2 + Math.Min(sizer, vert_sizer) / 2);
+ height = Math.Max(30 * (2 + sizer / 2), (9 + 32) * 2 / 3 * (1.5 + 0.75 * CountIns.Max(CountOuts)));*/
+ width = MinW; height = MinH;
// AvaloniaXamlLoader.Load(GetSelf()); // InitializeComponent(); Не вышло :///
// А так от Init бы полностью отказался бы ;'-} Принцип Подскановки Лископ бы просто пылал от этого, хоть абстрактному классу и положено зависеть от потомка ;'-}
DataContext = GetSelf();
@@ -91,10 +94,11 @@ public void Move(Point pos, bool global = false) {
UpdateJoins(global);
}
+ private double MinW => BodyRadius.TopLeft * 2 + (EllipseSize + BaseFraction * 2) * (Sides[0].Length.Max(Sides[3].Length).Max(2) - 0.8);
+ private double MinH => BodyRadius.TopLeft * 2 + (EllipseSize + BaseFraction * 2) * (Sides[1].Length.Max(Sides[2].Length).Max(2) - 0.8);
public void Resize(Size size, bool global = false) {
- double limit = (9 + 32) * 2 * (base_size / 25);
- width = size.Width.Max(limit / 3 * (CountIns == 0 || CountOuts == 0 ? 2.25 : 3));
- height = size.Height.Max(limit / 3 * (1.5 + 0.75 * CountIns.Max(CountOuts)));
+ width = size.Width.Max(MinW);
+ height = size.Height.Max(MinH);
RecalcSizes();
UpdateJoins(global);
}
diff --git a/LogicSimulator/Views/Shapes/OR_8.axaml b/LogicSimulator/Views/Shapes/OR_8.axaml
new file mode 100644
index 0000000..86e6707
--- /dev/null
+++ b/LogicSimulator/Views/Shapes/OR_8.axaml
@@ -0,0 +1,18 @@
+
+
+
+
diff --git a/LogicSimulator/Views/Shapes/OR_8.axaml.cs b/LogicSimulator/Views/Shapes/OR_8.axaml.cs
new file mode 100644
index 0000000..ff6d47b
--- /dev/null
+++ b/LogicSimulator/Views/Shapes/OR_8.axaml.cs
@@ -0,0 +1,25 @@
+using Avalonia.Controls;
+using System.ComponentModel;
+
+namespace LogicSimulator.Views.Shapes {
+ public partial class OR_8: GateBase, IGate, INotifyPropertyChanged {
+ public override int TypeId => 10;
+
+ public override UserControl GetSelf() => this;
+ protected override IGate GetSelfI => this;
+ protected override int[][] Sides => new int[][] {
+ System.Array.Empty(),
+ new int[] { 0, 0, 0, 0, 0, 0, 0, 0 },
+ new int[] { 1 },
+ System.Array.Empty()
+ };
+
+ protected override void Init() => InitializeComponent();
+
+ /*
+ * Мозги
+ */
+
+ public void Brain(ref bool[] ins, ref bool[] outs) => outs[0] = ins[0] || ins[1] || ins[2] || ins[3] || ins[4] || ins[5] || ins[6] || ins[7];
+ }
+}
diff --git a/LogicSimulator/for_test.json b/LogicSimulator/for_test.json
index fd947aa..42ce09f 100644
--- a/LogicSimulator/for_test.json
+++ b/LogicSimulator/for_test.json
@@ -1 +1 @@
-{"name": "Для тестирования", "created": 1683838621, "modified": 1683839324, "items": [{"id": 5, "pos": "$p$149,242", "size": "$s$75,75", "base_size": 25, "state": false}, {"id": 5, "pos": "$p$153,330", "size": "$s$75,75", "base_size": 25, "state": false}, {"id": 5, "pos": "$p$152,414", "size": "$s$75,75", "base_size": 25, "state": false}, {"id": 5, "pos": "$p$149,497", "size": "$s$75,75", "base_size": 25, "state": false}, {"id": 9, "pos": "$p$587,328", "size": "$s$105,105", "base_size": 25, "state": "0.1.0.1.0.0"}, {"id": 3, "pos": "$p$339,236", "size": "$s$90,90", "base_size": 25}, {"id": 3, "pos": "$p$348,336", "size": "$s$90,90", "base_size": 25}, {"id": 3, "pos": "$p$352,444", "size": "$s$90,90", "base_size": 25}, {"id": 3, "pos": "$p$355,546", "size": "$s$90,90", "base_size": 25}, {"id": 9, "pos": "$p$594,460", "size": "$s$105,105", "base_size": 25, "state": "0.0.1.0.0.0"}, {"id": 3, "pos": "$p$591,182", "size": "$s$90,90", "base_size": 25}, {"id": 7, "pos": "$p$749,199", "size": "$s$75,75", "base_size": 25}, {"id": 7, "pos": "$p$750,276", "size": "$s$75,75", "base_size": 25}, {"id": 7, "pos": "$p$751,354", "size": "$s$75,75", "base_size": 25}, {"id": 7, "pos": "$p$751,430", "size": "$s$75,75", "base_size": 25}, {"id": 7, "pos": "$p$752,506", "size": "$s$75,75", "base_size": 25}, {"id": 7, "pos": "$p$755,584", "size": "$s$75,75", "base_size": 25}, {"id": 1, "pos": "$p$592,596", "size": "$s$90,90", "base_size": 25}], "joins": [[0, 0, "Out", 5, 0, "In"], [1, 0, "Out", 6, 0, "In"], [2, 0, "Out", 7, 0, "In"], [3, 0, "Out", 8, 0, "In"], [4, 3, "Out", 6, 1, "In"], [11, 0, "In", 4, 3, "Out"], [4, 4, "Out", 10, 0, "In"], [12, 0, "In", 4, 4, "Out"], [13, 0, "In", 4, 5, "Out"], [4, 5, "Out", 17, 0, "In"], [4, 0, "In", 5, 2, "Out"], [6, 2, "Out", 4, 1, "In"], [6, 2, "Out", 9, 2, "In"], [7, 2, "Out", 4, 2, "In"], [7, 2, "Out", 9, 1, "In"], [8, 2, "Out", 9, 0, "In"], [9, 3, "Out", 10, 1, "In"], [14, 0, "In", 9, 3, "Out"], [15, 0, "In", 9, 4, "Out"], [9, 4, "Out", 17, 1, "In"], [16, 0, "In", 9, 5, "Out"], [9, 5, "Out", 7, 1, "In"], [10, 2, "Out", 5, 1, "In"], [17, 2, "Out", 8, 1, "In"]], "states": "00000100010000000000000"}
\ No newline at end of file
+{"name": "Для тестирования #2", "created": 1683843280, "modified": 1683846735, "items": [{"id": 3, "pos": "$p$6127,2377", "size": "$s$720,685", "base_size": 185.00624860645544}, {"id": 3, "pos": "$p$6127,3058", "size": "$s$720,685", "base_size": 185.00624860645544}, {"id": 3, "pos": "$p$6136,3747", "size": "$s$720,685", "base_size": 185.00624860645544}, {"id": 3, "pos": "$p$6172,4437", "size": "$s$720,685", "base_size": 185.00624860645544}, {"id": 7, "pos": "$p$9064,2637", "size": "$s$720,685", "base_size": 185.00624860645544}, {"id": 7, "pos": "$p$7829,2583", "size": "$s$720,685", "base_size": 185.00624860645544}, {"id": 7, "pos": "$p$8438,1911", "size": "$s$720,685", "base_size": 185.00624860645544}, {"id": 7, "pos": "$p$8420,3273", "size": "$s$720,685", "base_size": 185.00624860645544}, {"id": 7, "pos": "$p$7739,3917", "size": "$s$720,685", "base_size": 185.00624860645544}, {"id": 7, "pos": "$p$8420,4544", "size": "$s$720,685", "base_size": 185.00624860645544}, {"id": 7, "pos": "$p$9199,3917", "size": "$s$720,685", "base_size": 185.00624860645544}, {"id": 3, "pos": "$p$6208,5153", "size": "$s$720,685", "base_size": 185.00624860645544}, {"id": 3, "pos": "$p$6127,1679", "size": "$s$720,685", "base_size": 185.00624860645544}, {"id": 3, "pos": "$p$6127,989", "size": "$s$720,685", "base_size": 185.00624860645544}, {"id": 10, "pos": "$p$4108,933", "size": "$s$366,861", "base_size": 104.43120423539197}, {"id": 10, "pos": "$p$4121,1805", "size": "$s$366,861", "base_size": 104.43120423539197}, {"id": 10, "pos": "$p$4133,2675", "size": "$s$366,861", "base_size": 104.43120423539197}, {"id": 10, "pos": "$p$4141,3552", "size": "$s$366,861", "base_size": 104.43120423539197}, {"id": 10, "pos": "$p$4141,4438", "size": "$s$366,861", "base_size": 104.43120423539197}, {"id": 10, "pos": "$p$4158,5303", "size": "$s$366,861", "base_size": 104.43120423539197}, {"id": 10, "pos": "$p$4145,6180", "size": "$s$366,861", "base_size": 104.43120423539197}, {"id": 5, "pos": "$p$-1385,804", "size": "$s$714,702", "base_size": 203.50687346710035, "state": false}, {"id": 5, "pos": "$p$-1369,1537", "size": "$s$714,702", "base_size": 203.50687346710035, "state": false}, {"id": 5, "pos": "$p$-1353,2310", "size": "$s$714,702", "base_size": 203.50687346710035, "state": false}, {"id": 5, "pos": "$p$-1353,3075", "size": "$s$714,702", "base_size": 203.50687346710035, "state": false}, {"id": 5, "pos": "$p$-1412,5012", "size": "$s$714,702", "base_size": 203.50687346710035, "state": false}, {"id": 2, "pos": "$p$-746,1138", "size": "$s$333,327", "base_size": 94.93745839581057}, {"id": 2, "pos": "$p$-700,1878", "size": "$s$333,327", "base_size": 94.93745839581057}, {"id": 2, "pos": "$p$-712,2672", "size": "$s$333,327", "base_size": 94.93745839581057}, {"id": 2, "pos": "$p$-719,3477", "size": "$s$333,327", "base_size": 94.93745839581057}, {"id": 11, "pos": "$p$755,1028", "size": "$s$275,647", "base_size": 78.46070941802523}, {"id": 11, "pos": "$p$784,1715", "size": "$s$275,647", "base_size": 78.46070941802523}, {"id": 11, "pos": "$p$762,353", "size": "$s$275,647", "base_size": 78.46070941802523}, {"id": 11, "pos": "$p$771,-315", "size": "$s$275,647", "base_size": 78.46070941802523}, {"id": 11, "pos": "$p$787,2386", "size": "$s$275,647", "base_size": 78.46070941802523}, {"id": 11, "pos": "$p$787,3035", "size": "$s$275,647", "base_size": 78.46070941802523}, {"id": 11, "pos": "$p$781,3713", "size": "$s$275,647", "base_size": 78.46070941802523}, {"id": 11, "pos": "$p$778,4369", "size": "$s$275,647", "base_size": 78.46070941802523}, {"id": 11, "pos": "$p$759,-997", "size": "$s$275,647", "base_size": 78.46070941802523}, {"id": 11, "pos": "$p$759,-1665", "size": "$s$275,647", "base_size": 78.46070941802523}, {"id": 11, "pos": "$p$769,5053", "size": "$s$275,647", "base_size": 78.46070941802523}, {"id": 11, "pos": "$p$756,5753", "size": "$s$275,647", "base_size": 78.46070941802523}, {"id": 11, "pos": "$p$753,-2355", "size": "$s$275,647", "base_size": 78.46070941802523}, {"id": 11, "pos": "$p$789,6438", "size": "$s$275,647", "base_size": 78.46070941802523}, {"id": 11, "pos": "$p$785,7094", "size": "$s$275,647", "base_size": 78.46070941802523}, {"id": 11, "pos": "$p$791,7752", "size": "$s$275,647", "base_size": 78.46070941802516}, {"id": 2, "pos": "$p$403,-2225", "size": "$s$87,86", "base_size": 25}, {"id": 2, "pos": "$p$432,-1544", "size": "$s$87,86", "base_size": 25}, {"id": 2, "pos": "$p$422,-880", "size": "$s$87,86", "base_size": 25}, {"id": 2, "pos": "$p$423,-194", "size": "$s$83,83", "base_size": 25}, {"id": 2, "pos": "$p$417,467", "size": "$s$83,83", "base_size": 25}], "joins": [[4, 0, "In", 0, 2, "Out"], [7, 0, "In", 1, 2, "Out"], [8, 0, "In", 2, 2, "Out"], [10, 0, "In", 3, 2, "Out"], [9, 0, "In", 11, 2, "Out"], [5, 0, "In", 12, 2, "Out"], [6, 0, "In", 13, 2, "Out"], [14, 8, "Out", 13, 0, "In"], [15, 8, "Out", 12, 0, "In"], [16, 8, "Out", 0, 0, "In"], [17, 8, "Out", 1, 0, "In"], [18, 8, "Out", 2, 0, "In"], [19, 8, "Out", 3, 0, "In"], [20, 8, "Out", 11, 0, "In"], [26, 0, "In", 21, 0, "Out"], [27, 0, "In", 22, 0, "Out"], [28, 0, "In", 23, 0, "Out"], [29, 0, "In", 24, 0, "Out"], [46, 1, "Out", 42, 4, "In"], [46, 1, "Out", 42, 5, "In"], [46, 1, "Out", 42, 6, "In"], [46, 1, "Out", 42, 7, "In"], [47, 1, "Out", 39, 4, "In"], [39, 5, "In", 47, 1, "Out"], [47, 1, "Out", 39, 6, "In"], [39, 7, "In", 47, 1, "Out"], [48, 1, "Out", 38, 4, "In"], [48, 1, "Out", 38, 5, "In"], [48, 1, "Out", 38, 6, "In"], [48, 1, "Out", 38, 7, "In"], [49, 1, "Out", 33, 4, "In"], [49, 1, "Out", 33, 5, "In"], [49, 1, "Out", 33, 6, "In"], [49, 1, "Out", 33, 7, "In"], [50, 1, "Out", 32, 4, "In"], [50, 1, "Out", 32, 5, "In"], [50, 1, "Out", 32, 6, "In"], [50, 1, "Out", 32, 7, "In"]], "states": "000000000000000000000000000000011000001111111000000000000000000000000011111"}
\ No newline at end of file
diff --git a/build.num b/build.num
index 87b9849..6a333d3 100644
--- a/build.num
+++ b/build.num
@@ -1 +1 @@
-1089
\ No newline at end of file
+1107
\ No newline at end of file