allows to open measurement table and graph in running simulation

This commit is contained in:
hneemann 2017-11-10 10:35:45 +01:00
parent 297e85e201
commit 4053826889
10 changed files with 89 additions and 51 deletions

View File

@ -3,6 +3,7 @@ Release Notes
HEAD, planned as v0.16
- RAM components and EEPROM now allow an input invert configuration.
- Measurement values dialog is also able to modify the values.
- Now you can open the measurement value table and graph in a running simulation.
- Bug fixes
- fixed a Bug in the RAMSinglePortSel component: Write was not edge-triggered on WE. Now it is.

View File

@ -37,7 +37,7 @@ public final class InsertAction extends ToolTipAction {
this.node = node;
this.insertHistory = insertHistory;
this.circuitComponent = circuitComponent;
setActive(node.isUnique());
setEnabled(node.isUnique());
}
@Override

View File

@ -6,13 +6,9 @@ import de.neemann.digital.analyse.TruthTable;
import de.neemann.digital.analyse.expression.format.FormatToExpression;
import de.neemann.digital.core.*;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.Key;
import de.neemann.digital.core.element.Keys;
import de.neemann.digital.core.io.Button;
import de.neemann.digital.core.io.In;
import de.neemann.digital.core.io.InValue;
import de.neemann.digital.core.io.Out;
import de.neemann.digital.core.io.PowerSupply;
import de.neemann.digital.core.io.*;
import de.neemann.digital.core.memory.ROM;
import de.neemann.digital.core.wiring.Clock;
import de.neemann.digital.draw.elements.*;
@ -77,7 +73,6 @@ import static javax.swing.JOptionPane.showInputDialog;
* @author hneemann
*/
public final class Main extends JFrame implements ClosingWindowListener.ConfirmSave, ErrorStopper, FileHistory.OpenInterface, DigitalRemoteInterface, StatusInterface, Circuit.ChangedListener {
private static final ArrayList<Key> ATTR_LIST = new ArrayList<>();
private static final String KEY_START_STOP_ACTION = "startStop";
private static boolean experimental;
@ -88,12 +83,6 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
return experimental;
}
static {
ATTR_LIST.add(Keys.SHOW_DATA_TABLE);
ATTR_LIST.add(Keys.SHOW_DATA_GRAPH);
ATTR_LIST.add(Keys.SHOW_DATA_GRAPH_MICRO);
}
private static final String MESSAGE = Lang.get("message");
private static final Icon ICON_RUN = IconCreator.create("media-playback-start.png");
private static final Icon ICON_MICRO = IconCreator.create("media-playback-start-2.png");
@ -125,6 +114,8 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
private ToolTipAction doStep;
private ToolTipAction runToBreakAction;
private ToolTipAction showMeasurementDialog;
private ToolTipAction showMeasurementGraph;
private File baseFilename;
private File filename;
@ -395,7 +386,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
}
}
}
}.setAcceleratorCTRLplus('N').setToolTip(Lang.get("menu_new_tt")).setActive(allowAll);
}.setAcceleratorCTRLplus('N').setToolTip(Lang.get("menu_new_tt")).setEnabledChain(allowAll);
ToolTipAction newSubFile = new ToolTipAction(Lang.get("menu_newSub"), ICON_NEW_SUB) {
@Override
@ -421,7 +412,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
}
}
}
}.setAcceleratorCTRLplus('O').setActive(allowAll);
}.setAcceleratorCTRLplus('O').setEnabledChain(allowAll);
ToolTipAction openWin = new ToolTipAction(Lang.get("menu_openWin"), ICON_OPEN_WIN) {
@Override
@ -435,7 +426,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
.setVisible(true);
}
}
}.setToolTip(Lang.get("menu_openWin_tt")).setActive(allowAll);
}.setToolTip(Lang.get("menu_openWin_tt")).setEnabledChain(allowAll);
JMenu openRecent = new JMenu(Lang.get("menu_openRecent"));
fileHistory.setMenu(openRecent);
@ -478,7 +469,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
else
saveFile(filename, false);
}
}.setAcceleratorCTRLplus('S').setActive(false);
}.setAcceleratorCTRLplus('S').setEnabledChain(false);
JMenu export = new JMenu(Lang.get("menu_export"));
export.add(new ExportAction(Lang.get("menu_exportSVG"), "svg", GraphicSVGIndex::new));
@ -859,7 +850,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
new ErrorMessage(Lang.get("msg_fastRunError")).addCause(e1).show(Main.this);
}
}
}.setToolTip(Lang.get("menu_fast_tt")).setActive(false);
}.setToolTip(Lang.get("menu_fast_tt")).setEnabledChain(false);
ToolTipAction stoppedStateAction = stoppedState.createToolTipAction(Lang.get("menu_element"), ICON_STOP).setToolTip(Lang.get("menu_element_tt"));
@ -889,12 +880,29 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
}
}.setToolTip(Lang.get("menu_speedTest_tt"));
ToolTipAction editRunAttributes = new ToolTipAction(Lang.get("menu_editRunAttributes")) {
showMeasurementDialog = new ToolTipAction(Lang.get("menu_showDataTable")) {
@Override
public void actionPerformed(ActionEvent e) {
circuitComponent.editCircuitAttributes(Main.this, ATTR_LIST);
public void actionPerformed(ActionEvent actionEvent) {
if (model != null) {
ModelEvent event = ModelEvent.STEP;
if (stateManager.isActive(runModelMicroState))
event = ModelEvent.MICROSTEP;
showMeasurementDialog(event);
}
}
}.setToolTip(Lang.get("menu_editRunAttributes_tt"));
}.setToolTip(Lang.get("menu_showDataTable_tt")).setEnabledChain(false);
showMeasurementGraph = new ToolTipAction(Lang.get("menu_showDataGraph")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
if (model != null) {
ModelEvent event = ModelEvent.STEP;
if (stateManager.isActive(runModelMicroState))
event = ModelEvent.MICROSTEP;
showMeasurementGraph(event);
}
}
}.setToolTip(Lang.get("menu_showDataGraph_tt")).setEnabledChain(false);
circuitComponent.getInputMap().put(KeyStroke.getKeyStroke(' '), KEY_START_STOP_ACTION);
circuitComponent.getActionMap().put(KEY_START_STOP_ACTION, new AbstractAction() {
@ -909,7 +917,8 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
JMenu run = new JMenu(Lang.get("menu_sim"));
menuBar.add(run);
run.add(editRunAttributes.createJMenuItem());
run.add(showMeasurementDialog.createJMenuItem());
run.add(showMeasurementGraph.createJMenuItem());
run.addSeparator();
run.add(runModelAction.createJMenuItem());
run.add(runModelMicroAction.createJMenuItem());
@ -1037,6 +1046,8 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
circuitComponent.setModeAndReset(false, NoSync.INST);
doStep.setEnabled(false);
stoppedState.getAction().setEnabled(false);
showMeasurementDialog.setEnabled(false);
showMeasurementGraph.setEnabled(false);
runToBreakAction.setEnabled(false);
// keep errors
if (circuitComponent.getHighLightStyle() != Style.ERROR)
@ -1049,6 +1060,8 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
@Override
public void enter() {
super.enter();
showMeasurementDialog.setEnabled(true);
showMeasurementGraph.setEnabled(true);
stoppedState.getAction().setEnabled(true);
if (createAndStartModel(false, ModelEvent.MICROSTEP, null))
circuitComponent.setManualChangeObserver(new MicroStepObserver(model));
@ -1109,14 +1122,14 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
runToBreakAction.setEnabled(!realTimeClockRunning && model.isFastRunModel());
ElementAttributes settings = circuitComponent.getCircuit().getAttributes();
List<String> ordering = circuitComponent.getCircuit().getMeasurementOrdering();
if (settings.get(Keys.SHOW_DATA_TABLE))
windowPosManager.register("probe", new ProbeDialog(this, model, updateEvent, ordering, modelSync, circuitComponent)).setVisible(true);
showMeasurementDialog(updateEvent);
List<String> ordering = circuitComponent.getCircuit().getMeasurementOrdering();
if (settings.get(Keys.SHOW_DATA_GRAPH))
windowPosManager.register("dataSet", GraphDialog.createLiveDialog(this, model, updateEvent == ModelEvent.MICROSTEP, ordering, modelSync)).setVisible(true);
showMeasurementGraph(updateEvent);
if (settings.get(Keys.SHOW_DATA_GRAPH_MICRO))
windowPosManager.register("dataSetMicro", GraphDialog.createLiveDialog(this, model, true, ordering, modelSync)).setVisible(true);
showMeasurementGraph(ModelEvent.MICROSTEP);
if (modelModifier != null)
modelModifier.preInit(model);
@ -1130,6 +1143,16 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
return false;
}
private void showMeasurementGraph(ModelEvent updateEvent) {
List<String> ordering = circuitComponent.getCircuit().getMeasurementOrdering();
windowPosManager.register("dataSet", GraphDialog.createLiveDialog(this, model, updateEvent == ModelEvent.MICROSTEP, ordering, modelSync)).setVisible(true);
}
private void showMeasurementDialog(ModelEvent updateEvent) {
List<String> ordering = circuitComponent.getCircuit().getMeasurementOrdering();
windowPosManager.register("probe", new ProbeDialog(this, model, updateEvent, ordering, modelSync, circuitComponent)).setVisible(true);
}
@Override
public void showErrorAndStopModel(String message, Exception cause) {
SwingUtilities.invokeLater(() -> {
@ -1228,7 +1251,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
private void setFilename(File filename, boolean toPrefs) {
modifiedPrefixVisible = circuitComponent.getCircuit().isModified();
if (save != null)
save.setActive(modifiedPrefixVisible);
save.setEnabled(modifiedPrefixVisible);
String prefix = "";
if (modifiedPrefixVisible)
prefix = "*";
@ -1378,6 +1401,8 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
void enter(boolean runRealTime, ModelModifier modelModifier) {
super.enter();
stoppedState.getAction().setEnabled(true);
showMeasurementDialog.setEnabled(true);
showMeasurementGraph.setEnabled(true);
if (createAndStartModel(runRealTime, ModelEvent.STEP, modelModifier))
circuitComponent.setManualChangeObserver(new FullStepObserver(model));
}

View File

@ -66,6 +66,9 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
ATTR_LIST.add(Keys.BACKGROUND_COLOR);
ATTR_LIST.add(Keys.DESCRIPTION);
ATTR_LIST.add(Keys.LOCKED_MODE);
ATTR_LIST.add(Keys.SHOW_DATA_TABLE);
ATTR_LIST.add(Keys.SHOW_DATA_GRAPH);
ATTR_LIST.add(Keys.SHOW_DATA_GRAPH_MICRO);
}
private static final String DEL_ACTION = "myDelAction";
@ -133,7 +136,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
public void actionPerformed(ActionEvent e) {
activeMouseController.rotate();
}
}.setActive(false).setAccelerator("R").enableAcceleratorIn(this);
}.setEnabledChain(false).setAccelerator("R").enableAcceleratorIn(this);
cutAction = createCutAction(shapeFactory);
@ -337,7 +340,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
}
}
}
}.setActive(false).setAcceleratorCTRLplus('X').enableAcceleratorIn(this);
}.setEnabledChain(false).setAcceleratorCTRLplus('X').enableAcceleratorIn(this);
}
private ToolTipAction createCopyAction(ShapeFactory shapeFactory) {
@ -351,7 +354,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
activeMouseController.escapePressed();
}
}
}.setActive(false).setAcceleratorCTRLplus('C').enableAcceleratorIn(this);
}.setEnabledChain(false).setAcceleratorCTRLplus('C').enableAcceleratorIn(this);
}
private ArrayList<Movable> getSelectedElements(ShapeFactory shapeFactory) {
@ -1200,7 +1203,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
if (activeMouseController != null && activeMouseController != this)
activeMouseController.deactivate();
activeMouseController = this;
deleteAction.setActive(false);
deleteAction.setEnabled(false);
copyAction.setEnabled(false);
cutAction.setEnabled(false);
rotateAction.setEnabled(false);
@ -1326,7 +1329,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
super.activate();
this.element = element;
delta = null;
deleteAction.setActive(true);
deleteAction.setEnabled(true);
rotateAction.setEnabled(true);
}
@ -1392,7 +1395,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
initialPos = visualElement.getPos();
initialRot = visualElement.getRotate();
delta = initialPos.sub(pos);
deleteAction.setActive(true);
deleteAction.setEnabled(true);
rotateAction.setEnabled(true);
copyAction.setEnabled(true);
repaintNeeded();
@ -1473,7 +1476,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
this.pos = raster(pos);
this.initialWirePos = wire.getPos();
this.initialPos = this.pos;
deleteAction.setActive(true);
deleteAction.setEnabled(true);
removeHighLighted();
repaintNeeded();
}
@ -1697,7 +1700,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
super.activate();
this.corner1 = corner1;
this.corner2 = corner2;
deleteAction.setActive(true);
deleteAction.setEnabled(true);
copyAction.setEnabled(true);
cutAction.setEnabled(true);
rotateAction.setEnabled(true);
@ -1905,7 +1908,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
m.move(delta);
}
deleteAction.setActive(true);
deleteAction.setEnabled(true);
rotateAction.setEnabled(true);
}

