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