mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-15 07:48:29 -04:00
more simple state model
This commit is contained in:
parent
f19a4742e5
commit
aa711de5e9
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<circuit>
|
||||
<version>1</version>
|
||||
<attributes/>
|
||||
<visualElements>
|
||||
<visualElement>
|
||||
<elementName>Control.dig</elementName>
|
||||
@ -168,20 +169,22 @@
|
||||
<entry>
|
||||
<string>Data</string>
|
||||
<data>
|
||||
<size>13</size>
|
||||
<size>15</size>
|
||||
<long>5137</long>
|
||||
<long>5120</long>
|
||||
<long>6145</long>
|
||||
<long>15888</long>
|
||||
<long>29521</long>
|
||||
<long>31744</long>
|
||||
<long>15375</long>
|
||||
<long>26107</long>
|
||||
<long>26106</long>
|
||||
<long>8193</long>
|
||||
<long>16400</long>
|
||||
<long>29521</long>
|
||||
<long>31744</long>
|
||||
<long>15360</long>
|
||||
<long>26107</long>
|
||||
<long>28661</long>
|
||||
<long>26106</long>
|
||||
<long>28659</long>
|
||||
<bits>16</bits>
|
||||
</data>
|
||||
</entry>
|
||||
@ -235,7 +238,7 @@
|
||||
</entry>
|
||||
<entry>
|
||||
<string>Frequency</string>
|
||||
<int>200</int>
|
||||
<int>1000</int>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="1040" y="460"/>
|
||||
@ -253,7 +256,7 @@
|
||||
<int>16</int>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="620" y="60"/>
|
||||
<pos x="640" y="60"/>
|
||||
<rotate>0</rotate>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
@ -268,7 +271,7 @@
|
||||
<int>16</int>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="720" y="60"/>
|
||||
<pos x="740" y="60"/>
|
||||
<rotate>0</rotate>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
@ -441,6 +444,14 @@
|
||||
<p1 x="1440" y="500"/>
|
||||
<p2 x="1500" y="580"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="620" y="80"/>
|
||||
<p2 x="640" y="60"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="720" y="80"/>
|
||||
<p2 x="740" y="60"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="620" y="640"/>
|
||||
<p2 x="920" y="640"/>
|
||||
@ -898,7 +909,7 @@
|
||||
<p2 x="400" y="420"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="720" y="60"/>
|
||||
<p1 x="720" y="80"/>
|
||||
<p2 x="720" y="140"/>
|
||||
</wire>
|
||||
<wire>
|
||||
@ -994,7 +1005,7 @@
|
||||
<p2 x="1260" y="420"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="620" y="60"/>
|
||||
<p1 x="620" y="80"/>
|
||||
<p2 x="620" y="120"/>
|
||||
</wire>
|
||||
<wire>
|
||||
|
@ -49,8 +49,9 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave {
|
||||
private static final Icon iconFast = IconCreator.create("FastForward24.gif");
|
||||
private final CircuitComponent circuitComponent;
|
||||
private final ToolTipAction save;
|
||||
private final ElementLibrary library;
|
||||
private final ToolTipAction doStep;
|
||||
private final ToolTipAction runToBreak;
|
||||
private final ElementLibrary library;
|
||||
private final JCheckBoxMenuItem runClock;
|
||||
private final LibrarySelector librarySelector;
|
||||
private final ShapeFactory shapeFactory;
|
||||
@ -68,7 +69,6 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave {
|
||||
private State selectState;
|
||||
private State runModelState;
|
||||
private State runModelMicroState;
|
||||
private boolean clocksAreRunning;
|
||||
|
||||
private Main() {
|
||||
this(null, null, null);
|
||||
@ -250,31 +250,19 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave {
|
||||
.setToolTip(Lang.get("menu_run_tt"));
|
||||
ToolTipAction runModelMicroAction = runModelMicroState.createToolTipAction(Lang.get("menu_micro"), iconMicro)
|
||||
.setToolTip(Lang.get("menu_micro_tt"));
|
||||
ToolTipAction runFast = new ToolTipAction(Lang.get("menu_fast"), iconFast) {
|
||||
runToBreak = new ToolTipAction(Lang.get("menu_fast"), iconFast) {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (model == null || !model.isFastRunModel() || clocksAreRunning) {
|
||||
// start without running clocks
|
||||
createAndStartModel(false, ModelEvent.Event.BREAK);
|
||||
circuitComponent.setManualChangeObserver(new FullStepObserver(model));
|
||||
// inform StateManager that we manually entered the run state
|
||||
stateManager.stateEnteredManually(runModelState);
|
||||
if (!model.isFastRunModel()) {
|
||||
elementState.activate();
|
||||
new ErrorMessage(Lang.get("msg_needOneClockAndOneTimer")).show(Main.this);
|
||||
}
|
||||
try {
|
||||
int i = model.runToBreak();
|
||||
circuitComponent.repaint();
|
||||
statusLabel.setText(Lang.get("stat_clocks", i));
|
||||
} catch (NodeException e1) {
|
||||
elementState.activate();
|
||||
new ErrorMessage(Lang.get("msg_fastRunError")).addCause(e1).show(Main.this);
|
||||
}
|
||||
if (model != null && model.isFastRunModel() && !clocksAreRunning)
|
||||
try {
|
||||
int i = model.runToBreak();
|
||||
circuitComponent.repaint();
|
||||
statusLabel.setText(Lang.get("stat_clocks", i));
|
||||
} catch (NodeException e1) {
|
||||
elementState.activate();
|
||||
new ErrorMessage(Lang.get("msg_fastRunError")).addCause(e1).show(Main.this);
|
||||
}
|
||||
}
|
||||
}.setToolTip(Lang.get("menu_fast_tt"));
|
||||
}.setToolTip(Lang.get("menu_fast_tt")).setActive(false);
|
||||
|
||||
ToolTipAction speedTest = new ToolTipAction(Lang.get("menu_speedTest")) {
|
||||
@Override
|
||||
@ -299,7 +287,7 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave {
|
||||
run.add(runModelAction.createJMenuItem());
|
||||
run.add(runModelMicroAction.createJMenuItem());
|
||||
run.add(doStep.createJMenuItem());
|
||||
run.add(runFast.createJMenuItem());
|
||||
run.add(runToBreak.createJMenuItem());
|
||||
run.add(speedTest.createJMenuItem());
|
||||
run.add(traceEnable);
|
||||
run.add(runClock);
|
||||
@ -316,7 +304,7 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave {
|
||||
toolBar.add(circuitComponent.getDeleteAction().createJButtonNoText());
|
||||
toolBar.addSeparator();
|
||||
toolBar.add(runModelState.setIndicator(runModelAction.createJButtonNoText()));
|
||||
toolBar.add(runFast.createJButtonNoText());
|
||||
toolBar.add(runToBreak.createJButtonNoText());
|
||||
toolBar.add(runModelMicroState.setIndicator(runModelMicroAction.createJButtonNoText()));
|
||||
toolBar.add(doStep.createJButtonNoText());
|
||||
|
||||
@ -399,7 +387,8 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave {
|
||||
for (Clock c : model.getClocks())
|
||||
model.addObserver(new RealTimeClock(model, c, timerExecuter));
|
||||
}
|
||||
clocksAreRunning = runClock;
|
||||
|
||||
runToBreak.setEnabled(!runClock && model.isFastRunModel());
|
||||
|
||||
model.init();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user