Fixed a bug that made it impossible to analyze a model created with the fsm editor.

This commit is contained in:
hneemann 2019-05-21 17:42:56 +02:00
parent 23ff923a9d
commit b7e8ba7b9a
3 changed files with 24 additions and 2 deletions

View File

@ -75,6 +75,7 @@ public class Model implements Iterable<Node>, SyncAccess {
private boolean isInvalidSignal = false;
private AsyncSeq asyncInfos;
private boolean asyncMode = false;
private boolean allowGlobalValues = false;
private final ArrayList<ModelStateObserver> observers;
private ArrayList<ModelStateObserver> observersStep;
@ -740,6 +741,27 @@ public class Model implements Iterable<Node>, SyncAccess {
return null;
}
/**
* Registers a global value.
*
* @param name the name
* @param value the value
*/
public void registerGlobalValue(String name, ObservableValue value) {
if (allowGlobalValues)
GlobalValues.getInstance().register(name, value, this);
}
/**
* Set or denies the creation of global values.
*
* @param allowGlobalValues if true, global values are published
* @return this for chained calls
*/
public Model setAllowGlobalValues(boolean allowGlobalValues) {
this.allowGlobalValues = allowGlobalValues;
return this;
}
/**
* Sets async execution infos

View File

@ -54,7 +54,7 @@ public class Probe implements Element {
@Override
public void registerNodes(Model model) {
model.addSignal(new Signal(label, value).setFormat(format));
GlobalValues.getInstance().register(label, value, model);
model.registerGlobalValue(label, value);
}
}

View File

@ -269,7 +269,7 @@ public class ModelCreator implements Iterable<ModelEntry> {
* @throws NodeException NodeException
*/
public Model createModel(boolean attachWires) throws PinException, NodeException {
Model m = new Model();
Model m = new Model().setAllowGlobalValues(attachWires);
for (Net n : netList)
n.interconnect(m, attachWires);