@@ -1409,7 +1409,6 @@ export class FederatedApp extends App {
14091409 * @returns Whether every reactions at this tag are executed.
14101410 */
14111411 protected _react ( ) : boolean {
1412- this . _updateMaxLevel ( ) ;
14131412 let r : Reaction < Variable [ ] > ;
14141413 while ( this . _reactionQ . size ( ) > 0 ) {
14151414 r = this . _reactionQ . peek ( ) ;
@@ -1565,6 +1564,7 @@ export class FederatedApp extends App {
15651564 Log . debug ( this , ( ) => {
15661565 return "In update_last_known_status_on_input ports." ;
15671566 } ) ;
1567+ let anyStatusChanged = false ;
15681568 this . networkReceivers . forEach (
15691569 ( networkReceiver : NetworkReceiver < unknown > , portID : number ) => {
15701570 // This is called when a TAG is received.
@@ -1581,9 +1581,13 @@ export class FederatedApp extends App {
15811581 ) ;
15821582 } ) ;
15831583 networkReceiver . lastKnownStatusTag = tag ;
1584+ anyStatusChanged = true ;
15841585 }
15851586 }
15861587 ) ;
1588+ if ( anyStatusChanged ) {
1589+ this . _updateMaxLevel ( ) ;
1590+ }
15871591 }
15881592
15891593 /**
@@ -1631,7 +1635,7 @@ export class FederatedApp extends App {
16311635 * Enqueue network port absent reactions that will send a MSG_TYPE_PORT_ABSENT
16321636 * message to downstream federates if a given network output port is not present.
16331637 */
1634- protected _enqueuePortAbsentReactions ( ) : void {
1638+ private _enqueuePortAbsentReactions ( ) : void {
16351639 this . portAbsentReactions . forEach ( ( reaction ) => {
16361640 this . _reactionQ . push ( reaction ) ;
16371641 } ) ;
@@ -1696,6 +1700,15 @@ export class FederatedApp extends App {
16961700 } ) ;
16971701 }
16981702
1703+ /**
1704+ * @override
1705+ * Enqueue network port absent reactions and update max level for the new tag.
1706+ */
1707+ protected _startTimeStep ( ) : void {
1708+ this . _enqueuePortAbsentReactions ( ) ;
1709+ this . _updateMaxLevel ( ) ;
1710+ }
1711+
16991712 /**
17001713 * Send a message to a potentially remote federate's port via the RTI. This message
17011714 * is untimed, and will be timestamped by the destination federate when it is received.
@@ -1929,7 +1942,7 @@ export class FederatedApp extends App {
19291942
19301943 this . _loadStartupReactions ( ) ;
19311944
1932- this . _enqueuePortAbsentReactions ( ) ;
1945+ this . _startTimeStep ( ) ;
19331946
19341947 this . rtiClient . on ( "connected" , ( ) => {
19351948 this . rtiClient . sendNeighborStructure (
@@ -2053,6 +2066,7 @@ export class FederatedApp extends App {
20532066 // reactions at the given tag.
20542067 this . greatestTimeAdvanceGrant = ptag ;
20552068 this . _isLastTAGProvisional = true ;
2069+ this . _updateMaxLevel ( ) ;
20562070 this . _addDummyEvent ( ptag ) ;
20572071 this . _requestImmediateInvocationOfNext ( ) ;
20582072 } ) ;
0 commit comments