Application Programming using
the STK Object Model
Sylvain Dupont & Alan Ocampo
Analytical Graphics, Inc
October 2005
AGI
Pg 1 of 30
www.agiuc.com
Our goal
• Make it easier for integrators to reuse AGI
technology
– Reliance on industry standards
– Shorter learning curve & development cycle
AGI
Pg 2 of 30
www.agiuc.com
History
…
4.0
5.0
5.0
6.0
7.0
…
Connect
• TCP/IP socket
• String based language
Application Object Model
• Control STK windows
STK Plugins
COM based plugins
• ExecuteCommand
Internal HTML Viewer
• Window.external
Plugin scripts
Scripting languages only
(perl, VBScript & matlab)
STK Objects Library
• Manipulate the STK objects
• Available with STK, STK/X & 4DX
• Data providers
STK/X – 4DX
• Map & globe controls
• ExecuteCommand
AGI
Pg 3 of 30
www.agiuc.com
STK Objects Library - Technology
• Based on COM (Component Object Model)
• Available development environments
–
–
–
–
–
AGI
.Net (C#, Visual Basic .Net)
Java
C++
Visual Basic 6
Scripting languages
Pg 4 of 30
www.agiuc.com
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
AGI
Pg 5 of 30
www.agiuc.com
Example: Target object
AGI
Pg 6 of 30
www.agiuc.com
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
AGI
Pg 7 of 30
www.agiuc.com
Next…
• How to perform the most common Connect tasks
with the STK Object Model
AGI
Pg 8 of 30
www.agiuc.com
Agenda
• Life before the API: Connect
• What is the STK Object Model API?
• Features
• Basics of application development (using VB6)
• Benefits and Limitations
• Recommendations
AGI
Pg 9 of 30
www.agiuc.com
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)
AGI
Pg 10 of 30
www.agiuc.com
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
AGI
Pg 11 of 30
www.agiuc.com
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
AGI
Pg 12 of 30
www.agiuc.com
Overview of the API
– Object Model Features
• Application / Scenario level
interfaces
• STK object-related interfaces
• Data Provider-related
interfaces
– Object Model Diagram
AGI
Pg 13 of 30
www.agiuc.com
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)
AGI
Pg 14 of 30
www.agiuc.com
Using the API
• Demo application
–
–
–
–
–
–
AGI
Object Initialization
The Object Root (AgStkObjectRoot)
Working with scenario objects (IAgStkObject)
Accessing Data Provider information
Multiple Threshold Crossings
Events
Pg 15 of 30
www.agiuc.com
Using the API
• Object Initialization
– Using with STK/X
Dim m_stkApp As AgStkObjectRoot
Set m_stkApp = New AgStkObjectRoot
AGI
Pg 16 of 30
www.agiuc.com
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
AGI
Pg 17 of 30
www.agiuc.com
Using the API
• The Object Root (AgStkObjectRoot)
– Implements various interfaces
• Application-level (IAgStkObjectRoot)
–
–
–
–
NewScenario, LoadScenario, CloseScenario, SaveScenario
CurrentScenario
UnitPreferences
ExecuteCommand
–
–
–
–
–
PlayForward, PlayBackward
Rewind
Faster, Slower
StepBackward, StepForward
CurrentTime
• Animation (IAgAnimation)
• Batch Update (IAgSupportBatchUpdate)
– BeginUpdate
– EndUpdate
AGI
Pg 18 of 30
www.agiuc.com
Using the API
• Working with Scenario Objects
– IAgStkObject - Interface for a generic object
•
•
•
•
•
•
•
•
AGI
InstanceName
ClassType, ClassName
Path
ShortDescription, LongDescription
Parent
Children
DataProviders
GetAccess, GetAccessToObject
Pg 19 of 30
www.agiuc.com
Using the API
• Working with Scenario Objects (cont’d)
– Other interfaces specific to an STK object type
•
•
•
•
•
•
•
•
•
•
•
•
•
AGI
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)
Pg 20 of 30
www.agiuc.com
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)
AGI
Pg 21 of 30
www.agiuc.com
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
1. Get a reference to a scenario object
2. Retrieve the data provider from its DataProviders collection
3. Call Exec
» Returns an IAgDrResult value
AGI
Pg 22 of 30
www.agiuc.com
Using the API
– Basics of IAgDrResult
• Category
–
–
–
–
AGI
eDrCatDataSetList
eDrCatIntervalList
eDrCatMessage
eDrCatSubSectionList
Pg 23 of 30
www.agiuc.com
Using the API
• DataSets – map to the collection of columns in a report
– DataSet
» ElementName
» ElementType
» GetValues
ElementName
Values
Dataset
AGI
Dataset
Pg 24 of 30
Dataset
Dataset
www.agiuc.com
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:
1. Altitude < 3
2. 3 < Altitude < 4
3. 4 < Altitude < 5
4. Altitude > 5
AGI
Pg 25 of 30
www.agiuc.com
Using the API
•
Events
–
–
–
–
–
–
–
–
–
–
–
–
–
AGI
OnAnimationPause
OnAnimationPlayback
OnAnimationRewind
OnAnimUpdate
OnLogMessage
OnScenarioClose
OnScenarioLoad
OnScenarioNew
OnScenarioSave
OnStkObjectAdded
OnStkObjectCollectionChanged
OnStkObjectDeleted
OnStkObjectRenamed
Pg 26 of 30
www.agiuc.com
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
AGI
Pg 27 of 30
www.agiuc.com
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
AGI
Pg 28 of 30
www.agiuc.com
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
AGI
Pg 29 of 30
www.agiuc.com
Summary / Conclusion
• The API provides many conveniences over
Connect from a development standpoint
• Connect is not going away
AGI
Pg 30 of 30
www.agiuc.com
Descargar

Conjunction Analysis Fundamentals