|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfaa.tg.hla.aircraft.HlaAircraftMonitor
public class HlaAircraftMonitor
This object demonstrates how a Federate can attach to the TgfFed Federation Execution. It attaches to the rtiexec; registering for TgfHlaAircraft objects. Upon succesffuly doing so it makes copies of those aircraft and reflects changes the RTI makes to them within it's copied list. When the rti 'ticks' this information is then displayed to standard output. Originally this object was written for testing purposes only, however the need has arisen to possibly have this tool used for greater monitoring purposes. Expect future changes to incorporate a GUI, and allow for data access/query in a user-friendly way.See the source: HlaAircraftMonitor
| Field Summary | |
|---|---|
TgfHlaHandleIDs |
attributeHandles
This is a list of handles (IDs) mapped to specific TgfHlaAircraft variables defined in the TgfFed.fed file. |
static java.lang.String |
CVS_VERSION_ID
The CVS Version ID |
private TgfMonitorFedAmb |
fedAmbassador
The TgfMonitorFedAmb is a FederateAmbassador. |
private java.lang.String |
federateName
The name of this federate. |
private static java.lang.String |
FEDERATION_EXECUTION_DATA
The name of the federation execution file to use. |
private static java.lang.String |
FEDERATION_EXECUTION_NAME
The name of the federation execution to join. |
private TgfHlaAircraftList |
monitoredAircraft
A list of all the currently monitored aircraft. |
(package private) boolean |
resigning
A flag used to help us exit the federation politely. |
private hla.rti.RTIambassador |
rtiAmbassador
The RTIambassador is the data bus used to convey messages from the federate to the RTI. |
| Constructor Summary | |
|---|---|
HlaAircraftMonitor()
Constructs a new HlaAircraftMonitor. |
|
| Method Summary | |
|---|---|
void |
addMonitoredAircraft(TgfHlaAircraft aircraft)
Adds an aircraft to the list of monitored aircraft. |
void |
beginMonitoring()
Monitors the TgfHla federation execution for TgfHlaAircraft. |
private TgfHlaAircraft |
findAircraft(int instanceId)
Returns an aircraft whose ID matches the passed parameter or NULL if no match was found. |
void |
handleInteractions(hla.rti.ReceivedInteraction theInteraction)
Perform some function based upon theInteraction parameter passed to this object. |
static void |
main(java.lang.String[] args)
Starts up a new HlaAircraftMonitor. |
void |
reflect(int aircraftHandle,
hla.rti.ReflectedAttributes theAttributes)
Applies the values in 'theAttributes' parameter to matching aircraft within the 'monitoredAircraft' list of this object. |
void |
removeMonitoredAircraft(int aircraftHandle)
Removes an aircraft from the monitored aircraft list. |
private void |
requestInitialAttributeUpdate()
Deprecated. This method uses polling to query the rti - make sure the LazyObjectDiscovery is turned on in the RTI for a better way of handling this federate joining a federation. To ensure that it has been enabled check for this line under the FederationSection portion of the .rid file used to run the RTI: (AttributeScopeAdvisories Enabled ;; Some other parameters (LazyObjectDiscovery Enabled) ) |
(package private) void |
resignAndDestroyFedExec()
Attempts to resign the federate from the federation execution and destroy the FederationExecution process if this federate is the last remaining federate in the federation. |
private void |
startMainEventLoop()
The main event loop - reflects aircraft attributes found in the RTI to the list of aircraft this object is monitoring. |
private void |
subscribeForAircraftAttributes()
Invoking this method attempts to "subscribe" for aircraft attributes within the RTI. |
private void |
subscribeForInteractions()
Invoking this method attempts to "subscribe" for interactions within the RTI. |
(package private) void |
tick(double min,
double max)
Our own tick method - used as a helper - takes doubles. |
void |
updateAircraft(int aircraftHandle,
hla.rti.AttributeHandleSet theAttributes)
Takes the passed AttributeHandleSet and updates a matched aircraft with those values. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String CVS_VERSION_ID
private java.lang.String federateName
public TgfHlaHandleIDs attributeHandles
private hla.rti.RTIambassador rtiAmbassador
private TgfMonitorFedAmb fedAmbassador
TgfMonitorFedAmbprivate TgfHlaAircraftList monitoredAircraft
private static final java.lang.String FEDERATION_EXECUTION_NAME
private static final java.lang.String FEDERATION_EXECUTION_DATA
boolean resigning
| Constructor Detail |
|---|
public HlaAircraftMonitor()
throws hla.rti.RTIinternalError
hla.rti.RTIinternalError - if a problem occurs during the
construction of this object.| Method Detail |
|---|
private void subscribeForAircraftAttributes()
throws CouldNotSubscribe
CouldNotSubscribe - if this method is unable to
subscribe for aircraft.
private void subscribeForInteractions()
throws CouldNotSubscribe
CouldNotSubscribe - if this method was unable to subscribe
for interactions specific to the TgfHla interface.public void addMonitoredAircraft(TgfHlaAircraft aircraft)
aircraft - is the TgfHlaAircraft to add.private TgfHlaAircraft findAircraft(int instanceId)
instanceId - is the RTI ID of the aircraft to find.
It's the handle associated with a TgfHlaAircraft object that
the RTI uses to identify it from other TgfHlaAircraft.
public void reflect(int aircraftHandle,
hla.rti.ReflectedAttributes theAttributes)
throws hla.rti.ObjectNotKnown,
hla.rti.AttributeNotKnown,
hla.rti.FederateInternalError
aircraftHandle - is the RTI ID for the aircraft to reflect.
It's the handle associated with a TgfHlaAircraft object that
the RTI uses to identify it from other TgfHlaAircraft.theAttributes - is a list of handles (ID's to a TgfHlaAircraft
attributes) and the new value associated with the ID. (Think of it
as a hashtable [ID --- Value]).
hla.rti.ObjectNotKnown - if an aircraft which matches the
aircraftHandle can not be found.
hla.rti.AttributeNotKnown - if an attribute within theAttributes
parameter is unknown to the federate.
hla.rti.FederateInternalError - if an error occurs during the
reflection process.
public void updateAircraft(int aircraftHandle,
hla.rti.AttributeHandleSet theAttributes)
throws hla.rti.ObjectNotKnown
aircraftHandle - is the RTI ID for the aircraft to update.
It's the handle associated with a TgfHlaAircraft object that
the RTI uses to identify it from other TgfHlaAircraft.theAttributes - is a "pair" list. It contains a listing
of handles (ID's to a TgfHlaAircraft attributes) and the new
value associated with the ID. (Think of it as a hashtable.
[ID --- Value]).
hla.rti.ObjectNotKnown - if an aircraft which matches the
aircraftHandle can not be found.
private void requestInitialAttributeUpdate()
throws CouldNotUpdateAircraft
CouldNotUpdateAircraft - if one of the following conditions
are met:
1)- The attribute handle is not within the listing of valid handles.
2)- The TgfHlaAircraft object class was not defined in the .fed file.
3)- A save was in progress at the time this method was called.
4)- A restore was in progress at the time this method was called.
public void removeMonitoredAircraft(int aircraftHandle)
throws hla.rti.ObjectNotKnown
aircraftHandle - is the RTI ID for the aircraft to remove.
It's the handle associated with a TgfHlaAircraft object that
the RTI uses to identify it from other TgfHlaAircraft.
hla.rti.ObjectNotKnown - if a matching aircraft is not found
within the simulatd aircraft list.
public void beginMonitoring()
throws hla.rti.RTIexception,
hla.rti.FederateNotExecutionMember,
java.net.MalformedURLException
hla.rti.RTIexception - if an unrecoverable error occurs during the RTI
execution.
hla.rti.FederateNotExecutionMember - if this object fails to join the
federation execution.
java.net.MalformedURLException - if the federate has problems reading
the .fed or .rid files.
private void startMainEventLoop()
throws hla.rti.RTIexception
hla.rti.RTIexception
void resignAndDestroyFedExec()
throws CouldNotResign,
CouldNotDestroy
CouldNotResign - if one of the following conditons are met:
1) - The federate still owns an attribute.
2) - The federate is not an execution member.
3) - The resign action is not supported.
4) - Concurrent access to this method is attempted.
CouldNotDestroy - if one of the following conditions are met:
1) - There is another federate still attached to the RTI.
2) - The federation execution never existed.
3) - Concurrent access to this method is attempted.
public void handleInteractions(hla.rti.ReceivedInteraction theInteraction)
throws hla.rti.FederateInternalError,
hla.rti.InteractionParameterNotKnown
theInteraction - is the simulation interaction to
handle.
hla.rti.FederateInternalError
hla.rti.InteractionParameterNotKnownpublic static void main(java.lang.String[] args)
args - are the command line arguments to parse.
void tick(double min,
double max)
throws hla.rti.RTIexception
min - is the minimal amount of time to get things done.max - is the maximum amount of time to get things done.
hla.rti.RTIexception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||