mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-13 14:56:29 -04:00
Refined "finish micro steps" action. See #284
This commit is contained in:
parent
dbd3a99924
commit
cd7ddd364b
@ -335,25 +335,27 @@ public class Model implements Iterable<Node>, SyncAccess {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void runToBreakMicro() throws NodeException {
|
||||||
* Completes the actual micro step session to a full step.
|
|
||||||
*
|
|
||||||
* @param noise true if noise should be enabled
|
|
||||||
* @throws NodeException NodeException
|
|
||||||
*/
|
|
||||||
public void finishMicroSteps(boolean noise) throws NodeException {
|
|
||||||
ArrayList<BreakDetector> brVal = new ArrayList<>();
|
ArrayList<BreakDetector> brVal = new ArrayList<>();
|
||||||
for (Break b : breaks)
|
for (Break b : breaks)
|
||||||
brVal.add(new BreakDetector(b));
|
brVal.add(new BreakDetector(b));
|
||||||
stepWithCondition(noise, () -> {
|
|
||||||
boolean wasBreak = false;
|
ObservableValue clkVal = clocks.get(0).getClockOutput();
|
||||||
for (BreakDetector bd : brVal)
|
|
||||||
if (bd.detected()) {
|
fireEvent(ModelEvent.FASTRUN);
|
||||||
fireEvent(ModelEvent.BREAK);
|
final boolean[] wasBreak = {false};
|
||||||
wasBreak = true;
|
while (!wasBreak[0]) {
|
||||||
}
|
if (!needsUpdate())
|
||||||
return needsUpdate() && !wasBreak;
|
clkVal.setBool(!clkVal.getBool());
|
||||||
});
|
stepWithCondition(false, () -> {
|
||||||
|
for (BreakDetector bd : brVal)
|
||||||
|
if (bd.detected()) {
|
||||||
|
fireEvent(ModelEvent.BREAK);
|
||||||
|
wasBreak[0] = true;
|
||||||
|
}
|
||||||
|
return needsUpdate() && !wasBreak[0];
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -132,7 +132,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
|||||||
private final boolean keepPrefMainFile;
|
private final boolean keepPrefMainFile;
|
||||||
|
|
||||||
private ToolTipAction doStep;
|
private ToolTipAction doStep;
|
||||||
private ToolTipAction finishStep;
|
private ToolTipAction runToBreakMicroAction;
|
||||||
private ToolTipAction runToBreakAction;
|
private ToolTipAction runToBreakAction;
|
||||||
private ToolTipAction showMeasurementDialog;
|
private ToolTipAction showMeasurementDialog;
|
||||||
private ToolTipAction showMeasurementGraph;
|
private ToolTipAction showMeasurementGraph;
|
||||||
@ -954,28 +954,26 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
|||||||
circuitComponent.graphicHasChanged();
|
circuitComponent.graphicHasChanged();
|
||||||
final boolean needsUpdate = model.needsUpdate();
|
final boolean needsUpdate = model.needsUpdate();
|
||||||
doStep.setEnabled(needsUpdate);
|
doStep.setEnabled(needsUpdate);
|
||||||
finishStep.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"));
|
}.setToolTip(Lang.get("menu_step_tt"));
|
||||||
finishStep = new ToolTipAction(Lang.get("menu_stepFinish"), 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) {
|
||||||
try {
|
try {
|
||||||
model.finishMicroSteps(false);
|
model.runToBreakMicro();
|
||||||
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();
|
final boolean needsUpdate = model.needsUpdate();
|
||||||
doStep.setEnabled(needsUpdate);
|
doStep.setEnabled(needsUpdate);
|
||||||
finishStep.setEnabled(needsUpdate);
|
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
showErrorAndStopModel(Lang.get("msg_errorCalculatingStep"), e1);
|
showErrorAndStopModel(Lang.get("msg_errorCalculatingStep"), e1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.setToolTip(Lang.get("menu_stepFinish_tt"));
|
}.setToolTip(Lang.get("menu_runToBreakMicro_tt")).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"));
|
||||||
@ -1098,7 +1096,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
|||||||
run.addSeparator();
|
run.addSeparator();
|
||||||
run.add(runModelMicroAction.createJMenuItem());
|
run.add(runModelMicroAction.createJMenuItem());
|
||||||
run.add(doStep.createJMenuItem());
|
run.add(doStep.createJMenuItem());
|
||||||
run.add(finishStep.createJMenuItem());
|
run.add(runToBreakMicroAction.createJMenuItem());
|
||||||
run.addSeparator();
|
run.addSeparator();
|
||||||
run.add(runTests.createJMenuItem());
|
run.add(runTests.createJMenuItem());
|
||||||
run.add(runAllTests.createJMenuItem());
|
run.add(runAllTests.createJMenuItem());
|
||||||
@ -1106,7 +1104,6 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
|||||||
run.add(speedTest.createJMenuItem());
|
run.add(speedTest.createJMenuItem());
|
||||||
run.add(stats.createJMenuItem());
|
run.add(stats.createJMenuItem());
|
||||||
doStep.setEnabled(false);
|
doStep.setEnabled(false);
|
||||||
finishStep.setEnabled(false);
|
|
||||||
|
|
||||||
toolBar.add(runModelState.setIndicator(runModelAction.createJButtonNoText()));
|
toolBar.add(runModelState.setIndicator(runModelAction.createJButtonNoText()));
|
||||||
toolBar.add(runToBreakAction.createJButtonNoText());
|
toolBar.add(runToBreakAction.createJButtonNoText());
|
||||||
@ -1114,7 +1111,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
|||||||
toolBar.addSeparator();
|
toolBar.addSeparator();
|
||||||
toolBar.add(runModelMicroState.setIndicator(runModelMicroAction.createJButtonNoText()));
|
toolBar.add(runModelMicroState.setIndicator(runModelMicroAction.createJButtonNoText()));
|
||||||
toolBar.add(doStep.createJButtonNoText());
|
toolBar.add(doStep.createJButtonNoText());
|
||||||
toolBar.add(finishStep.createJButtonNoText());
|
toolBar.add(runToBreakMicroAction.createJButtonNoText());
|
||||||
toolBar.addSeparator();
|
toolBar.addSeparator();
|
||||||
toolBar.add(runTests.createJButtonNoText());
|
toolBar.add(runTests.createJButtonNoText());
|
||||||
}
|
}
|
||||||
@ -1251,11 +1248,11 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
|||||||
clearModelDescription();
|
clearModelDescription();
|
||||||
circuitComponent.setModeAndReset(false, SyncAccess.NOSYNC);
|
circuitComponent.setModeAndReset(false, SyncAccess.NOSYNC);
|
||||||
doStep.setEnabled(false);
|
doStep.setEnabled(false);
|
||||||
finishStep.setEnabled(false);
|
|
||||||
stoppedState.getAction().setEnabled(false);
|
stoppedState.getAction().setEnabled(false);
|
||||||
showMeasurementDialog.setEnabled(false);
|
showMeasurementDialog.setEnabled(false);
|
||||||
showMeasurementGraph.setEnabled(false);
|
showMeasurementGraph.setEnabled(false);
|
||||||
runToBreakAction.setEnabled(false);
|
runToBreakAction.setEnabled(false);
|
||||||
|
runToBreakMicroAction.setEnabled(false);
|
||||||
runTests.setEnabled(true);
|
runTests.setEnabled(true);
|
||||||
// keep errors
|
// keep errors
|
||||||
if (circuitComponent.getHighLightStyle() != Style.ERROR)
|
if (circuitComponent.getHighLightStyle() != Style.ERROR)
|
||||||
@ -1369,8 +1366,12 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
|||||||
handleKeyboardComponent(updateEvent);
|
handleKeyboardComponent(updateEvent);
|
||||||
|
|
||||||
doStep.setEnabled(false);
|
doStep.setEnabled(false);
|
||||||
finishStep.setEnabled(false);
|
if (!realTimeClockRunning && model.isRunToBreakAllowed()) {
|
||||||
runToBreakAction.setEnabled(!realTimeClockRunning && model.isRunToBreakAllowed());
|
if (updateEvent == ModelEvent.MICROSTEP)
|
||||||
|
runToBreakMicroAction.setEnabled(true);
|
||||||
|
else
|
||||||
|
runToBreakAction.setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
ElementAttributes settings = circuitComponent.getCircuit().getAttributes();
|
ElementAttributes settings = circuitComponent.getCircuit().getAttributes();
|
||||||
if (settings.get(Keys.SHOW_DATA_TABLE) || windowPosManager.isVisible("probe"))
|
if (settings.get(Keys.SHOW_DATA_TABLE) || windowPosManager.isVisible("probe"))
|
||||||
@ -1390,11 +1391,8 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
|||||||
|
|
||||||
model.init();
|
model.init();
|
||||||
|
|
||||||
if (updateEvent == ModelEvent.MICROSTEP) {
|
if (updateEvent == ModelEvent.MICROSTEP)
|
||||||
final boolean needsUpdate = model.needsUpdate();
|
doStep.setEnabled(model.needsUpdate());
|
||||||
doStep.setEnabled(needsUpdate);
|
|
||||||
finishStep.setEnabled(needsUpdate);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (NodeException | PinException | RuntimeException | ElementNotFoundException e) {
|
} catch (NodeException | PinException | RuntimeException | ElementNotFoundException e) {
|
||||||
@ -1415,9 +1413,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();
|
||||||
final boolean needsUpdate = model.needsUpdate();
|
doStep.setEnabled(model.needsUpdate());
|
||||||
doStep.setEnabled(needsUpdate);
|
|
||||||
finishStep.setEnabled(needsUpdate);
|
|
||||||
circuitComponent.graphicHasChanged();
|
circuitComponent.graphicHasChanged();
|
||||||
};
|
};
|
||||||
else
|
else
|
||||||
@ -1650,11 +1646,8 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
|||||||
modelCreator.addNodeElementsTo(model.nodesToUpdate(), circuitComponent.getHighLighted());
|
modelCreator.addNodeElementsTo(model.nodesToUpdate(), circuitComponent.getHighLighted());
|
||||||
model.fireManualChangeEvent();
|
model.fireManualChangeEvent();
|
||||||
circuitComponent.graphicHasChanged();
|
circuitComponent.graphicHasChanged();
|
||||||
if (!realTimeClockRunning) {
|
if (!realTimeClockRunning)
|
||||||
final boolean needsUpdate = model.needsUpdate();
|
doStep.setEnabled(model.needsUpdate());
|
||||||
doStep.setEnabled(needsUpdate);
|
|
||||||
finishStep.setEnabled(needsUpdate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1448,8 +1448,8 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
|
|||||||
<string name="menu_speedTest_tt">Führt einen Geschwindigkeitstest durch. Es wird die maximal mögliche Taktfrequenz ermittelt</string>
|
<string name="menu_speedTest_tt">Führt einen Geschwindigkeitstest durch. Es wird die maximal mögliche Taktfrequenz ermittelt</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_stepFinish">Gatterschritte beenden</string>
|
<string name="menu_runToBreakMicro">Run To Break im Gatterschrittmodus</string>
|
||||||
<string name="menu_stepFinish_tt">Führt alle Einzelgatterschritte aus, bis die Schaltung sich stabilisiert hat oder 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.</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>
|
||||||
|
@ -1433,8 +1433,8 @@
|
|||||||
<string name="menu_speedTest_tt">Performs a speed test by calculating the max. clock frequency.</string>
|
<string name="menu_speedTest_tt">Performs a speed test by calculating the max. clock frequency.</string>
|
||||||
<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_stepFinish">Finish Gate Step</string>
|
<string name="menu_runToBreakMicro">Run To Break in Single Gate Mode</string>
|
||||||
<string name="menu_stepFinish_tt">Executes all single gate steps until the circuit has stabilized or 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.</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>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user