-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for running in fast mode, simply return immediatly from a…
…ny call to wait_until.
- Loading branch information
Showing
10 changed files
with
140 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
lfc/core/src/main/java/org/lflang/target/property/BooleanProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.lflang.target.property; | ||
|
||
import org.lflang.MessageReporter; | ||
import org.lflang.ast.ASTUtils; | ||
import org.lflang.lf.Element; | ||
import org.lflang.target.property.type.PrimitiveType; | ||
|
||
public abstract class BooleanProperty extends TargetProperty<Boolean, PrimitiveType> { | ||
|
||
protected BooleanProperty() { | ||
super(PrimitiveType.BOOLEAN); | ||
} | ||
|
||
@Override | ||
public Boolean initialValue() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public Boolean fromAst(Element node, MessageReporter reporter) { | ||
return ASTUtils.toBoolean(node); | ||
} | ||
|
||
@Override | ||
protected Boolean fromString(String string, MessageReporter reporter) { | ||
return Boolean.parseBoolean(string); | ||
} | ||
|
||
@Override | ||
public Element toAstElement(Boolean value) { | ||
return ASTUtils.toElement(value); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
lfc/core/src/main/java/org/lflang/target/property/FastProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.lflang.target.property; | ||
|
||
import org.lflang.MessageReporter; | ||
import org.lflang.ast.ASTUtils; | ||
import org.lflang.lf.Action; | ||
import org.lflang.lf.ActionOrigin; | ||
import org.lflang.lf.LfPackage.Literals; | ||
import org.lflang.lf.Reactor; | ||
import org.lflang.target.Target; | ||
import org.lflang.target.TargetConfig; | ||
|
||
/** | ||
* If true, configure the execution environment such that it does not wait for physical time to | ||
* match logical time. The default is false. | ||
*/ | ||
public final class FastProperty extends BooleanProperty { | ||
|
||
/** Singleton target property instance. */ | ||
public static final FastProperty INSTANCE = new FastProperty(); | ||
|
||
private FastProperty() { | ||
super(); | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return "fast"; | ||
} | ||
|
||
@Override | ||
public void validate(TargetConfig config, MessageReporter reporter) { | ||
var pair = config.lookup(this); | ||
if (config.isSet(this) && config.isFederated()) { | ||
reporter | ||
.at(pair, Literals.KEY_VALUE_PAIR__NAME) | ||
.error("The fast target property is incompatible with federated programs."); | ||
} | ||
|
||
// if (config.target != Target.CPP) { | ||
// Check for physical actions | ||
for (Reactor reactor : ASTUtils.getAllReactors(config.getMainResource())) { | ||
// Check to see if the program has a physical action in a reactor | ||
for (Action action : reactor.getActions()) { | ||
if (action.getOrigin().equals(ActionOrigin.PHYSICAL)) { | ||
reporter | ||
.at(pair, Literals.KEY_VALUE_PAIR__NAME) | ||
.error( | ||
String.format( | ||
"In the %s target, the fast target property is incompatible with physical" | ||
+ " actions.", | ||
config.target.toString())); | ||
break; | ||
} | ||
} | ||
} | ||
// } | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
lfc/core/src/main/java/org/lflang/target/property/KeepaliveProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.lflang.target.property; | ||
|
||
/** | ||
* If true, configure the execution environment to keep executing if there are no more events on the | ||
* event queue. The default is false. | ||
*/ | ||
public final class KeepaliveProperty extends BooleanProperty { | ||
|
||
/** Singleton target property instance. */ | ||
public static final KeepaliveProperty INSTANCE = new KeepaliveProperty(); | ||
|
||
private KeepaliveProperty() { | ||
super(); | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return "keepalive"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
target uC { | ||
fast: true, | ||
timeout: 1 hour | ||
} | ||
|
||
main reactor { | ||
timer t(0, 1 sec) | ||
reaction(t) {= =} | ||
|
||
reaction(shutdown) {= | ||
printf("Finally shutdown executed for %" PRId64 " logical sec\n", env->get_elapsed_logical_time(env)/SEC(1)); | ||
=} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters