allows also to execute the remaining micro steps.

This commit is contained in:
hneemann 2019-07-19 09:07:39 +02:00
parent d85c77d663
commit 5ab523e8f0
4 changed files with 43 additions and 32 deletions

View File

@ -345,21 +345,26 @@ public class Model implements Iterable<Node>, SyncAccess {
for (Break b : breaks) for (Break b : breaks)
brVal.add(new BreakDetector(b)); brVal.add(new BreakDetector(b));
ObservableValue clkVal = clocks.get(0).getClockOutput(); if (brVal.isEmpty()) {
// simply stabilize the circuit
doStep();
} else {
ObservableValue clkVal = clocks.get(0).getClockOutput();
fireEvent(ModelEvent.FASTRUN); fireEvent(ModelEvent.FASTRUN);
final boolean[] wasBreak = {false}; final boolean[] wasBreak = {false};
while (!wasBreak[0]) { while (!wasBreak[0]) {
if (!needsUpdate()) if (!needsUpdate())
clkVal.setBool(!clkVal.getBool()); clkVal.setBool(!clkVal.getBool());
stepWithCondition(false, () -> { stepWithCondition(false, () -> {
for (BreakDetector bd : brVal) for (BreakDetector bd : brVal)
if (bd.detected()) { if (bd.detected()) {
fireEvent(ModelEvent.BREAK); fireEvent(ModelEvent.BREAK);
wasBreak[0] = true; wasBreak[0] = true;
} }
return needsUpdate() && !wasBreak[0]; return needsUpdate() && !wasBreak[0];
}); });
}
} }
} }

View File

