STK Integration

STK-related features are only available if you acquired Behavior Execution Engine as part of STK Enterprise or otherwise have a valid license for STK. If you acquired Behavior Execution Engine as part of ModelCenter Enterprise but have access to a valid STK license, contact us for access to the STK-related features.

The STK Object Model provides an automation layer on top of STK. It contains types, interfaces, events, and classes representing various aspects of the STK application structure. It is designed to make it easy for you to control and automate STK objects, perform analysis, and interact directly with STK's physics-based analysis engine. Behavior Execution Engine provides additional libraries to adapt the STK Object Model for use in an executable architecture by implementing support for discrete event-driven behaviors.

The JAR file for the Behavior Execution Engine STK utilities library is moxie-stk-utilities.jar, located in the \delegates\com.agi.moxie.stk directory in your Behavior Execution Engine installation.

STK desktop versus STK Engine

Behavior Execution Engine offers the flexibility to interact with either the STK desktop application or directly with the STK Engine. Both options provide you access to STK's powerful physics-based analysis, while offering different benefits depending on where you are in your simulation life cycle. STK provides a robust set of visualization capabilities as well as the ability to interact with the STK objects to generate further analysis and graphs at various points during and after your simulations. This can be especially helpful as you are developing or debugging your simulation. Once your simulation is working as expected, you can switch to using STK Engine, maintaining the same physics-based analysis while eliminating the overhead of the desktop application's visualization processing. This can help when performing a large number of simulations in parallel as part of a multidomain optimization or trade study exploring alternate design parameters.

Use one of Behavior Execution Engine's STK stereotypes to control how your simulation starts and connects to either STK or STK Engine. For an example using the MoxieStkScenarioFromFile stereotype, see the STK Connection tutorial section.

StkToolbox

The StkToolbox is the primary means of interacting with STK from Behavior Execution Engine. It is available to all delegates as an injection parameter.

Units

When working with STK, you must ensure STK is configured to accept and return the correct units for your analysis. The following lambda expression demonstrates how to ensure the provided STK Object Model code is using meters and radians units: stkToolbox.withMetersAndRadians(()-> { /* your provided code here */ }). After the expression executes, the toolbox resets the unit settings to their previous values.

DataProviderExecutor

DataProviderExecutor provides a number of helper methods to facilitate the execution and retrieval of data from STK data providers via the STK object model. To execute a data provider on a single STK object, call the appropriate execute method and specify the STK object, the full data provider path, and if needed, the start time, stop time, step size, and elements of interest. To execute an access data provider between two STK objects, call the getAccessAsTable method and specify both objects, as well as the same parameters as for an execute method. Either way, Behavior Execution Engine will evaluate elements of the data provider over the specified period of time and return a data table. Each column of the data table represents an element of the data provider, making it easy to iterate through the resulting data. The dataProviderPath is a string that contains the data provider group name as well as the data provider item name separated by a / if applicable. For more information, see the com.agi.moxie.stk.utilities.DataProviderExecutor API documentation.

StkObjectSpatialEntity

StkObjectSpatialEntity is a special delegate class that enables you to hold references to STK objects in your custom delegate instances. StkObjectSpatialEntity is designed to work with or without the Moxie-STK::Configuration::MoxieStkExistingObject stereotype applied. This section covers the usage of StkObjectSpatialEntity without the stereotype.

StkObjectSpatialEntity provides you with a way to connect to an existing STK object from your custom delegate instance, or even to create a new one on the fly. Take a look at the following snippets:

public class StkObjectEntityExample extends StkObjectSpatialEntity {
    protected StkObjectEntityExample(StkToolbox stkToolbox, StkEarth stkEarth, TimeProvider timeProvider) {
        super(stkToolbox, stkEarth, timeProvider);
    }
    private void updateFromObjectPath(IAgStkObject stkObject) {
        updateFromStkObject(stkObject);
    }
    private IAgStkObject updateFromNewObjectPath(String newStkObjectPath) {
        return updateFromNewStkObject(newStkObjectPath);
    }
}

Figure 1: Extending StkObjectSpatialEntity

StkObjectEntityExample stkObjectEntityExample = new StkObjectEntityExample(mToolbox, mStkEarth, mTimeProvider);
String stkObjectPath = "*/Target/testObject";
IAgStkObject stkObject = mToolbox.getRoot().getObjectFromPath(stkObjectPath);
stkObjectEntityExample.updateFromObjectPath(stkObject);

Figure 2: Updating an StkObjectSpatialEntity with an STK object instance from your STK scenario

Figure 1 shows you how to create an StkObjectEntityExample class that extends StkObjectSpatialEntity. Once you create an instance of StkObjectEntityExample, you can obtain a reference to an IAgStkObject from your STK scenario using the STK toolbox, as shown in Figure 2. You can then call updateFromObjectPath and pass the object into an instance of StkObjectSpatialEntity.

Alternatively, you can call updateFromNewObjectPath and pass in the object path to create a new STK object on the fly, as shown in Figure 3.

StkObjectEntityExample stkObjectEntityExample = new StkObjectEntityExample(mToolbox, mStkEarth, mTimeProvider);
String newStkObjectPath = "*/Target/newStkObject";
IAgStkObject stkObject = stkObjectEntityExample.updateFromNewObjectPath(newStkObjectPath);

Figure 3: Creating a new STK object in your STK scenario on the fly