lf-lang / vscode-lingua-franca

Lingua Franca extension for Visual Studio Code
Other
4 stars 3 forks source link

`NoSuchElementException` thrown from Elk #124

Open petervdonovan opened 1 year ago

petervdonovan commented 1 year ago

Error message:

Failed to perform diagram layout.\ java.util.NoSuchElementException\     at java.base/java.util.ArrayList$ListItr.previous(ArrayList.java:1043)\     at org.eclipse.elk.alg.layered.p4nodes.NetworkSimplexPlacer.markCrossingEdges(NetworkSimplexPlacer.java:1334)\     at org.eclipse.elk.alg.layered.p4nodes.NetworkSimplexPlacer.lambda$29(NetworkSimplexPlacer.java:1300)\     at java.base/java.util.stream.ReduceOps$2ReducingSink.accept(ReduceOps.java:123)\     at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)\     at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)\     at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)\     at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)\   &n...

Program:

target C {
  timeout: 2 sec,
  keepalive: true,
  build-type: "RelWithDebInfo",
  compile-definitions: {
    EXECUTABLE_PREAMBLE: "",
    WORKERS_NEEDED_FOR_FEDERATE: "2",
    NUMBER_OF_FEDERATES: "2",
    FEDERATED: "",
    FEDERATED_CENTRALIZED: ""
  },
  _fed_setup: "include/_federate__fed1_preamble.h",
  logging: "debug",
  threading: true,
  tracing: true,
  cmake-include: "include/federate__fed1_extension.cmake"
}

preamble {=
#ifdef __cplusplus
extern "C" {
#endif
#include "core/federated/federate.h"
#include "core/federated/net_common.h"
#include "core/federated/net_util.h"
#include "core/federated/clock-sync.h"
#include "core/threaded/reactor_threaded.h"
#include "core/utils/util.h"
extern federate_instance_t _fed;
#ifdef __cplusplus
}
#endif

=}

reactor Fed {
  input in: int
  output out: int
}
reactor _fed1in {
  input port0: int

  output port: int

  port0 -> port
}
reactor NetworkSender_0 {
  input msg: int

  logical action outputControlReactionTrigger

  reaction(msg) {=
    // Sending from msg in federate federate__fed1 to fed2.in in federate federate__fed2
    if (!msg->is_present) return;
    size_t message_length = sizeof(int);
    send_timed_message(NEVER, MSG_TYPE_TAGGED_MESSAGE, 0, 1, "federate 1 via the RTI", message_length, (unsigned char*)&msg->value);
  =}

  reaction(outputControlReactionTrigger) msg {=
    // If the output port has not been lf_set for the current logical time,
    // send an ABSENT message to the receiving federate
    LF_PRINT_LOG("Contemplating whether to send port "
              "absent for port %d to federate %d.",
              0, 1);
    if (msg == NULL || !msg->is_present) {
        // The output port is NULL or it is not present.
        send_port_absent_to_federate(NEVER, 0, 1);
    }
  =}
}
reactor NetworkReceiver_1 {
  output msg: int

  logical action networkMessage_1: int

  reaction(networkMessage_1) -> msg {=
    msg->physical_time_of_arrival = self->_lf__networkMessage_1.physical_time_of_arrival;
    lf_set(msg, networkMessage_1->value);
  =}
}
@_fed_config(network_message_actions="networkMessage_1", dependencyPairs="")
main reactor  {

    fed1 = new Fed()

    ns_federate__fed2 = new NetworkSender_0()
    nr_federate__fed1 = new NetworkReceiver_1()
    _fed1in0 = new _fed1in()
    _fed1in0.port -> fed1.in
    fed1.out -> ns_federate__fed2.msg
    nr_federate__fed1.msg -> _fed1in0.port0
}

Steps to reproduce:

Open the above example program in VS Code (the file name was federate__Fed1.lf, but that probably doesn't matter), open the diagram, and click "Full Control" in the control panel on the right.