Analysis Tool Controllers
As its name suggests, an AnalysisToolController
is what controls an
analysis tool.
Each delegate is associated with a specific analysis tool controller, which is in turn responsible for instantiating all of its
delegates before the start of the simulation. Each controller is responsible for injecting any dependencies from the external analysis tool into
the delegates at runtime. In the case of STK, this would include data about STK objects and other global analysis objects. For a custom tool, it
could be any ambient or object-specific data relevant to that particular delegate instance. For more on how to inject this data, see the
section on injection constructors.
The AnalysisToolController
implementation class is instantiated by reflection. It must either have a public
no-argument constructor or
a public constructor with the @Inject
annotation. The BuiltInAnalysisToolController
constructor also accepts the MoxieSimulation
configuration settings provided in the SysML,
which specify the analysisStartTime
and analysisStopTime
values for the simulation.
For most applications that do not require special tool customizations, using the BuiltInAnalysisToolController
is
sufficient. It is entirely possible to connect to external tools using the BuiltInAnalysisToolController
, but
only if all the necessary information is provided directly in data defined in the SysML elements.
If you are using STK as your analysis tool, you can inject instructions into the StkController
using a stereotype
to spawn a new instance of STK, create a new scenario, or load an existing scenario at the start of a simulation. Check out STK Stereotypes for more information.
BuiltInAnalysisToolController
also implements the following methods from the AnalysisToolController
interface:
getValidInterval
- The Moxie Engine calls this to retrieve the time interval over which the analysis tool can simulate. The Moxie Engine combines this interval with the intervals from other analysis tools specified in separate delegate modules and feeds the combined interval back to this instance viacreateDelegateDependencyProvider
.createDelegateDependencyProvider
- The Moxie Engine calls this once the simulation interval has been determined. The returnedDelegateDependencyProvider
participates in the delegate instantiation process. It provides additional values that can be passed to the constructors of those delegate instances.updateSimulationTime
- This is a callback that is invoked when the engine advances the simulation time.
You can apply most of the implementations shown above to any simulation. More advanced simulations may require additional custom
logic. Feel free to use the code shown in this reference or in the sample source code supplied in the Moxie installation as a starting point.
Moxie includes two AnalysisToolController
implementations, which you can take
advantage of right
away: BuiltInAnalysisToolController
and StkController
.
Built-in controller dependencies
The createDelegateDependencyProvider
method in AnalysisToolController
can provide
constructor dependencies
for delegate instances. In addition to those provided by the specific AnalysisToolController
, some values are
provided by default:
Dependency (shown as a constructor injection parameter) | Description |
---|---|
@InjectByName("timeProvider")
|
The In this snippet, the
|
@InjectByName("moxieUnitConverter")
|
The You can find more information about the "Units of Measurement" 2.0 API in JSR-385 at https://unitsofmeasurement.github.io/pages/about.html. |
@InjectByName("stateMachineRemoteControl") |
Provides manual control over sending call events and signal events to state machine sessions from within operations. When using
Here is an example of sending a signal event using the
|
@InjectByName("delegateInstanceManager")
|
Provides a mechanism for instantiating new Java delegate objects and SysML instance specifications during simulation.
The classifier behaviors for each newly created delegate instance will start immediately after it is created. The
Here is an example of creating a new instance with initialized slots and a custom stereotype:
|
@NotNull @InjectByName("instanceName")
|
Provides the name of the instance that this Java object represents. This is useful when multiple instances of the same type participate in a simulation, as it allows you to differentiate among them. In most cases, the instance name will be the name specified in the SysML instance specification. In cases where new objects are created at runtime without an instance specification, however, the instance name may not correspond to anything in the saved model. |
@NotNull @InjectByName("randomNumberGenerator")
|
Provides utility functions for pseudo-random generated numbers within inclusive ranges. It also supports uniformly distributed random numbers in
double , int , and float types. It further supports
Gaussian-distributed random numbers in
double or int types with specific standard deviations and mean values. In addition, it allows
for seed selection through the Moxie-Base::Configuration::MoxieStochasticSettings stereotype.
|
@InjectByName("simulationLogger")
|
The In this snippet, the
|
STK controller dependencies
The StkController
adds some delegate dependencies beyond those that are built in.
Dependency (shown as a constructor injection parameter) | Description |
---|---|
@NotNull @InjectByName("stkToolbox")
|
The The following snippet creates and returns a new STK Aircraft Object:
|
@NotNull @InjectByName("stkEarth")
|
Provides access to the default representation of Earth inside of STK. In particular, for space-domain operations, it provides information about the inertial and fixed frames exposed as part of the Moxie model libraries. The
|
@NotNull @InjectByName("stkApplication")
|
While most interactions with STK happen through the The following snippet will start and attach to a new instance of STK and load a blank scenario called "BalloonRide":
|
@Nullable @InjectByName("stkObject")
|
Provides access to the STK object in the current scenario with the path specified in the In this snippet, the
|
@Nullable @InjectByName("stkObjectPath")
|
Provides the path to the STK object for this instance as specified in the stkObjectPath tag of the
Moxie-STK::Configuration::MoxieStkExistingObject stereotype applied to the SysML object instance.
|
@Nullable @InjectStereotype MoxieStkExistingObject
|
Provides the stereotype data from the Moxie-STK::Configuration::MoxieStkExistingObject
stereotype applied to the SysML object instance.
|
@Nullable @InjectStereotype MoxieStkFixedStepSampling
|
Provides the stereotype data from the Moxie-STK::Configuration::MoxieStkFixedStepSampling
stereotype applied to the SysML object instance.
|
For more details on using STK objects, see STK Programming Help.