@ -131,7 +131,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
private final InsertHistory insertHistory; private final InsertHistory insertHistory;
private final boolean keepPrefMainFile; private final boolean keepPrefMainFile;
private ToolTipAction doStep; private ToolTipAction doMicroStep;
private ToolTipAction runToBreakMicroAction; private ToolTipAction runToBreakMicroAction;
private ToolTipAction runToBreakAction; private ToolTipAction runToBreakAction;
private ToolTipAction showMeasurementDialog; private ToolTipAction showMeasurementDialog;
@ -944,7 +944,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
* @param toolBar the tool bar * @param toolBar the tool bar
*/ */
private void createStartMenu(JMenuBar menuBar, JToolBar toolBar) { private void createStartMenu(JMenuBar menuBar, JToolBar toolBar) {
doStep = new ToolTipAction(Lang.get("menu_step"), ICON_STEP) { doMicroStep = new ToolTipAction(Lang.get("menu_step"), ICON_STEP) {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
try { try {
@ -952,13 +952,12 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
circuitComponent.removeHighLighted(); circuitComponent.removeHighLighted();
modelCreator.addNodeElementsTo(model.nodesToUpdate(), circuitComponent.getHighLighted()); modelCreator.addNodeElementsTo(model.nodesToUpdate(), circuitComponent.getHighLighted());
circuitComponent.graphicHasChanged(); circuitComponent.graphicHasChanged();
final boolean needsUpdate = model.needsUpdate(); checkMicroStepActions(model);
doStep.setEnabled(needsUpdate);
} catch (Exception e1) { } catch (Exception e1) {
showErrorAndStopModel(Lang.get("msg_errorCalculatingStep"), e1); showErrorAndStopModel(Lang.get("msg_errorCalculatingStep"), e1);
} }
} }
}.setToolTip(Lang.get("menu_step_tt")).setAccelerator("F4"); }.setToolTip(Lang.get("menu_step_tt")).setAccelerator("M").setEnabledChain(false);
runToBreakMicroAction = new ToolTipAction(Lang.get("menu_runToBreakMicro"), ICON_STEP_FINISH) { runToBreakMicroAction = new ToolTipAction(Lang.get("menu_runToBreakMicro"), ICON_STEP_FINISH) {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -967,13 +966,12 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
circuitComponent.removeHighLighted(); circuitComponent.removeHighLighted();
modelCreator.addNodeElementsTo(model.nodesToUpdate(), circuitComponent.getHighLighted()); modelCreator.addNodeElementsTo(model.nodesToUpdate(), circuitComponent.getHighLighted());
circuitComponent.graphicHasChanged(); circuitComponent.graphicHasChanged();
final boolean needsUpdate = model.needsUpdate(); checkMicroStepActions(model);
doStep.setEnabled(needsUpdate);
} catch (Exception e1) { } catch (Exception e1) {
showErrorAndStopModel(Lang.get("msg_errorCalculatingStep"), e1); showErrorAndStopModel(Lang.get("msg_errorCalculatingStep"), e1);
} }
} }
}.setToolTip(Lang.get("menu_runToBreakMicro_tt")).setEnabledChain(false); }.setToolTip(Lang.get("menu_runToBreakMicro_tt")).setAcceleratorCTRLplus('M').setEnabledChain(false);
ToolTipAction runModelAction = runModelState.createToolTipAction(Lang.get("menu_run"), ICON_RUN) ToolTipAction runModelAction = runModelState.createToolTipAction(Lang.get("menu_run"), ICON_RUN)
.setToolTip(Lang.get("menu_run_tt")); .setToolTip(Lang.get("menu_run_tt"));
@ -1095,7 +1093,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
run.add(stoppedStateAction.createJMenuItem()); run.add(stoppedStateAction.createJMenuItem());
run.addSeparator(); run.addSeparator();
run.add(runModelMicroAction.createJMenuItem()); run.add(runModelMicroAction.createJMenuItem());
run.add(doStep.createJMenuItem()); run.add(doMicroStep.createJMenuItem());
run.add(runToBreakMicroAction.createJMenuItem()); run.add(runToBreakMicroAction.createJMenuItem());
run.addSeparator(); run.addSeparator();
run.add(runTests.createJMenuItem()); run.add(runTests.createJMenuItem());
@ -1103,14 +1101,13 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
run.addSeparator(); run.addSeparator();
run.add(speedTest.createJMenuItem()); run.add(speedTest.createJMenuItem());
run.add(stats.createJMenuItem()); run.add(stats.createJMenuItem());
doStep.setEnabled(false);
toolBar.add(runModelState.setIndicator(runModelAction.createJButtonNoText())); toolBar.add(runModelState.setIndicator(runModelAction.createJButtonNoText()));
toolBar.add(runToBreakAction.createJButtonNoText()); toolBar.add(runToBreakAction.createJButtonNoText());
toolBar.add(stoppedStateAction.createJButtonNoText()); toolBar.add(stoppedStateAction.createJButtonNoText());
toolBar.addSeparator(); toolBar.addSeparator();
toolBar.add(runModelMicroState.setIndicator(runModelMicroAction.createJButtonNoText())); toolBar.add(runModelMicroState.setIndicator(runModelMicroAction.createJButtonNoText()));
toolBar.add(doStep.createJButtonNoText()); toolBar.add(doMicroStep.createJButtonNoText());
toolBar.add(runToBreakMicroAction.createJButtonNoText()); toolBar.add(runToBreakMicroAction.createJButtonNoText());
toolBar.addSeparator(); toolBar.addSeparator();
toolBar.add(runTests.createJButtonNoText()); toolBar.add(runTests.createJButtonNoText());
@ -1247,7 +1244,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
super.enter(); super.enter();
clearModelDescription(); clearModelDescription();
circuitComponent.setModeAndReset(false, SyncAccess.NOSYNC); circuitComponent.setModeAndReset(false, SyncAccess.NOSYNC);
doStep.setEnabled(false); doMicroStep.setEnabled(false);
stoppedState.getAction().setEnabled(false); stoppedState.getAction().setEnabled(false);
showMeasurementDialog.setEnabled(false); showMeasurementDialog.setEnabled(false);
showMeasurementGraph.setEnabled(false); showMeasurementGraph.setEnabled(false);
@ -1365,7 +1362,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
handleKeyboardComponent(updateEvent); handleKeyboardComponent(updateEvent);
doStep.setEnabled(false); doMicroStep.setEnabled(false);
if (!realTimeClockRunning && model.isRunToBreakAllowed()) { if (!realTimeClockRunning && model.isRunToBreakAllowed()) {
if (updateEvent == ModelEvent.MICROSTEP) if (updateEvent == ModelEvent.MICROSTEP)
runToBreakMicroAction.setEnabled(true); runToBreakMicroAction.setEnabled(true);
@ -1392,7 +1389,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
model.init(); model.init();
if (updateEvent == ModelEvent.MICROSTEP) if (updateEvent == ModelEvent.MICROSTEP)
doStep.setEnabled(model.needsUpdate()); checkMicroStepActions(model);
return true; return true;
} catch (NodeException | PinException | RuntimeException | ElementNotFoundException e) { } catch (NodeException | PinException | RuntimeException | ElementNotFoundException e) {
@ -1404,6 +1401,13 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
return false; return false;
} }
private void checkMicroStepActions(Model model) {
final boolean needsUpdate = model.needsUpdate();
doMicroStep.setEnabled(needsUpdate);
if (!model.isRunToBreakAllowed())
runToBreakMicroAction.setEnabled(needsUpdate);
}
private void handleKeyboardComponent(ModelEvent updateEvent) { private void handleKeyboardComponent(ModelEvent updateEvent) {
KeyboardDialog.KeyPressedHandler handler = null; KeyboardDialog.KeyPressedHandler handler = null;
for (Keyboard k : model.findNode(Keyboard.class)) { for (Keyboard k : model.findNode(Keyboard.class)) {
@ -1413,7 +1417,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
keyboard.hasChanged(); keyboard.hasChanged();
modelCreator.addNodeElementsTo(model.nodesToUpdate(), circuitComponent.getHighLighted()); modelCreator.addNodeElementsTo(model.nodesToUpdate(), circuitComponent.getHighLighted());
model.fireManualChangeEvent(); model.fireManualChangeEvent();
doStep.setEnabled(model.needsUpdate()); checkMicroStepActions(model);
circuitComponent.graphicHasChanged(); circuitComponent.graphicHasChanged();
}; };
else else
@ -1647,7 +1651,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
model.fireManualChangeEvent(); model.fireManualChangeEvent();
circuitComponent.graphicHasChanged(); circuitComponent.graphicHasChanged();
if (!realTimeClockRunning) if (!realTimeClockRunning)
doStep.setEnabled(model.needsUpdate()); checkMicroStepActions(model);
} }
} }

