certi-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[certi-dev] NERA implementation


From: Usman Awais
Subject: [certi-dev] NERA implementation
Date: Mon, 4 Feb 2013 17:01:52 +0100

Hi,

I am trying to use NERA in combination with NER, as suggested in the reference. A single federate works fine but more than one federates make the application hanged. In fact neither of the federates are granted with the time slice, so both of them hang. Here is the python code of the relevant section

def main (name, timeStep):
    print("Create ambassador")
    rtia = rti.RTIAmbassador()
    print(rtia)               
    
    fedAmb = FederateAmb()
    fedAmb.initialize(rtia)
    
    try:

        rtia.createFederationExecution("Test", "Test.xml")
        fedAmb.creator = True
        print("Federation created.")
    except Exception , e:
        print("Federation exists: %s" % repr(e))
    finally:
        print ('Federation done.')
        

    try:
    
        rtia.joinFederationExecution(name, "Test", fedAmb)
        fedAmb.enableTimeSwitches(0.0)
        fedAmb.publish()
        fedAmb.subscribe()
        fedAmb.waitReadyToPopulate()
        fedAmb.registerInstance(name)
        fedAmb.waitReadyToRun()
        T_INCR = timeStep
        pt = 0
        while fedAmb.time < 500:
            pt = pt + T_INCR
            print('requested time : '+repr(pt))
            rtia.nextEventRequestAvailable(pt)
            while 1:
                if fedAmb.granted==False:
                    rtia.tick()
                else:
                    fedAmb.granted=False
                    break
            print('grnated time : '+ repr(fedAmb.time))
            fedAmb.X += 1
            fedAmb.Y += 1

            fedAmb.updateAttributes()
            
            rtia.nextEventRequest(fedAmb.time)

            while 1:
                if fedAmb.granted==False:
                    rtia.tick()
                else:
                    fedAmb.granted=False
                    break
    
    except Exception, e:
        print("Could not do, exception: %s" % repr(e))

    finally:    
        try:
            fedAmb.terminate()
        except Exception, e:
            print("Could not do, exception: %s" % repr(e))
        try:
            rtia.resignFederationExecution(rti.ResignAction.DeleteObjectsAndReleaseAttributes)
        except Exception, e:
            print("Could not do, exception: %s" % repr(e))

        try:
            rtia.destroyFederationExecution('Test')
        except Exception, e:
            print("Could not do, exception: %s" % repr(e))

        print("Done.")


Regards,
Muhammad Usman Awais



reply via email to

[Prev in Thread] Current Thread [Next in Thread]