Pergunta

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?

Foi útil?

Solução

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.

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top