/* External federate, informs the to test the features of HLA - PM */
# include "controller_tutorial. HPP
"# include & lt; Fedtime. Hh>
# include & lt; Stdlib. H>
# include & lt; String. H>
# include & lt; Stdlib. H>
# include & lt; Stdio. H>
# include & lt; Sys/types. H>
# include & lt; Iostream>
# include & lt; Iomanip>
# if! Defined (_MSC_VER)
# include & lt; Netinet/in. H>
# include & lt; Unistd. H> For sleep with a/* */
# the else
# include & lt; Windows. H> For Sleep with a/* */
# endif
# include & lt; Strstrea. H>
using namespace std;
# include "s_hla_stream. HPP
"
/* RTI ambassador Shared among the functions provides of the program */
The static RTI: : RTIambassador rti_amb;
/* Federate ambassador */
The static Master_FA fedAmb;
Static int time_regulation_enabled=0;
Static int time_constrained_enabled=0;
The static const char * fedExecName;
The static RTI: : Boolean timeToQuit=RTI: : RTI_FALSE;
The static RTIfedTime currentTime (0.0);
The static RTIfedTime next_time ()
{RTIfedTime lookahead.
Rti_amb. QueryLookahead (lookahead);
Return currentTime + lookahead. GetTime (); }
The static RTI: : Boolean timeAdvanceOutstanding=RTI: : RTI_FALSE;
The static RTI: : FederateHandle federateId;
//Interarctions
Enum OrderAttributes {Bearing, Speed, NbOrderAttributes};
Enum ReplyAttributes {Id, ChangeLat ChangeLong, NbReplyAttributes};
The static const char * const orderAttrTypeStr []=
{" bearing "and" speed "};
The static const char * const replyAttrTypeStr []=
{" id ", "change_lat", "change_long"};
The static RTI: : InteractionClassHandle order_handle;
The static RTI: : ParameterHandle order_parameters [NbOrderAttributes];
The static RTI: : InteractionClassHandle reply_handle;
The static RTI: : ParameterHandle reply_parameters [NbReplyAttributes];
/* * * * * * * Pending Requests/* * * * * *
The class PendingRequest
{
Public:
PendingRequest (void) : next (NULL) {}
Virtual ~ PendingRequest (void) {}
//the apply appropriate behaviors
Virtual void the apply (void)=0;
Static int the empty () {return head==NULL (PendingRequest *); }
The static void the enqueue (PendingRequest * pr);
The static PendingRequest * to dequeue ();
Private:
The class PendingRequest * next;
The static PendingRequest * head;
The static PendingRequest * tail;
Friend class Master_FA;
};
PendingRequest * PendingRequest: : head=(PendingRequest *) NULL;
PendingRequest * PendingRequest: : tail=(PendingRequest *) NULL;
Void
PendingRequest: : the enqueue (pr) PendingRequest *
{
If (head==NULL) (PendingRequest *)
{
The head=pr;
Tail=pr;
}
The else
{
Tail - & gt; Next=pr;
Tail=pr;
}
}
PendingRequest *
PendingRequest: : to dequeue ()
{
If (head==NULL) (PendingRequest *)
return head;
PendingRequest * result=head;
The head=head - & gt; Next;
If (tail==result)
Tail=head;
return result;
}
The class ProvideAttributeValueUpdatePR: public PendingRequest
{
Public:
ProvideAttributeValueUpdatePR (RTI: : ObjectHandle oid,
Const RTI: : AttributeHandleSet & amp; Attr);
Virtual ~ ProvideAttributeValueUpdatePR (void)
{if (size) delete [] handleSet; }
Virtual void the apply (void);
Private:
RTI: : ObjectHandle objid;
Unsigned long size;
RTI: : AttributeHandle * handleSet;
};
ProvideAttributeValueUpdatePR: : ProvideAttributeValueUpdatePR (RTI: : ObjectHandle oid,
Const RTI: : AttributeHandleSet & amp; Attr)
: objid (oid), size (attr. The size ()
{
HandleSet=new RTI: : AttributeHandle [size];
If (handleSet==NULL)
{
Cerr & lt; <"Unable to create an array of attribute handles, can 't the process attribute update request" & lt;
return;
}
for (int i=0; I & lt; The size; I++)
{
HandleSet. [I]=attr getHandle (I);
}
}
Void
ProvideAttributeValueUpdatePR: : the apply ()
{
}
/* * * * * * * Federate Ambassador * * * * * * * * * */
Constructor/* */
Master_FA: : Master_FA () : RTI: : FederateAmbassador ()
{}
/* */Destructor
Master_FA: : ~ Master_FA throw () ()
{}
/* Services called by the RTI */
////////////////////////////////////
//Federation Management Services//
////////////////////////////////////
////////////////////////////////
//Object Management Services//
////////////////////////////////
Void
Master_FA: : reflectAttributeValues (RTI: : ObjectHandle theObject,
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull