usnistgov / ucef-meta

WebGME Federate and Experiment Designer
MIT License
3 stars 3 forks source link

Add code to handle SimEnd to default behavior in impl java #15

Open MartyBurns opened 6 years ago

MartyBurns commented 6 years ago

Version information

af5cbf19d66d2b5400575ddbc3a9e4ffe91d9a4f

Observed behavior

When terminiating the simulation, the federate prints an unhandled interaction for SimEnd even though there is default handling of this message in SynchronizedFederate (in ucef-core).

Expected behavior

Should not print out warning.

Steps to reproduce issue

Create a federation; run; send TERMINATE message

MartyBurns commented 6 years ago

Can be resolved by modifying the code generated for the implementation java class:

    private void checkReceivedSubscriptions() {
        log.debug("in checkReceivedSubscriptions");

        InteractionRoot interaction = null;
        while ((interaction = getNextInteractionNoWait()) != null) {
            if (interaction instanceof ThePong) {
                handleInteractionClass((ThePong) interaction);
            } else if (interaction instanceof SimEnd) {
                ////////////////////////////////////////////////////
                // TODO perform any additional handling of SimEnd //
                ////////////////////////////////////////////////////
            }
            else {
                log.warn("unhandled interaction: {}", interaction.getClassName());
            }
        }
     }

only the "else" clause is needed:

            } else if (interaction instanceof SimEnd) {
                ////////////////////////////////////////////////////
                // TODO perform any additional handling of SimEnd //
                ////////////////////////////////////////////////////
            }