Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Banks of modal rectors do not receive inputs #1264

Closed
edwardalee opened this issue Jul 1, 2022 · 2 comments · Fixed by #1279
Closed

Banks of modal rectors do not receive inputs #1264

edwardalee opened this issue Jul 1, 2022 · 2 comments · Fixed by #1279
Assignees
Labels
bug Something isn't working modal models

Comments

@edwardalee
Copy link
Collaborator

In the following program, the Receiver is a bank of (trivial) modal reactors with just one mode. Although all bank members receive an input (and print it), only the last bank member receives the input inside its one and only mode.

target C {timeout: 1 sec}

reactor Receiver(bank_index:int(0)){
    input msg:int;
    reaction(msg) {=
        lf_print("[At %lld] Receiver %d received message %d outside mode", 
            lf_time_logical_elapsed(), self->bank_index, msg->value
        );
    =}
    initial mode A {
        reaction(msg) {=
            lf_print("[At %lld] Receiver %d received message %d inside mode", 
                lf_time_logical_elapsed(), self->bank_index, msg->value
            );
        =}
    }
}

reactor Sender(bank_index:int(0), arrival_interval:time(5000 msec), charge_time:time(5000 msec)) {
    output msg:int;
    timer t(0, 1 sec);
    reaction(t) -> msg {=
        lf_set(msg, self->bank_index);
        lf_print("Sender %d sending its ID", self->bank_index);
    =}
}

main reactor{
    vc = new[3] Sender();
    cs = new[3] Receiver();
    vc.msg -> cs.msg;
}

image

The output is:

Sender 2 sending its ID
Sender 0 sending its ID
Sender 1 sending its ID
[At 0] Receiver 1 received message 1 outside mode
[At 0] Receiver 2 received message 2 outside mode
[At 0] Receiver 0 received message 0 outside mode
[At 0] Receiver 2 received message 2 inside mode
Sender 1 sending its ID
Sender 2 sending its ID
Sender 0 sending its ID
[At 1000000000] Receiver 2 received message 2 outside mode
[At 1000000000] Receiver 0 received message 0 outside mode
[At 1000000000] Receiver 1 received message 1 outside mode
[At 1000000000] Receiver 2 received message 2 inside mode

The output should be:

Sender 2 sending its ID
Sender 0 sending its ID
Sender 1 sending its ID
[At 0] Receiver 1 received message 1 outside mode
[At 0] Receiver 1 received message 1 inside mode
[At 0] Receiver 2 received message 2 outside mode
[At 0] Receiver 0 received message 0 outside mode
[At 0] Receiver 0 received message 0 inside mode
[At 0] Receiver 2 received message 2 inside mode
...
@edwardalee edwardalee added bug Something isn't working modal models labels Jul 1, 2022
@a-sr
Copy link
Collaborator

a-sr commented Jul 5, 2022

Yes, the generated mode infrastructure does not correctly account for banks. I am on it but it will probably take some more time because there are some intricacies with the bank indices.

@a-sr
Copy link
Collaborator

a-sr commented Jul 6, 2022

PR #1279 provides a fix.

While creating test models, I encountered a strange bug when triggering multiple banks from the same reaction, see #1278.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working modal models
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants