Object-Oriented programming 1 SSD3: Object-Oriented Programming and Design.
Application Programming using the STK Object Model
description
Transcript of Application Programming using the STK Object Model
![Page 1: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/1.jpg)
Pg 1 of 30AGI www.agiuc.com
Application Programming using the STK Object Model
Sylvain Dupont & Alan OcampoAnalytical Graphics, Inc
October 2005
![Page 2: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/2.jpg)
Pg 2 of 30AGI www.agiuc.com
Our goal
• Make it easier for integrators to reuse AGI technology– Reliance on industry standards– Shorter learning curve & development cycle
![Page 3: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/3.jpg)
Pg 3 of 30AGI www.agiuc.com
History
Connect• TCP/IP socket• String based language
6.05.0 7.0 …5.04.0…
Plugin scriptsScripting languages only(perl, VBScript & matlab)
Application Object Model
• Control STK windows• ExecuteCommandInternal HTML Viewer• Window.external
STK/X – 4DX• Map & globe controls• ExecuteCommand
STK PluginsCOM based plugins
STK Objects Library• Manipulate the STK objects• Available with STK, STK/X & 4DX• Data providers
![Page 4: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/4.jpg)
Pg 4 of 30AGI www.agiuc.com
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
![Page 5: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/5.jpg)
Pg 5 of 30AGI 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
![Page 6: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/6.jpg)
Pg 6 of 30AGI www.agiuc.com
Example: Target object
![Page 7: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/7.jpg)
Pg 7 of 30AGI 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
![Page 8: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/8.jpg)
Pg 8 of 30AGI www.agiuc.com
Next…
• How to perform the most common Connect tasks with the STK Object Model
![Page 9: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/9.jpg)
Pg 9 of 30AGI 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
![Page 10: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/10.jpg)
Pg 10 of 30AGI 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 scenariom_stkApp.ExecuteCommand "Load / Scenario """ & “c:\temp\scenario.sc”
& """"
‘get a string containing a list of all object pathsDim result As AgExecCmdResultDim instanceNames As StringDim objectList() As String Set result = m_stkApp.ExecuteCommand("AllInstanceNames /")instanceNames = result.item(0)
![Page 11: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/11.jpg)
Pg 11 of 30AGI 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
![Page 12: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/12.jpg)
Pg 12 of 30AGI 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
![Page 13: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/13.jpg)
Pg 13 of 30AGI 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
![Page 14: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/14.jpg)
Pg 14 of 30AGI 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)
![Page 15: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/15.jpg)
Pg 15 of 30AGI www.agiuc.com
Using the API
• Demo application– Object Initialization– The Object Root (AgStkObjectRoot)– Working with scenario objects (IAgStkObject)– Accessing Data Provider information– Multiple Threshold Crossings– Events
![Page 16: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/16.jpg)
Pg 16 of 30AGI www.agiuc.com
Using the API
• Object Initialization– Using with STK/X
Dim m_stkApp As AgStkObjectRootSet m_stkApp = New AgStkObjectRoot
![Page 17: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/17.jpg)
Pg 17 of 30AGI www.agiuc.com
Using the API
• Object Initialization (continued)– Using with STK
‘Load STK (reference AgUiApplicationLib)Dim uiApp As AgUiAppDispImplSet uiApp = New AgUiAppDispImplWith uiApp.LoadPersonality "STK".Visible = True.UserControl = True
End With‘get object rootDim m_stkApp As AgStkObjectRootSet m_stkApp = uiApp.Personality2
![Page 18: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/18.jpg)
Pg 18 of 30AGI www.agiuc.com
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
![Page 19: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/19.jpg)
Pg 19 of 30AGI www.agiuc.com
Using the API
• Working with Scenario Objects– IAgStkObject - Interface for a generic object
• InstanceName• ClassType, ClassName• Path• ShortDescription, LongDescription• Parent• Children• DataProviders• GetAccess, GetAccessToObject
![Page 20: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/20.jpg)
Pg 20 of 30AGI www.agiuc.com
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)
![Page 21: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/21.jpg)
Pg 21 of 30AGI 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)
![Page 22: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/22.jpg)
Pg 22 of 30AGI 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 information1. Get a reference to a scenario object2. Retrieve the data provider from its DataProviders collection3. Call Exec
» Returns an IAgDrResult value
![Page 23: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/23.jpg)
Pg 23 of 30AGI www.agiuc.com
Using the API
– Basics of IAgDrResult• Category
– eDrCatDataSetList– eDrCatIntervalList– eDrCatMessage– eDrCatSubSectionList
![Page 24: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/24.jpg)
Pg 24 of 30AGI www.agiuc.com
• DataSets – map to the collection of columns in a report– DataSet
» ElementName» ElementType» GetValues
Using the API
Dataset
Dataset
Dataset
Dataset
Values
ElementName
![Page 25: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/25.jpg)
Pg 25 of 30AGI 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 < 32. 3 < Altitude < 43. 4 < Altitude < 54. Altitude > 5
![Page 26: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/26.jpg)
Pg 26 of 30AGI www.agiuc.com
Using the API
• Events– OnAnimationPause– OnAnimationPlayback– OnAnimationRewind– OnAnimUpdate– OnLogMessage– OnScenarioClose– OnScenarioLoad– OnScenarioNew– OnScenarioSave– OnStkObjectAdded– OnStkObjectCollectionChanged– OnStkObjectDeleted– OnStkObjectRenamed
![Page 27: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/27.jpg)
Pg 27 of 30AGI 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
![Page 28: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/28.jpg)
Pg 28 of 30AGI 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
![Page 29: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/29.jpg)
Pg 29 of 30AGI 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
![Page 30: Application Programming using the STK Object Model](https://reader030.fdocuments.us/reader030/viewer/2022020417/568139be550346895da162ad/html5/thumbnails/30.jpg)
Pg 30 of 30AGI www.agiuc.com
Summary / Conclusion
• The API provides many conveniences over Connect from a development standpoint
• Connect is not going away