View File

@ -417,7 +417,7 @@ public final class EditorFactory {
}
}
}
.setActive(attr.getFile(ROM.LAST_DATA_FILE_KEY) != null)
.setEnabledChain(attr.getFile(ROM.LAST_DATA_FILE_KEY) != null)
.setToolTip(Lang.get("btn_reload_tt"))
.createJButton()
);

View File

@ -201,7 +201,7 @@ public class GraphDialog extends JDialog implements Observer {
* @return this for chained calls
*/
public GraphDialog disableTable() {
showTable.setActive(false);
showTable.setEnabled(false);
return this;
}

View File

@ -176,7 +176,7 @@ public class ValueTableDialog extends JDialog {
* @return this for chained calls
*/
public ValueTableDialog disableGraph() {
asGraph.setActive(false);
asGraph.setEnabled(false);
return this;
}

View File

@ -123,7 +123,7 @@ public abstract class ToolTipAction extends AbstractAction {
* @param newValue the new state
* @return this for call chaining
*/
public ToolTipAction setActive(boolean newValue) {
public ToolTipAction setEnabledChain(boolean newValue) {
super.setEnabled(newValue);
return this;
}

View File

@ -810,12 +810,12 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
<string name="key_rotation_tt">Legt die Ausrichtung des Elementes in der Schaltung fest.</string>
<string name="key_runRealTime">Echtzeittakt starten</string><!-- Clock -->
<string name="key_runRealTime_tt">Wenn eingeschaltet, wird beim Start der Schaltung der Echtzeittakt gestartet.</string>
<string name="key_showDataGraph">Zeige Messwertegraph</string>
<string name="key_showDataGraph">Zeige Messwertegraph bei Simulationsstart</string>
<string name="key_showDataGraph_tt">Beim Start der Simulation wird ein Graph mit den Messwerten angezeigt.</string>
<string name="key_showDataGraphMicro">Zeige Messwertgraph im Gatterschrittmodus</string>
<string name="key_showDataGraphMicro">Zeige Messwertgraph im Gatterschrittmodus bei Simulationsstart</string>
<string name="key_showDataGraphMicro_tt">Beim Start der Simulation wird ein Graph mit den Messwerten im Gatterschrittmodus
angezeigt. Dabei werden alle Gatterwechsel angezeigt.</string>
<string name="key_showDataTable">Zeige Messwertetabelle</string>
<string name="key_showDataTable">Zeige Messwertetabelle bei Simulationsstart</string>
<string name="key_showDataTable_tt">Beim Start der Simulation wird eine Tabelle mit den Messwerten angezeigt.</string>
<string name="key_termHeight">Zeilen</string><!-- Terminal -->
<string name="key_termHeight_tt">Die Anzahl der anzuzeigenden Zeilen.</string>
@ -939,8 +939,6 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
<string name="menu_edit">Bearbeiten</string>
<string name="menu_editAttributes">Schaltungsattribute bearbeiten</string>
<string name="menu_editAttributes_tt">Diese Attribute beeinflussen die Schaltung, wenn sie in andere Schaltungen eingebettet wird.</string>
<string name="menu_editRunAttributes">Simulationseinstellungen</string>
<string name="menu_editRunAttributes_tt">Einstellungen für den Start der Simulation</string>
<string name="menu_editSettings">Einstellungen</string>
<string name="menu_editSettings_tt">Bearbeitet die globalen Einstellungen</string>
<string name="menu_element">Stoppen der Simulation</string>
@ -1095,6 +1093,13 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
<string name="menu_karnaughMap_tt">Zeigt eine KV-Tafel der Tabelle an.</string>
<string name="menu_pdfDocumentation">Dokumentation</string>
<string name="menu_openPdfDocumentation">Öffne {0}</string>
<string name="menu_showDataTable">Zeige Messwertetabelle</string>
<string name="menu_showDataTable_tt">Zeigt eine Tabelle mit allen Messwerten in einem eigenen Fenster an.</string>
<string name="menu_showDataGraph">Zeige Messwertegraph</string>
<string name="menu_showDataGraph_tt">Ein Graph mit den Messwerten wird in einem eigenen Fenster angezeigt.</string>
<string name="msg_errorOpeningDocumentation">Fehler beim Öffnen einer PDF-Datei!</string>
<string name="message">&lt;h1&gt;Digital&lt;/h1&gt;Ein einfacher Simulator für digitale Schaltkreise.

View File

@ -807,12 +807,12 @@ The names of the variables may not be unique.</string>
<string name="key_rotation_tt">The orientation of the Element in the circuit.</string>
<string name="key_runRealTime">Start real time clock</string><!-- Clock -->
<string name="key_runRealTime_tt">If enabled the runtime clock is started when the circuit is started</string>
<string name="key_showDataGraph">Show measurement graph</string>
<string name="key_showDataGraph">Show measurement graph at simulation start</string>
<string name="key_showDataGraph_tt">When the simulation is started, a graph with the measured values is shown.</string>
<string name="key_showDataGraphMicro">Show measurement graph in single gate step mode</string>
<string name="key_showDataGraphMicro">Show measurement graph in single gate step mode at simulation start</string>
<string name="key_showDataGraphMicro_tt">When the simulation is started, a graph with the measured values in the
gate step mode is shown. All gate changes are included in the graph.</string>
<string name="key_showDataTable">Show measurement values</string>
<string name="key_showDataTable">Show measurement values at simulation start</string>
<string name="key_showDataTable_tt">When the simulation is started, a table with the measured values is shown.</string>
<string name="key_termHeight">Lines</string><!-- Terminal -->
<string name="key_termHeight_tt">The number of lines to show.</string>
@ -933,8 +933,6 @@ The names of the variables may not be unique.</string>
<string name="menu_edit">Edit</string>
<string name="menu_editAttributes">Edit circuit attributes</string>
<string name="menu_editAttributes_tt">These attributes effect the behavior if the circuit is included in other circuits.</string>
<string name="menu_editRunAttributes">Simulation Settings</string>
<string name="menu_editRunAttributes_tt">Settings used to start the simulation</string>
<string name="menu_editSettings">Settings</string>
<string name="menu_editSettings_tt">Edits Digitals preferences</string>
<string name="menu_element">Stop Simulation</string>
@ -1090,6 +1088,12 @@ The names of the variables may not be unique.</string>
<string name="menu_openPdfDocumentation">Open {0}</string>
<string name="msg_errorOpeningDocumentation">Error opening a PDF file!</string>
<string name="menu_showDataGraph">Show measurement graph</string>
<string name="menu_showDataGraph_tt">Shows a graph with the measured values in a separate window.</string>
<string name="menu_showDataTable">Show measurement value table</string>
<string name="menu_showDataTable_tt">Show table with the measured values in a separate window.</string>
<string name="message">&lt;h1&gt;Digital&lt;/h1&gt;A simple simulator for digital circuits.
Written by H. Neemann in 2016, 2017.