mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-19 01:44:44 -04:00
moved real time clock enable to clock element
This commit is contained in:
parent
3aecf4150f
commit
0ffd7f1705
1001
src/main/dig/bcd.hex
Normal file
1001
src/main/dig/bcd.hex
Normal file
File diff suppressed because it is too large
Load Diff
@ -35,10 +35,11 @@ public class AttributeKey<VALUE> {
|
||||
|
||||
public static final AttributeKey<Boolean> ShowDataTable = new AttributeKey<>("showDataTable", Lang.get("key_showDataTable"), false);
|
||||
public static final AttributeKey<Boolean> ShowDataGraph = new AttributeKey<>("showDataGraph", Lang.get("key_showDataGraph"), false);
|
||||
public static final AttributeKey<Boolean> StartTimer = new AttributeKey<>("startTimer", Lang.get("key_startClock"), false);
|
||||
//public static final AttributeKey<Boolean> StartTimer = new AttributeKey<>("startTimer", Lang.get("key_startClock"), false);
|
||||
public static final AttributeKey<Boolean> MicroStep = new AttributeKey<>("microStep", Lang.get("key_microStep"), false);
|
||||
|
||||
public static final AttributeKey<Boolean> IsHighZ = new AttributeKey<>("isHighZ", Lang.get("key_isHighZ"), false);
|
||||
public static final AttributeKey<Boolean> RunAtRealTime = new AttributeKey<>("runRealTime", Lang.get("key_runRealTime"), false);
|
||||
|
||||
private final String key;
|
||||
private final VALUE def;
|
||||
|
@ -14,20 +14,32 @@ import de.neemann.digital.lang.Lang;
|
||||
*/
|
||||
public class Clock implements Element {
|
||||
|
||||
/**
|
||||
* the clocks description
|
||||
*/
|
||||
public static final ElementTypeDescription DESCRIPTION = new ElementTypeDescription("Clock", Clock.class)
|
||||
.addAttribute(AttributeKey.Rotate)
|
||||
.addAttribute(AttributeKey.Label)
|
||||
.addAttribute(AttributeKey.RunAtRealTime)
|
||||
.addAttribute(AttributeKey.Frequency);
|
||||
|
||||
private final ObservableValue output;
|
||||
private final int frequency;
|
||||
private final String label;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param attributes the clocks attributes
|
||||
*/
|
||||
public Clock(ElementAttributes attributes) {
|
||||
output = new ObservableValue("C", 1);
|
||||
int f = attributes.get(AttributeKey.Frequency);
|
||||
if (f < 1) f = 1;
|
||||
frequency = f;
|
||||
if (attributes.get(AttributeKey.RunAtRealTime)) {
|
||||
int f = attributes.get(AttributeKey.Frequency);
|
||||
if (f < 1) f = 1;
|
||||
frequency = f;
|
||||
} else
|
||||
frequency = 0;
|
||||
label = attributes.get(AttributeKey.Label);
|
||||
}
|
||||
|
||||
@ -47,10 +59,16 @@ public class Clock implements Element {
|
||||
model.addSignal(label, output);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the clock output value
|
||||
*/
|
||||
public ObservableValue getClockOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the clocks frequency
|
||||
*/
|
||||
public int getFrequency() {
|
||||
return frequency;
|
||||
}
|
||||
|
@ -50,9 +50,6 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
|
||||
add(Out.LEDDESCRIPTION, menu);
|
||||
add(Button.DESCRIPTION, menu);
|
||||
add(Probe.DESCRIPTION, menu);
|
||||
add(Clock.DESCRIPTION, menu);
|
||||
add(Reset.DESCRIPTION, menu);
|
||||
add(Break.DESCRIPTION, menu);
|
||||
add(Out.SEVENDESCRIPTION, menu);
|
||||
add(Out.SEVENHEXDESCRIPTION, menu);
|
||||
add(Terminal.DESCRIPTION, menu);
|
||||
@ -64,10 +61,13 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
|
||||
add(Decoder.DESCRIPTION, menu);
|
||||
|
||||
menu = Lang.get("lib_wires");
|
||||
add(Splitter.DESCRIPTION, menu);
|
||||
add(Const.DESCRIPTION, menu);
|
||||
add(Splitter.DESCRIPTION, menu);
|
||||
add(Clock.DESCRIPTION, menu);
|
||||
add(Delay.DESCRIPTION, menu);
|
||||
add(Driver.DESCRIPTION, menu);
|
||||
add(Reset.DESCRIPTION, menu);
|
||||
add(Break.DESCRIPTION, menu);
|
||||
|
||||
menu = Lang.get("lib_flipFlops");
|
||||
add(RS_FF.DESCRIPTION, menu);
|
||||
|
@ -19,9 +19,16 @@ import static de.neemann.digital.draw.shapes.OutputShape.SIZE;
|
||||
* @author hneemann
|
||||
*/
|
||||
public class ClockShape implements Shape {
|
||||
private static final int WI = SIZE / 2;
|
||||
private static final Vector POS = new Vector(-SIZE * 2 + WI / 2, WI / 2);
|
||||
|
||||
private final String label;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param attr
|
||||
*/
|
||||
public ClockShape(ElementAttributes attr) {
|
||||
this.label = attr.getLabel();
|
||||
}
|
||||
@ -49,7 +56,19 @@ public class ClockShape implements Shape {
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean heighLight) {
|
||||
graphic.drawPolygon(new Polygon(true).add(-SIZE * 2 - 1, -SIZE).add(-1, -SIZE).add(-1, SIZE).add(-SIZE * 2 - 1, SIZE), Style.NORMAL);
|
||||
graphic.drawPolygon(new Polygon(true)
|
||||
.add(-SIZE * 2 - 1, -SIZE)
|
||||
.add(-1, -SIZE)
|
||||
.add(-1, SIZE)
|
||||
.add(-SIZE * 2 - 1, SIZE), Style.NORMAL);
|
||||
|
||||
graphic.drawPolygon(new Polygon(false)
|
||||
.add(POS)
|
||||
.add(POS.add(WI, 0))
|
||||
.add(POS.add(WI, -WI))
|
||||
.add(POS.add(2 * WI, -WI))
|
||||
.add(POS.add(2 * WI, 0))
|
||||
.add(POS.add(3 * WI, 0)), Style.THIN);
|
||||
|
||||
Vector textPos = new Vector(-SIZE * 3, 0);
|
||||
graphic.drawText(textPos, textPos.add(1, 0), label, Orientation.RIGHTCENTER, Style.NORMAL);
|
||||
|
@ -45,7 +45,6 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E
|
||||
private static final ArrayList<AttributeKey> ATTR_LIST = new ArrayList<>();
|
||||
|
||||
static {
|
||||
ATTR_LIST.add(AttributeKey.StartTimer);
|
||||
ATTR_LIST.add(AttributeKey.ShowDataTable);
|
||||
ATTR_LIST.add(AttributeKey.ShowDataGraph);
|
||||
ATTR_LIST.add(AttributeKey.ShowListing);
|
||||
@ -376,7 +375,7 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E
|
||||
@Override
|
||||
public void enter() {
|
||||
super.enter();
|
||||
if (createAndStartModel(settings.get(AttributeKey.StartTimer), ModelEvent.STEP))
|
||||
if (createAndStartModel(true, ModelEvent.STEP))
|
||||
circuitComponent.setManualChangeObserver(new FullStepObserver(model));
|
||||
}
|
||||
});
|
||||
@ -418,12 +417,21 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E
|
||||
}
|
||||
|
||||
|
||||
private boolean createAndStartModel(boolean runClock, ModelEvent updateEvent) {
|
||||
private boolean createAndStartModel(boolean globalRunClock, ModelEvent updateEvent) {
|
||||
try {
|
||||
circuitComponent.removeHighLighted();
|
||||
circuitComponent.setModeAndReset(true);
|
||||
|
||||
setModelDescription(new ModelDescription(circuitComponent.getCircuit(), library));
|
||||
|
||||
boolean runClock = false;
|
||||
if (globalRunClock)
|
||||
for (Clock c : model.getClocks())
|
||||
if (c.getFrequency() > 0) {
|
||||
model.addObserver(new RealTimeClock(model, c, timerExecuter, this));
|
||||
runClock = true;
|
||||
}
|
||||
|
||||
if (runClock) {
|
||||
// if clock is running, enable automatic update of gui
|
||||
GuiModelObserver gmo = new GuiModelObserver(circuitComponent, updateEvent);
|
||||
@ -433,11 +441,6 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E
|
||||
// all repainting is initiated by user actions!
|
||||
modelDescription.connectToGui(null);
|
||||
|
||||
if (runClock) {
|
||||
for (Clock c : model.getClocks())
|
||||
model.addObserver(new RealTimeClock(model, c, timerExecuter, this));
|
||||
}
|
||||
|
||||
runToBreak.setEnabled(!runClock && model.isFastRunModel());
|
||||
|
||||
List<String> ordering = circuitComponent.getCircuit().getMeasurementOrdering();
|
||||
|
@ -35,9 +35,10 @@ key_valueIsProbe=Als Messwert verwenden
|
||||
key_showListing=Zeige Listing an, wenn verf\u00FCgbar
|
||||
key_showDataTable=Zeige Messwertetabelle
|
||||
key_showDataGraph=Zeige Messwertegraph
|
||||
key_startClock=Starte den Takt
|
||||
key_microStep=Zeige Mikroschritte
|
||||
key_isHighZ=Eingang kann hochohmig sein
|
||||
key_runRealTime=Echtzeittakt starten
|
||||
|
||||
|
||||
rot_0=0\u00B0
|
||||
rot_90=90\u00B0
|
||||
|
@ -35,9 +35,9 @@ key_valueIsProbe=Use as measurment value
|
||||
key_showListing=Show list file if available
|
||||
key_showDataTable=Show measurement values
|
||||
key_showDataGraph=Show measurement graph
|
||||
key_startClock=Start timer
|
||||
key_microStep=Show micro steps
|
||||
key_isHighZ=Is three-state input
|
||||
key_runRealTime=Start real time clock
|
||||
|
||||
rot_0=0\u00B0
|
||||
rot_90=90\u00B0
|
||||
|
Loading…
x
Reference in New Issue
Block a user