3

I have HLA simulation in Java using pRTI with two federates. I want to advance time of my simulation. As far I know, following method is used for this purpose:

_ambassador.timeAdvanceRequest(time);

, where ambassador is an RTI ambassador.

My question is what to pass into time parameter? I assume it should be the time I want my simulation advance to, but how to get this one?

DNA
  • 40,109
  • 12
  • 96
  • 136
Kao
  • 6,619
  • 7
  • 39
  • 64
  • I've changed the tag, since the `hla` tag refers to High Level Assembly, not High Level Architecture (simulation) – DNA May 02 '14 at 21:13

2 Answers2

2

Ok, I figured it out.

It is neccessary to use one of LogicalTime interface implementations, for example using TimeFactory:

LogicalTime time =  _ambassador.getTimeFactory().makeFinal();

calling timeAdvanceRequest() will send request to RTI. The, if time was advanced, the timeAdvanceGrant() will be called on federate.

Further info here.

Kao
  • 6,619
  • 7
  • 39
  • 64
  • Did this approach work for you? Were you actually seeing timeAdvanceGrant callbacks and, if so, what were those times? I would assume that you'd never get a timeAdvanceGrant because the requested time is bigger than all possible times (I thought makeFinal() is supposed to return the largest possible time value). I know this question and answer are old but I'd be interested to know how you managed this. – Anthony Cramp Jan 24 '17 at 00:26
1

Here's how I think it is supposed to work in HLA 1516-2010. From HLA 1516-2010, the RTI is required to provide two time representations: HLAinteger64Time and HLAfloat64Time (sections 12.4 and 12.11.2 of the HLA Interface Specification). To access these, you use the LogicalTimeFactoryFactory. For example, the following code gets a HLAfloat64TimeFactory:

HLAfloat64TimeFactory timeFactory = 
     (HLAfloat64TimeFactory)LogicalTimeFactoryFactory.getLogicalTimeFactory("HLAfloat64Time")

This timeFactory instance can then be used to create HLAfloat64Time and HLAfloat64Interval instances:

HLAfloat64Time t = timeFactory.makeTime(3.0);
HLAfloat64Interval interval = timeFactory.makeInterval(1.0);

or, using the interfaces

LogicalTime t = timeFactory.makeTime(3.0);
LogicalTimeInterval interval = timeFactory.makeInterval(1.0);

Similar code is used for an Integer time factory.

Anthony Cramp
  • 4,257
  • 6
  • 23
  • 27