Skip to content

Commit

Permalink
Update completed based on TAN not next_event
Browse files Browse the repository at this point in the history
  • Loading branch information
Soroosh129 committed Apr 4, 2022
1 parent 83d8d00 commit 8fe8d60
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions core/federated/RTI/rti.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,20 +807,15 @@ void handle_time_advance_notice(federate_t* fed) {
LOG_PRINT("RTI received from federate %d the Time Advance Notice (TAN) %lld.",
fed->id, fed->time_advance - start_time);

// If the TAN is greater than the most recently received NET, then
// update the NET to match the TAN. The NET is a promise that, absent
// network inputs, the federate will not produce an output with tag
// less than the NET.
// Update the completed tag to match the TAN.
tag_t ta = (tag_t) {.time = fed->time_advance, .microstep = 0};
if (compare_tags(ta, fed->next_event) > 0) {
fed->next_event = ta;
// We need to reply just as if this were a NET because it could unblock
// network input port control reactions.
// This is a side-effect of the combination of distributed cycles and
// physical actions in federates. FIXME: More explanation is needed.
if (fed->num_upstream > 0) {
send_advance_grant_if_safe(fed);
}
fed->completed = ta;
// We need to reply just as if this were a NET because it could unblock
// network input port control reactions.
// This is a side-effect of the combination of distributed cycles and
// physical actions in federates. FIXME: More explanation is needed.
if (fed->num_upstream > 0) {
send_advance_grant_if_safe(fed);
}

// Check downstream federates to see whether they should now be granted a TAG.
Expand Down

0 comments on commit 8fe8d60

Please sign in to comment.