Alberto Merletti
Alberto Merletti

Reputation: 1

Time policy in HLA - RTI1516e

I'm trying to build a simple federation with openRTI using RTI1516e, which consist of two federate, one that is time-regulating and one that is time-constrained. However, when I try to enable the time regulation policy, my program get stuck waiting for a callback; I tried to enable the two policies using two different threads, but the time regulating policy, even if it is activated using the thread system, does not seem to work correctly (if I advance time with the regulating federate, time on the constrained federate stays the same).

Here is how I enable the time regulatin policy:

void myFederate::timePolicy()
    {
         double lookahead = fedamb->federateLookahead;
         auto_ptr<HLAfloat64Interval> interval( new HLAfloat64Interval(lookahead) );
     try
     {
       rtiamb->enableTimeRegulation( *interval );
     }
     while (fedamb->isRegulating == false) {
       rtiamb->evokeMultipleCallbacks(0.1, 1.0);
     }
    }

So basically, if I call myfed->timePolicy() from Main, I got stuck in the while loop; if I call it via thread, it seems to activate the policy but it does not work when I advance time.

Last info, if I only have one federate in the federation, time policy is activated correctly from the main - I don't get stuck in the while loop.

Here is how activate time constrained policy:

 rtiamb->enableTimeConstrained();

 while (!fedamb->isConstrained) {
    rtiamb->evokeMultipleCallbacks(0.1, 1.0);
 

And here is how I advanceTime:

fedamb->isAdvancing = true;
 auto_ptr<HLAfloat64Time> newTime( new HLAfloat64Time(fedamb->federateTime+timestep) );
 rtiamb->timeAdvanceRequest( *newTime );
    
 while( fedamb->isAdvancing )
 {
   rtiamb->evokeMultipleCallbacks( 0.1, 1.0 );
 }

Thank you for the help!

I tried to enable time policy on two federate - on as a regulating federate and one as a constraied federate. enabling of the time-regulating policy does not seem to work: I either get stuck in a while loop waiting for a callback from the RTI or advance time on the regulating federate without having a callback on the constrained federate.

Upvotes: 0

Views: 31

Answers (0)

Related Questions