Example #1
0
        private void DisplayUI()
        {
            // clear all previous results
            mtoTreeView.Nodes.Clear();

            // check if scenario is loaded
            if (m_root.CurrentScenario == null)
            {
                MessageBox.Show("Please load a scenario.");
            }
            else
            {
                // get all MTOs
                IAgStkObjectElementCollection mtos = m_root.CurrentScenario.Children.GetElements(AgESTKObjectType.eMTO);

                if (mtos.Count > 0)
                {
                    foreach (IAgStkObject thisMto in mtos)
                    {
                        TreeNode thisNode = mtoTreeView.Nodes.Add(thisMto.InstanceName);
                        thisNode.Checked = true;

                        // get tracks
                        IAgMto thisRealMto = thisMto as IAgMto;
                        foreach (IAgMtoTrack thisTrack in thisRealMto.Tracks)
                        {
                            TreeNode thisSubNode = thisNode.Nodes.Add(thisTrack.Id.ToString());
                            thisSubNode.Checked = true;
                        }
                    }
                }
            }
        }
        // update points pull-down to include all Facilities, Targets and Place
        private void trafficDirectionsTabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (trafficDirectionsTabControl.SelectedIndex == 1)
            {
                IAgStkObjectElementCollection facs = m_root.CurrentScenario.Children.GetElements(AgESTKObjectType.eFacility);
                IAgStkObjectElementCollection tgts = m_root.CurrentScenario.Children.GetElements(AgESTKObjectType.eTarget);
                IAgStkObjectElementCollection plcs = m_root.CurrentScenario.Children.GetElements(AgESTKObjectType.ePlace);

                fromObjectComboBox.Items.Clear();
                toObjectComboBox.Items.Clear();

                foreach (IAgStkObject thisFac in facs)
                {
                    fromObjectComboBox.Items.Add("Facility/" + thisFac.InstanceName);
                    toObjectComboBox.Items.Add("Facility/" + thisFac.InstanceName);
                }

                foreach (IAgStkObject thisTgt in tgts)
                {
                    fromObjectComboBox.Items.Add("Target/" + thisTgt.InstanceName);
                    toObjectComboBox.Items.Add("Target/" + thisTgt.InstanceName);
                }

                foreach (IAgStkObject thisPlc in plcs)
                {
                    fromObjectComboBox.Items.Add("Place/" + thisPlc.InstanceName);
                    toObjectComboBox.Items.Add("Place/" + thisPlc.InstanceName);
                }

                // populate default
                if (fromObjectComboBox.Items.Count > 0)
                {
                    fromObjectComboBox.SelectedIndex = 0;
                    toObjectComboBox.SelectedIndex   = 0;
                }
            }
        }
        private void InitGUI()
        {
            IAgStkObjectElementCollection allSats = m_root.CurrentScenario.Children.GetElements(AgESTKObjectType.eSatellite);

            int num_Sats = allSats.Count;

            if (num_Sats == 0)
            {
                // NO SATS IN SCENARIO
                STKHelper.CreateSat(m_satellite);
            }

            else
            {
                IAgSatellite temp = null;
                foreach (IAgStkObject obj in allSats)
                {
                    IAgSatellite currentSat = obj as IAgSatellite;
                    if (currentSat.PropagatorType == AgEVePropagatorType.ePropagatorJ2Perturbation)
                    {
                        temp = currentSat as IAgSatellite;
                    }
                }

                if (temp == null)
                {
                    STKHelper.CreateSat(m_satellite);
                }
                else
                {
                    m_satellite = temp;
                }
            }

            UpdateSelectSatComboBox();
            selectSatelliteComboBox_SelectedIndexChanged(null, null);
        }
        // update sliders to current value when new satellite is selected
        public void selectSatelliteComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            // get selected satellite orbital elements

            IAgStkObject old_m_satellite = SatelliteStkObject;

            HideVectors(SatelliteAgSatellite);

            IAgStkObjectElementCollection allSats = m_root.CurrentScenario.Children.GetElements(AgESTKObjectType.eSatellite);

            for (int i = 0; i < allSats.Count; ++i)
            {
                if (allSats[i].InstanceName == selectSatelliteComboBox.SelectedItem.ToString())
                {
                    m_satellite = allSats[i] as IAgSatellite;
                }
            }


            if (SatelliteStkObject.InstanceName != old_m_satellite.InstanceName)
            {
                HideVectors(old_m_satellite as AgSatellite);
            }



            IAgDrResult dpResults = SatelliteStkObject.DataProviders.GetDataPrvTimeVarFromPath("Classical Elements//ICRF").ExecSingle(SatelliteStkObject.ObjectCoverage.StartTime);

            coordTypeComboBox.SelectedItem = coordTypeComboBox.Items[1];

            // initiallize sliders
            orbElLabel1.Text         = "a";
            unitLabel1.Text          = "km";
            trackBar1.Minimum        = 6380;
            trackBar1.Maximum        = 50000;
            trackBar1.Value          = Convert.ToInt32(dpResults.DataSets.GetDataSetByName("Semi-major Axis").GetValues().GetValue(0));
            valueTextBox1.Text       = trackBar1.Value.ToString();
            checkBox_orbElt1.Visible = true;

            orbElLabel2.Text  = "e";
            unitLabel2.Text   = "";
            trackBar2.Minimum = 0;
            trackBar2.Maximum = 999;
            trackBar2.Value   = Convert.ToInt32(Convert.ToDouble(dpResults.DataSets.GetDataSetByName("Eccentricity").GetValues().GetValue(0)) * 1000.0);
            double val = Convert.ToDouble(trackBar2.Value) / 1000;

            valueTextBox2.Text       = val.ToString();
            checkBox_orbElt2.Visible = true;

            orbElLabel3.Text         = "i";
            unitLabel3.Text          = "deg";
            trackBar3.Minimum        = 0;
            trackBar3.Maximum        = 180;
            trackBar3.Value          = Convert.ToInt32(dpResults.DataSets.GetDataSetByName("Inclination").GetValues().GetValue(0));;
            valueTextBox3.Text       = trackBar3.Value.ToString();
            checkBox_orbElt3.Visible = true;

            orbElLabel4.Text         = "AoP";
            unitLabel4.Text          = "deg";
            trackBar4.Minimum        = 0;
            trackBar4.Maximum        = 360;
            trackBar4.Value          = Convert.ToInt32(dpResults.DataSets.GetDataSetByName("Arg of Perigee").GetValues().GetValue(0));
            valueTextBox4.Text       = trackBar4.Value.ToString();
            checkBox_orbElt4.Visible = true;

            orbElLabel5.Text         = "RAAN";
            unitLabel5.Text          = "deg";
            trackBar5.Minimum        = 0;
            trackBar5.Maximum        = 360;
            trackBar5.Value          = Convert.ToInt32(dpResults.DataSets.GetDataSetByName("RAAN").GetValues().GetValue(0));;
            valueTextBox5.Text       = trackBar5.Value.ToString();
            checkBox_orbElt5.Visible = true;

            orbElLabel6.Text         = "TA";
            unitLabel6.Text          = "deg";
            trackBar6.Minimum        = 0;
            trackBar6.Maximum        = 360;
            trackBar6.Value          = Convert.ToInt32(dpResults.DataSets.GetDataSetByName("True Anomaly").GetValues().GetValue(0));;
            valueTextBox6.Text       = trackBar6.Value.ToString();
            checkBox_orbElt6.Visible = true;

            orbElLabel7.Visible         = false;
            equinoctialComboBox.Visible = false;

            m_init = false;

            UpdateSTKHelper();
        }