View File

@ -1450,7 +1450,8 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
<string name="menu_step">Gatterschritt</string> <string name="menu_step">Gatterschritt</string>
<string name="menu_step_tt">Führt einen Einzelgatterschritt aus</string> <string name="menu_step_tt">Führt einen Einzelgatterschritt aus</string>
<string name="menu_runToBreakMicro">Run To Break im Gatterschrittmodus</string> <string name="menu_runToBreakMicro">Run To Break im Gatterschrittmodus</string>
<string name="menu_runToBreakMicro_tt">Führt alle Einzelgatterschritte aus, bis eine steigende Flanke an einem Break-Element erkannt wird.</string> <string name="menu_runToBreakMicro_tt">Führt alle Einzelgatterschritte aus, bis eine steigende Flanke an einem Break-Element erkannt wird.
Ist kein Break-Element vorhanden, werden die verbleibenden Einzelgatterschritte ausgeführt.</string>
<string name="menu_synthesise">Synthese</string> <string name="menu_synthesise">Synthese</string>
<string name="menu_synthesise_tt">Erzeugt minimale boolsche Ausdrücke, welche durch eine Wahrheitstabelle beschrieben werden.</string> <string name="menu_synthesise_tt">Erzeugt minimale boolsche Ausdrücke, welche durch eine Wahrheitstabelle beschrieben werden.</string>
<string name="menu_table_N_variables">{0} Variablen</string> <string name="menu_table_N_variables">{0} Variablen</string>

View File

@ -1435,7 +1435,8 @@
<string name="menu_step">Gate Step</string> <string name="menu_step">Gate Step</string>
<string name="menu_step_tt">Calculates a single gate step</string> <string name="menu_step_tt">Calculates a single gate step</string>
<string name="menu_runToBreakMicro">Run To Break in Single Gate Mode</string> <string name="menu_runToBreakMicro">Run To Break in Single Gate Mode</string>
<string name="menu_runToBreakMicro_tt">Executes all single gate steps until a rising edge is detected on a break component.</string> <string name="menu_runToBreakMicro_tt">Executes all single gate steps until a rising edge is detected on a break component.
If there is no break component, the remaining single gate steps are executed.</string>
<string name="menu_synthesise">Synthesise</string> <string name="menu_synthesise">Synthesise</string>
<string name="menu_synthesise_tt">Generates the minimal bool expressions described by a truth table.</string> <string name="menu_synthesise_tt">Generates the minimal bool expressions described by a truth table.</string>
<string name="menu_table_N_variables">{0} variables</string> <string name="menu_table_N_variables">{0} variables</string>