210 likes | 316 Views
HLA Support in a Discrete Event Simulation Language. C. D. Pham R. L. Bagrodia. RESAM laboratory Université Claude Bernard, Lyon FRANCE. Department of Computer Science University of California, Los Angeles U.S.A. DiS-RT’99, Greenbelt, MD. Friday, October 22nd, 1999. Outline.
E N D
HLA Support in a Discrete Event Simulation Language C. D. Pham R. L. Bagrodia RESAM laboratory Université Claude Bernard, Lyon FRANCE Department of Computer Science University of California, Los Angeles U.S.A. DiS-RT’99, Greenbelt, MD. Friday, October 22nd, 1999
Outline Overview of HLA and DES The main points for HLA integration into a DES language An example with the Parsec language Conclusions
Federation Logical simulations real-time players tools simulator Runtime Infrastructure (RTI) Display, statistics... Federation Management Declaration Management Object Management Ownership Management Time Management Data Distribution Management Hardware, human-in-the loop real-time simulators The HLA framework • Without HLA, simulations are mostly independents and interoperability is not easy. • The High Level Architecture calls for a federation of simulations to achieve interoperability and reuse of software. 10 Rules for the federation and the federates behavior An Interface Specification An Object Model Template to describe the simulation objects
Real system HLA: How to interoperate? communication node throughput, position Interoperability is achieved by subscription and publication of object’s attributes between the federates in the federation execution. Objects can have attributes radio transmitter power, frequency wired node # links
subscribeObjectClass Attribute publishObjectClass reflectAttributesValues startUpdates HLA: Publication and Subscription • Publication of an attribute means a federate can produce values for that attribute. • Subscription to an attribute means a federate wishes to receive values for that attribute. I can provide the position for mobile hosts I want to know the position of all mobile hosts. Federate Federate Ambassador Federate Federate Ambassador RTI Ambassador RTI Ambassador updateAttributeValues RTI
Time-constrained Time-regulated NO! FEDERATE FEDERATE 21 25 25 27 RO Lookahead = 2 29 RO Ask for time advance grant RO 23 RO 25 RTI RTI Compute a Lower Bound Time Stamp (LBTS) 27 29 HLA: Time management HLA includes advanced time management services with receive order and time stamped messages
Discrete Event Simulation • Amodel consists of simulation objects and events. • Only time stamped events are exchanged between objects. • Objects’ state can only be modified upon reception of an event and by the object itself. • Simulated time advances according to the timestamp of the processed events.
BUT Easier to develop HLA compliant logical time simulators. Rapid porting of a large number of existing DES simulations into the HLA framework. Support of HLA in a DES language Difficulties come from the differences in… • the time management: HLA is still mainly oriented towards real-time while DES is mainly logical. • the way simulated objects interact:HLA is publication/subscription-based while DES is event-driven.
The solution adopted • All the HLA interface specification (v1.3) is supported: users can call the RTI functions directly if needed. • Some RTI functions or set of functions are provided by additional high-level functions for sake of simplicity and transparency.
Time management • Logical time simulations are usually time-constrained and time-regulated. • Time advancement is usually transparent in logical time simulations.
Simulated object Time advance Simulated objects interact directly with the RTI but do not wait explicitly for a time advance grant blocking function call HLA_timeAdvanceGrantRequest() Request and wait for a time advance grant using nextEventRequest. RTI
Translation of notifications • Each simulated object can not provide its own set of callback functions. We use pre-defined generic callback functions. • A notification from the RTI is translated into a simulation message and sent back to the objects. • Need registration and multicast features. • Ensure that both TSO and RO messages can be mixed into the DES system. • RO messages have to be timestamped.
Differences introduced by callback messages • All messages are timestamped, even those that were initially of the RO type. • The handling of the callback functions is done by the object itself: • direct access to the object’s variables
HLA_registerEntity( self, reflect | discover); #define DECLARATION_MANAGEMENT_SET \ startRegistrationForObjectClass|\ stopRegistrationForObjectClass|\ turnInteractionsOn|\ turnInteractionsOff c1.a1 c1.a1 h Receive the notification message reflectAttributeValues Registration and callback masks • Simulated objects can register to receive a given set of notification typescallback masks. • Callback messages of a given type are multicasted to the simulated objects has subscribed to c1.a1 1 has registered to reflect and discover 3 callback RTI 2 has subscribed to c1.a1 has registered to reflect and discover
Advantages of multicasting In HLA Callback notifications are sent on a federate basis: one notification of a given type per federate. Not well-suited for multiple objects simulations More knowledge is put in callback functions to call the appropriate object ’s processing function. Practically, there are as many if statements as the number of object ’s classes the federate has susbscribed to. • Replicated simulated objects in a simulation usually have identical behavior. • The multicast mechanism allows each object to take independent actions. • The complexity is put in the simulated object rather than in the callback functions. • an object knows exactly which classes it has subscribed to.
The PARSEC language Message-based, process-interaction approach • LP are programmed as an actor or entity • all activities of an entity are initiated on message receipts • An LP cannot directly modify the state of another LP • Event are represented by message communications • e(t,p,a): send message m(e) at time t to LP p • On receiving m(e), p executes actions a • change its state represented by local variables • schedule events (messages) at time >=t • LPs are scheduled with a large variety of algorithms • Conservative with null-messages, conditional events, • synchronous, optimistic and adaptive algorithms.
The pcHello example • Similar to the HelloWorld but... • Event-driven instead of time-stepped • Defines a country with a name and an initial population. • Each country publishes its name and population and subscribes to the same attributes. • The population increases periodically.
Initialization of the federate 1 entity driver(int argc, char **argv) { 2 3 rtiAmb = HLA_createAmbassador(); 4 5 RTI_RTIambassador_createFederationExecution( 6 &ex, rtiAmb, "HelloWorld", "helloWorld.fed"); 7 8 countryId = new Country(self, argv[1], argv[2]); 9 10 while (!Joined && (numTries++ < 20)) { 11 RTI_RTIambassador_joinFederationExecution( 12 &ex,ms_rtiAmb,"USA","HelloWorld", HLACallbackStruct); 13 14 HLA_enableTimeConstrained(); 15 HLA_enableTimeRegulation(0.0, 1.0); 16 }
Main simulation loop 94 receive (HLACallback m) { 95 switch (m.type) { 96 case discoverObjectInstance: 97 if (m.theObjectClassHandle == ms_countryTypeId) { 98 /* creates new structures, saves the object handle */ 99 } 100 break; 101 102 case reflectAttributeValues: 103 p = Country_Find(m.theObjectHandle); 104 if (p) Country_UpdateRemote(pCountry, 105 m.theAttributeHandleValuePairSet); 106 break; 107 108 case receiveInteraction: 109 if (m.theInteractionClassHandle == ms_commTypeId) 110 Country_UpdateInteraction( 111 m.theParameterHandleValuePairSet); 112 break; 113 ...
Main simulation loop (con’t) 118 case turnUpdatesOnForObjectInstance: 119 if (m.theObjectClassHandle == ms_countryTypeId) 120 Country_SetUpdateControl(RTI_Boolean_RTI_TRUE, 121 m.theAttributeHandleSet); 122 break; 123 124 ... 125 } or timeout after(0) {} 126 127 /* Here we update the country state */ 128 receive (Survey theSurvey) { 129 CountryUpdateTime(); 130 } HLA callback messages are checked first
Conclusions • HLA support in a DES language enables a rapid development of HLA-compliant logical time simulators. • We have presented some general design issues, and an implementation within the Parsec language. • Future work: more transparency regarding the time advance mechanism.