STK OBJECT MODEL TUTORIAL Follow the instructions in the accompanying tutorial (a PDF file) to enter the following code into your Visual Studio project. The code is organized (1) by sections of the tutorial, then (2) by programming language. NOTE: Code fragments are tabbed in such a way that the indentation should be correct when you copy them into your project. When copying a line, be sure to select the entire line, starting from the left margin of the page. * ------------------------------------------------------------- * * SECTION: Add the Core of the STK Object Model to your Project * * ------------------------------------------------------------- * LANGUAGE: C# ------------ 1) Add the following using statements to the beginning of Form1.cs: using AGI.STKObjects; using AGI.STKUtil; 2) Add this declaration to the beginning of the Form1 class definition: private AGI.STKObjects.AgStkObjectRoot root; 3) In the Form1 class constructor, after the InitializeComponent() method, add: root = new AGI.STKObjects.AgStkObjectRoot(); 4) Subscribe FormClosing Event and close STK Object root properly by adding: if (root != null) { if (root.CurrentScenario != null) { root.CloseScenario(); } System.Runtime.InteropServices.Marshal.ReleaseComObject(root); root = null; } LANGUAGE: VB.NET ---------------- 1) Add the following Imports statements to the beginning of Form1.vb: Imports AGI.STKObjects Imports AGI.STKUtil Imports System.Runtime.InteropServices 2) Add this declaration to the beginning of the Form1 class definition: Friend WithEvents root As AGI.STKObjects.AgStkObjectRoot 3) In the Form1 class constructor (if it is already there), after the InitializeComponent() method, add the following line: root = New AGI.STKObjects.AgStkObjectRoot Your constructor should look like this (please add lines the below if it is not there): Public Sub New() InitializeComponent() root = New AGI.STKObjects.AgStkObjectRoot End Sub 4) Overload OnFormClosing to close STK Object root properly, add: Protected Overrides Sub OnFormClosing(ByVal e As FormClosingEventArgs) If (Not Me.root Is Nothing) Then If (Not Me.root.CurrentScenario Is Nothing) Then Me.root.CloseScenario End If Marshal.ReleaseComObject(Me.root) Me.root = Nothing End If MyBase.OnFormClosing(e) End Sub * ------------------------------ * * SECTION: Create a New Scenario * * ------------------------------ * NOTE: SKIP THIS SECTION IF YOU ARE USING THE CUSTOM APPLICATION FRAMEWORK! LANGUAGE: C# ------------ 1) Create a scenario named "OMTutorial" public void NewScenario() { try { // first close any existing scenario root.CloseScenario(); root.NewScenario("OMTutorial"); } catch(Exception e) { MessageBox.Show(e.Message); } } 2) Add to Click event procedure for New Scenario button: NewScenario(); NOTE: SKIP THIS SECTION IF YOU ARE USING THE CUSTOM APPLICATION FRAMEWORK! LANGUAGE: VB.NET ---------------- 1) Create a scenario named "OMTutorial" Public Sub NewScenario() Try ' first close any existing scenario root.CloseScenario() root.NewScenario("OMTutorial") Catch e As Exception MessageBox.Show(e.Message) End Try End Sub 'NewScenario 2) Add to Click event procedure for New Scenario button: NewScenario() * ------------------------------------------- * * SECTION: Set Time Period & Unit Preferences * * ------------------------------------------- * NOTE: SKIP THIS SECTION IF YOU ARE USING THE 4DX APPLICATION FRAMEWORK! LANGUAGE: C# ------------ In the NewScenario() method, after the call to root.NewScenario(), add: // Reset the units to the STK defaults IAgUnitPrefsDimCollection dimensions = root.UnitPreferences; dimensions.ResetUnits(); // Set the date unit, acquire an interface to the scenario and use // it to set the time period and epoch dimensions.SetCurrentUnit("DateFormat", "UTCG"); IAgScenario scene= (IAgScenario)root.CurrentScenario; scene.StartTime = "1 Jul 2002 00:00:00.00"; scene.StopTime = "1 Jul 2002 04:00:00.00"; scene.Epoch = "1 Jul 2002 00:00:00.00"; // Set new preference for Temperature dimensions.SetCurrentUnit("Temperature", "degC"); comboBox1.Enabled = true; button2.Enabled = true; button3.Enabled = true; button4.Enabled = true; button5.Enabled = true; button6.Enabled = true; button7.Enabled = true; NOTE: SKIP THIS SECTION IF YOU ARE USING THE 4DX APPLICATION FRAMEWORK! LANGUAGE: VB.NET ---------------- In the NewScenario() method, after the call to root.NewScenario(), add: ' Reset the units to the STK defaults Dim dimensions As IAgUnitPrefsDimCollection = root.UnitPreferences dimensions.ResetUnits() ' Set the date unit, acquire an interface to the scenario and use ' it to set the time period and epoch dimensions.SetCurrentUnit("DateFormat", "UTCG") Dim scene As IAgScenario = CType(root.CurrentScenario, IAgScenario) scene.StartTime = "1 Jul 2002 00:00:00.00" scene.StopTime = "1 Jul 2002 04:00:00.00" scene.Epoch = "1 Jul 2002 00:00:00.00" ' Set new preference for Temperature dimensions.SetCurrentUnit("Temperature", "degC") ComboBox1.Enabled = True Button2.Enabled = True Button3.Enabled = True Button4.Enabled = True Button5.Enabled = True Button6.Enabled = True Button7.Enabled = True * -------------------------- * * SECTION: Create a Facility * * -------------------------- * LANGUAGE: C# ------------ 1) The following two methods use various options provided by the Object Model to create some facilities: public void CreateFacilities() { try { // The code that creates the Baikonur facility uses // a fine-grained interface that lets you set each // property individually baikonur = (IAgFacility)root.CurrentScenario.Children.New(AgESTKObjectType. eFacility, "Baikonur"); baikonur.UseTerrain = false; IAgGeodetic geodetic = (IAgGeodetic)baikonur.Position.ConvertTo(AgEPositionType.eGeodetic); geodetic.Lat = 48.0; geodetic.Lon = 55.0; geodetic.Alt = 0.0; baikonur.Position.Assign(geodetic); ((IAgStkObject)baikonur).ShortDescription = "Launch Site"; ((IAgStkObject)baikonur).LongDescription = "Launch site in Kazakhstan. Also known as Tyuratam."; // The Perth and Wallops facilities are created with // a coarse-grained interface that lets you specify // position type and lat/lon/alt values in a single // helper method (AssignGeodetic) perth = (IAgFacility)root.CurrentScenario.Children.New(AgESTKObjectType.eFacility, "Perth"); wallops = (IAgFacility)root.CurrentScenario.Children.New(AgESTKObjectType.eFacility, "Wallops"); perth.Position.AssignGeodetic(-31, 116, 0); ((IAgStkObject)perth).ShortDescription = "Australian Tracking Station"; wallops.Position.AssignGeodetic(37.8602, -75.5095, -0.0127878); ((IAgStkObject)wallops).ShortDescription = "NASA Launch Site/Tracking Station"; // The Seoul and WhiteSands facilities are // created using the Facility Database string filelocation = this.GetSTKDataDir("Facility") + @"\stkFacility.fd"; // For Windows Vista and later Windows operating // systems, the database path should be // c:\ProgramData\AGI\STK 9\Databases\Facility\stkFacility.fd string command = "ImportFromDB * Facility \"" + filelocation + "\"Class Facility SiteName Seoul Network \"GeoEye\""; root.ExecuteCommand(command); command = "ImportFromDB * Facility \"" + filelocation + "\"Class Facility SiteName \"White Sands\" Network \"Other\""; root.ExecuteCommand(command); seoul = (IAgFacility)root.CurrentScenario.Children["Seoul"]; whitesands = (IAgFacility)root.CurrentScenario.Children["White_Sands"]; } catch (Exception e) { MessageBox.Show(e.Message); } } internal string GetSTKDataDir(string DatabaseType) { string stkDataDir = null; try { AGI.STKUtil.AgExecCmdResult result = (AGI.STKUtil.AgExecCmdResult)this.root.ExecuteCommand("GetDirectory / Database " + DatabaseType); stkDataDir = result[0]; } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); } return stkDataDir; } 2) Add the following to the variable declarations for the Form1 class (after the declaration of root): private IAgFacility baikonur, perth, wallops, seoul, whitesands; 3) In the Form1 class constructor, after the line where you initialize the root reference, add: comboBox1.Items.Add("Create Facilities"); comboBox1.Items.Add("Change Facilities Color"); comboBox1.Items.Add("Create Target"); comboBox1.Items.Add("Create Ship"); comboBox1.Items.Add("Create Satellites"); comboBox1.Items.Add("Modify Shuttle Display"); comboBox1.Items.Add("Create AreaTarget"); comboBox1.Items.Add("Access"); comboBox1.Items.Add("Remove Access"); comboBox1.Items.Add("Create Sensors"); comboBox1.Items.Add("Limit Sensor Visibility"); comboBox1.Items.Add("Enlarge Time Period"); comboBox1.Items.Add("Custom Display Intervals"); comboBox1.Items.Add("Access Display Intervals"); comboBox1.Items.Add("Facility Access"); comboBox1.Items.Add("SunElevationAngle Constraint"); comboBox1.Items.Add("Range Constraint"); 4) In the SelectedIndexChanged() method for the combo box, add: int item = comboBox1.SelectedIndex; string action = comboBox1.Items[item].ToString(); root.BeginUpdate(); //Suspends graphics updates until //EndUpdate() is called if(action == "Create Facilities") { CreateFacilities(); } root.EndUpdate(); LANGUAGE: VB.NET ---------------- 1) The following two methods use various options provided by the Object Model to create some facilities: Public Sub CreateFacilities() Try ' The code that creates the Baikonur facility uses ' a fine-grained interface that lets you set each ' property individually baikonur = CType(root.CurrentScenario.Children.New(AgESTKObjectType.eFacility, "Baikonur"), IAgFacility) Dim geodetic As IAgGeodetic = CType(baikonur.Position.ConvertTo(AgEPositionType.eGeodetic), IAgGeodetic) geodetic.Lat = 48.0 geodetic.Lon = 55.0 geodetic.Alt = 0.0 baikonur.Position.Assign(geodetic) CType(baikonur, IAgStkObject).ShortDescription = "Launch Site" CType(baikonur, IAgStkObject).LongDescription = "Launch site in Kazakhstan. Also known as Tyuratam." ' The Perth and Wallops facilities are created with ' a coarse-grained interface that lets you specify ' position type and lat/lon/alt values in a single ' helper method (AssignGeodetic) perth = CType(root.CurrentScenario.Children.New(AgESTKObjectType.eFacility, "Perth"), IAgFacility) wallops = CType(root.CurrentScenario.Children.New(AgESTKObjectType.eFacility, "Wallops"), IAgFacility) perth.Position.AssignGeodetic(-31, 116, 0) CType(perth, IAgStkObject).ShortDescription = "Australian Tracking Station" wallops.Position.AssignGeodetic(37.8602, -75.5095, -0.0127878) CType(wallops, IAgStkObject).ShortDescription = "NASA Launch Site/Tracking Station" Dim filelocation As String = Me.GetSTKDataDir("Facility") + "STKData\Databases\Facility\stkFacility.fd" Dim command As String = "ImportFromDB * Facility """ + filelocation + """Class Facility SiteName Seoul Network ""GeoEye""" root.ExecuteCommand(command) command = "ImportFromDB * Facility """ + filelocation + """Class Facility SiteName ""White Sands"" Network ""Other""" root.ExecuteCommand(command) seoul = CType(root.CurrentScenario.Children("Seoul"), IAgFacility) whitesands = CType(root.CurrentScenario.Children("White_Sands"), IAgFacility) Catch e As Exception MessageBox.Show(e.Message) End Try End Sub 'CreateFacilities Friend Function GetSTKDataDir(DatabaseType As String) As String Dim stkDataDir As String = Nothing Try Dim result As AGI.STKUtil.AgExecCmdResult = Me.root.ExecuteCommand("GetDirectory / Database " + DatabaseType) stkDataDir = result(0) Catch e As Exception Console.WriteLine(e.Message) Console.WriteLine(e.StackTrace) End Try Return stkDataDir End Function 'GetSTKDataDir 2) Add the following to the variable declarations for the Form1 class: Private baikonur, perth, wallops, seoul, whitesands As IAgFacility 3) In the Form1 class constructor, after the line where you initialize the root reference, add: ComboBox1.Items.Add("Create Facilities") ComboBox1.Items.Add("Change Facilities Color") ComboBox1.Items.Add("Create Target") ComboBox1.Items.Add("Create Ship") ComboBox1.Items.Add("Create Satellites") ComboBox1.Items.Add("Modify Shuttle Display") ComboBox1.Items.Add("Create AreaTarget") ComboBox1.Items.Add("Access") ComboBox1.Items.Add("Remove Access") ComboBox1.Items.Add("Create Sensors") ComboBox1.Items.Add("Limit Sensor Visibility") ComboBox1.Items.Add("Enlarge Time Period") ComboBox1.Items.Add("Custom Display Intervals") ComboBox1.Items.Add("Access Display Intervals") ComboBox1.Items.Add("Facility Access") ComboBox1.Items.Add("SunElevationAngle Constraint") ComboBox1.Items.Add("Range Constraint") 4) In the SelectedIndexChanged() method for the combo box, add: Dim item As Integer = ComboBox1.SelectedIndex Dim action As String = ComboBox1.Items(item).ToString() root.BeginUpdate() 'Suspends graphics updates until 'EndUpdate() is called Select Case action Case "Create Facilities" CreateFacilities() End Select root.EndUpdate() * ------------------------------------- * * SECTION: Set Some Facility Properties * * ------------------------------------- * LANGUAGE: C# ------------ 1) Add a method to change the display colors for the facilities: public void ChangeFacilitiesColor() { try { baikonur.Graphics.Color = System.Drawing.Color.Yellow; perth.Graphics.Color = System.Drawing.Color.Green; wallops.Graphics.Color = System.Drawing.Color.Aquamarine; seoul.Graphics.Color = System.Drawing.Color.Purple; whitesands.Graphics.Color = System.Drawing.Color.Pink; } catch (Exception e) { MessageBox.Show(e.Message); } } 2) Add the following if-else block to the SelectedIndexChanged() method for the combo box: else if(action == "Change Facilities Color") { ChangeFacilitiesColor(); } LANGUAGE: VB.NET ---------------- 1) Add a method to change the display colors for the facilities: Public Sub ChangeFacilitiesColor() Try baikonur.Graphics.Color = System.Drawing.Color.Yellow perth.Graphics.Color = System.Drawing.Color.Green wallops.Graphics.Color = System.Drawing.Color.Aquamarine seoul.Graphics.Color = System.Drawing.Color.Purple whitesands.Graphics.Color = System.Drawing.Color.Pink Catch e As Exception MessageBox.Show(e.Message) End Try End Sub 'ChangeFacilitiesColor 2) Add the following case to the Select Case block in the SelectedIndexChanged() method for the combo box: Case "Change Facilities Color" ChangeFacilitiesColor() * ------------------------ * * SECTION: Create a Target * * ------------------------ * LANGUAGE: C# ------------ 1) Add a method to create a target: public void CreateTarget() { //Create a Target object named "Iceberg", then use a coarse-grained interface //to select Geodetic as the position type and set its lat/lon/alt values, and enter //a short description try { IAgTarget iceberg = (IAgTarget)root.CurrentScenario.Children.New(AgESTKObjectType. eTarget, "Iceberg"); iceberg.Position.AssignGeodetic(74.91, -74.5, 0.0); ((IAgStkObject)iceberg).ShortDescription = "Only the tip."; } catch(Exception e) { MessageBox.Show(e.Message); } } 2) Add the following else-if block to the SelectedIndexChanged() method for the combo box: else if(action == "Create Target") { CreateTarget(); } LANGUAGE: VB.NET ---------------- 1) Add a method to create a target: Public Sub CreateTarget() 'Create a Target object named "Iceberg", then use a coarse-grained interface 'to select Geodetic as the position type and set its lat/lon/alt values, and enter 'a short description Try Dim iceberg As IAgTarget = CType(root.CurrentScenario.Children.New(AgESTKObjectType.eTarget, "Iceberg"), IAgTarget) iceberg.Position.AssignGeodetic(74.91, -74.5, 0.0) CType(iceberg, IAgStkObject).ShortDescription = "Only the tip." Catch e As Exception MessageBox.Show(e.Message) End Try End Sub 'CreateTarget 2) Add the following case to the Select Case block in the SelectedIndexChanged() method for the combo box: Case "Create Target" CreateTarget() * ---------------------- * * SECTION: Create a Ship * * ---------------------- * LANGUAGE: C# ------------ 1) Add a convenience method for definition of new waypoints, then use it in the method for creating a ship: private void AddWaypoint(IAgVeWaypointsCollection waypoints, object lat, object lon, double alt, double speed, double tr) { IAgVeWaypointsElement elem = waypoints.Add(); elem.Latitude = (double)lat; elem.Longitude = (double)lon; elem.Altitude = alt; elem.Speed = speed; elem.TurnRadius = tr; } public void CreateShip() { try { IAgShip cruise = (IAgShip)root.CurrentScenario.Children.New(AgESTKObjectType.eShip, "Cruise"); cruise.SetRouteType(AgEVePropagatorType.ePropagatorGreatArc); IAgVePropagatorGreatArc greatArc = (IAgVePropagatorGreatArc)cruise.Route; greatArc.EphemerisInterval.SetStartAndStopTimes("1 Jul 2002 00:00:00.00", "1 Jul 2002 00:00:00.00"); greatArc.Method = AgEVeWayPtCompMethod.eDetermineTimeAccFromVel; //Use the convenience method defined above //to add waypoints specifying the ship's route AddWaypoint(greatArc.Waypoints, 44.1, -8.5, 0.0, .015, 0.0); AddWaypoint(greatArc.Waypoints, 51.0, -26.6, 0.0, .015, 0.0); AddWaypoint(greatArc.Waypoints, 52.1, -40.1, 0.0, .015, 0.0); AddWaypoint(greatArc.Waypoints, 60.2, -55.0, 0.0, .015, 0.0); AddWaypoint(greatArc.Waypoints, 68.2, -65.0, 0.0, .015, 0.0); AddWaypoint(greatArc.Waypoints, 72.5, -70.1, 0.0, .015, 0.0); AddWaypoint(greatArc.Waypoints, 74.9, -74.5, 0.0, .015, 0.0); cruise.SetAttitudeType(AgEVeAttitude.eAttitudeStandard); IAgVeRouteAttitudeStandard attitude = (IAgVeRouteAttitudeStandard)cruise.Attitude; attitude.Basic.SetProfileType(AgEVeProfile. eProfileECFVelocityAlignmentWithRadialConstraint); cruise.Graphics.WaypointMarker.IsWaypointMarkersVisible = true; cruise.Graphics.WaypointMarker.IsTurnMarkersVisible = true; greatArc.Propagate(); root.Rewind(); } catch (Exception e) { MessageBox.Show(e.Message); } } 2) Add the following else-if block to the SelectedIndexChanged() method for the combo box: else if(action == "Create Ship") { CreateShip(); } LANGUAGE: VB.NET ---------------- 1) Add a convenience method for definition of new waypoints, then use it in the method for creating a ship: Private Sub AddWaypoint(ByVal waypoints As IAgVeWaypointsCollection, ByVal Lat As Object, ByVal Lon As Object, ByVal Alt As Double, ByVal Speed As Double, ByVal tr As Double) Dim elem As IAgVeWaypointsElement = waypoints.Add() elem.Latitude = CDbl(Lat) elem.Longitude = CDbl(Lon) elem.Altitude = Alt elem.Speed = Speed elem.TurnRadius = tr End Sub 'AddWaypoint Public Sub CreateShip() Try Dim cruise As IAgShip = CType(root.CurrentScenario.Children.New(AgESTKObjectType.eShip, "Cruise"), IAgShip) cruise.SetRouteType(AgEVePropagatorType.ePropagatorGreatArc) Dim greatArc As IAgVePropagatorGreatArc = CType(cruise.Route, IAgVePropagatorGreatArc) greatArc.EphemerisInterval.SetStartAndStopTimes("1 Jul 2002 00:00:00.00", "1 Jul 2002 00:00:00.00") greatArc.Method = AgEVeWayPtCompMethod.eDetermineTimeAccFromVel 'Use the convenience method defined above 'to add waypoints specifying the ship's route AddWaypoint(greatArc.Waypoints, 44.1, -8.5, 0.0, 0.015, 0.0) AddWaypoint(greatArc.Waypoints, 51.0, -26.6, 0.0, 0.015, 0.0) AddWaypoint(greatArc.Waypoints, 52.1, -40.1, 0.0, 0.015, 0.0) AddWaypoint(greatArc.Waypoints, 60.2, -55.0, 0.0, 0.015, 0.0) AddWaypoint(greatArc.Waypoints, 68.2, -65.0, 0.0, 0.015, 0.0) AddWaypoint(greatArc.Waypoints, 72.5, -70.1, 0.0, 0.015, 0.0) AddWaypoint(greatArc.Waypoints, 74.9, -74.5, 0.0, 0.015, 0.0) cruise.SetAttitudeType(AgEVeAttitude.eAttitudeStandard) Dim attitude As IAgVeRouteAttitudeStandard = CType(cruise.Attitude, IAgVeRouteAttitudeStandard) attitude.Basic.SetProfileType(AgEVeProfile.eProfileECFVelocityAlignmentWithRadialConstraint) cruise.Graphics.WaypointMarker.IsWaypointMarkersVisible = True cruise.Graphics.WaypointMarker.IsTurnMarkersVisible = True greatArc.Propagate() root.Rewind() Catch e As Exception MessageBox.Show(e.Message) End Try End Sub 'CreateShip 2) Add the following case to the Select Case block in the SelectedIndexChanged() method for the combo box: Case "Create Ship" CreateShip() * ------------------------------- * * SECTION: Create Some Satellites * * ------------------------------- * LANGUAGE: C# ------------ 1) Add a method to create some satellites: public void CreateSatellites() { try { //SATELLITE #1: TDRS //Assign a two-body propagator to propagate it IAgSatellite tdrs = (IAgSatellite)root.CurrentScenario.Children.New(AgESTKObjectType. eSatellite, "TDRS"); tdrs.SetPropagatorType(AgEVePropagatorType.ePropagatorTwoBody); IAgVePropagatorTwoBody twobody = (IAgVePropagatorTwoBody)tdrs.Propagator; //Define the TDRS satellite's orbit using //classical (Keplerian) orbital elements IAgOrbitStateClassical classical = (IAgOrbitStateClassical)twobody.InitialState.Representation.ConvertTo(AgEOrbitStateType.eOrbitStateClassical); //Set J2000 as the coordinate system //and set the time period and time step classical.CoordinateSystemType = AgECoordinateSystem.eCoordinateSystemJ2000; twobody.EphemerisInterval.SetStartAndStopTimes("1 Jul 2002 00:00:00.000", "1 Jul 2002 04:00:00.000"); twobody.Step = 60; //Use period and eccentricity to define the size //and shape of the orbit classical.SizeShapeType = AgEClassicalSizeShape.eSizeShapePeriod; IAgClassicalSizeShapePeriod period = (IAgClassicalSizeShapePeriod)classical.SizeShape; period.Eccentricity = 0.0; period.Period = 86164.090540; //Use argument of perigee, inclination //and longitude of ascending node to //define the orientation of the orbit classical.Orientation.ArgOfPerigee = 0.0; classical.Orientation.Inclination = 0.0; classical.Orientation.AscNodeType = AgEOrientationAscNode.eAscNodeLAN; IAgOrientationAscNodeLAN lan = (IAgOrientationAscNodeLAN)classical.Orientation.AscNode; lan.Value = 259.999982; //Use true anomaly to specify the position of //the satellite in orbit classical.LocationType = AgEClassicalLocation.eLocationTrueAnomaly; IAgClassicalLocationTrueAnomaly trueAnomaly = (IAgClassicalLocationTrueAnomaly)classical.Location; trueAnomaly.Value = 178.845262; //Assign the orbital elements to the TDRS //satellite's propagator and propagate the orbit twobody.InitialState.Representation.Assign(classical); twobody.Propagate(); //SATELLITE #2: TDRS 3 //Use the ImportFromDB Connect command //to import a satellite from the STK Satellite //Database string filelocation = this.GetSTKDataDir("Satellite") + @"\stkSatDB.sd"; string command = "ImportFromDB * Satellite \"" + filelocation + "\" Propagate On CommonName \"TDRS 3\""; root.ExecuteCommand(command); IAgSatellite tdrs3 = (IAgSatellite)root.CurrentScenario.Children["TDRS_3_19548"]; //Assign an SGP4 propagator to the TDRS 3 //satellite and set its time period IAgVePropagatorSGP4 sgp4 = (IAgVePropagatorSGP4)tdrs3.Propagator; sgp4.EphemerisInterval.SetStartAndStopTimes("1 Jul 2002 00:00:00.000","1 Jul 2002 04:00:00.000"); //SATELLITE #3: ERS1 //Assign a J4 Perturbation propagator to the //satellite and set various time properties ers1 = (IAgSatellite)root.CurrentScenario.Children.New(AgESTKObjectType. eSatellite, "ERS1"); ers1.SetPropagatorType(AgEVePropagatorType. ePropagatorJ4Perturbation); IAgVePropagatorJ4Perturbation j4 = (IAgVePropagatorJ4Perturbation)ers1.Propagator; j4.EphemerisInterval.SetStartAndStopTimes("1 Jul 2002 00:00:00.000","1 Jul 2002 04:00:00.000"); j4.Step = 60.00; j4.InitialState.OrbitEpoch.SetExplicitTime("1 Jul 2002 00:00:00.00"); //Use Keplerian elements to define the orbit //as you did for the TDRS satellite, but use //semimajor axis and eccentricity to define the //size and shape of the orbit classical = (IAgOrbitStateClassical)j4.InitialState.Representation. ConvertTo(AgEOrbitStateType.eOrbitStateClassical); classical.CoordinateSystemType = AgECoordinateSystem.eCoordinateSystemJ2000; classical.LocationType = AgEClassicalLocation.eLocationTrueAnomaly; trueAnomaly = (IAgClassicalLocationTrueAnomaly)classical.Location; trueAnomaly.Value = 0.0; classical.SizeShapeType = AgEClassicalSizeShape.eSizeShapeSemimajorAxis; IAgClassicalSizeShapeSemimajorAxis semi = (IAgClassicalSizeShapeSemimajorAxis)classical.SizeShape; semi.SemiMajorAxis = 7163.14; semi.Eccentricity = 0.0; classical.Orientation.ArgOfPerigee = 0.0; classical.Orientation.AscNodeType = AgEOrientationAscNode.eAscNodeLAN; lan = (IAgOrientationAscNodeLAN)classical.Orientation.AscNode; lan.Value = 99.38; classical.Orientation.Inclination = 98.50; j4.InitialState.Representation.Assign(classical); j4.Propagate(); root.Rewind(); //If you uncomment the following line, only //the descending (north-to-south) portion of //each orbit pass of ERS1 is displayed. //NOTE: Be sure to re-comment (or remove) the line, //since full path display is needed for some //later activities //ers1.Graphics.Passes.VisibleSides = AgEVeGfxVisibleSides.eVisibleSidesDescending; //SATELLITE #4: Shuttle //Here you use the J4 Perturbation propagator again, //as well as Keplerian elements, with orbit size and //shape specified via apogee and perigee altitude shuttle = (IAgSatellite)root.CurrentScenario.Children.New(AgESTKObjectType. eSatellite, "Shuttle"); shuttle.SetPropagatorType(AgEVePropagatorType. ePropagatorJ4Perturbation); j4 = (IAgVePropagatorJ4Perturbation)shuttle.Propagator; j4.EphemerisInterval.SetStartAndStopTimes("1 Jul 2002 00:00:00.000", "1 Jul 2002 03:00:00.000"); j4.Step = 60.00; j4.InitialState.OrbitEpoch.SetExplicitTime("1 Jul 2002 00:00:00.00"); classical = (IAgOrbitStateClassical)j4.InitialState.Representation. ConvertTo(AgEOrbitStateType.eOrbitStateClassical); classical.CoordinateSystemType = AgECoordinateSystem.eCoordinateSystemJ2000; classical.LocationType = AgEClassicalLocation.eLocationTrueAnomaly; trueAnomaly = (IAgClassicalLocationTrueAnomaly)classical.Location; trueAnomaly.Value = 0.0; classical.SizeShapeType = AgEClassicalSizeShape.eSizeShapeAltitude; IAgClassicalSizeShapeAltitude altitude = (IAgClassicalSizeShapeAltitude)classical.SizeShape; altitude.ApogeeAltitude = 370.4; altitude.PerigeeAltitude = 370.4; classical.Orientation.ArgOfPerigee = 0.0; classical.Orientation.AscNodeType = AgEOrientationAscNode.eAscNodeLAN; lan = (IAgOrientationAscNodeLAN)classical.Orientation.AscNode; lan.Value = -151.0; classical.Orientation.Inclination = 28.5; j4.InitialState.Representation.Assign(classical); j4.Propagate(); root.Rewind(); } catch (Exception e) { MessageBox.Show(e.Message); } } 2) Add the following to the variable declarations for the Form1 class: private IAgSatellite ers1, shuttle; 3) Add the following else-if block to the SelectedIndexChanged() method for the combo box: else if(action == "Create Satellites") { CreateSatellites(); } 4) Add a method to modify the display of the Shuttle's orbit, change the marker and add contours: public void ModifyShuttleDisplay() { //Change the display of the Shuttle's orbit and ground //tracks to a dashed line, change the marker style to a //plus, and add elevation contours try { shuttle.Graphics.SetAttributesType(AgEVeGfxAttributes. eAttributesBasic); IAgVeGfxAttributesOrbit orbitgfx = (IAgVeGfxAttributesOrbit)shuttle.Graphics.Attributes; orbitgfx.Line.Style = AgELineStyle.eDashed; orbitgfx.MarkerStyle = "Plus"; IAgVeGfxElevContours contours = (IAgVeGfxElevContours)shuttle.Graphics.ElevContours; IAgVeGfxElevationsCollection elevations = contours.Elevations; elevations.RemoveAll(); //Define contour levels for ground elevation //angles from 0 to 50 deg in steps of 10 deg elevations.AddLevelRange(0, 50, 10); for(int i = 0; i < elevations.Count; i++) //Draw each of the 6 contour lines with no label //and with a medium-thick line width { IAgVeGfxElevationsElement elem = elevations[i]; elem.DistanceVisible = false; elem.LineWidth = AgELineWidth.e3; } //Show the contours! contours.IsVisible = true; root.Rewind(); } catch (Exception e) { MessageBox.Show(e.Message); } } 5) Add the following else-if block to the SelectedIndexChanged() method for the combo box: else if(action == "Modify Shuttle Display") { ModifyShuttleDisplay(); } LANGUAGE: VB.NET ---------------- 1) Add a method to create some satellites: Public Sub CreateSatellites() Try 'SATELLITE #1: TDRS 'Assign a two-body propagator to propagate it Dim tdrs As IAgSatellite = CType(root.CurrentScenario.Children.New(AgESTKObjectType.eSatellite, "TDRS"), IAgSatellite) tdrs.SetPropagatorType(AgEVePropagatorType.ePropagatorTwoBody) Dim twobody As IAgVePropagatorTwoBody = CType(tdrs.Propagator, IAgVePropagatorTwoBody) 'Define the TDRS satellite's orbit using 'classical (Keplerian) orbital elements Dim classical As IAgOrbitStateClassical = CType(twobody.InitialState.Representation.ConvertTo(AgEOrbitStateType.eOrbitStateClassical), IAgOrbitStateClassical) 'Set J2000 as the coordinate system 'and set the time period and time step classical.CoordinateSystemType = AgECoordinateSystem.eCoordinateSystemJ2000 twobody.EphemerisInterval.SetStartAndStopTimes("1 Jul 2002 00:00:00.000", "1 Jul 2002 04:00:00.000") twobody.Step = 60 'Use period and eccentricity to define the size 'and shape of the orbit classical.SizeShapeType = AgEClassicalSizeShape.eSizeShapePeriod Dim period As IAgClassicalSizeShapePeriod = CType(classical.SizeShape, IAgClassicalSizeShapePeriod) period.Eccentricity = 0.0 period.Period = 86164.09054 'Use argument of perigee, inclination 'and longitude of ascending node to 'define the orientation of the orbit classical.Orientation.ArgOfPerigee = 0.0 classical.Orientation.Inclination = 0.0 classical.Orientation.AscNodeType = AgEOrientationAscNode.eAscNodeLAN Dim lan As IAgOrientationAscNodeLAN = CType(classical.Orientation.AscNode, IAgOrientationAscNodeLAN) lan.Value = 259.999982 'Use true anomaly to specify the position of 'the satellite in orbit classical.LocationType = AgEClassicalLocation.eLocationTrueAnomaly Dim trueAnomaly As IAgClassicalLocationTrueAnomaly = CType(classical.Location, IAgClassicalLocationTrueAnomaly) trueAnomaly.Value = 178.845262 'Assign the orbital elements to the TDRS 'satellite's propagator and propagate the orbit twobody.InitialState.Representation.Assign(classical) twobody.Propagate() 'SATELLITE #2: TDRS 3 'Use the ImportFromDB Connect command 'to import a satellite from the STK Satellite 'Database Dim filelocation As String = Me.GetSTKDataDir("Satellite") + "\stkSatDB.sd" Dim command As String = "ImportFromDB * Satellite """ + filelocation + """ Propagate On CommonName ""TDRS 3""" root.ExecuteCommand(command) Dim tdrs3 As IAgSatellite = CType(root.CurrentScenario.Children("TDRS_3_19548"), IAgSatellite) 'Assign an SGP4 propagator to the TDRS 3 'satellite and set its time period Dim sgp4 As IAgVePropagatorSGP4 = CType(tdrs3.Propagator, IAgVePropagatorSGP4) sgp4.EphemerisInterval.SetStartAndStopTimes("1 Jul 2002 00:00:00.000","1 Jul 2002 04:00:00.000") 'SATELLITE #3: ERS1 'Assign a J4 Perturbation propagator to the 'satellite and set various time properties ers1 = CType(root.CurrentScenario.Children.New(AgESTKObjectType.eSatellite, "ERS1"), IAgSatellite) ers1.SetPropagatorType(AgEVePropagatorType.ePropagatorJ4Perturbation) Dim j4 As IAgVePropagatorJ4Perturbation = CType(ers1.Propagator, IAgVePropagatorJ4Perturbation) j4.EphemerisInterval.SetStartAndStopTimes("1 Jul 2002 00:00:00.000","1 Jul 2002 04:00:00.000") j4.Step = 60.0 j4.InitialState.OrbitEpoch.SetExplicitTime("1 Jul 2002 00:00:00.00") 'Use Keplerian elements to define the orbit 'as you did for the TDRS satellite, but use 'semimajor axis and eccentricity to define the 'size and shape of the orbit classical = CType(j4.InitialState.Representation.ConvertTo(AgEOrbitStateType.eOrbitStateClassical), IAgOrbitStateClassical) classical.CoordinateSystemType = AgECoordinateSystem.eCoordinateSystemJ2000 classical.LocationType = AgEClassicalLocation.eLocationTrueAnomaly trueAnomaly = CType(classical.Location, IAgClassicalLocationTrueAnomaly) trueAnomaly.Value = 0.0 classical.SizeShapeType = AgEClassicalSizeShape.eSizeShapeSemimajorAxis Dim semi As IAgClassicalSizeShapeSemimajorAxis = CType(classical.SizeShape, IAgClassicalSizeShapeSemimajorAxis) semi.SemiMajorAxis = 7163.14 semi.Eccentricity = 0.0 classical.Orientation.ArgOfPerigee = 0.0 classical.Orientation.AscNodeType = AgEOrientationAscNode.eAscNodeLAN lan = CType(classical.Orientation.AscNode, IAgOrientationAscNodeLAN) lan.Value = 99.38 classical.Orientation.Inclination = 98.5 j4.InitialState.Representation.Assign(classical) j4.Propagate() root.Rewind() 'If you uncomment the following line, only 'the descending (north-to-south) portion of 'each orbit pass of ERS1 is displayed. 'NOTE: Be sure to re-comment (or remove) the line, 'since full path display is needed for some 'later activities 'ers1.Graphics.Passes.VisibleSides = AgEVeGfxVisibleSides.eVisibleSidesDescending; 'SATELLITE #4: Shuttle 'Here you use the J4 Perturbation propagator again, 'as well as Keplerian elements, with orbit size and 'shape specified via apogee and perigee altitude shuttle = CType(root.CurrentScenario.Children.New(AgESTKObjectType.eSatellite, "Shuttle"), IAgSatellite) shuttle.SetPropagatorType(AgEVePropagatorType.ePropagatorJ4Perturbation) j4 = CType(shuttle.Propagator, IAgVePropagatorJ4Perturbation) j4.EphemerisInterval.SetStartAndStopTimes("1 Jul 2002 00:00:00.000", "1 Jul 2002 03:00:00.000") j4.Step = 60.0 j4.InitialState.OrbitEpoch.SetExplicitTime("1 Jul 2002 00:00:00.00") classical = CType(j4.InitialState.Representation.ConvertTo(AgEOrbitStateType.eOrbitStateClassical), IAgOrbitStateClassical) classical.CoordinateSystemType = AgECoordinateSystem.eCoordinateSystemJ2000 classical.LocationType = AgEClassicalLocation.eLocationTrueAnomaly trueAnomaly = CType(classical.Location, IAgClassicalLocationTrueAnomaly) trueAnomaly.Value = 0.0 classical.SizeShapeType = AgEClassicalSizeShape.eSizeShapeAltitude Dim altitude As IAgClassicalSizeShapeAltitude = CType(classical.SizeShape, IAgClassicalSizeShapeAltitude) altitude.ApogeeAltitude = 370.4 altitude.PerigeeAltitude = 370.4 classical.Orientation.ArgOfPerigee = 0.0 classical.Orientation.AscNodeType = AgEOrientationAscNode.eAscNodeLAN lan = CType(classical.Orientation.AscNode, IAgOrientationAscNodeLAN) lan.Value = -151.0 classical.Orientation.Inclination = 28.5 j4.InitialState.Representation.Assign(classical) j4.Propagate() root.Rewind() Catch e As Exception MessageBox.Show(e.Message) End Try End Sub 'CreateSatellites 2) Add the following to the variable declarations for the Form1 class: Private ers1, shuttle As IAgSatellite 3) Add the following case to the Select Case block in the SelectedIndexChanged() method for the combo box: Case "Create Satellites" CreateSatellites() 4) Add a method to modify the display of the Shuttle's orbit, change the marker and add contours: Public Sub ModifyShuttleDisplay() 'Change the display of the Shuttle's orbit and ground 'tracks to a dashed line, change the marker style to a 'plus, and add elevation contours Try shuttle.Graphics.SetAttributesType(AgEVeGfxAttributes.eAttributesBasic) Dim orbitgfx As IAgVeGfxAttributesOrbit = CType(shuttle.Graphics.Attributes, IAgVeGfxAttributesOrbit) orbitgfx.Line.Style = AgELineStyle.eDashed orbitgfx.MarkerStyle = "Plus" Dim contours As IAgVeGfxElevContours = CType(shuttle.Graphics.ElevContours, IAgVeGfxElevContours) Dim elevations As IAgVeGfxElevationsCollection = contours.Elevations elevations.RemoveAll() 'Define contour levels for ground elevation 'angles from 0 to 50 deg in steps of 10 deg elevations.AddLevelRange(0, 50, 10) Dim i As Integer For i = 0 To elevations.Count - 1 'Draw each of the 6 contour lines with no label 'and with a medium-thick line width Dim elem As IAgVeGfxElevationsElement = elevations(i) elem.DistanceVisible = False elem.LineWidth = AgELineWidth.e3 Next i 'Show the contours! contours.IsVisible = True root.Rewind() Catch e As Exception MessageBox.Show(e.Message) End Try End Sub 'ModifyShuttleDisplay 5) Add the following case to the Select Case block in the SelectedIndexChanged() method for the combo box: Case "Modify Shuttle Display" ModifyShuttleDisplay() * ----------------------- * * SECTION: Compute Access * * ----------------------- * LANGUAGE: C# ------------ 1) Add a method to create an area target and one to compute access: public void CreateAreaTarget() { //Create an area target near the North Pole try { searchArea = (IAgAreaTarget)root.CurrentScenario.Children.New(AgESTKObjectType. eAreaTarget, "SearchArea"); //Set some graphics properties for the area target IAgATGraphics atGfx = searchArea.Graphics; atGfx.MarkerStyle = "None"; atGfx.Inherit = false; atGfx.LabelVisible = false; atGfx.CentroidVisible = false; //Select the Pattern type for defining the //area target boundary, and add lat/lon values searchArea.AreaType = AgEAreaType.ePattern; IAgAreaTypePatternCollection patterns = (IAgAreaTypePatternCollection)searchArea.AreaTypeData; patterns.Add(78.4399, -77.6125); patterns.Add(77.7879, -71.1578); patterns.Add(74.5279, -69.0714); patterns.Add(71.6591, -69.1316); patterns.Add(70.0291, -70.8318); patterns.Add(71.9851, -76.3086); searchArea.AutoCentroid = false; //A course-grained method is convenient for defining //the position of the area target centroid. The //AssignSpherical method lets you set select the //Spherical position type and set latitude, //longitude and radius in one step searchArea.Position.AssignSpherical(74.9533, -74.5482, 6358.186790); } catch (Exception e) { MessageBox.Show(e.Message); } } public void ComputeAccess() { //Compute access from the ERS1 satellite to the area target try { //Specify the 'from' and 'to' objects access = ((IAgStkObject)ers1).GetAccessToObject((IAgStkObject)searchArea); access.ComputeAccess(); root.Rewind(); IAgDataPrvInterval interval = (IAgDataPrvInterval)access.DataProviders["Access Data"]; IAgDrResult result = (IAgDrResult)interval.Exec("1 Jul 2002 00:00:00.000", "1 Jul 2002 04:00:00.000"); } catch(Exception e) { MessageBox.Show(e.Message); } //with the result returned, the user can use the data any way they prefer. } 2) Add the following to the variable declarations for the Form1 class: private IAgAreaTarget searchArea; private IAgStkAccess access; 3) Add the following else-if blocks to the SelectedIndexChanged() method for the combo box: else if(action == "Create AreaTarget") { CreateAreaTarget(); } else if(action == "Access") { ComputeAccess(); } 4) Add a method to remove access: public void RemoveAccess() { try { access.RemoveAccess(); root.Rewind(); } catch(Exception e) { MessageBox.Show(e.Message); } } 5) Add the following else-if block to the SelectedIndexChanged() method for the combo box: else if(action == "Remove Access") { RemoveAccess(); } LANGUAGE: VB.NET ---------------- 1) Add a method to create an area target and one to compute access: Public Sub CreateAreaTarget() 'Create an area target near the North Pole Try searchArea = CType(root.CurrentScenario.Children.New(AgESTKObjectType.eAreaTarget, "SearchArea"), IAgAreaTarget) 'Set some graphics properties for the area target Dim atGfx As IAgATGraphics = searchArea.Graphics atGfx.MarkerStyle = "None" atGfx.Inherit = False atGfx.LabelVisible = False atGfx.CentroidVisible = False 'Select the Pattern type for defining the 'area target boundary, and add lat/lon values searchArea.AreaType = AgEAreaType.ePattern Dim patterns As IAgAreaTypePatternCollection = CType(searchArea.AreaTypeData, IAgAreaTypePatternCollection) patterns.Add(78.4399, -77.6125) patterns.Add(77.7879, -71.1578) patterns.Add(74.5279, -69.0714) patterns.Add(71.6591, -69.1316) patterns.Add(70.0291, -70.8318) patterns.Add(71.9851, -76.3086) searchArea.AutoCentroid = False 'A course-grained method is convenient for defining 'the position of the area target centroid. The 'AssignSpherical method lets you set select the 'Spherical position type and set latitude, 'longitude and radius in one step searchArea.Position.AssignSpherical(74.9533, -74.5482, 6358.18679) Catch e As Exception MessageBox.Show(e.Message) End Try End Sub 'CreateAreaTarget Public Sub ComputeAccess() 'Compute access from the ERS1 satellite to the area target Try 'Specify the 'from' and 'to' objects access = CType(ers1, IAgStkObject).GetAccessToObject(CType(searchArea, IAgStkObject)) access.ComputeAccess() root.Rewind() Dim interval As IAgDataPrvInterval = CType(access.DataProviders("Access Data"), IAgDataPrvInterval) Dim result As IAgDrResult = CType(interval.Exec("1 Jul 2002 00:00:00.000", "1 Jul 2002 04:00:00.000"), IAgDrResult) Catch e As Exception MessageBox.Show(e.Message) End Try End Sub 'Access 'with the result returned, the user can use the data any way they prefer. 2) Add the following to the variable declarations for the Form1 class: Private searchArea As IAgAreaTarget Private access As IAgStkAccess 3) Add the following else-if blocks to the SelectedIndexChanged() method for the combo box: Case "Create AreaTarget" CreateAreaTarget() Case "Access" ComputeAccess() 4) Add a method to remove access: Public Sub RemoveAccess() Try access.RemoveAccess() root.Rewind() Catch e As Exception MessageBox.Show(e.Message) End Try End Sub 'RemoveAccess 5) Add the following case to the Select Case block in the SelectedIndexChanged() method for the combo box: Case "Remove Access" RemoveAccess() * ---------------------------- * * SECTION: Create Some Sensors * * ---------------------------- * LANGUAGE: C# ------------ 1) Add a method to create 2 sensors: public void CreateSensors() { //Attach 2 sensors to the ERS1 satellite try { //SENSOR #1: Horizon //Define a simple conic sensor pattern with //a cone angle of 90 deg horizon = (IAgSensor)root.CurrentScenario.Children["ERS1"].Children. New(AgESTKObjectType.eSensor, "Horizon"); horizon.SetPatternType(AgESnPattern.eSnSimpleConic); IAgSnSimpleConicPattern simpleConic = (IAgSnSimpleConicPattern)horizon.Pattern; simpleConic.ConeAngle = 90; //Select a Fixed pointing type and the Az-El //orientation type, and set the elevation angle to //90 deg, so that the sensor points straight down //with reference to the satellite horizon.SetPointingType(AgESnPointing.eSnPtFixed); IAgSnPtFixed fixedPt = (IAgSnPtFixed)horizon.Pointing; IAgOrientationAzEl azEl = (IAgOrientationAzEl)fixedPt.Orientation.ConvertTo(AgEOrientationType. eAzEl); azEl.Elevation = 90; azEl.AboutBoresight = AgEAzElAboutBoresight.eAzElAboutBoresightRotate; fixedPt.Orientation.Assign(azEl); //Some cleanup: remove the ERS1 elevation contours //from the 2D window ers1.Graphics.ElevContours.IsVisible = false; //SENSOR #2: Downlink //Define a half power sensor with the parameters //specified below IAgSensor downlink = (IAgSensor)root.CurrentScenario.Children["ERS1"].Children. New(AgESTKObjectType.eSensor, "Downlink"); downlink.SetPatternType(AgESnPattern.eSnHalfPower); IAgSnHalfPowerPattern halfpower = (IAgSnHalfPowerPattern)downlink.Pattern; halfpower.Frequency = .85; halfpower.AntennaDiameter = 1.0; //Select the Targeted pointing type with a tracking //boresight, and target the sensor to point at the //facilities that you created downlink.SetPointingType(AgESnPointing.eSnPtTargeted); IAgSnPtTargeted targeted = (IAgSnPtTargeted)downlink.Pointing; targeted.Boresight = AgESnPtTrgtBsightType.eSnPtTrgtBsightTracking; IAgSnTargetCollection targets = targeted.Targets; targets.Add("Facility/Baikonur"); targets.Add("Facility/White_Sands"); targets.Add("Facility/Perth"); targets.AddObject((IAgStkObject)seoul); targets.Add(((IAgStkObject)wallops).Path); root.Rewind(); } catch(Exception e) { MessageBox.Show(e.Message); } } 2) Add the following to the variable declarations for the Form1 class: private IAgSensor horizon; 3) Add the following else-if block to the SelectedIndexChanged() method for the combo box: else if(action == "Create Sensors") { CreateSensors(); } 4) Add a new sensor defined to have a 5 degree elevation requirement on visibility: public void LimitSensorVisibility() { try { //Attach a sensor named "FiveDegElev" to the Wallops //facility IAgSensor fiveDegElev = (IAgSensor)root.CurrentScenario.Children["Wallops"].Children. New(AgESTKObjectType.eSensor, "FiveDegElev"); //Define a Complex Conic sensor pattern with an outer //cone half-angle of 85 to impose a 5 deg elevation //requirement on the sensor's visibility fiveDegElev.SetPatternType(AgESnPattern.eSnComplexConic); IAgSnComplexConicPattern complexConic = (IAgSnComplexConicPattern)fiveDegElev.Pattern; complexConic.InnerConeHalfAngle = 0; complexConic.OuterConeHalfAngle = 85; complexConic.MinimumClockAngle = 0; complexConic.MaximumClockAngle = 360; //Point the sensor up with respect to the facility fiveDegElev.SetPointingType(AgESnPointing.eSnPtFixed); IAgSnPtFixed fixedPt = (IAgSnPtFixed)fiveDegElev.Pointing; IAgOrientationAzEl azEl = (IAgOrientationAzEl)fixedPt.Orientation.ConvertTo(AgEOrientationType. eAzEl); //Good example of use of fine-grained interface; //you are only setting elevation, not azimuth azEl.Elevation= 90; azEl.AboutBoresight = AgEAzElAboutBoresight.eAzElAboutBoresightRotate; fixedPt.Orientation.Assign(azEl); //Set the sensor's 2D Graphics projection properties //so that it projects to a specified maximum altitude fiveDegElev.Graphics.Projection.DistanceType = AgESnProjectionDistanceType.eConstantAlt; IAgSnProjDisplayDistance dispDistance = (IAgSnProjDisplayDistance)fiveDegElev.Graphics.Projection.DistanceData; dispDistance.Max = 785.248; dispDistance.Min = 0; dispDistance.NumberOfSteps = 1; root.Rewind(); } catch(Exception e) { MessageBox.Show(e.Message); } } 5) Add the following else-if block to the SelectedIndexChanged() method for the combo box: else if(action == "Limit Sensor Visibility") { LimitSensorVisibility(); } LANGUAGE: VB.NET ---------------- 1) Add a method to create 2 sensors: Public Sub CreateSensors() 'Attach 2 sensors to the ERS1 satellite Try 'SENSOR #1: Horizon 'Define a simple conic sensor pattern with 'a cone angle of 90 deg horizon = CType(root.CurrentScenario.Children("ERS1").Children.New(AgESTKObjectType.eSensor, "Horizon"), IAgSensor) horizon.SetPatternType(AgESnPattern.eSnSimpleConic) Dim simpleConic As IAgSnSimpleConicPattern = CType(horizon.Pattern, IAgSnSimpleConicPattern) simpleConic.ConeAngle = 90 'Select a Fixed pointing type and the Az-El 'orientation type, and set the elevation angle to '90 deg, so that the sensor points straight down 'with reference to the satellite horizon.SetPointingType(AgESnPointing.eSnPtFixed) Dim fixedPt As IAgSnPtFixed = CType(horizon.Pointing, IAgSnPtFixed) Dim azEl As IAgOrientationAzEl = CType(fixedPt.Orientation.ConvertTo(AgEOrientationType.eAzEl), IAgOrientationAzEl) azEl.Elevation = 90 azEl.AboutBoresight = AgEAzElAboutBoresight.eAzElAboutBoresightRotate fixedPt.Orientation.Assign(azEl) 'Some cleanup: remove the ERS1 elevation contours 'from the 2D window ers1.Graphics.ElevContours.IsVisible = False 'SENSOR #2: Downlink 'Define a half power sensor with the parameters 'specified below Dim downlink As IAgSensor = CType(root.CurrentScenario.Children("ERS1").Children.New(AgESTKObjectType.eSensor, "Downlink"), IAgSensor) downlink.SetPatternType(AgESnPattern.eSnHalfPower) Dim halfpower As IAgSnHalfPowerPattern = CType(downlink.Pattern, IAgSnHalfPowerPattern) halfpower.Frequency = 0.85 halfpower.AntennaDiameter = 1.0 'Select the Targeted pointing type with a tracking 'boresight, and target the sensor to point at the 'facilities that you created downlink.SetPointingType(AgESnPointing.eSnPtTargeted) Dim targeted As IAgSnPtTargeted = CType(downlink.Pointing, IAgSnPtTargeted) targeted.Boresight = AgESnPtTrgtBsightType.eSnPtTrgtBsightTracking Dim targets As IAgSnTargetCollection = targeted.Targets targets.Add("Facility/Baikonur") targets.Add("Facility/White_Sands") targets.Add("Facility/Perth") targets.AddObject(CType(seoul, IAgStkObject)) targets.Add(CType(wallops, IAgStkObject).Path) root.Rewind() Catch e As Exception MessageBox.Show(e.Message) End Try End Sub 'CreateSensors 2) Add the following to the variable declarations for the Form1 class: Private horizon As IAgSensor 3) Add the following case to the Select Case block in the SelectedIndexChanged() method for the combo box: Case "Create Sensors" CreateSensors() 4) Add a new sensor defined to have a 5 degree elevation requirement on visibility: Public Sub LimitSensorVisibility() Try 'Attach a sensor named "FiveDegElev" to the Wallops 'facility Dim fiveDegElev As IAgSensor = CType(root.CurrentScenario.Children("Wallops").Children.New(AgESTKObjectType.eSensor, "FiveDegElev"), IAgSensor) 'Define a Complex Conic sensor pattern with an outer 'cone half-angle of 85 to impose a 5 deg elevation 'requirement on the sensor's visibility fiveDegElev.SetPatternType(AgESnPattern.eSnComplexConic) Dim complexConic As IAgSnComplexConicPattern = CType(fiveDegElev.Pattern, IAgSnComplexConicPattern) complexConic.InnerConeHalfAngle = 0 complexConic.OuterConeHalfAngle = 85 complexConic.MinimumClockAngle = 0 complexConic.MaximumClockAngle = 360 'Point the sensor up with respect to the facility fiveDegElev.SetPointingType(AgESnPointing.eSnPtFixed) Dim fixedPt As IAgSnPtFixed = CType(fiveDegElev.Pointing, IAgSnPtFixed) Dim azEl As IAgOrientationAzEl = CType(fixedPt.Orientation.ConvertTo(AgEOrientationType.eAzEl), IAgOrientationAzEl) 'Good example of use of fine-grained interface; 'you are only setting elevation, not azimuth azEl.Elevation = 90 azEl.AboutBoresight = AgEAzElAboutBoresight.eAzElAboutBoresightRotate fixedPt.Orientation.Assign(azEl) 'Set the sensor's 2D Graphics projection properties 'so that it projects to a specified maximum altitude fiveDegElev.Graphics.Projection.DistanceType = AgESnProjectionDistanceType.eConstantAlt Dim dispDistance As IAgSnProjDisplayDistance = CType(fiveDegElev.Graphics.Projection.DistanceData, IAgSnProjDisplayDistance) dispDistance.Max = 785.248 dispDistance.Min = 0 dispDistance.NumberOfSteps = 1 root.Rewind() Catch e As Exception MessageBox.Show(e.Message) End Try End Sub 'LimitSensorVisibility 5) Add the following case to the Select Case block in the SelectedIndexChanged() method for the combo box: Case "Limit Sensor Visibility" LimitSensorVisibility() * ---------------------------------- * * SECTION: Control Display Intervals * * ---------------------------------- * LANGUAGE: C# ------------ 1) Add methods to increase the time period for the ERS1 satellite and to set custom and access display intervals: public void EnlargeTimePeriod() { //Increase the time period of the ERS1 satellite from //4 hrs to 24 hrs try { IAgVePropagatorJ4Perturbation j4 = (IAgVePropagatorJ4Perturbation)ers1.Propagator; j4.EphemerisInterval.SetStartAndStopTimes("1 Jul 2002 00:00:00.000", "2 Jul 2002 00:00:00.000"); j4.Propagate(); root.Rewind(); } catch(Exception e) { MessageBox.Show(e.Message); } } public void CustomDisplayIntervals() { //Define 2 time intervals in which the graphics display //of ERS1's ground and orbit tracks is altered try { ers1.Graphics.SetAttributesType(AgEVeGfxAttributes. eAttributesCustom); IAgVeGfxAttributesCustom customAtt = (IAgVeGfxAttributesCustom)ers1.Graphics.Attributes; //First Interval: 1/2 hour before noon //Color the tracks red and make the line thicker IAgVeGfxInterval gfxInterval = customAtt.Intervals.Add("1 Jul 2002 11:30:00.000", "1 Jul 2002 12:00:00.000"); gfxInterval.GfxAttributes.Color = System.Drawing.Color.Red; gfxInterval.GfxAttributes.IsVisible = true; gfxInterval.GfxAttributes.Inherit= true; gfxInterval.GfxAttributes.Line.Width = AgELineWidth.e3; //Second Interval: 1/2 hour before midnight //Color the tracks blue and make the line thicker gfxInterval = customAtt.Intervals.Add("1 Jul 2002 23:30:00.000", "1 Jul 2002 24:00:00.000"); gfxInterval.GfxAttributes.Color = System.Drawing.Color.Blue; gfxInterval.GfxAttributes.IsVisible = true; gfxInterval.GfxAttributes.Inherit = true; gfxInterval.GfxAttributes.Line.Width = AgELineWidth.e3; root.Rewind(); } catch(Exception e) { MessageBox.Show(e.Message); } } public void AccessDisplayIntervals() { //Configure the display of ERS1 and the Horizon sensor //to occur only during access to a facility try { //Assign the 5 facilities as access objects for ERS1 ers1.Graphics.SetAttributesType(AgEVeGfxAttributes. eAttributesAccess); IAgVeGfxAttributesAccess gfxAccess = (IAgVeGfxAttributesAccess)ers1.Graphics.Attributes; gfxAccess.AccessObjects.Add("Facility/Wallops"); gfxAccess.AccessObjects.Add("Facility/Seoul"); gfxAccess.AccessObjects.Add("Facility/Baikonur"); gfxAccess.AccessObjects.Add("Facility/Perth"); gfxAccess.AccessObjects.Add(((IAgStkObject)whitesands).Path); //Set ERS1's display properties for periods during //which there is no access to any facility IAgVeGfxAttributesOrbit orbitGfx = (IAgVeGfxAttributesOrbit)gfxAccess.NoAccess; orbitGfx.IsVisible = true; orbitGfx.Inherit = false; orbitGfx.IsGroundMarkerVisible = false; orbitGfx.IsOrbitMarkerVisible = false; //Set up the Horizon sensor to display only when //it has access to a facility IAgDisplayTm horizonDispTm = (IAgDisplayTm)horizon; horizonDispTm.SetDisplayStatusType(AgEDisplayTimesType. eDuringAccess); IAgDuringAccess duringAccess = (IAgDuringAccess)horizonDispTm.DisplayTimesData; IAgObjectLinkCollection accessObjects = duringAccess.AccessObjects; accessObjects.Add("Facility/Wallops"); accessObjects.Add("Facility/Seoul"); accessObjects.Add("Facility/Baikonur"); accessObjects.AddObject((IAgStkObject)perth); accessObjects.Add(((IAgStkObject)whitesands).Path); root.Rewind(); } catch(Exception e) { MessageBox.Show(e.Message); } } 2) Add the following else-if blocks to the SelectedIndexChanged() method for the combo box: else if (action == "Enlarge Time Period") { EnlargeTimePeriod(); } else if (action == "Custom Display Intervals") { CustomDisplayIntervals(); } else if(action == "Access Display Intervals") { AccessDisplayIntervals(); } LANGUAGE: VB.NET ---------------- 1) Add methods to increase the time period for the ERS1 satellite and to set custom and access display intervals: Public Sub EnlargeTimePeriod() 'Increase the time period of the ERS1 satellite from '4 hrs to 24 hrs Try Dim j4 As IAgVePropagatorJ4Perturbation = CType(ers1.Propagator, IAgVePropagatorJ4Perturbation) j4.EphemerisInterval.SetStartAndStopTimes("1 Jul 2002 00:00:00.000","2 Jul 2002 00:00:00.000") j4.Propagate() root.Rewind() Catch e As Exception MessageBox.Show(e.Message) End Try End Sub 'EnlargeTimePeriod Public Sub CustomDisplayIntervals() 'Define 2 time intervals in which the graphics display 'of ERS1's ground and orbit tracks is altered Try ers1.Graphics.SetAttributesType(AgEVeGfxAttributes.eAttributesCustom) Dim customAtt As IAgVeGfxAttributesCustom = CType(ers1.Graphics.Attributes, IAgVeGfxAttributesCustom) 'First Interval: 1/2 hour before noon 'Color the tracks red and make the line thicker Dim gfxInterval As IAgVeGfxInterval = customAtt.Intervals.Add("1 Jul 2002 11:30:00.000", "1 Jul 2002 12:00:00.000") gfxInterval.GfxAttributes.Color = System.Drawing.Color.Red gfxInterval.GfxAttributes.IsVisible = True gfxInterval.GfxAttributes.Inherit = True gfxInterval.GfxAttributes.Line.Width = AgELineWidth.e3 'Second Interval: 1/2 hour before midnight 'Color the tracks blue and make the line thicker gfxInterval = customAtt.Intervals.Add("1 Jul 2002 23:30:00.000", "1 Jul 2002 24:00:00.000") gfxInterval.GfxAttributes.Color = System.Drawing.Color.Blue gfxInterval.GfxAttributes.IsVisible = True gfxInterval.GfxAttributes.Inherit = True gfxInterval.GfxAttributes.Line.Width = AgELineWidth.e3 root.Rewind() Catch e As Exception MessageBox.Show(e.Message) End Try End Sub 'CustomDisplayIntervals Public Sub AccessDisplayIntervals() 'Configure the display of ERS1 and the Horizon sensor 'to occur only during access to a facility Try 'Assign the 5 facilities as access objects for ERS1 ers1.Graphics.SetAttributesType(AgEVeGfxAttributes.eAttributesAccess) Dim gfxAccess As IAgVeGfxAttributesAccess = CType(ers1.Graphics.Attributes, IAgVeGfxAttributesAccess) gfxAccess.AccessObjects.Add("Facility/Wallops") gfxAccess.AccessObjects.Add("Facility/Seoul") gfxAccess.AccessObjects.Add("Facility/Baikonur") gfxAccess.AccessObjects.Add("Facility/Perth") gfxAccess.AccessObjects.Add(CType(whitesands, IAgStkObject).Path) 'Set ERS1's display properties for periods during 'which there is no access to any facility Dim orbitGfx As IAgVeGfxAttributesOrbit = CType(gfxAccess.NoAccess, IAgVeGfxAttributesOrbit) orbitGfx.IsVisible = True orbitGfx.Inherit = False orbitGfx.IsGroundMarkerVisible = False orbitGfx.IsOrbitMarkerVisible = False 'Set up the Horizon sensor to display only when 'it has access to a facility Dim horizonDispTm As IAgDisplayTm = CType(horizon, IAgDisplayTm) horizonDispTm.SetDisplayStatusType(AgEDisplayTimesType.eDuringAccess) Dim duringAccess As IAgDuringAccess = CType(horizonDispTm.DisplayTimesData, IAgDuringAccess) Dim accessObjects As IAgObjectLinkCollection = duringAccess.AccessObjects accessObjects.Add("Facility/Wallops") accessObjects.Add("Facility/Seoul") accessObjects.Add("Facility/Baikonur") accessObjects.AddObject(CType(perth, IAgStkObject)) accessObjects.Add(CType(whitesands, IAgStkObject).Path) root.Rewind() Catch e As Exception MessageBox.Show(e.Message) End Try End Sub 'AccessDisplayIntervals 2) Add the following cases to the Select Case block in the SelectedIndexChanged() method for the combo box: Case "Enlarge Time Period" EnlargeTimePeriod() Case "Custom Display Intervals" CustomDisplayIntervals() Case "Access Display Intervals" AccessDisplayIntervals() * --------------------------------- * * SECTION: Apply Access Constraints * * --------------------------------- * LANGUAGE: C# ------------ 1) Add methods to compute sensor-to-facility access and impose 2 access constraints: public void FacilityAccess() { //Compute access from the Horizon sensor to Baikonur try { access = ((IAgStkObject)horizon).GetAccessToObject((IAgStkObject)baikonur); access.ComputeAccess(); root.Rewind(); } catch(Exception e) { MessageBox.Show(e.Message); } } public void AccessConstraintsRange() { //Constrain access from the Horizon sensor to Baikonur to //occur only when the distance between them <= 2000 km try { IAgAccessCnstrMinMax minMax = (IAgAccessCnstrMinMax)horizon.AccessConstraints. AddConstraint(AgEAccessConstraints.eCstrRange); minMax.EnableMax = true; minMax.Max = 2000; // Experiment with other values by uncommenting one // or more of the following lines: // minMax.Max = 1500; // minMax.Max = 1000; // minMax.Max = 500; root.Rewind(); } catch(Exception e) { MessageBox.Show(e.Message); } } public void AccessConstraintsSunElevationAngle() { //Constrain access from the Horizon sensor to Baikonur to //occur only when the elevation angle to the apparent //position of the sun >= 15 deg try { IAgAccessCnstrMinMax minMax = (IAgAccessCnstrMinMax)horizon.AccessConstraints. AddConstraint(AgEAccessConstraints.eCstrSunElevationAngle); minMax.EnableMin = true; minMax.Min = 15; // Experiment with other values by uncommenting one // or more of the following lines: // minMax.Min = 10; // minMax.Min = 5; // minMax.Min = 20; this.root.Rewind(); } catch(Exception e) { MessageBox.Show(e.Message); } } 2) Add the following else-if blocks to the SelectedIndexChanged() method for the combo box: else if(action == "Facility Access") { FacilityAccess(); } else if(action == "SunElevationAngle Constraint") { AccessConstraintsSunElevationAngle(); } else if(action == "Range Constraint") { AccessConstraintsRange(); } LANGUAGE: VB.NET ---------------- 1) Add methods to compute sensor-to-facility access and impose 2 access constraints: Public Sub FacilityAccess() 'Compute access from the Horizon sensor to Baikonur Try access = CType(horizon, IAgStkObject).GetAccessToObject(CType(baikonur, IAgStkObject)) access.ComputeAccess() root.Rewind() Catch e As Exception MessageBox.Show(e.Message) End Try End Sub 'FacilityAccess Public Sub AccessConstraintsRange() 'Constrain access from the Horizon sensor to Baikonur to 'occur only when the distance between them <= 2000 km Try Dim minMax As IAgAccessCnstrMinMax = CType(horizon.AccessConstraints.AddConstraint(AgEAccessConstraints.eCstrRange), IAgAccessCnstrMinMax) minMax.EnableMax = True minMax.Max = 2000 ' Experiment with other values by uncommenting one ' or more of the following lines: ' minMax.Max = 1500; ' minMax.Max = 1000; ' minMax.Max = 500; root.Rewind() Catch e As Exception MessageBox.Show(e.Message) End Try End Sub 'AccessConstraintsRange Public Sub AccessConstraintsSunElevationAngle() 'Constrain access from the Horizon sensor to Baikonur to 'occur only when the elevation angle to the apparent 'position of the sun >= 15 deg Try Dim minMax As IAgAccessCnstrMinMax = CType(horizon.AccessConstraints.AddConstraint(AgEAccessConstraints.eCstrSunElevationAngle), IAgAccessCnstrMinMax) minMax.EnableMin = True minMax.Min = 15 ' Experiment with other values by uncommenting one ' or more of the following lines: ' minMax.Min = 10 ' minMax.Min = 5 ' minMax.Min = 20 Me.root.Rewind() Catch e As Exception MessageBox.Show(e.Message) End Try End Sub 'AccessConstraintsSunElevationAngle 2) Add the following cases to the Select Case block in the SelectedIndexChanged() method for the combo box: Case "Facility Access" FacilityAccess() Case "SunElevationAngle Constraint" AccessConstraintsSunElevationAngle() Case "Range Constraint" AccessConstraintsRange()