Example #5
0
        public static void CreateCoverage(AgStkObjectRoot root, TLE tle)
        {
            try
            {
                IAgCoverageDefinition covDef = root.CurrentScenario.Children.New(AgESTKObjectType.eCoverageDefinition, "CovDef") as IAgCoverageDefinition;

                // add all target objects as assets
                IAgStkObjectElementCollection allChildrenOfType = root.CurrentScenario.Children.GetElements(AgESTKObjectType.eTarget);
                IAgCvAssetListCollection      assetCollection   = covDef.AssetList;
                foreach (IAgStkObject o in allChildrenOfType)
                {
                    string satAssetName = "Target/" + o.InstanceName;
                    assetCollection.Add(satAssetName);
                }

                covDef.Graphics.Static.IsPointsVisible = false;

                // set the grid resolution
                IAgCvGrid cvGrid = covDef.Grid;
                cvGrid.ResolutionType = AgECvResolution.eResolutionLatLon;
                IAgCvResolutionLatLon res = cvGrid.Resolution as IAgCvResolutionLatLon;
                res.LatLon = 1;

                // set the points altitude
                IAgCvPointDefinition pointDefinition = covDef.PointDefinition;
                pointDefinition.AltitudeMethod = AgECvAltitudeMethod.eAltitude;
                pointDefinition.Altitude       = 20.0;
                covDef.PointDefinition.GroundAltitudeMethod = AgECvGroundAltitudeMethod.eCvGroundAltitudeMethodUsePointAlt;

                // set the start/stop time
                DateTime startDate = tle.GetTleEpoch();
                DateTime stopDate  = startDate.AddMilliseconds(1);
                covDef.Interval.AnalysisInterval.SetExplicitInterval(startDate.ToString("dd MMM yyyy hh:mm:ss.fff"), stopDate.ToString("dd MMM yyyy hh:mm:ss.fff"));

                covDef.Advanced.AutoRecompute = false;
                covDef.ComputeAccesses();


                IAgFigureOfMerit fom = root.CurrentScenario.Children["CovDef"].Children.New(AgESTKObjectType.eFigureOfMerit, "Likelihood") as IAgFigureOfMerit;
                fom.SetDefinitionType(AgEFmDefinitionType.eFmNAssetCoverage);
                fom.Graphics.Animation.IsVisible     = false;
                fom.Graphics.Static.FillTranslucency = 20;
                IAgFmGfxContours contours = fom.Graphics.Static.Contours;
                contours.IsVisible   = true;
                contours.ContourType = AgEFmGfxContourType.eSmoothFill;
                contours.ColorMethod = AgEFmGfxColorMethod.eExplicit;
                contours.LevelAttributes.RemoveAll();

                IAgFmGfxLevelAttributesElement level1 = contours.LevelAttributes.AddLevel(1);
                IAgFmGfxLevelAttributesElement level2 = contours.LevelAttributes.AddLevel(2);
                IAgFmGfxLevelAttributesElement level3 = contours.LevelAttributes.AddLevel(3);
                IAgFmGfxLevelAttributesElement level4 = contours.LevelAttributes.AddLevel(4);

                level1.Color = Color.Khaki;
                level2.Color = Color.Gold;
                level3.Color = Color.Orange;
                level4.Color = Color.Red;

                root.ExecuteCommand("Graphics */CoverageDefinition/CovDef/FigureOfMerit/Likelihood SmoothFillParameters NNSampleMode Smooth");
            }
            catch (Exception)
            {
                throw new Exception();
            }
        }