You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following program throws an IllegalArgumentException in ASTUtils.
Worse, the compilation claims to have succeeded, so running the code just runs the previous version.
The stack trace is:
java.lang.IllegalArgumentException: Parameter null is not a parameter of reactor instance _i1in0.
at org.lflang.ast.ASTUtils.initialValue(ASTUtils.java:1327)
at org.lflang.ast.ASTUtils.initialValueInt(ASTUtils.java:1412)
at org.lflang.generator.ReactorInstance.initialIntParameterValue(ReactorInstance.java:467)
at org.lflang.generator.PortInstance.setInitialWidth(PortInstance.java:424)
at org.lflang.generator.PortInstance.<init>(PortInstance.java:83)
at org.lflang.generator.ReactorInstance.<init>(ReactorInstance.java:869)
at org.lflang.generator.ReactorInstance.<init>(ReactorInstance.java:882)
at org.lflang.generator.ReactorInstance.<init>(ReactorInstance.java:94)
at org.lflang.ast.ASTUtils.createMainReactorInstance(ASTUtils.java:604)
at org.lflang.generator.c.CGenerator.setUpGeneralParameters(CGenerator.java:1966)
at org.lflang.generator.c.CGenerator.doGenerate(CGenerator.java:397)
at org.lflang.generator.LFGenerator.doGenerate(LFGenerator.java:130)
at org.lflang.federated.generator.FedGenerator.lambda$compileFederates$2(FedGenerator.java:330)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
target C {
coordination: decentralized
}
reactor Node(
id: int = 0,
is_initial_primary: bool = false,
num_nodes_minus_one: int = 2,
heartbeat_period: time = 1s
) {
input[num_nodes_minus_one] in: int
output out: int
initial mode Idle {
reaction(startup) -> reset(Backup), reset(Primary) {=
if (self->is_initial_primary) {
lf_set_mode(Primary);
} else {
lf_set_mode(Backup);
}
=}
}
mode Backup {
timer t(heartbeat_period, heartbeat_period)
reaction(t) in -> reset(Suspected) {=
int primary_id = -1;
for (int i = 0; i < in_width; i++) {
if (in[i]->is_present) {
if (primary_id >= 0) {
lf_print_error("Multiple primaries detected!!");
}
primary_id = in[i]->value;
lf_print("Node %d received heartbeat from node %d.", self->id, primary_id);
}
}
if (primary_id < 0) {
lf_set_mode(Suspected);
}
=} STP (0) {=
lf_set_mode(Suspected);
=}
}
mode Primary {
timer heartbeat(0, heartbeat_period)
timer fail(10s)
reaction(heartbeat) -> out {=
lf_print("Primary node %d sends heartbeat.", self->id);
lf_set(out, self->id);
=}
}
mode Suspected {
reaction(reset) {=
lf_print("Node %d entered Suspected mode.", self->id);
=}
}
}
federated reactor {
i0 = new Node()
i1 = new Node(id=1)
i2 = new Node(id=2, is_initial_primary = true)
i0.out, i1.out -> i2.in after 10 ms
i1.out, i2.out -> i0.in after 10 ms
i0.out, i2.out -> i1.in after 10 ms
}
The text was updated successfully, but these errors were encountered:
This bug has something to do with the multiport input to the Node reactor, specifically the fact that the width is parameterized. Replacing the width with a numeric constant enables the program to compile.
The following program throws an IllegalArgumentException in ASTUtils.
Worse, the compilation claims to have succeeded, so running the code just runs the previous version.
The stack trace is:
The text was updated successfully, but these errors were encountered: