380 likes | 1.41k Views
Application Programming using the STK Object Model. Sylvain Dupont & Alan Ocampo Analytical Graphics, Inc October 2005. Our goal. Make it easier for integrators to reuse AGI technology Reliance on industry standards Shorter learning curve & development cycle. History. …. 5.0. 6.0. 7.0.
E N D
Application Programming using the STK Object Model Sylvain Dupont & Alan OcampoAnalytical Graphics, Inc October 2005
Our goal • Make it easier for integrators to reuse AGI technology • Reliance on industry standards • Shorter learning curve & development cycle
History … 5.0 6.0 7.0 … 5.0 4.0 • Connect • TCP/IP socket • String based language STK Plugins COM based plugins • Application Object Model • Control STK windows • ExecuteCommand • Internal HTML Viewer • Window.external • STK Objects Library • Manipulate the STK objects • Available with STK, STK/X & 4DX • Data providers Plugin scripts Scripting languages only(perl, VBScript & matlab) • STK/X – 4DX • Map & globe controls • ExecuteCommand
STK Objects Library - Technology • Based on COM (Component Object Model) • Available development environments • .Net (C#, Visual Basic .Net) • Java • C++ • Visual Basic 6 • Scripting languages
Scope for STK 7 • First release covers: (~ PRO & AVO licenses) • 484 interfaces, 2019 properties, 214 methods • Coverage will increase with subsequent releases • Fall back to Connect for capabilities not yet supported
Benefits • Better development tools support • Errors detected at compile time • Rich exception information provided at run-time • Less code to write for 3rd party developers • Avoid tedious string parsing & formatting
Next… • How to perform the most common Connect tasks with the STK Object Model
Agenda • Life before the API: Connect • What is the STK Object Model API? • Features • Basics of application development (using VB6) • Benefits and Limitations • Recommendations
Life Before the API : Connect Revisited • What is ‘Connect’? • Connect is the ‘language’ of STK. • You can send Connect commands to STK via TCP/IP or COM • Sample code using Connect (via COM) ‘m_stkApp is an instance of an STK/X application object ‘Load a scenario m_stkApp.ExecuteCommand "Load / Scenario """ & “c:\temp\scenario.sc” & """" ‘get a string containing a list of all object paths Dim result As AgExecCmdResult Dim instanceNames As String Dim objectList() As String Set result = m_stkApp.ExecuteCommand("AllInstanceNames /") instanceNames = result.item(0)
Life Before the API : Connect Revisited • Benefits • Straightforward implementation, does not require a lot of development skill or experience • Almost all of the functionality available from the STK GUI can be executed using Connect • Limitations • It is difficult to memorize the syntax of commands • Limited exception handling • Most commands with a return value need further parsing to be more useful
Overview of the API • What is it? • COM type library that provides an object model that represents STK objects • Version History • Released starting with STK version 6.1.3 as the ‘STK Data Provider API’ • Renamed to ‘STK Object Model API’ in STK version 7
Overview of the API • Object Model Features • Application / Scenario level interfaces • STK object-related interfaces • Data Provider-related interfaces • Object Model Diagram
Using the API • Installation • System requirements same as STK • Installation procedure • Before STK 7, separate installation package • Setting up a development project • Add a reference to ‘AGI STK/Objects 7’ (AgStkObjects.dll – located in the bin folder)
Using the API • Demo application • Object Initialization • The Object Root (AgStkObjectRoot) • Working with scenario objects (IAgStkObject) • Accessing Data Provider information • Multiple Threshold Crossings • Events
Using the API • Object Initialization • Using with STK/X Dim m_stkApp As AgStkObjectRoot Set m_stkApp = New AgStkObjectRoot
Using the API • Object Initialization (continued) • Using with STK ‘Load STK (reference AgUiApplicationLib) Dim uiApp As AgUiAppDispImpl Set uiApp = New AgUiAppDispImpl With uiApp .LoadPersonality "STK" .Visible = True .UserControl = True End With ‘get object root Dim m_stkApp As AgStkObjectRoot Set m_stkApp = uiApp.Personality2
Using the API • The Object Root (AgStkObjectRoot) • Implements various interfaces • Application-level (IAgStkObjectRoot) • NewScenario, LoadScenario, CloseScenario, SaveScenario • CurrentScenario • UnitPreferences • ExecuteCommand • Animation (IAgAnimation) • PlayForward, PlayBackward • Rewind • Faster, Slower • StepBackward, StepForward • CurrentTime • Batch Update (IAgSupportBatchUpdate) • BeginUpdate • EndUpdate
Using the API • Working with Scenario Objects • IAgStkObject - Interface for a generic object • InstanceName • ClassType, ClassName • Path • ShortDescription, LongDescription • Parent • Children • DataProviders • GetAccess, GetAccessToObject
Using the API • Working with Scenario Objects (cont’d) • Other interfaces specific to an STK object type • Aircraft (IAgAircraft) • Area Target (IAgAreaTarget) • Facility (IAgFacility) • Ground Vehicle (IAgGroundVehicle) • Launch Vehicle (IAgLaunchVehicle) • Missile (IAgMissile) • Planet (IAgPlanet) • Satellite (IAgSatellite) • Scenario (IAgScenario) • Sensor (IAgSensor) • Ship (IAgShip) • Star (IAgStar) • Target (IAgTarget)
Using the API • Data Providers • Enumerating Data Providers • In STK, the data providers available to an object are listed in the ‘Content’ properties page when creating or editing a report. There is no Connect command to retrieve the list. • In the API, the data providers can be accessed using the DataProviders property of an STK Object. • By iterating through the collection (fine grained: provides full access to data provider objects) • using the GetSchema method (coarse grained: returns an XML string)
Using the API • Retrieving Data Provider Information • Commonly-used data provider types: • Fixed • Time Varying (Start Time, Stop Time) • Interval (Start Time, Stop Time, Interval) • Steps for retrieving data provider information • Get a reference to a scenario object • Retrieve the data provider from its DataProviders collection • Call Exec • Returns an IAgDrResult value
Using the API • Basics of IAgDrResult • Category • eDrCatDataSetList • eDrCatIntervalList • eDrCatMessage • eDrCatSubSectionList
ElementName Values Dataset Dataset Dataset Dataset Using the API • DataSets – map to the collection of columns in a report • DataSet • ElementName • ElementType • GetValues
Using the API • Multiple Threshold Crossings • The API features the ability to filter a data provider result to return time intervals where dataset values cross specific ranges • For example: return time intervals where an aircraft’s altitude crosses 3, 4, and 5 (km); that is, return time intervals where: • Altitude < 3 • 3 < Altitude < 4 • 4 < Altitude < 5 • Altitude > 5
Using the API • Events • OnAnimationPause • OnAnimationPlayback • OnAnimationRewind • OnAnimUpdate • OnLogMessage • OnScenarioClose • OnScenarioLoad • OnScenarioNew • OnScenarioSave • OnStkObjectAdded • OnStkObjectCollectionChanged • OnStkObjectDeleted • OnStkObjectRenamed
Benefits and Limitations • Benefits • Extra features not available using Connect • Enumerate Data Providers • Multiple Threshold Crossings • Events • Rich object model results in strongly-typed code; easier to track errors at compile time • Intellisense • More robust runtime exception handling
Benefits and Limitations • Limitations • Currently supports functionality available in PRO and AVO • Some Connect commands currently have no equivalent • ‘VO View’ • Batch update using wildcards in object paths (‘*’) • One Connect command does not necessarily map to one API command
Recommendations • When to use • Data Provider API • Use the API as much as possible unless there is no equivalent to a Connect command • Connect • Still good for ‘one-off’ applications
Summary / Conclusion • The API provides many conveniences over Connect from a development standpoint • Connect is not going away