A Simple Federate

Help
Anonymous
2012-09-20
2013-05-30
  • Anonymous - 2012-09-20

    Hi Michael,

    I've been trying to get a super simple IEEE-1516 compliant federate to connect to the OHLA RTI, using the code below.  I keep getting a CouldNotCreateLogicalTimeFactory exception:

    Exception in thread "main" hla.rti1516.RTIinternalError: hla.rti1516e.exceptions.CouldNotCreateLogicalTimeFactory: could not create LogicalTimeFactory: HLAfloat64Time
    at net.sf.ohla.rti.hla.rti1516.IEEE1516RTIambassador.joinFederationExecution(IEEE1516RTIambassador.java:292)
    at samplefed.SimpleFed.runFederate(SimpleFed.java:43)
    at samplefed.SimpleFed.main(SimpleFed.java:21)
    Caused by: hla.rti1516e.exceptions.CouldNotCreateLogicalTimeFactory: could not create LogicalTimeFactory: HLAfloat64Time
    at net.sf.ohla.rti.federate.Federate.<init>(Federate.java:353)
    at net.sf.ohla.rti.hla.rti1516e.IEEE1516eRTIambassador.joinFederationExecution(IEEE1516eRTIambassador.java:652)
    at net.sf.ohla.rti.hla.rti1516e.IEEE1516eRTIambassador.joinFederationExecution(IEEE1516eRTIambassador.java:764)
    at net.sf.ohla.rti.hla.rti1516.IEEE1516RTIambassador.joinFederationExecution(IEEE1516RTIambassador.java:288)
    … 2 more

    Can you tell me what I'm doing wrong?  Thanks!

    code:

    package samplefed;

    import hla.rti1516.FederateAmbassador;
    import hla.rti1516.ResignAction;
    import hla.rti1516.RTIambassador;

    import hla.rti1516.jlc.NullFederateAmbassador;
    import hla.rti1516.jlc.RtiFactoryFactory;
    import hla.rti1516.jlc.RtiFactory;

    import java.net.URL;

    public class SimpleFed {

    private RTIambassador rtiamb;
    private static URL url;

    public static void main(String args) throws Exception{

    url = new URL("file:\\TestObjectModel-1516.xml");
    new SimpleFed().runFederate();
    }

        public void runFederate() throws Exception 
        { 
        FederateAmbassador fedamb = null;

            // get a link to the RTI
            RtiFactory factory = RtiFactoryFactory.getRtiFactory(); 
            rtiamb = factory.getRtiAmbassador();
           
            // create a federation
            rtiamb.createFederationExecution("exampleFed", url);
           
            // join the federation
            fedamb = new MyFederateAmbassador();
            rtiamb.joinFederationExecution("myFederate", "exampleFed", fedamb, null);

            // resign from federation
            rtiamb.resignFederationExecution(ResignAction.DELETE_OBJECTS ); 
             
            // destroy federation
            rtiamb.destroyFederationExecution( "exampleFederation" ); 
        } 

        private class MyFederateAmbassador extends NullFederateAmbassador 
        { 
        } 

    }

     
  • Michael Newcomb

    Michael Newcomb - 2012-09-20

    I think there is a problem with the classpath on the client. Execute the following code at the beginnning of your main() method:

    LogicalTimeFactoryFactory.getLogicalTimeFactory("HLAfloat64Time");

    If that returns null, then there is indeed a problem because the RTI calls the exact same method and it succeeded (or else you would have gotten an error when creating the federation execution).

    Also, execute the following to be extra sure:

    Iterator<LogicalTimeFactory> i = ServiceRegistry.lookupProviders(LogicalTimeFactory.class);
    while (i.hasNext())
    {
      System.out.println(i.next().getName());
    }

    This will show you what the client sees as far as LogicalTimeFactorys.

    Also, what version of OHLA and Java are you using?

    Thanks,
    Michael

     
  • Anonymous - 2012-09-20

    I do get null.  I'm using OHLA 0.5 with Java 1.6.0_20-b02.

     
  • Michael Newcomb

    Michael Newcomb - 2012-09-21

    There is something wrong with the ServiceRegistry.

    Check the ohla.jar file for the following file:
    META-INF/services/hla.rti1516e.LogicalTimeFactory

    It is a text file that should have the following:

    net.sf.ohla.rti.hla.rti1516e.time.IEEE1516eHLAfloat64TimeFactory
    net.sf.ohla.rti.hla.rti1516e.time.IEEE1516eHLAinteger64TimeFactory

    The ServiceRegistry checks that file and is supposed to load those classes. Try loading them manually:

    Class.forName("net.sf.ohla.rti.hla.rti1516e.time.IEEE1516eHLAfloat64TimeFactory).newInstance();

     
  • retola

    retola - 2012-09-29

    Hi,
    how can I synchonized the federates?

     
  • retola

    retola - 2012-10-12

    rtiamb.registerFederationSynchronizationPoint("test", null);
    rtiamb.synchronizationPointAchieved("test");                                 ?

     
  • Michael Newcomb

    Michael Newcomb - 2012-10-22

    Well, technically, after you call registerFederationSynchronizationPoint(), you need to wait until you get a callback that the registration succeeded or failed.

    Once you know it has successfully been registered, you wait until it has been announced. Once it has been announced, you can then synchronizationPointAchieved().

    Once all the federates have achieved the checkpoint, you will receive a callback saying that the federation has been synchronized.

    You can also look at the SynchronizationTestNG class in the testsuite for some ideas of how it works.

     
  • retola

    retola - 2012-12-08

    Hi mnewcomb,

    I have made a software for an internal restaurant  using openhla,this is a modern system to make orders .Are you intersting in this software or anyone?I'd like to sell it..Because my prof don't like it I' d like to sell it .Thanks you

     
  • retola

    retola - 2012-12-08

    Hi mnewcomb,

    I have made a software for an internal restaurant  using openhla,this is a modern system to make orders .Are you intersting in this software or anyone?I'd like to sell it..Because my prof don't like it I' d like to sell it .Thank you

     
  • matthew

    matthew - 2012-12-08

    Really the most interesting question I have seen in sourceforge forums.

     
  • matthew

    matthew - 2012-12-17

    Hello everyone,

    I was investigating the the test cases so naturally codes in net.sf package.  I saw in testsuite, in object module, InteractionTestNG class. I want to investigate the work of  sendInteraction(…)  method. when I go through it, eventually I followed the following path:

    1) rtiAmbassadors.get(0).sendInteraction(testInteractionClassHandle2, testParameterValues2, TAG);
        Ctrl+click on sendInteaction(), then it goes to 2,

    2)  IEEE1516eRTIambassador.sendInteraction();
        Ctrl+click on sendInteaction(), then it goes to 3,

    3)  Then inside that method I see "federate.sendInteraction()" method used. Whether it is implementation specific or not I think it is not true. Because federate can t know about the "sendInteraction()" method. It only knows the methods provided by its"rtiAmbassador()"

    Am I right ?

    Thanks

     
  • Michael Newcomb

    Michael Newcomb - 2012-12-19

    Yes. HLA developers should only use classes/interfaces in the hla.* packages. Those other classes are implementation specific to OHLA.

     
  • matthew

    matthew - 2012-12-29

    Hello everyone,

    Lets say I will use it as a user but not developer. I want first a running an RTI engine then want my two federates namely federate1 and federate2. What I basically want is that something like RTI.exe or RTI.jar. When I run it, the RTI engine will start working. Then when I start running my federate1 program, then it will connect to RTI etc.

    How can I do this ?

    Thanks

     
  • matthew

    matthew - 2012-12-29

    Hello everyone,

    Lets say I will use it as a user but not developer. I want first a running an RTI engine then want my two federates namely federate1 and federate2 connect to RTI. What I basically want is that something like RTI.exe or RTI.jar. When I run it, the RTI engine will start working. Then when I start running my federate1 program, then it will connect to RTI etc and same is for federate2.

    How can I do this ?

    Thanks

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks