Metadata

Because of the wide variety of data feeds, each vastly different from the other, all Entity objects have the ability to store and retrieve metadata. The Metadata property is an instance of AgEntityMetaDataCollection and allows for the storing of arbitrary information tied to that specific Entity. The metadata contains a string based hierarchical look-up mechanism and persists with the entity through all stages of the framework.

For example, suppose you have a data feed tracking a variety of aircraft, one of which is an F14 Tomcat. Suppose that the feed provides detailed information about the current state of the weapons systems on board. The number of rounds of ammunition left on the M61 Vulcan gun could be stored using the code snippet depicted below, where RoundsLeft is a long provided by the data stream itself.

AgPointEntity F14 = new AgPointEntity();
F14.MetaData.Set("Ammunition", RoundsLeft);

The amount of ammunition left can be retrieved at any time:

long CurrentRounds = (long) F14.MetaData.Get("Ammunition")

This is a very simple example and does not make a lot of sense in the real world - the reason being that "Ammunition" tells us very little about the data. For example, if “Ammunition” was shown to the end user, he would not know specifically which of the weapons it referred to. This is solved by using the hierarchical aspect of the metadata to store more information on each weapon.

AgPointEntity F14 = new AgPointEntity();
F14.MetaData.Set("Armament.Guns.M61.Rounds", RoundsLeft);
F14.MetaData.Set("Armament.Missiles.AIM-9", AIM9Left);
F14.MetaData.Set("Armament.Missiles.AIM-54", AIM54Left);
F14.MetaData.Set("Armament.Bombs.GBU-10", GBU10Left);

In the example above, all weapons information is separated and placed into the Armament collection. It is further subdivided into three categories - Guns, Missiles, and Bombs. Now the metadata can be generically traversed in order to give a more informative picture to the end user. In addition, a subset of the data can be accessed individually. For example, to access the metadata regarding missiles, use the code below, which gives an AgEntityDataCollection containing just the missile data.

AgEntityMetaDataCollection MissileData = F14.MetaData.Get("Armament.Missiles") as AgEntityMetaDataCollection;

Furthermore, entire objects can be stored in the metadata - not just simple types. Continuing the example above, suppose there is a class for managing data information about an F14 weapons system; this class is called F14WeaponsSystem. An instance of this class could be created and set as the Armament metadata:

AgPointEntity F14 = new AgPointEntity();
F14.MetaData.Set("Armament", new F14WeaponsSystem(InitData));

Later, when this particular information is needed, it can be retrieved from the Entity:

F14WeaponsSystem Armament = F14.MetaData.Get("Armament") as F14WeaponsSystem;
long RoundsLeft = Armament.Guns.M16.RoundsLeft;

Finally, if the F14WeaponsSystem class implements IAgEntityMetaDataCollection, the functionality of both examples above works; all of the metadata can be accessed in a truly generic way, but the instance of F14WeaponsSystem can also be obtained when needed. This would mean that both of the examples above and below work.

AgPointEntity F14 = new AgPointEntity();
F14.MetaData.Set("Armament", new F14WeaponsSystem(InitData));
long RoundsLeft1 = F14.MetaData.GetMetaData("Armament.RoundsLeft");
F14WeaponsSystem Armament = F14.MetaData.Get("Armament") as F14WeaponsSystem;
long RoundsLeft2 = Armament.Guns.M16.RoundsLeft;

As the set of examples above shows, the metadata construct allows for a simple and effective way to manage any amount of data that you wish to attach to individual entities within the framework. Furthermore, RT3 has built-in support for using this data in various ways, including a metadata query object for sorting objects in the display based on their metadata, as well as built-in support for viewing the metadata in STK or Viewer using the GetInfo Tool.

STK Programming Interface 11.0.1