improved the chapter "first steps" in the documentation

This commit is contained in:
hneemann 2018-01-27 12:10:21 +01:00
parent 146e51c740
commit 876984dc72
37 changed files with 146 additions and 27 deletions

View File

@ -1,11 +1,15 @@
package de.neemann.digital.docu; package de.neemann.digital.docu;
import de.neemann.digital.gui.Main; import de.neemann.digital.gui.Main;
import de.neemann.digital.gui.components.AttributeDialog;
import de.neemann.digital.gui.components.karnaugh.KarnaughMapDialog;
import de.neemann.digital.gui.components.table.TableDialog;
import de.neemann.digital.integration.GuiTester; import de.neemann.digital.integration.GuiTester;
import de.neemann.digital.integration.Resources; import de.neemann.digital.integration.Resources;
import de.neemann.digital.lang.Lang; import de.neemann.digital.lang.Lang;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.InputEvent; import java.awt.event.InputEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@ -18,10 +22,11 @@ public class ScreenShots {
public static void main(String[] args) { public static void main(String[] args) {
int x = 300; int x = 300;
int y = 200; int y = 180;
new GuiTester() new GuiTester()
.add(new GuiTester.WindowCheck<>(Main.class, (gt, w) -> w.setSize(850, 500))) .add(new GuiTester.WindowCheck<>(Main.class, (gt, w) -> w.setSize(850, 500)))
.add(new ScreenShot<>(Main.class)) .add(new ScreenShot<>(Main.class))
// input
.press("F10") .press("F10")
.press("RIGHT", 5) .press("RIGHT", 5)
.press("DOWN", 2) .press("DOWN", 2)
@ -29,13 +34,13 @@ public class ScreenShots {
.press("DOWN", 2) .press("DOWN", 2)
.add(new ScreenShot<>(Main.class)) .add(new ScreenShot<>(Main.class))
.press("ENTER") .press("ENTER")
.mouseMove(x, y) .add(new ClickAtCircuit(x, y, InputEvent.BUTTON1_MASK))
.mouseClick(InputEvent.BUTTON1_MASK)
.add(new ScreenShot<>(Main.class)) .add(new ScreenShot<>(Main.class))
// input
.press("typed l") .press("typed l")
.mouseMove(x, y + SIZE * 2) .add(new ClickAtCircuit(x, y + SIZE * 2, InputEvent.BUTTON1_MASK))
.mouseClick(InputEvent.BUTTON1_MASK)
.add(new ScreenShot<>(Main.class)) .add(new ScreenShot<>(Main.class))
// xor
.press("F10") .press("F10")
.press("RIGHT", 5) .press("RIGHT", 5)
.press("DOWN", 1) .press("DOWN", 1)
@ -43,57 +48,117 @@ public class ScreenShots {
.press("DOWN", 4) .press("DOWN", 4)
.add(new ScreenShot<>(Main.class)) .add(new ScreenShot<>(Main.class))
.press("ENTER") .press("ENTER")
.mouseMove(x + SIZE * 5, y + SIZE * 1 + SIZE2) .add(new ClickAtCircuit(x + SIZE * 5, y + SIZE, InputEvent.BUTTON1_MASK))
.mouseClick(InputEvent.BUTTON1_MASK)
.add(new ScreenShot<>(Main.class)) .add(new ScreenShot<>(Main.class))
// output
.press("F10") .press("F10")
.press("RIGHT", 5) .press("RIGHT", 5)
.press("DOWN", 2) .press("DOWN", 2)
.press("RIGHT") .press("RIGHT")
//.press("DOWN", 4)
.add(new ScreenShot<>(Main.class)) .add(new ScreenShot<>(Main.class))
.press("ENTER") .press("ENTER")
.mouseMove(x + SIZE * 9, y + SIZE * 1 + SIZE2) .add(new ClickAtCircuit(x + SIZE * 9, y + SIZE, InputEvent.BUTTON1_MASK))
.mouseClick(InputEvent.BUTTON1_MASK)
.add(new ScreenShot<>(Main.class)) .add(new ScreenShot<>(Main.class))
.mouseMove(x, y - SIZE) .add(new ClickAtCircuit(x, y - SIZE, InputEvent.BUTTON1_MASK))
.mouseClick(InputEvent.BUTTON1_MASK) .add(new ClickAtCircuit(x + SIZE * 2, y - SIZE, InputEvent.BUTTON1_MASK))
.mouseMove(x + SIZE * 2, y - SIZE)
.mouseClick(InputEvent.BUTTON1_MASK)
.add(new ScreenShot<>(Main.class)) .add(new ScreenShot<>(Main.class))
.mouseMove(x, y + SIZE) .add(new ClickAtCircuit(x, y + SIZE, InputEvent.BUTTON1_MASK))
.mouseClick(InputEvent.BUTTON1_MASK) .add(new ClickAtCircuit(x + SIZE * 2, y + SIZE, InputEvent.BUTTON1_MASK))
.mouseMove(x + SIZE * 2, y + SIZE) .add(new ClickAtCircuit(x + SIZE * 5, y, InputEvent.BUTTON1_MASK))
.mouseClick(InputEvent.BUTTON1_MASK) .add(new ClickAtCircuit(x + SIZE * 7, y, InputEvent.BUTTON1_MASK))
.mouseMove(x + SIZE * 5, y)
.mouseClick(InputEvent.BUTTON1_MASK)
.mouseMove(x + SIZE * 7, y)
.mouseClick(InputEvent.BUTTON1_MASK)
.add(new ScreenShot<>(Main.class)) .add(new ScreenShot<>(Main.class))
.press(' ') .press(' ')
.add(new ScreenShot<>(Main.class)) .add(new ScreenShot<>(Main.class))
.mouseMove(x - SIZE, y) .add(new ClickAtCircuit(x - SIZE, y - SIZE, InputEvent.BUTTON1_MASK))
.mouseClick(InputEvent.BUTTON1_MASK)
.add(new ScreenShot<>(Main.class)) .add(new ScreenShot<>(Main.class))
.press(' ')
// labels
.add(new ClickAtCircuit(x - SIZE, y - SIZE, InputEvent.BUTTON3_MASK))
.press("shift typed a")
.add(new ScreenShot<>(AttributeDialog.class).useParent())
.press("ENTER")
.add(new ClickAtCircuit(x - SIZE, y + SIZE, InputEvent.BUTTON3_MASK))
.press("shift typed b", "ENTER")
.add(new ClickAtCircuit(x + SIZE * 8, y, InputEvent.BUTTON3_MASK))
.press("shift typed y", "ENTER")
//.add(new ScreenShot<>(Main.class))
// analyse
.press("F10")
.press("RIGHT", 4)
.press("DOWN", 1)
.add(new ScreenShot<>(Main.class))
.press("ENTER")
.delay(500)
.add(new GuiTester.WindowCheck<>(TableDialog.class, (gt, td) -> {
final Point location = td.getParent().getLocation();
location.x+=10;
location.y+=10;
td.setLocation(location);
td.getContentPane().setPreferredSize(new Dimension(400,400));
td.pack();
}))
.delay(500)
.add(new ScreenShot<>(TableDialog.class).useParent())
.press("F10")
.press("RIGHT", 5)
.press("DOWN", 1)
.add(new ScreenShot<>(TableDialog.class).useParent())
.press("ENTER")
.delay(500)
.add(new ScreenShot<>(KarnaughMapDialog.class).useParent().useParent())
.execute(); .execute();
} }
private static class ScreenShot<W extends Window> extends GuiTester.WindowCheck<W> { private static class ScreenShot<W extends Window> extends GuiTester.WindowCheck<W> {
private static int n; private static int n;
private int parentCount;
ScreenShot(Class<W> expectedClass) { ScreenShot(Class<W> expectedClass) {
super(expectedClass); super(expectedClass);
parentCount = 0;
} }
@Override @Override
public void checkWindow(GuiTester guiTester, W window) throws Exception { public void checkWindow(GuiTester guiTester, W window) throws Exception {
BufferedImage image = guiTester.getRobot().createScreenCapture(window.getBounds()); Window win = window;
for (int i = 0; i < parentCount; i++)
win = (Window) win.getParent();
BufferedImage image = guiTester.getRobot().createScreenCapture(win.getBounds());
String str = Integer.toString(n); String str = Integer.toString(n);
if (str.length() == 1) if (str.length() == 1)
str = '0' + str; str = '0' + str;
File file = new File(Resources.getRoot(), "docu/images/"+ Lang.currentLanguage().getName()+"/scr" + str + ".png"); File file = new File(Resources.getRoot(), "docu/images/" + Lang.currentLanguage().getName() + "/scr" + str + ".png");
ImageIO.write(image, "png", file); ImageIO.write(image, "png", file);
n++; n++;
} }
ScreenShot<W> useParent() {
parentCount++;
return this;
}
}
private static class ClickAtCircuit extends GuiTester.WindowCheck<Main> {
private final int x;
private final int y;
private final int button;
ClickAtCircuit(int x, int y, int button) {
super(Main.class);
this.x = x;
this.y = y;
this.button = button;
}
@Override
public void checkWindow(GuiTester guiTester, Main main) throws Exception {
Point p = new Point(x, y);
SwingUtilities.convertPointToScreen(p, main.getCircuitComponent());
guiTester.getRobot().mouseMove(p.x, p.y);
if (button != 0) {
guiTester.mouseClickNow(button);
}
}
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -30,7 +30,7 @@
<par> <par>
<image src="scr00.png"> <image src="scr00.png">
Im Hauptfenster können aus dem Menü <e>Bauteile</e> die verschiedenen Bauteile ausgewahlt werden. Im Hauptfenster können aus dem Menü <e>Bauteile</e> die verschiedenen Bauteile ausgewahlt werden.
Danach werden diese auf dem Zeichenfeld positioniert. Dieser Vorgang kann mit der ESC-Taste Danach werden diese auf dem Zeichenfeld positioniert. Das Positionieren kann mit der ESC-Taste
jederzeit abgebrochen werden. jederzeit abgebrochen werden.
</image> </image>
<image src="scr01.png"> <image src="scr01.png">
@ -88,6 +88,35 @@
aktiv ist, verändert sich der Augang entsprechend der aktuellen Eingangszustände. aktiv ist, verändert sich der Augang entsprechend der aktuellen Eingangszustände.
Die Schaltung verhällt sich wie erwartet wie ein XOR-Gatter. Die Schaltung verhällt sich wie erwartet wie ein XOR-Gatter.
</image> </image>
<image src="scr12.png">
Um die Schaltung weiter bearbeiten zu können, muss die Simulation zunächst gestoppt werden.
Dies geschieht am einfachsten mit dem Stop-Knopf in der ToolBar.
Durch Klicken mit der rechten Maustaste auf eine Komponente öffnet sich ein Dialog, welcher die
Eigenschaften dieser Komponente anzeigt. Für den ersten Eingang kann über diesen Dialog die
Bezeichnung 'A' festgelegt werden.
</image>
<image src="scr13.png">
Auf diese Weise, können die Bezeichnungen für die übrigen Ein- und Ausgänge
definiert werden.
Im Hauptmenü im Menüpunkt <e>Analyse</e> findet sich auch ein Menüpunkt <e>Analyse</e>. Damit läst sich
eine Analyse der aktuellen Schaltung durchführen. Dies ist jedoch nur möglich, wenn alle Ein- und
Ausgänge mit einer Bezeichnung versehen sind.
</image>
<image src="scr14.png">
Es öffnet sich ein Fenster, welches die Wahrheitstabelle der aktuellen Schaltung zeigt. Unter der
Tabelle findet sich der algebraische Ausdruck, welcher zu der Schaltung gehört. Gibt es mehrere
mögliche algebraische Ausdrücke, öffnet sich ein separates Fenster, welches alle Ausdrücke
anzeigt.
</image>
<image src="scr15.png">
Der Tabellendialog hat in seinem Hauptmenü den Menüeintrag <e>KV-Tafel</e>. Über diesen läst sich die
Wahrheitstabelle in Form einer KV-Tafel anzeigen.
</image>
<image src="scr16.png">
Oben in diesem Dialog gibt es eine Auswahlbox über welche der gewünschte Ausdruck in der KV-Tafel
ausgewählt werden kann. Auf diese Weise läst sich z.B. verdeutlichen, wie sich mehrere equivalente
algebraische Ausdrücke ergeben können. Durch Klicken in der KV-Tafel läst sich die Tabelle bearbeiten.
</image>
</par> </par>
</subchapter> </subchapter>
<subchapter name="Verbindungsleitungen"> <subchapter name="Verbindungsleitungen">

View File

@ -78,6 +78,31 @@
By clicking with the mouse, the inputs can be switched. Since the simulation is now active, the By clicking with the mouse, the inputs can be switched. Since the simulation is now active, the
output changes according to the current input states. The circuit behaves as expected like an XOR gate. output changes according to the current input states. The circuit behaves as expected like an XOR gate.
</image> </image>
<image src="scr12.png">
To further process the circuit, the simulation must first be stopped. The easiest way to do this is
with the Stop button in the ToolBar. Clicking on a component with the right mouse button opens a
dialog which displays the properties of this component. The name 'A' can be defined for the first
input via this dialog.
</image>
<image src="scr13.png">
In this way, the names for the remaining inputs and outputs can be defined. The menu item
<e>Analysis</e> also contains a menu item <e>Analysis</e>. This function performs an analysis of
the current circuit. However, this is only possible if all inputs and outputs are labeled.
</image>
<image src="scr14.png">
It opens a window showing the truth table of the current circuit. Below the table is the algebraic
expression associated with the circuit. If there are several possible algebraic expressions, a
separate window will open showing all expressions.
</image>
<image src="scr15.png">
The table dialog has the menu entry <e>K-Map</e> in its main menu. This allows to display the truth
table in the form of a K-map.
</image>
<image src="scr16.png">
At the top of this dialog there is a drop-down list which allows the selection of the desired
expression in the K-map. In this way you can, for example, illustrate how several equivalent
algebraic expressions can result. By clicking in the K-map the table can be modified.
</image>
</par> </par>
</subchapter> </subchapter>
<subchapter name="Wires"> <subchapter name="Wires">