コード例 #1
0
        //#####################################################################
        /// <summary>
        /// 创建新场景(若已有场景,则保存并关闭)
        /// </summary>
        public static void CreateScenario(string SceneName)
        {
            try
            {
                //首先保存并关闭当前场景
                SaveCloseScenario();

                //创建新场景
                StkObjectHelper.stkRoot.NewScenario(SceneName);
                Application.DoEvents();

                // Reset the units to the STKpara defaults
                IAgUnitPrefsDimCollection dimensions = StkObjectHelper.stkRoot.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)StkObjectHelper.stkRoot.CurrentScenario;

                scene.StartTime           = "1 Jul 2011 06:00:00.000";
                scene.StopTime            = "2 Jul 2011 00:00:00.000";
                scene.Epoch               = "1 Jan 2011 06:00:00.000";
                scene.Animation.StartTime = "1 Jan 2011 06:00:00.000";

                StkObjectHelper.stkRoot.Rewind();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "创建场景出错!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #2
0
        public NewGroundEventForm()
        {
            InitializeComponent();
            _contactEvent       = new GroundEvent();
            ManualSSR.Checked   = true;
            SSRFromFile.Checked = false;
            FileText.Enabled    = false;
            Browse.Enabled      = false;

            foreach (var type in CommonData.Preferences.EventTypeList)
            {
                TypeSelect.Items.Add(type);
            }
            TypeSelect.SelectedIndex = 0;

            IAgScenario scenario = (IAgScenario)CommonData.StkRoot.CurrentScenario;

            StartTimeText.Text   = scenario.StartTime;
            StopTimeText.Text    = scenario.StopTime;
            ImportActive.Checked = true;
            IDText.Text          = "NewEvent";
            Latitude.Text        = "0";
            Longitude.Text       = "0";
            CountryText.Text     = "Global";

            foreach (string c in Enum.GetNames(typeof(CustomUserInterface.ColorOptions)))
            {
                ColorSelection.Items.Add(c);
                SheetColor.Items.Add(c);
            }
            ColorSelection.SelectedIndex = 0;
            SheetColor.SelectedIndex     = 0;
        }
コード例 #3
0
        public NewAssetForm()
        {
            InitializeComponent();
            filter1 = new FilterConfig();
            filter1.SelectedOptions = new List <string>();
            filter2 = new FilterConfig();
            filter2.SelectedOptions = new List <string>();
            filter3 = new FilterConfig();
            filter3.SelectedOptions = new List <string>();
            SMAValue.Enabled        = false;
            EccValue.Enabled        = false;
            IncValue.Enabled        = false;
            RAANValue.Enabled       = false;
            AoPValue.Enabled        = false;
            TAValue.Enabled         = false;
            NameValue.Enabled       = false;
            DatabaseBox.Visible     = false;
            ElementsBox.Visible     = false;


            PopulateExistingConstellations();
            _selectedSatList            = new List <string>();
            CommonData.SatCatItemList   = new List <SatCatItem>();
            CommonData.MetadataTypeList = new List <string>();
            CommonData.MetadataOptions1 = new List <string>();
            CommonData.MetadataOptions2 = new List <string>();
            CommonData.MetadataOptions3 = new List <string>();
            CommonData.MetadataOptions4 = new List <string>();
            CommonData.MetadataOptions5 = new List <string>();
            CommonData.SatCatFofo       = new List <string>();

            CoordSystem.Items.Add("Fixed");
            CoordSystem.Items.Add("Inertial");
            CoordSystem.SelectedIndex = 1;

            ImportType.Items.Add("Orbital Elements");
            ImportType.Items.Add("TLE/TCE");
            ImportType.Items.Add("Ephemeris");
            ImportType.Items.Add("Satellite Database");
            ImportType.SelectedIndex = 3;

            ConstType.Items.Add("Default Constellation");
            ConstType.Items.Add("Existing Constellation");
            ConstType.Items.Add("New Constellation");
            ConstType.SelectedIndex = 0;
            ConstName.Enabled       = false;
            ConstName.Visible       = false;
            NameLabel.Visible       = false;
            ExistingConst.Enabled   = false;
            ExistingConst.Visible   = false;

            TimeSlip.Enabled = false;
            TimeSlip.Visible = false;
            SlipTime.Visible = false;
            label17.Visible  = false;

            IAgScenario scenario = CommonData.StkRoot.CurrentScenario as IAgScenario;

            SlipTime.Text = scenario.StartTime.ToString();
        }
コード例 #4
0
        //pulls data providers for the aircraft in ICRF frame
        public static List <Array> GetAttitudeData(IAgStkObject obj, double startTime, double timeStep)
        {
            List <Array>           attitudeData = new List <Array>();
            IAgScenario            scenario     = CommonData.StkRoot.CurrentScenario as IAgScenario;
            IAgDrDataSetCollection datasets     = null;

            if (CommonData.objectClass == "Aircraft")
            {
                IAgDataProviderGroup attitudeDP1 = obj.DataProviders["Body Axes Orientation:YPR 321"] as IAgDataProviderGroup;
                IAgDataPrvTimeVar    attitudeDP2 = attitudeDP1.Group["ICRF"] as IAgDataPrvTimeVar;
                IAgDrResult          result      = attitudeDP2.Exec(startTime, scenario.StopTime, timeStep);
                datasets = result.DataSets;
            }
            else if (CommonData.objectClass == "Satellite")
            {
                IAgDataProviderGroup attitudeDP1 = obj.DataProviders["Attitude YPR"] as IAgDataProviderGroup;
                IAgDataPrvTimeVar    attitudeDP2 = attitudeDP1.Group["Seq YPR"] as IAgDataPrvTimeVar;
                IAgDrResult          result      = attitudeDP2.Exec(startTime, scenario.StopTime, timeStep);
                datasets = result.DataSets;
            }

            for (int i = 0; i < datasets.Count; i++)
            {
                attitudeData.Add(datasets[i].GetValues());
            }

            return(attitudeData);
        }
コード例 #5
0
        //populates some form values, gets scenario timeframe
        private void InitConnection()
        {
            if (!_stkconnected)
            {
                // Get reference to running STK instance
                _uiApp = System.Runtime.InteropServices.Marshal.GetActiveObject("STK11.Application") as AgUiApplication;

                // Get our IAgStkObjectRoot interface
                _stkRoot      = _uiApp.Personality2 as AgStkObjectRoot;
                _zscen        = _stkRoot.CurrentScenario as IAgScenario;
                _stkconnected = true;

                dtp_start.Value = DateTime.ParseExact(_zscen.StartTime, ParsingFormats, null, System.Globalization.DateTimeStyles.None);
                dtp_end.Value   = DateTime.ParseExact(_zscen.StopTime, ParsingFormats, null, System.Globalization.DateTimeStyles.None);

                //btn_refresh.BackColor = Color.LimeGreen;
            }
            else
            {
                //refresh scenario times
                dtp_start.Value = DateTime.ParseExact(_zscen.StartTime, ParsingFormats, null, System.Globalization.DateTimeStyles.None);
                dtp_end.Value   = DateTime.ParseExact(_zscen.StopTime, ParsingFormats, null, System.Globalization.DateTimeStyles.None);
            }


            if (string.IsNullOrEmpty(_workingUserDirectory))
            {
                //get user directory for working purposes
                IAgExecCmdResult conRes = _stkRoot.ExecuteCommand(@"GetDirectory / UserData");
                _workingUserDirectory = conRes[0];
            }

            SafelyUpdateLabel("Connected and using: " + Environment.NewLine + _workingUserDirectory);
        }
コード例 #6
0
        public static void Initialize()
        {
            if (!DefaultsSet)
            {
                SetInitialConditions();
            }

            _stkApplication = System.Runtime.InteropServices.Marshal.GetActiveObject("STK11.Application");
            _root           = _stkApplication.GetType().InvokeMember("Personality2", System.Reflection.BindingFlags.GetProperty, null, _stkApplication, null) as AgStkObjectRoot;

            if (!_root.CurrentScenario.Children.GetElements(AgESTKObjectType.eAircraft).Contains(AircraftName))
            {
                _root.CurrentScenario.Children.New(AgESTKObjectType.eAircraft, AircraftName);
            }

            _root.ExecuteCommand("SetUnits / EPOCHSEC");//   %sets date format to epochsec
            _root.ExecuteCommand($"Realtime */Aircraft/{AircraftName} SetProp");
            _root.ExecuteCommand($"SetAttitude */Aircraft/{AircraftName} RealTime Extrapolate 100 200");

            try
            {
                _root.ExecuteCommand($"SetAttitude */Aircraft/{AircraftName} DATAREFERENCE Fixed QUAT 0 0 0 1 \"Aircraft/{AircraftName} FlightPath\"");
                _root.ExecuteCommand($"VO */Aircraft/{AircraftName} Model File \"C:\\Program Files\\AGI\\STK 11\\STKData\\VO\\Models\\Air\\rq-1a_predator.mdl\"");
            }
            catch
            {
            }

            _scen       = (IAgScenario)_root.CurrentScenario;
            _scen.Epoch = "Today";
            _root.PlayForward();
        }
コード例 #7
0
        private void Ephem2Text(string filePath, Array times, IAgScenario scen, IAgStkObject ephemObject, string coordSys, Array x,
                                Array y, Array z, Array xVel, Array yVel, Array zVel)
        {
            // Print ephem data to text file
            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }
            using (StreamWriter sw = File.CreateText(filePath))
            {
                var ephemLength = times.Length;
                sw.WriteLine("stk.v.5.0");
                sw.WriteLine("BEGIN Ephemeris");
                sw.WriteLine("NumberOfEphemerisPoints    " + ephemLength.ToString());
                var StartTimeUTCG = CommonData.StkRoot.ConversionUtility.ConvertDate("EpSec", "UTCG", scen.StartTime.ToString());
                sw.WriteLine("ScenarioEpoch         " + StartTimeUTCG);
                if ((ephemObject.ClassName == "Missile") || (ephemObject.ClassName == "LaunchVehicle"))
                {
                    sw.WriteLine("InterpolationMethod       Lagrange");
                    sw.WriteLine("InterpolationSamplesM1        5");
                }
                else if (ephemObject.ClassName == "Satellite")
                {
                    sw.WriteLine("InterpolationSamplesM1        7");
                }
                else
                {
                    try
                    {
                        var ephemObjAC = ephemObject as IAgAircraft;
                        if (ephemObjAC.RouteType.ToString() == "ePropagatorAviator")
                        {
                            sw.WriteLine("InterpolationMethod       Hermite");
                        }
                    }

                    catch
                    {
                        if (coordSys == "CentralBody/Earth Fixed")
                        {
                            sw.WriteLine("InterpolationMethod       GreatArc");
                        }
                    }
                    sw.WriteLine("InterpolationSamplesM1        1");
                }
                sw.WriteLine("DistanceUnit      Kilometers");
                sw.WriteLine("CentralBody        " + ephemObject.CentralBodyName);
                string[] objs = coordSys.Split(' ');
                sw.WriteLine("CoordinateSystem       Custom " + objs[1] + " " + objs[0]);
                sw.WriteLine("EphemerisTimePosVel");
                for (int k = 0; k < ephemLength; k++)
                {
                    sw.WriteLine("{0}   {1}   {2}   {3}   {4}   {5}   {6}", times.GetValue(k), x.GetValue(k),
                                 y.GetValue(k), z.GetValue(k), xVel.GetValue(k), yVel.GetValue(k), zVel.GetValue(k));
                }
                sw.WriteLine("END Ephemeris");
            }
        }
コード例 #8
0
        public ModelUpdateClass(IAgStkObjectRoot root)
        {
            m_root = root;
            m_root.UnitPreferences["DateFormat"].SetCurrentUnit("EpSec");
            IAgScenario scenario = (IAgScenario)m_root.CurrentScenario;

            m_scene = scenario.SceneManager as AgStkGraphicsSceneManager;

            objectTypeArray.Add(AgESTKObjectType.eAircraft);
            objectTypeArray.Add(AgESTKObjectType.eFacility);
            objectTypeArray.Add(AgESTKObjectType.eGroundVehicle);
            objectTypeArray.Add(AgESTKObjectType.eLaunchVehicle);
            objectTypeArray.Add(AgESTKObjectType.eMissile);
            objectTypeArray.Add(AgESTKObjectType.eSatellite);
            objectTypeArray.Add(AgESTKObjectType.eShip);

            for (int i = 0; i < m_scene.Scenes.Count; i++)
            {
                ((AgStkGraphicsScene)m_scene.Scenes[i]).Rendering += new IAgStkGraphicsSceneEvents_RenderingEventHandler(ModelUpdateClass_Rendering);
            }
            foreach (AgESTKObjectType objectType in objectTypeArray)
            {
                foreach (IAgStkObject objectInstance in m_root.CurrentScenario.Children.GetElements(objectType))
                {
                    if (objectType == AgESTKObjectType.eAircraft)
                    {
                        ((IAgAircraft)objectInstance).VO.Model.DetailThreshold.EnableDetailThreshold = false;
                    }
                    else if (objectType == AgESTKObjectType.eFacility)
                    {
                        ((IAgFacility)objectInstance).VO.Model.DetailThreshold.EnableDetailThreshold = false;
                    }
                    else if (objectType == AgESTKObjectType.eGroundVehicle)
                    {
                        ((IAgGroundVehicle)objectInstance).VO.Model.DetailThreshold.EnableDetailThreshold = false;
                    }
                    else if (objectType == AgESTKObjectType.eLaunchVehicle)
                    {
                        ((IAgLaunchVehicle)objectInstance).VO.Model.DetailThreshold.EnableDetailThreshold = false;
                    }
                    else if (objectType == AgESTKObjectType.eMissile)
                    {
                        ((IAgMissile)objectInstance).VO.Model.DetailThreshold.EnableDetailThreshold = false;
                    }
                    else if (objectType == AgESTKObjectType.eSatellite)
                    {
                        ((IAgSatellite)objectInstance).VO.Model.DetailThreshold.EnableDetailThreshold = false;
                    }
                    else if (objectType == AgESTKObjectType.eShip)
                    {
                        ((IAgShip)objectInstance).VO.Model.DetailThreshold.EnableDetailThreshold = false;
                    }
                }
            }

            magDiff     = new Dictionary <string, double>();
            scaleFactor = 1;
        }
コード例 #9
0
        private void cbStkObjects_SelectedIndexChanged(object sender, EventArgs e)
        {
            string simpleName;
            string className;

            Events.Items.Clear();
            //Change options in Events box
            StringCollection objectPaths = m_stkObjectsLibrary.GetObjectPathListFromInstanceNamesXml(CommonData.StkRoot.AllInstanceNamesToXML(), "");

            simpleName = cbStkObjects.Text;

            foreach (string path in objectPaths)
            {
                string objectName = m_stkObjectsLibrary.ObjectName(path);
                className = m_stkObjectsLibrary.ClassNameFromObjectPath(path);
                if (objectName == simpleName && className != "Scenario")
                {
                    className = m_stkObjectsLibrary.ClassNameFromObjectPath(path);
                    string       objectPath = className + "/" + simpleName;
                    IAgStkObject obj        = CommonData.StkRoot.GetObjectFromPath(objectPath);

                    events = obj.Vgt.Events;
                    int eventCount = obj.Vgt.Events.Count;

                    for (int i = 0; i < eventCount; i++)
                    {
                        IAgCrdn currentEvent = (IAgCrdn)events[i];
                        Events.Items.Add(currentEvent.Name);
                    }
                }
            }
            if (cbStkObjects.Text.Contains("Access"))
            {
                IAgScenario scenario = CommonData.StkRoot.CurrentScenario as IAgScenario;
                Array       accesses = scenario.GetExistingAccesses();

                int numAccesses = accesses.GetLength(0);
                for (int i = 0; i < numAccesses; i++)
                {
                    string object1      = accesses.GetValue(i, 0).ToString();
                    string shortobject1 = object1.Substring(object1.IndexOf('/') + 1);
                    string object2      = accesses.GetValue(i, 1).ToString();
                    string shortobject2 = object2.Substring(object2.IndexOf('/') + 1);

                    if (cbStkObjects.Text.Contains(shortobject1) && cbStkObjects.Text.Contains(shortobject2))
                    {
                        IAgStkAccess access = scenario.GetAccessBetweenObjectsByPath(object1, object2);
                        accessEvents = access.Vgt.Events;
                        for (int j = 0; j < accessEvents.Count; j++)
                        {
                            IAgCrdn currentEvent = (IAgCrdn)accessEvents[j];
                            Events.Items.Add(currentEvent.Name);
                        }
                    }
                }
            }
        }
コード例 #10
0
        //Get all events in scenario
        public static List <IAgCrdn> GetAllEventInstances()
        {
            StkObjectsLibrary m_stkObjectsLibrary = new StkObjectsLibrary();
            List <IAgCrdn>    events = new List <IAgCrdn>();

            IAgScenario scenario = CommonData.StkRoot.CurrentScenario as IAgScenario;

            //Get all access events available in scenario
            Array accesses    = scenario.GetExistingAccesses();
            int   numAccesses = accesses.GetLength(0);

            for (int i = 0; i < numAccesses; i++)
            {
                string object1      = accesses.GetValue(i, 0).ToString();
                string shortobject1 = object1.Substring(object1.IndexOf('/') + 1);
                string object2      = accesses.GetValue(i, 1).ToString();
                string shortobject2 = object2.Substring(object2.IndexOf('/') + 1);

                IAgStkAccess      access       = scenario.GetAccessBetweenObjectsByPath(object1, object2);
                IAgCrdnEventGroup accessEvents = access.Vgt.Events;
                for (int j = 0; j < accessEvents.Count; j++)
                {
                    IAgCrdn currentEvent = (IAgCrdn)accessEvents[j];
                    events.Add(currentEvent);
                }
            }
            //Get all object events available in scenario
            string simpleName;
            string className;

            foreach (string path in CommonData.objectPaths)
            {
                int instanceNameStartPos = path.LastIndexOf("/") + 1;
                simpleName = path.Substring(instanceNameStartPos);
                className  = m_stkObjectsLibrary.ClassNameFromObjectPath(path);
                string       objectPath = className + "/" + simpleName;
                IAgStkObject obj        = null;
                try
                {
                    obj = CommonData.StkRoot.GetObjectFromPath(objectPath);
                    IAgCrdnEventGroup eventGroup = obj.Vgt.Events;
                    int eventCount = obj.Vgt.Events.Count;

                    for (int i = 0; i < eventCount; i++)
                    {
                        IAgCrdn currentEvent = (IAgCrdn)eventGroup[i];
                        events.Add(currentEvent);
                    }
                }
                catch (Exception)
                {
                }
            }
            return(events);
        }
コード例 #11
0
        public SatelliteEpochUpdatePlugin()
        {
            InitializeComponent();
            _satelliteUpdateList = new List <string>();
            ASTGRunCheck.Checked = false;
            _cScenario           = CommonData.StkRoot.CurrentScenario as IAgScenario;

            dtp_start.Value = Convert.ToDateTime(_cScenario.StartTime.ToString());
            dtp_end.Value   = Convert.ToDateTime(_cScenario.StopTime.ToString());

            CreatorFunctions.PopulateObjectListByClass(SatelliteList, "Satellite");
        }
コード例 #12
0
ファイル: Setup.cs プロジェクト: sarthakAGI/STKCodeExamples
        public void OnMouseClick(IAgUiPlugin3DMouseEventArgs eventArgs, IAgUiPlugin3DNotifyContext context)
        {
            Array       position = new object[] { eventArgs.X, eventArgs.Y };
            IAgScenario scenario = (IAgScenario)CommonData.StkRoot.CurrentScenario;
            IAgStkGraphicsSceneManager sceneManager = scenario.SceneManager;
            IAgStkGraphicsScene        scene        = scenario.SceneManager.Scenes[eventArgs.SceneID - 1];

            //object[] cartographic = (object[])scene.Camera.WindowToCartographic("Earth", ref position);
            //string latitudeString = cartographic.GetValue(0).ToString();
            //string longitudeString = cartographic.GetValue(1).ToString();
            //double altitude = double.Parse(cartographic.GetValue(1).ToString());

            //NOTE:
            //If the angle unit is set to HMS or DMS, latitude and longitude string might not be directly converted to doubles.
        }
コード例 #13
0
        static double GetObjStopTime(IAgStkObject ephemObject, IAgScenario scen, string objectPath)
        {
            double stopTime;

            try
            {
                var provider = ephemObject.DataProviders["Time Instant"] as IAgDataProviderGroup;
                stopTime = ((IAgDataPrvInterval)provider.Group["AvailabilityStopTime"]).Exec(scen.StartTime, scen.StopTime).DataSets.GetDataSetByName("Time Instant").GetValues().GetValue(0);
            }
            catch
            {
                // If error occurs above, object is Ship, Ground Vehicle or Aircraft object
                var provider = CommonData.StkRoot.VgtRoot.GetProvider(objectPath);
                stopTime = provider.Events["EphemerisStopTime"].FindOccurrence().Epoch;
            }
            return(stopTime);
        }
コード例 #14
0
ファイル: STK.cs プロジェクト: xiaozangyu/STKCodeExamples
        public static void ConfigurePropagator(AgStkObjectRoot root)
        {
            try
            {
                // duplicate the default HPOP propagator % works good
                //root.ExecuteCommand("ComponentBrowser */ Duplicate Propagators \"Earth HPOP Default v10\" \"CustomProp\"");
                //root.ExecuteCommand("ComponentBrowser */ SetValue Propagators \"CustomProp\" PropFuncs.Gravitational_Force.Degree 70");
                //root.ExecuteCommand("ComponentBrowser */ SetValue Propagators \"CustomProp\" PropFuncs.Gravitational_Force.Order 70");
                //root.ExecuteCommand("ComponentBrowser */ SetValue Propagators \"CustomProp\" PropFuncs.Jacchia-Roberts.AtmosDataSource \"Data File\"");


                // load external propagators
                IAgScenario scen            = root.CurrentScenario as IAgScenario;
                string      propagatorsPath = Directory.GetCurrentDirectory() + "\\Propagators\\";
                scen.ComponentDirectory.GetComponents(AgEComponent.eComponentAstrogator).GetFolder("Propagators").LoadComponent(propagatorsPath + "NRLMSISE 2000.propagator");
                scen.ComponentDirectory.GetComponents(AgEComponent.eComponentAstrogator).GetFolder("Propagators").LoadComponent(propagatorsPath + "Jacchia-Roberts.propagator");
            }
            catch { }
        }
コード例 #15
0
        void PopulateComboBox()
        {
            string           simpleName;
            string           className;
            StringCollection objectNames = m_stkObjectsLibrary.GetObjectPathListFromInstanceNamesXml(CommonData.StkRoot.AllInstanceNamesToXML(), "");

            foreach (string objectName in objectNames)
            {
                className = m_stkObjectsLibrary.ClassNameFromObjectPath(objectName);

                if (className != "Scenario")
                {
                    simpleName = m_stkObjectsLibrary.ObjectName(objectName);
                    cbStkObjects.Items.Add(simpleName);
                }
            }

            if (cbStkObjects.Items.Count > 0)
            {
                cbStkObjects.SelectedIndex = 0;
            }
            IAgScenario scenario = CommonData.StkRoot.CurrentScenario as IAgScenario;
            Array       accesses = scenario.GetExistingAccesses();

            //Add accesses to list
            int numAccesses = accesses.GetLength(0);

            for (int i = 0; i < numAccesses; i++)
            {
                string object1 = accesses.GetValue(i, 0).ToString();
                object1 = object1.Substring(object1.IndexOf('/') + 1);
                string object2 = accesses.GetValue(i, 1).ToString();
                object2 = object2.Substring(object2.IndexOf('/') + 1);

                //IAgStkAccess access = scenario.GetAccessBetweenObjectsByPath(object1, object2);
                cbStkObjects.Items.Add("Access from " + object1 + " to " + object2);
            }
        }
コード例 #16
0
        public NewGroundEventForm()
        {
            InitializeComponent();

            ManualSSR.Checked = true;
            SSRFromFile.Checked = false;
            FileText.Enabled = false;
            Browse.Enabled = false;

            foreach (var type in CommonData.Preferences.EventTypeList)
            {
                TypeSelect.Items.Add(type);
            }
            TypeSelect.SelectedIndex = 0;

            IAgScenario scenario = (IAgScenario)CommonData.StkRoot.CurrentScenario;
            StartTimeText.Text = scenario.StartTime;
            StopTimeText.Text = scenario.StopTime;
            ImportActive.Checked = true;
            IDText.Text = "NewEvent";
            Latitude.Text = "0";
            Longitude.Text = "0";
            CountryText.Text = "Global";
        }
コード例 #17
0
        private void Create_Click(object sender, EventArgs e)
        {
            string className;
            int    check;

            if (TypeSelect.SelectedIndex == 0) //3D
            {
                check = FieldCheck3D();
                if (check == 0)
                {
                    current.WindowName     = WindowSelect.Text;
                    current.WindowId       = SmartViewFunctions.GetWindowId(WindowSelect.Text, 1);
                    current.Name           = ViewName3D.Text;
                    current.ViewType       = TypeSelect.Text;
                    current.ViewObjectData = CommonData.CurrentViewObjectData;
                    className          = SmartViewFunctions.GetClassName(FocusedItem.Text);
                    current.ViewTarget = className + "/" + FocusedItem.Text;
                    current.ViewAxes   = "Inertial";

                    if (EnableUniversalOrbitTrack.Checked)
                    {
                        if (UniversalLeadTrail.Checked)
                        {
                            current.EnableUniversalOrbitTrack = true;
                            current.UniqueLeadTrail           = false;
                            if (LeadType3D.Text == "Time")
                            {
                                current.LeadType = LeadType3D.Text;
                                current.LeadTime = OrbitLeadTime.Text;
                            }
                            else
                            {
                                current.LeadType = LeadType3D.Text;
                            }

                            if (TrailType3D.Text == "Time")
                            {
                                current.TrailType = TrailType3D.Text;
                                current.TrailTime = OrbitTrailTime.Text;
                            }
                            else
                            {
                                current.TrailType = TrailType3D.Text;
                            }
                        }
                        else if (UniqueLeadTrail.Checked)
                        {
                            current.UniqueLeadTrail           = true;
                            current.EnableUniversalOrbitTrack = true;
                        }
                    }
                    else
                    {
                        current.EnableUniversalOrbitTrack = false;
                        current.LeadType  = "None";
                        current.TrailType = "None";
                    }

                    //Add required primary data display components
                    if (UseDataDisplay.Checked)
                    {
                        current.PrimaryDataDisplay.DataDisplayActive = true;
                    }
                    else
                    {
                        current.PrimaryDataDisplay.DataDisplayActive = false;
                    }
                    current.PrimaryDataDisplay.DataDisplayLocation = DisplayLocation.Text;
                    className = SmartViewFunctions.GetClassName(DisplayObject.Text);
                    current.PrimaryDataDisplay.DataDisplayObject     = className + "/" + DisplayObject.Text;
                    current.PrimaryDataDisplay.DataDisplayReportName = DisplayReport.Text;
                    className = SmartViewFunctions.GetClassName(PredataObject.Text);
                    current.PrimaryDataDisplay.PredataObject = className + "/" + PredataObject.Text;

                    //Define stored view if required by current view point option
                    if (UseCurrentViewPoint.Checked)
                    {
                        current.UseStoredView  = true;
                        current.StoredViewName = ViewName3D.Text;
                        CommonData.StkRoot.ExecuteCommand("VO * SaveStoredView \"" + ViewName3D.Text + "\" " + current.WindowId);
                    }
                    else
                    {
                        current.UseStoredView  = false;
                        current.StoredViewName = "None";
                    }
                }
            }
            else if (TypeSelect.SelectedIndex == 1) //2D
            {
                check = FieldCheck2D();
                if (check == 0)
                {
                    current.WindowName     = WindowSelect.Text;
                    current.WindowId       = SmartViewFunctions.GetWindowId(WindowSelect.Text, 0);
                    current.ViewObjectData = CommonData.CurrentViewObjectData;
                    current.Name           = ViewName2D.Text;
                    current.ViewType       = TypeSelect.Text;
                    current.ViewType2D     = TypeSelect2D.Text;
                    className               = SmartViewFunctions.GetClassName(ObjectName2D.Text);
                    current.ViewTarget      = className + "/" + ObjectName2D.Text;
                    current.ZoomCenterLat   = ZoomCenterLat.Text;
                    current.ZoomCenterLong  = ZoomCenterLong.Text;
                    current.ZoomCenterDelta = ZoomDelta.Text;

                    if (EnableUniversalGroundTrack.Checked)
                    {
                        if (LeadType2D.Text == "Time")
                        {
                            current.LeadType = LeadType2D.Text + " " + GroundLeadTime.Text;
                            current.LeadTime = GroundLeadTime.Text;
                        }
                        else
                        {
                            current.LeadType = LeadType2D.Text;
                        }

                        if (TrailType2D.Text == "Time")
                        {
                            current.TrailType = TrailType2D.Text + " " + GroundTrailTime.Text;
                            current.TrailTime = GroundTrailTime.Text;
                        }
                        else
                        {
                            current.TrailType = TrailType2D.Text;
                        }
                    }
                    else
                    {
                        current.LeadType  = "None";
                        current.TrailType = "None";
                    }
                }
            }
            if (UseCurrentTime.Checked)
            {
                current.UseAnimationTime = true;
                IAgAnimation animationRoot = (IAgAnimation)CommonData.StkRoot;
                double       currentTime   = animationRoot.CurrentTime;
                string       newTime       = CommonData.StkRoot.ConversionUtility.ConvertDate("EpSec", "UTCG", currentTime.ToString());
                current.AnimationTime = newTime.ToString();
            }
            else
            {
                current.UseAnimationTime = false;
                IAgScenario scenario = (IAgScenario)(CommonData.StkRoot.CurrentScenario);
                current.AnimationTime = scenario.StartTime;
            }
            if (ObjectHideShow.Checked)
            {
                current.ObjectHideShow = true;
                List <ObjectData> data = new List <ObjectData>();
                data = CommonData.CurrentViewObjectData;
                current.ViewObjectData = data;
            }
            else
            {
                current.ObjectHideShow = false;
            }
            if (UseVectorHideShow.Checked)
            {
                current.VectorHideShow = true;
            }
            else
            {
                current.VectorHideShow = false;
            }

            if (UseCameraPath.Checked)
            {
                current.UseCameraPath  = true;
                current.CameraPathName = CameraPathName.Text;
            }
            else
            {
                current.UseCameraPath = false;
            }
            CommonData.SavedViewList.Add(current);
            try
            {
                ReadWrite.WriteSavedViews(CommonData.DirectoryStr + "\\StoredViewData.json");
            }
            catch (Exception)
            {
                MessageBox.Show("Could not Write Stored Views File");
            }

            //try
            //{
            //    ReadWrite.WriteObjectData(CommonData.DirectoryStr + "\\StoredObjectData.txt");
            //}
            //catch (Exception)
            //{

            //    MessageBox.Show("Could not Write Object Data File");
            //}
            CommonData.NewView = true;
            this.Close();
        }
コード例 #18
0
        private void Apply_Click(object sender, EventArgs e)
        {
            ViewData current = new ViewData();

            current.WindowName     = WindowSelect.Text;
            current.ViewType       = "Target/Threat";
            current.ThreatSatNames = _threatNames;
            string className = SmartViewFunctions.GetClassName(TargetSatellite.Text);

            current.TargetSatellite = className + "/" + TargetSatellite.Text;
            current.Name            = TTViewName.Text;

            if (TTUseDataDisplay.Checked)
            {
                current.TtDataDisplayActive   = true;
                current.TtDataDisplayLocation = TTDisplayLocation.Text;
                if (TTDisplayObject.SelectedIndex == 0)
                {
                    className = SmartViewFunctions.GetClassName(TargetSatellite.Text);
                    current.TtDataDisplayObject     = className + "/" + TargetSatellite.Text;
                    current.TtDataDisplayReportName = TTDisplayReport.Text;
                }
                else if (TTDisplayObject.SelectedIndex == 1)
                {
                    current.TtDataDisplayObject     = "AllThreat";
                    current.TtDataDisplayReportName = TTDisplayReport.Text;
                }
                else
                {
                    className = SmartViewFunctions.GetClassName(TTDisplayObject.Text);
                    current.TtDataDisplayObject     = className + "/" + TTDisplayObject.Text;
                    current.TtDataDisplayReportName = TTDisplayReport.Text;
                }
            }
            else
            {
                current.TtDataDisplayActive   = false;
                current.TtDataDisplayLocation = TTDisplayLocation.Text;
                className = SmartViewFunctions.GetClassName(TTDisplayObject.Text);
                current.TtDataDisplayObject     = className + "/" + TTDisplayObject.Text;
                current.TtDataDisplayReportName = TTDisplayReport.Text;
            }

            if (UseProxBox.Checked)
            {
                current.EnableProximityBox = true;
            }
            else
            {
                current.EnableProximityBox = false;
            }

            if (EnableEllipsoid.Checked)
            {
                current.EnableProximityEllipsoid = true;
                current.EllipsoidX = EllipsoidX.Text;
                current.EllipsoidY = EllipsoidY.Text;
                current.EllipsoidZ = EllipsoidZ.Text;
            }
            else
            {
                current.EnableProximityEllipsoid = false;
                current.EllipsoidX = "100";
                current.EllipsoidY = "100";
                current.EllipsoidZ = "100";
            }

            if (UseCurrentTime.Checked)
            {
                IAgAnimation animationRoot = (IAgAnimation)CommonData.StkRoot;
                double       currentTime   = animationRoot.CurrentTime;
                current.UseAnimationTime = true;
                current.AnimationTime    = CurrentTime.Text;
            }
            else
            {
                current.UseAnimationTime = false;
                IAgScenario scenario = (IAgScenario)(CommonData.StkRoot.CurrentScenario);
                current.AnimationTime = scenario.StartTime;
            }

            if (ObjectHideShow.Checked)
            {
                current.ObjectHideShow = true;
                List <ObjectData> data = new List <ObjectData>();
                data = CommonData.CurrentViewObjectData;
                current.ViewObjectData = data;
            }
            else
            {
                current.ObjectHideShow = false;
            }
            CommonData.SavedViewList[CommonData.SelectedIndex] = current;

            try
            {
                ReadWrite.WriteSavedViews(CommonData.DirectoryStr + "\\StoredViewData.json");
            }
            catch (Exception)
            {
                MessageBox.Show("Could not Write Stored Views File");
            }

            //try
            //{
            //    ReadWrite.WriteObjectData(CommonData.DirectoryStr + "\\StoredObjectData.txt");
            //}
            //catch (Exception)
            //{

            //    MessageBox.Show("Could not Write Object Data File");
            //}
            CommonData.UpdatedView = true;
            this.Close();
        }
コード例 #19
0
        private void Apply_Click(object sender, EventArgs e)
        {
            ViewData current = new ViewData();

            current.WindowName = WindowSelect.Text;
            current.WindowId   = SmartViewFunctions.GetWindowId(WindowSelect.Text, 0);
            current.Name       = ViewName2D.Text;
            current.ViewType   = "2D";
            current.ViewType2D = TypeSelect2D.Text;
            string className = SmartViewFunctions.GetClassName(ObjectName2D.Text);

            current.ViewTarget      = className + "/" + ObjectName2D.Text;
            current.ZoomCenterLat   = ZoomCenterLat.Text;
            current.ZoomCenterLong  = ZoomCenterLong.Text;
            current.ZoomCenterDelta = ZoomDelta.Text;

            if (EnableUniversalGroundTrack.Checked)
            {
                if (LeadType2D.Text == "Time")
                {
                    current.LeadType = LeadType2D.Text + " " + GroundLeadTime.Text;
                    current.LeadTime = GroundLeadTime.Text;
                }
                else
                {
                    current.LeadType = LeadType2D.Text;
                }

                if (TrailType2D.Text == "Time")
                {
                    current.TrailType = TrailType2D.Text + " " + GroundTrailTime.Text;
                    current.TrailTime = GroundTrailTime.Text;
                }
                else
                {
                    current.TrailType = TrailType2D.Text;
                }
            }
            else
            {
                current.LeadType  = "None";
                current.TrailType = "None";
            }

            if (UseCurrentTime.Checked)
            {
                IAgAnimation animationRoot = (IAgAnimation)CommonData.StkRoot;
                double       currentTime   = animationRoot.CurrentTime;
                current.UseAnimationTime = true;
                current.AnimationTime    = CurrentTime.Text;
            }
            else
            {
                current.UseAnimationTime = false;
                IAgScenario scenario = (IAgScenario)(CommonData.StkRoot.CurrentScenario);
                current.AnimationTime = scenario.StartTime;
            }

            if (ObjectHideShow.Checked)
            {
                current.ObjectHideShow = true;
                List <ObjectData> data = new List <ObjectData>();
                data = CommonData.CurrentViewObjectData;
                current.ViewObjectData = data;
            }
            else
            {
                current.ObjectHideShow = false;
            }

            CommonData.SavedViewList[CommonData.SelectedIndex] = current;
            CommonData.UpdatedView = true;
            try
            {
                ReadWrite.WriteSavedViews(CommonData.DirectoryStr + "\\StoredViewData.json");
            }
            catch (Exception)
            {
                MessageBox.Show("Could not Write Stored Views File");
            }
            this.Close();
        }
コード例 #20
0
        private void Apply_Click(object sender, EventArgs e)
        {
            int check = FieldCheck3D();

            if (check == 0)
            {
                ViewData current = new ViewData();
                current.WindowName = WindowSelect.Text;
                current.WindowId   = SmartViewFunctions.GetWindowId(WindowSelect.Text, 1);
                current.Name       = ViewName3D.Text;
                current.ViewType   = "3D";
                string className = SmartViewFunctions.GetClassName(FocusedItem.Text);
                current.ViewTarget = className + "/" + FocusedItem.Text;
                current.ViewAxes   = ViewType.Text;

                if (EnableUniversalOrbitTrack.Checked)
                {
                    current.EnableUniversalOrbitTrack = true;
                    if (LeadType3D.Text == "Time")
                    {
                        current.LeadType = LeadType3D.Text + " " + OrbitLeadTime.Text;
                        current.LeadTime = OrbitLeadTime.Text;
                    }
                    else
                    {
                        current.LeadType = LeadType3D.Text;
                    }

                    if (TrailType3D.Text == "Time")
                    {
                        current.TrailType = TrailType3D.Text + " " + OrbitTrailTime.Text;
                        current.TrailTime = OrbitTrailTime.Text;
                    }
                    else
                    {
                        current.TrailType = TrailType3D.Text;
                    }
                }
                else
                {
                    current.LeadType  = "None";
                    current.TrailType = "None";
                }

                if (UseDataDisplay.Checked)
                {
                    current.DataDisplayActive   = true;
                    current.DataDisplayLocation = DisplayLocation.Text;
                    className = SmartViewFunctions.GetClassName(DisplayObject.Text);
                    current.DataDisplayObject     = className + "/" + DisplayObject.Text;
                    current.DataDisplayReportName = DisplayReport.Text;
                }
                else
                {
                    current.DataDisplayActive   = false;
                    current.DataDisplayLocation = DisplayLocation.Text;
                    className = SmartViewFunctions.GetClassName(DisplayObject.Text);
                    current.DataDisplayObject     = className + "/" + DisplayObject.Text;
                    current.DataDisplayReportName = DisplayReport.Text;
                }

                if (UseCurrentTime.Checked)
                {
                    IAgAnimation animationRoot = (IAgAnimation)CommonData.StkRoot;
                    double       currentTime   = animationRoot.CurrentTime;
                    current.UseAnimationTime = true;
                    current.AnimationTime    = CurrentTime.Text;
                }
                else
                {
                    current.UseAnimationTime = false;
                    IAgScenario scenario = (IAgScenario)(CommonData.StkRoot.CurrentScenario);
                    current.AnimationTime = scenario.StartTime;
                }

                if (UseCurrentViewPoint.Checked)
                {
                    current.UseStoredView  = true;
                    current.StoredViewName = ViewName3D.Text;
                    CommonData.StkRoot.ExecuteCommand("VO * SaveStoredView \"" + ViewName3D.Text + "\" " + current.WindowId);
                }
                else
                {
                    current.UseStoredView  = false;
                    current.StoredViewName = "None";
                }

                if (ObjectHideShow.Checked)
                {
                    current.ObjectHideShow = true;
                    List <ObjectData> data = new List <ObjectData>();
                    data = CommonData.CurrentViewObjectData;
                    current.ViewObjectData = data;
                }
                else
                {
                    current.ObjectHideShow = false;
                }

                CommonData.SavedViewList[CommonData.SelectedIndex] = current;
                CommonData.UpdatedView = true;
                try
                {
                    ReadWrite.WriteSavedViews(CommonData.DirectoryStr + "\\StoredViewData.json");
                }
                catch (Exception)
                {
                    MessageBox.Show("Could not Write Stored Views File");
                }
                this.Close();
            }
        }
コード例 #21
0
        // update GUI when coordinate type changed
        private void coordTypeComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            inputVal_errorLabel.Visible = false;
            m_init = true;

            IAgScenario  sc      = m_root.CurrentScenario as IAgScenario;
            IAgStkObject thisSat = SatelliteStkObject;

            // set up GUI
            switch (coordTypeComboBox.SelectedItem.ToString())
            {
            case "Cartesian ICRF":



                // get current state
                IAgDrResult posResult = SatelliteStkObject.DataProviders.GetDataPrvTimeVarFromPath("Cartesian Position//ICRF").ExecSingle(sc.StartTime);
                IAgDrResult velResult = SatelliteStkObject.DataProviders.GetDataPrvTimeVarFromPath("Cartesian Velocity//ICRF").ExecSingle(sc.StartTime);

                // update GUI

                ChangeCheckBoxVisible(false);


                orbElLabel1.Text  = "x";
                unitLabel1.Text   = "km";
                trackBar1.Minimum = -50000;
                trackBar1.Maximum = 50000;
                int val1 = Convert.ToInt32(posResult.DataSets[1].GetValues().GetValue(0));
                SetVal(val1, trackBar1);
                valueTextBox1.Text = Convert.ToString(trackBar1.Value);

                orbElLabel2.Text  = "y";
                unitLabel2.Text   = "km";
                trackBar2.Minimum = -50000;
                trackBar2.Maximum = 50000;
                int val2 = Convert.ToInt32(posResult.DataSets[2].GetValues().GetValue(0));
                SetVal(val2, trackBar2);
                valueTextBox2.Text = posResult.DataSets[2].GetValues().GetValue(0).ToString();

                orbElLabel3.Text  = "z";
                unitLabel3.Text   = "km";
                trackBar3.Minimum = -50000;
                trackBar3.Maximum = 50000;
                int val3 = Convert.ToInt32(posResult.DataSets[3].GetValues().GetValue(0));
                SetVal(val3, trackBar3);
                valueTextBox3.Text = posResult.DataSets[3].GetValues().GetValue(0).ToString();

                orbElLabel4.Text  = "dx";
                unitLabel4.Text   = "km/s";
                trackBar4.Minimum = -100;
                trackBar4.Maximum = 100;
                int val4 = Convert.ToInt32(Convert.ToDouble(velResult.DataSets[1].GetValues().GetValue(0)) * 10.0);
                SetVal(val4, trackBar4);
                valueTextBox4.Text = velResult.DataSets[1].GetValues().GetValue(0).ToString();

                orbElLabel5.Text  = "dy";
                unitLabel5.Text   = "km/s";
                trackBar5.Minimum = -100;
                trackBar5.Maximum = 100;
                int val5 = Convert.ToInt32(Convert.ToDouble(velResult.DataSets[2].GetValues().GetValue(0)) * 10.0);
                SetVal(val5, trackBar5);
                valueTextBox5.Text = velResult.DataSets[2].GetValues().GetValue(0).ToString();

                orbElLabel6.Text  = "dz";
                unitLabel6.Text   = "km/s";
                trackBar6.Minimum = -100;
                trackBar6.Maximum = 100;
                int val6 = Convert.ToInt32(Convert.ToDouble(velResult.DataSets[3].GetValues().GetValue(0)) * 10.0);
                valueTextBox6.Text = velResult.DataSets[3].GetValues().GetValue(0).ToString();

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

            case "Classical":


                // get current state
                IAgDrResult ceResult = SatelliteStkObject.DataProviders.GetDataPrvTimeVarFromPath("Classical Elements//ICRF").ExecSingle(sc.StartTime);

                // update GUI


                ChangeCheckBoxVisible(true);


                orbElLabel1.Text  = "a";
                unitLabel1.Text   = "km";
                trackBar1.Minimum = 6380;
                trackBar1.Maximum = 50000;
                int val1cl = Convert.ToInt32(ceResult.DataSets[1].GetValues().GetValue(0));
                SetVal(val1cl, trackBar1);
                valueTextBox1.Text = trackBar1.Value.ToString();

                orbElLabel2.Text  = "e";
                unitLabel2.Text   = "";
                trackBar2.Minimum = 0;
                trackBar2.Maximum = 999;
                int val2cl = Convert.ToInt32(Convert.ToDouble(ceResult.DataSets[2].GetValues().GetValue(0)) * 1000.0);
                SetVal(val2cl, trackBar2);
                valueTextBox2.Text = ceResult.DataSets[2].GetValues().GetValue(0).ToString();

                orbElLabel3.Text  = "i";
                unitLabel3.Text   = "deg";
                trackBar3.Minimum = 0;
                trackBar3.Maximum = 180;
                int val3cl = Convert.ToInt32(ceResult.DataSets[3].GetValues().GetValue(0));
                SetVal(val3cl, trackBar3);
                valueTextBox3.Text = trackBar3.Value.ToString();

                orbElLabel4.Text  = "AoP";
                unitLabel4.Text   = "deg";
                trackBar4.Minimum = 0;
                trackBar4.Maximum = 360;
                int val4cl = Convert.ToInt32(ceResult.DataSets[5].GetValues().GetValue(0));
                SetVal(val4cl, trackBar4);
                valueTextBox4.Text = trackBar4.Value.ToString();

                orbElLabel5.Text  = "RAAN";
                unitLabel5.Text   = "deg";
                trackBar5.Minimum = 0;
                trackBar5.Maximum = 360;
                int val5cl = Convert.ToInt32(ceResult.DataSets[4].GetValues().GetValue(0));
                SetVal(val5cl, trackBar5);
                valueTextBox5.Text = trackBar5.Value.ToString();

                orbElLabel6.Text  = "TA";
                unitLabel6.Text   = "deg";
                trackBar6.Minimum = 0;
                trackBar6.Maximum = 360;
                int val6cl = Convert.ToInt32(ceResult.DataSets[6].GetValues().GetValue(0));
                SetVal(val6cl, trackBar6);
                valueTextBox6.Text = ceResult.DataSets[6].GetValues().GetValue(0).ToString();

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

            case "Equinoctial":

                // get current state
                IAgDrResult eqResult = SatelliteStkObject.DataProviders.GetDataPrvTimeVarFromPath("Equinoctial Elements//ICRF").ExecSingle(sc.StartTime);

                // update GUI


                ChangeCheckBoxVisible(false);

                orbElLabel1.Text  = "a";
                unitLabel1.Text   = "km";
                trackBar1.Minimum = 6380;
                trackBar1.Maximum = 50000;
                int val6e = Convert.ToInt32(eqResult.DataSets[1].GetValues().GetValue(0));
                SetVal(val6e, trackBar1);
                valueTextBox1.Text = eqResult.DataSets[1].GetValues().GetValue(0).ToString();

                orbElLabel2.Text  = "h";
                unitLabel2.Text   = "";
                trackBar2.Minimum = -99;
                trackBar2.Maximum = 99;
                SetVal(Convert.ToInt32(Convert.ToDouble(eqResult.DataSets[2].GetValues().GetValue(0)) * 100.0), trackBar2);
                valueTextBox2.Text = eqResult.DataSets[2].GetValues().GetValue(0).ToString();

                orbElLabel3.Text  = "k";
                unitLabel3.Text   = "";
                trackBar3.Minimum = -99;
                trackBar3.Maximum = 99;
                SetVal(Convert.ToInt32(Convert.ToDouble(eqResult.DataSets[3].GetValues().GetValue(0)) * 100.0), trackBar3);
                valueTextBox3.Text = eqResult.DataSets[3].GetValues().GetValue(0).ToString();

                orbElLabel4.Text  = "p";
                unitLabel4.Text   = "";
                trackBar4.Minimum = -100;
                trackBar4.Maximum = 100;
                SetVal(Convert.ToInt32(Convert.ToDouble(eqResult.DataSets[4].GetValues().GetValue(0)) * 100.0), trackBar4);
                valueTextBox4.Text = eqResult.DataSets[4].GetValues().GetValue(0).ToString();

                orbElLabel5.Text  = "q";
                unitLabel5.Text   = "";
                trackBar5.Minimum = -100;
                trackBar5.Maximum = 100;
                SetVal(Convert.ToInt32(Convert.ToDouble(eqResult.DataSets[5].GetValues().GetValue(0)) * 100.0), trackBar5);
                valueTextBox5.Text = eqResult.DataSets[5].GetValues().GetValue(0).ToString();

                orbElLabel6.Text  = "mean long";
                unitLabel6.Text   = "deg";
                trackBar6.Minimum = 0;
                trackBar6.Maximum = 360;
                SetVal(Convert.ToInt32(eqResult.DataSets[6].GetValues().GetValue(0)), trackBar6);
                valueTextBox6.Text = eqResult.DataSets[6].GetValues().GetValue(0).ToString();

                orbElLabel7.Visible         = true;
                equinoctialComboBox.Visible = true;
                break;

            case "Delaunay":
                // get current state
                IAgDrResult deResult = SatelliteStkObject.DataProviders.GetDataPrvTimeVarFromPath("Delaunay Elements//ICRF").ExecSingle(sc.StartTime);

                MessageBox.Show("Delaunay Elements:" +
                                Environment.NewLine + "l: " + deResult.DataSets[6].GetValues().GetValue(0).ToString() +
                                Environment.NewLine + "g: " + deResult.DataSets[5].GetValues().GetValue(0).ToString() +
                                Environment.NewLine + "h: " + deResult.DataSets[4].GetValues().GetValue(0).ToString() +
                                Environment.NewLine + "L: " + deResult.DataSets[3].GetValues().GetValue(0).ToString() +
                                Environment.NewLine + "G: " + deResult.DataSets[2].GetValues().GetValue(0).ToString() +
                                Environment.NewLine + "H: " + deResult.DataSets[1].GetValues().GetValue(0).ToString());

                // update GUI


                ChangeCheckBoxVisible(false);

                orbElLabel1.Text  = "l";
                unitLabel1.Text   = "deg";
                trackBar1.Minimum = 0;
                trackBar1.Maximum = 360;
                SetVal(Convert.ToInt32(deResult.DataSets[6].GetValues().GetValue(0)), trackBar1);
                valueTextBox1.Text = deResult.DataSets[6].GetValues().GetValue(0).ToString();

                orbElLabel2.Text  = "g";
                unitLabel2.Text   = "deg";
                trackBar2.Minimum = 0;
                trackBar2.Maximum = 360;
                SetVal(Convert.ToInt32(deResult.DataSets[5].GetValues().GetValue(0)), trackBar2);
                valueTextBox2.Text = deResult.DataSets[5].GetValues().GetValue(0).ToString();

                orbElLabel3.Text  = "h";
                unitLabel3.Text   = "deg";
                trackBar3.Minimum = 0;
                trackBar3.Maximum = 360;
                SetVal(Convert.ToInt32(deResult.DataSets[4].GetValues().GetValue(0)), trackBar3);
                valueTextBox3.Text = deResult.DataSets[4].GetValues().GetValue(0).ToString();

                orbElLabel4.Text  = "L*1e-9";
                unitLabel4.Text   = "";
                trackBar4.Minimum = 0;
                trackBar4.Maximum = 100;
                SetVal(Convert.ToInt32(Convert.ToDouble(deResult.DataSets[3].GetValues().GetValue(0)) / 1000000000.0), trackBar4);
                valueTextBox4.Text = (Convert.ToDouble(deResult.DataSets[3].GetValues().GetValue(0)) / 1000000000.0).ToString();

                orbElLabel5.Text  = "G*1e-9";
                unitLabel5.Text   = "";
                trackBar5.Minimum = 0;
                trackBar5.Maximum = 100;
                SetVal(Convert.ToInt32(Convert.ToDouble(deResult.DataSets[2].GetValues().GetValue(0)) / 1000000000.0), trackBar5);
                valueTextBox5.Text = (Convert.ToDouble(deResult.DataSets[2].GetValues().GetValue(0)) / 1000000000.0).ToString();

                orbElLabel6.Text  = "H*1e-9";
                unitLabel6.Text   = "";
                trackBar6.Minimum = 0;
                trackBar6.Maximum = 100;
                SetVal(Convert.ToInt32(Convert.ToDouble(deResult.DataSets[1].GetValues().GetValue(0)) / 1000000000.0), trackBar6);
                valueTextBox6.Text = (Convert.ToDouble(deResult.DataSets[1].GetValues().GetValue(0)) / 1000000000.0).ToString();

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

            case "Mixed Spherical":
                // get current state
                IAgDrResult msResult = SatelliteStkObject.DataProviders.GetDataPrvTimeVarFromPath("Mixed Spherical Elements//ICRF").ExecSingle(sc.StartTime);



                // update GUI

                ChangeCheckBoxVisible(false);

                orbElLabel1.Text  = "Lon";
                unitLabel1.Text   = "deg";
                trackBar1.Minimum = 0;
                trackBar1.Maximum = 360;

                Int32 lonValue = Convert.ToInt32(msResult.DataSets[2].GetValues().GetValue(0));
                if (Convert.ToInt32(msResult.DataSets[2].GetValues().GetValue(0)) < 0)
                {
                    lonValue += 360;
                }
                SetVal(lonValue, trackBar1);
                valueTextBox1.Text = lonValue.ToString();

                orbElLabel2.Text  = "Lat";
                unitLabel2.Text   = "deg";
                trackBar2.Minimum = -89;
                trackBar2.Maximum = 89;
                SetVal(Convert.ToInt32(msResult.DataSets[1].GetValues().GetValue(0)), trackBar2);
                valueTextBox2.Text = msResult.DataSets[1].GetValues().GetValue(0).ToString();

                orbElLabel3.Text  = "Alt";
                unitLabel3.Text   = "deg";
                trackBar3.Minimum = 0;
                trackBar3.Maximum = 50000;
                SetVal(Convert.ToInt32(msResult.DataSets[3].GetValues().GetValue(0)), trackBar3);
                valueTextBox3.Text = msResult.DataSets[3].GetValues().GetValue(0).ToString();

                orbElLabel4.Text  = "Hor FPA";
                unitLabel4.Text   = "deg";
                trackBar4.Minimum = -89;
                trackBar4.Maximum = 89;
                SetVal(Convert.ToInt32(msResult.DataSets[4].GetValues().GetValue(0)), trackBar4);
                valueTextBox4.Text = msResult.DataSets[4].GetValues().GetValue(0).ToString();

                orbElLabel5.Text  = "Az";
                unitLabel5.Text   = "deg";
                trackBar5.Minimum = 0;
                trackBar5.Maximum = 360;
                SetVal(Convert.ToInt32(msResult.DataSets[5].GetValues().GetValue(0)), trackBar5);
                valueTextBox5.Text = msResult.DataSets[5].GetValues().GetValue(0).ToString();

                orbElLabel6.Text  = "Vel";
                unitLabel6.Text   = "km/s";
                trackBar6.Minimum = 1;
                trackBar6.Maximum = 100;
                SetVal(Convert.ToInt32(Convert.ToDouble(msResult.DataSets[6].GetValues().GetValue(0)) * 10.0), trackBar6);
                valueTextBox6.Text = msResult.DataSets[6].GetValues().GetValue(0).ToString();

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

            case "Spherical":
                // get current state
                IAgDrResult spResult = SatelliteStkObject.DataProviders.GetDataPrvTimeVarFromPath("Spherical Elements//ICRF").ExecSingle(sc.StartTime);



                // update GUI

                ChangeCheckBoxVisible(false);

                orbElLabel1.Text  = "RA";
                unitLabel1.Text   = "deg";
                trackBar1.Minimum = 0;
                trackBar1.Maximum = 360;
                SetVal(Convert.ToInt32(spResult.DataSets[1].GetValues().GetValue(0)), trackBar1);
                valueTextBox1.Text = spResult.DataSets[1].GetValues().GetValue(0).ToString();

                orbElLabel2.Text  = "Dec";
                unitLabel2.Text   = "deg";
                trackBar2.Minimum = -89;
                trackBar2.Maximum = 89;
                SetVal(Convert.ToInt32(spResult.DataSets[2].GetValues().GetValue(0)), trackBar2);
                valueTextBox2.Text = spResult.DataSets[2].GetValues().GetValue(0).ToString();

                orbElLabel3.Text  = "Radius";
                unitLabel3.Text   = "km";
                trackBar3.Minimum = 6380;
                trackBar3.Maximum = 50000;
                SetVal(Convert.ToInt32(spResult.DataSets[3].GetValues().GetValue(0)), trackBar3);
                valueTextBox3.Text = spResult.DataSets[3].GetValues().GetValue(0).ToString();

                orbElLabel4.Text  = "Hor FPA";
                unitLabel4.Text   = "deg";
                trackBar4.Minimum = -89;
                trackBar4.Maximum = 89;
                SetVal(Convert.ToInt32(spResult.DataSets[4].GetValues().GetValue(0)), trackBar4);
                valueTextBox4.Text = spResult.DataSets[4].GetValues().GetValue(0).ToString();

                orbElLabel5.Text  = "Az";
                unitLabel5.Text   = "deg";
                trackBar5.Minimum = 0;
                trackBar5.Maximum = 360;
                SetVal(Convert.ToInt32(spResult.DataSets[5].GetValues().GetValue(0)), trackBar5);
                valueTextBox5.Text = spResult.DataSets[5].GetValues().GetValue(0).ToString();

                orbElLabel6.Text  = "Vel";
                unitLabel6.Text   = "km/s";
                trackBar6.Minimum = 1;
                trackBar6.Maximum = 100;
                SetVal(Convert.ToInt32(Convert.ToDouble(spResult.DataSets[6].GetValues().GetValue(0)) * 10.0), trackBar6);
                valueTextBox6.Text = spResult.DataSets[6].GetValues().GetValue(0).ToString();

                orbElLabel7.Visible         = false;
                equinoctialComboBox.Visible = false;
                break;
            }

            m_init = false;
        }
コード例 #22
0
        private void Calculate_Click(object sender, EventArgs e)
        {
            int check = FieldCheck();

            if (check == 0)
            {
                compComplete = false;
                AllPlaneCrossingsList.Clear();
                IAgCrdnPlaneNormal orbitPlane;
                IAgStkObject       crossObj;
                IAgCrdnProvider    crossVgt;
                IAgStkObject       satRefObj = CreatorFunctions.GetCreateSatellite(PlaneSatellite.Text);
                IAgSatellite       satRef    = (IAgSatellite)satRefObj;
                IAgCrdnProvider    vgtPrv    = satRefObj.Vgt;

                //Create reference plane
                string planeName = PlaneSatellite.Text + "_OrbitPlane";
                orbitPlane = AWBFunctions.GetCreatePlaneNormal(vgtPrv, vgtPrv.Points["Center"], vgtPrv.Vectors["Velocity"], vgtPrv.Vectors["Orbit_Normal"], planeName, "Orbit plane referencing orbit normal");

                //Loop for each crossing object. Create angle, calc scalar, extrema time array, and conditionals if required
                string angleName;
                string extremaName;
                string conditionName;
                string cScalName;
                string condEventArrayName;
                foreach (var cObject in crossingObjects)
                {
                    //Initialize new plane crossing group
                    PlaneCrossingGroup crossingGroup = new PlaneCrossingGroup();
                    IAgScenario        scenario      = CommonData.StkRoot.CurrentScenario as IAgScenario;
                    crossingGroup.AnalysisStartTime        = scenario.StartTime;
                    crossingGroup.AnalysisStopTime         = scenario.StopTime;
                    crossingGroup.PlaneReferenceObjectName = satRefObj.InstanceName;
                    crossingGroup.CrossingObjectName       = cObject;

                    //Compute required VGT component names
                    crossObj           = CommonData.StkRoot.GetObjectFromPath(ObjectClass.Text + "/" + cObject);
                    crossVgt           = crossObj.Vgt;
                    angleName          = crossObj.InstanceName + "x" + satRefObj.InstanceName + "_Angle";
                    cScalName          = angleName;
                    extremaName        = crossObj.InstanceName + "x" + satRefObj.InstanceName + "_CrossingTimes";
                    conditionName      = crossObj.InstanceName + "x" + satRefObj.InstanceName + "_CrossingBounds";
                    condEventArrayName = crossObj.InstanceName + "x" + satRefObj.InstanceName + "_BoundedCrossingTimes";

                    //Create angle from current crossing object position to reference plane
                    IAgCrdnAngleToPlane planeAngle = AWBFunctions.GetCreateAngleToPlane(crossVgt, vgtPrv.Planes[planeName], crossVgt.Vectors["Position"], angleName, "Angle from satellite position to" + satRefObj.InstanceName + "orbit plane");

                    //Create calc scalar of angle
                    IAgCrdnCalcScalarAngle calcScalarAngle = AWBFunctions.GetCreateAngleCalcScalar(crossVgt, (IAgCrdnAngle)planeAngle, cScalName);

                    //Create Extrema time array to find exact crossing times
                    IAgCrdnEventArrayExtrema extrema = AWBFunctions.GetCreateEventArrayExtrema(crossVgt, (IAgCrdnCalcScalar)calcScalarAngle, extremaName, AgECrdnExtremumConstants.eCrdnExtremumMinimum, false);

                    //If conditional then create condition and condition crossing event
                    IAgCrdnEventArrayConditionCrossings conditionCrossings = null;
                    if (ConditionalCrossing.Checked)
                    {
                        //create condition
                        IAgCrdnConditionScalarBounds condition = AWBFunctions.GetCreateConditionScalarBounds(crossVgt, (IAgCrdnCalcScalar)calcScalarAngle, conditionName, AgECrdnConditionThresholdOption.eCrdnConditionThresholdOptionInsideMinMax);
                        AWBFunctions.SetAngleConditionScalarBounds(condition, Double.Parse(ConditionalLB.Text), Double.Parse(ConditionalUB.Text));

                        //Create condition crossing event
                        if (crossVgt.EventArrays.Contains(condEventArrayName))
                        {
                            conditionCrossings = (IAgCrdnEventArrayConditionCrossings)crossVgt.EventArrays[condEventArrayName];
                        }
                        else
                        {
                            conditionCrossings = (IAgCrdnEventArrayConditionCrossings)crossVgt.EventArrays.Factory.CreateEventArrayConditionCrossings(condEventArrayName, "");
                        }
                        conditionCrossings.Condition            = condition as IAgCrdnCondition;
                        conditionCrossings.SatisfactionCrossing =
                            AgECrdnSatisfactionCrossing.eCrdnSatisfactionCrossingNone;
                        //if (OffOnSat.Checked && OnOffSat.Checked)
                        //{
                        //    conditionCrossings.SatisfactionCrossing =
                        //        AgECrdnSatisfactionCrossing.eCrdnSatisfactionCrossingNone;
                        //}
                        //else if (OffOnSat.Checked && !OnOffSat.Checked)
                        //{
                        //    conditionCrossings.SatisfactionCrossing =
                        //        AgECrdnSatisfactionCrossing.eCrdnSatisfactionCrossingIn;
                        //}
                        //else if (!OffOnSat.Checked && OnOffSat.Checked)
                        //{
                        //    conditionCrossings.SatisfactionCrossing =
                        //        AgECrdnSatisfactionCrossing.eCrdnSatisfactionCrossingOut;
                        //}
                    }
                    //Extract Data
                    IAgCrdnEventArray      extremaArray = (IAgCrdnEventArray)extrema;
                    IAgCrdnFindTimesResult extremaTimes = extremaArray.FindTimes();
                    IAgCrdnEventArray      boundedArray = null;
                    IAgCrdnFindTimesResult boundedTimes = null;
                    if (extremaTimes.IsValid)
                    {
                        int numTimes = extremaTimes.Times.Length;
                        if (ConditionalCrossing.Checked)
                        {
                            boundedArray = conditionCrossings as IAgCrdnEventArray;
                            boundedTimes = boundedArray.FindTimes();
                            if (boundedTimes.Times.Length != 2 * numTimes)
                            {
                                MessageBox.Show("A bounded crossing time may be outside the analysis interval. Check results.");
                            }
                        }
                        PlaneCrossing crossing;
                        for (int i = 0; i < numTimes; i++)
                        {
                            crossing = new PlaneCrossing();
                            crossing.CrossingTime = extremaTimes.Times.GetValue(i).ToString();
                            if (ConditionalCrossing.Checked)
                            {
                                crossing.IsBounded  = true;
                                crossing.LowerBound = Double.Parse(ConditionalLB.Text);
                                crossing.UpperBound = Double.Parse(ConditionalUB.Text);

                                if (boundedTimes.Times.Length != 2 * numTimes)
                                {
                                    try
                                    {
                                        crossing.LowerBoundCrossingTime = boundedTimes.Times.GetValue(2 * i).ToString();
                                        crossing.UpperBoundCrossingTime = boundedTimes.Times.GetValue(2 * i + 1).ToString();
                                    }
                                    catch (Exception) //Index out of range
                                    {
                                        crossing.LowerBoundCrossingTime = "";
                                        crossing.UpperBoundCrossingTime = "";
                                    }
                                }
                                else
                                {
                                    crossing.LowerBoundCrossingTime = boundedTimes.Times.GetValue(2 * i).ToString();
                                    crossing.UpperBoundCrossingTime = boundedTimes.Times.GetValue(2 * i + 1).ToString();
                                }
                            }
                            crossingGroup.PlaneCrossings.Add(crossing);
                        }
                    }
                    AllPlaneCrossingsList.Add(crossingGroup);
                    compComplete = true;

                    //Add components to timeline view
                    if (AddToTimeline.Checked)
                    {
                        string cmd1 = null;
                        string cmd2 = null;
                        if (ConditionalCrossing.Checked)
                        {
                            cmd1 = "Timeline * TimeComponent Remove ContentView \"Scenario Availability\"" + " \"" + ObjectClass.Text + "/" + crossObj.InstanceName + " " + condEventArrayName + " Time Array\"";
                            cmd2 = "Timeline * TimeComponent Add ContentView \"Scenario Availability\" DisplayName \"" + condEventArrayName + "\"" + " \"" + ObjectClass.Text + "/" + crossObj.InstanceName + " " + condEventArrayName + " Time Array\"";
                        }
                        else
                        {
                            cmd1 = "Timeline * TimeComponent Remove ContentView \"Scenario Availability\"" + " \"" + ObjectClass.Text + "/" + crossObj.InstanceName + " " + extremaName + " Time Array\"";
                            cmd2 = "Timeline * TimeComponent Add ContentView \"Scenario Availability\" DisplayName \"" + extremaName + "\"" + " \"" + ObjectClass.Text + "/" + crossObj.InstanceName + " " + extremaName + " Time Array\"";
                        }

                        try
                        {
                            CommonData.StkRoot.ExecuteCommand(cmd1);
                        }
                        catch (Exception)
                        {
                        }
                        try
                        {
                            CommonData.StkRoot.ExecuteCommand(cmd2);
                            CommonData.StkRoot.ExecuteCommand("Timeline * Refresh");
                        }
                        catch (Exception exception)
                        {
                            //likely no timeline exists
                        }
                    }
                }

                //Export options
                if (compComplete && ExportToTxt.Checked)
                {
                    ReadWrite.WritePlaneCrossingOutput(satRefObj.InstanceName, AllPlaneCrossingsList);
                }
                MessageBox.Show("Computation Complete!");
            }
        }
コード例 #23
0
ファイル: SARSYS.cs プロジェクト: wt201501/STKSIMUL
        /// <summary>
        /// 新建一个SARSYS在当前sc文件中
        /// 需要建立最基础的系统
        /// 参数大多数有默认值
        /// </summary>
        public void newsarsys()
        {
            #region 写入信息
            AGI.STKX.IAgExecCmdResult resultmsg = rootapp.ExecuteCommand("SetDescription * long SARSYS");
            #endregion

            #region 设定单位、仿真时间
            // Reset the units to the STK defaults
            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");

            scene = (IAgScenario)root.CurrentScenario;
            scene.StartTime = simstarttime;
            scene.StopTime = simstoptime;
            scene.Epoch = simstarttime;

            // Set new preference for Temperature
            dimensions.SetCurrentUnit("Temperature", "degC");
            #endregion

            #region 放置发射站
            //SATELLITE #1: TDRS
            //Assign a two-body propagator to propagate it
            tdrs = (IAgSatellite)root.CurrentScenario.Children.New(AgESTKObjectType.
                eSatellite, "TDRS");
            tdrs.SetPropagatorType(AgEVePropagatorType.ePropagatorTwoBody);
            twobody = (IAgVePropagatorTwoBody)tdrs.Propagator;

            //Define the TDRS satellite's orbit using
            //classical (Keplerian) orbital elements
            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(simstarttime, simstoptime);
            twobody.Step = 60;

            //定义半主轴长度,离心率
            //Use period and eccentricity to define the size
            //and shape of the orbit
            classical.SizeShapeType = AgEClassicalSizeShape.eSizeShapeSemimajorAxis;
            IAgClassicalSizeShapeSemimajorAxis semi = (IAgClassicalSizeShapeSemimajorAxis)classical.SizeShape;
            semi.SemiMajorAxis = 35860;
            semi.Eccentricity = 0.0;

            //定义轨道倾角,升交点赤经,近地点幅角
            //Use argument of perigee, inclination
            //and longitude of ascending node to
            //define the orientation of the orbit
            classical.Orientation.ArgOfPerigee = 15.0;
            classical.Orientation.Inclination = 40.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();

            root.Rewind();

            #endregion

            #region 放置接收站
            cruise = (IAgAircraft)root.CurrentScenario.Children.New(AgESTKObjectType.eAircraft, "Cruise");
            cruise.SetRouteType(AgEVePropagatorType.ePropagatorGreatArc);
            greatArc = (IAgVePropagatorGreatArc)cruise.Route;
            greatArc.EphemerisInterval.SetStartAndStopTimes(simstarttime, simstoptime);
            greatArc.Method = AgEVeWayPtCompMethod.eDetermineTimeAccFromVel;

            ((IAgVOModelFile)cruise.VO.Model.ModelData).Filename = @"\STKData\VO\Models\Air\e-3a_sentry_awacs.mdl";
            cruise.VO.Offsets.Rotational.Enable = true;
            cruise.VO.Offsets.Rotational.X = 180;

            //Use the convenience method defined above
            //to add waypoints specifying the ship's route
            AddWaypoint(greatArc.Waypoints, -42.1, -121.5, 3.0, .15, 0.0);
            AddWaypoint(greatArc.Waypoints, 62.0, -56.6, 3.0, .15, 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();

            #endregion

            #region 放置发射站雷达
            horizon = (IAgSensor)root.CurrentScenario.Children["TDRS"].Children.
                    New(AgESTKObjectType.eSensor, "Horizon");
            horizon.SetPatternType(AgESnPattern.eSnSimpleConic);
            IAgSnSimpleConicPattern simpleConic = (IAgSnSimpleConicPattern)horizon.Pattern;
            simpleConic.ConeAngle = 0.1;

            //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 = 89.2;
            azEl.AboutBoresight = AgEAzElAboutBoresight.eAzElAboutBoresightRotate;
            fixedPt.Orientation.Assign(azEl);

            root.Rewind();

            #endregion
        }
コード例 #24
0
        //Main Function
        private void Generate_Click(object sender, EventArgs e)
        {
            int check = FieldCheck();

            if (check == 0)
            {
                RemoveProximityGeometry();
                try
                {
                    CommonData.StkRoot.UnitPreferences.SetCurrentUnit("Distance", "km");
                    CommonData.RunList.Clear();
                    CommonData.TargetName = TargetSat.Text;
                    CommonData.ActorName  = ActorSat.Text;
                    //Set user bounds for safety
                    double userMinRange = Double.Parse(SphericalMag.Text) / 1000;
                    double userMinR     = Double.Parse(RMag.Text) / 1000;
                    double userMinI     = Double.Parse(IMag.Text) / 1000;
                    double userMinC     = Double.Parse(CMag.Text) / 1000;

                    IAgScenario  scenario = CommonData.StkRoot.CurrentScenario as IAgScenario;
                    IAgStkObject satObj   = CommonData.StkRoot.GetObjectFromPath("Satellite/" + ActorSat.Text);
                    IAgSatellite sat      = satObj as IAgSatellite;

                    //Get all maneuver end times for actor satellite
                    IAgDataProviderGroup   maneuverDpGroup = satObj.DataProviders["Astrogator Maneuver Ephemeris Block Final"] as IAgDataProviderGroup;
                    IAgDataPrvTimeVar      maneuverDp      = maneuverDpGroup.Group["Cartesian Elems"] as IAgDataPrvTimeVar;
                    IAgDrResult            result          = maneuverDp.Exec(scenario.StartTime, scenario.StopTime, 60);
                    IAgDrDataSetCollection maneuverData    = result.DataSets;



                    //If there is maneuvers, run iterations for each maneuver. If no maneuvers then just pull closest RIC data for entire trajectory
                    if (maneuverData.Count != 0)
                    {
                        CommonData.HasManeuvers = true;

                        //Get maneuver numbers
                        IAgDataPrvInterval summaryDp     = satObj.DataProviders["Maneuver Summary"] as IAgDataPrvInterval;
                        IAgDrResult        summaryResult = summaryDp.Exec(scenario.StartTime, scenario.StopTime);
                        Array maneuverNumbers            = summaryResult.DataSets.GetDataSetByName("Maneuver Number").GetValues();
                        int   maxManeuverNum             = maneuverNumbers.Length;

                        //Get handles to cartesian position and velocity to seed passive safety runs
                        IAgDataProviderGroup cartPos   = satObj.DataProviders["Cartesian Position"] as IAgDataProviderGroup;
                        IAgDataPrvTimeVar    cartPosDP = cartPos.Group["ICRF"] as IAgDataPrvTimeVar;

                        IAgDataProviderGroup cartVel   = satObj.DataProviders["Cartesian Velocity"] as IAgDataProviderGroup;
                        IAgDataPrvTimeVar    cartVelDP = cartVel.Group["ICRF"] as IAgDataPrvTimeVar;

                        //Create passive safety satellite. Set to Astrogator and pull handles to initial state and propagate segments
                        IAgStkObject passiveSatObj = CreatorFunctions.GetCreateSatellite("PassiveCheck");
                        IAgSatellite passiveSat    = passiveSatObj as IAgSatellite;
                        passiveSat.SetPropagatorType(AgEVePropagatorType.ePropagatorAstrogator);
                        IAgVADriverMCS passiveDriver = passiveSat.Propagator as IAgVADriverMCS;

                        IAgVAMCSInitialState          intState = passiveDriver.MainSequence[0] as IAgVAMCSInitialState;
                        IAgVAMCSPropagate             prop     = passiveDriver.MainSequence[1] as IAgVAMCSPropagate;
                        IAgVAStoppingConditionElement sc1      = prop.StoppingConditions[0];
                        IAgVAStoppingCondition        sc       = sc1.Properties as IAgVAStoppingCondition;
                        sc.Trip = PropTime.Text;

                        AgVAElementCartesian element = intState.Element as AgVAElementCartesian;
                        Array    epoch;
                        Array    vx;
                        Array    vy;
                        Array    vz;
                        Array    x;
                        Array    y;
                        Array    z;
                        String   epochCur;
                        DateTime dateCur;
                        //Assign cartesian elements to PassiveCheck satellite from actor maneuver maneuver data. Run each iteration to see if resulting trajectory violates constraints
                        for (int i = 0; i < maxManeuverNum; i++)
                        {
                            //Get maneuver time and offset in time by 0.25 sec to account for boundrary conditions around impulsive maneuvers
                            epoch    = maneuverData[0 + (i * 7)].GetValues();
                            epochCur = epoch.GetValue(0).ToString();
                            dateCur  = DateTime.Parse(epochCur);
                            dateCur  = dateCur.AddMilliseconds(250);
                            //dateCur = DateTime.ParseExact(epochCur, "dd MMM yyyy HH:mm:ss.fff", CultureInfo.InvariantCulture);
                            epochCur = dateCur.ToString("dd MMM yyyy HH:mm:ss.fff");

                            //Get cartesian state vector for given time
                            result = cartPosDP.ExecSingle(epochCur);
                            x      = result.DataSets.GetDataSetByName("x").GetValues();
                            y      = result.DataSets.GetDataSetByName("y").GetValues();
                            z      = result.DataSets.GetDataSetByName("z").GetValues();

                            result = cartVelDP.ExecSingle(epochCur);
                            vx     = result.DataSets.GetDataSetByName("x").GetValues();
                            vy     = result.DataSets.GetDataSetByName("y").GetValues();
                            vz     = result.DataSets.GetDataSetByName("z").GetValues();

                            //Create passive run output to be used in visualization
                            PassiveRun run = new PassiveRun();
                            run.UserMinRange    = Double.Parse(SphericalMag.Text) / 1000;
                            run.UserMinR        = Double.Parse(RMag.Text) / 1000;
                            run.UserMinI        = Double.Parse(IMag.Text) / 1000;
                            run.UserMinC        = Double.Parse(CMag.Text) / 1000;
                            intState.OrbitEpoch = epochCur;
                            element.Vx          = Double.Parse(vx.GetValue(0).ToString());
                            element.Vy          = Double.Parse(vy.GetValue(0).ToString());
                            element.Vz          = Double.Parse(vz.GetValue(0).ToString());
                            element.X           = Double.Parse(x.GetValue(0).ToString());
                            element.Y           = Double.Parse(y.GetValue(0).ToString());
                            element.Z           = Double.Parse(z.GetValue(0).ToString());

                            passiveDriver.RunMCS();

                            run.Vx       = Double.Parse(vx.GetValue(0).ToString());
                            run.Vy       = Double.Parse(vy.GetValue(0).ToString());
                            run.Vz       = Double.Parse(vz.GetValue(0).ToString());
                            run.X        = Double.Parse(x.GetValue(0).ToString());
                            run.Y        = Double.Parse(y.GetValue(0).ToString());
                            run.Z        = Double.Parse(z.GetValue(0).ToString());
                            run.PropTime = Double.Parse(PropTime.Text);

                            //Pull closest point to target for each iteration and save to passive run output
                            IAgDataProvider psatDp = passiveSatObj.DataProviders["RIC Coordinates"] as IAgDataProvider;
                            psatDp.PreData = "Satellite/" + TargetSat.Text;
                            IAgDataPrvTimeVar psatDpTimeVar = psatDp as IAgDataPrvTimeVar;
                            IAgDrResult       psatDp2       = psatDpTimeVar.Exec(scenario.StartTime, scenario.StopTime, Double.Parse(TimeStep.Text));
                            run.Range         = psatDp2.DataSets.GetDataSetByName("Range").GetValues();
                            run.Intrack       = psatDp2.DataSets.GetDataSetByName("In-Track").GetValues();
                            run.Crosstrack    = psatDp2.DataSets.GetDataSetByName("Cross-Track").GetValues();
                            run.Radial        = psatDp2.DataSets.GetDataSetByName("Radial").GetValues();
                            run.MinRange      = MathFunctions.ArrayMin(run.Range);
                            run.MinIntrack    = MathFunctions.ArrayMinAbs(run.Intrack);
                            run.MinCrosstrack = MathFunctions.ArrayMinAbs(run.Crosstrack);
                            run.MinRadial     = MathFunctions.ArrayMinAbs(run.Radial);
                            //run.ManeuverTime = epoch.GetValue(0).ToString();
                            run.ManeuverTime = epochCur;

                            //spherical
                            if (radioButton1.Checked)
                            {
                                run.IsSpherical = true;
                                if (run.MinRange < userMinRange)
                                {
                                    run.Safe = false;
                                }
                                else
                                {
                                    run.Safe = true;
                                }
                            }
                            //independent axis
                            else
                            {
                                run.IsSpherical = false;
                                if (Math.Abs(run.MinIntrack) < userMinI && Math.Abs(run.MinRadial) < userMinR && Math.Abs(run.MinCrosstrack) < userMinC)
                                {
                                    bool tripped = false;
                                    for (int j = 0; j < run.Range.Length; j++)
                                    {
                                        if (Math.Abs(Double.Parse(run.Intrack.GetValue(j).ToString())) < userMinI && Math.Abs(Double.Parse(run.Radial.GetValue(j).ToString())) < userMinR && Math.Abs(Double.Parse(run.Crosstrack.GetValue(j).ToString())) < userMinC)
                                        {
                                            run.Safe = false;
                                            tripped  = true;
                                            break;
                                        }
                                    }
                                    if (!tripped)
                                    {
                                        run.Safe = true;
                                    }
                                }
                                else
                                {
                                    run.Safe = true;
                                }
                            }

                            CommonData.RunList.Add(run);
                        }
                    }
                    else
                    {
                        CommonData.HasManeuvers = false;
                        PassiveRun      run   = new PassiveRun();
                        IAgDataProvider satDp = satObj.DataProviders["RIC Coordinates"] as IAgDataProvider;
                        satDp.PreData = "Satellite/" + TargetSat.Text;
                        IAgDataPrvTimeVar satDpTimeVar = satDp as IAgDataPrvTimeVar;
                        IAgDrResult       satDp2       = satDpTimeVar.Exec(scenario.StartTime, scenario.StopTime, Double.Parse(TimeStep.Text));
                        run.Range         = satDp2.DataSets.GetDataSetByName("Range").GetValues();
                        run.Intrack       = satDp2.DataSets.GetDataSetByName("In-Track").GetValues();
                        run.Crosstrack    = satDp2.DataSets.GetDataSetByName("Cross-Track").GetValues();
                        run.Radial        = satDp2.DataSets.GetDataSetByName("Radial").GetValues();
                        run.MinRange      = MathFunctions.ArrayMin(run.Range);
                        run.MinIntrack    = MathFunctions.ArrayMinAbs(run.Intrack);
                        run.MinCrosstrack = MathFunctions.ArrayMinAbs(run.Crosstrack);
                        run.MinRadial     = MathFunctions.ArrayMinAbs(run.Radial);
                        run.ManeuverTime  = "N/A";

                        //spherical
                        if (radioButton1.Checked)
                        {
                            run.IsSpherical = true;
                            if (run.MinRange < userMinRange)
                            {
                                run.Safe = false;
                            }
                            else
                            {
                                run.Safe = true;
                            }
                        }
                        //independent axis
                        else
                        {
                            run.IsSpherical = false;
                            if (Math.Abs(run.MinIntrack) < userMinI && Math.Abs(run.MinRadial) < userMinR && Math.Abs(run.MinCrosstrack) < userMinC)
                            {
                                bool tripped = false;
                                for (int j = 0; j < run.Range.Length; j++)
                                {
                                    if (Math.Abs(Double.Parse(run.Intrack.GetValue(j).ToString())) < userMinI && Math.Abs(Double.Parse(run.Radial.GetValue(j).ToString())) < userMinR && Math.Abs(Double.Parse(run.Crosstrack.GetValue(j).ToString())) < userMinC)
                                    {
                                        run.Safe = false;
                                        tripped  = true;
                                        break;
                                    }
                                }
                                if (!tripped)
                                {
                                    run.Safe = true;
                                }
                            }
                            else
                            {
                                run.Safe = true;
                            }
                        }

                        CommonData.RunList.Add(run);
                    }
                    CommonData.BeenRun = true;
                }
                catch (Exception)
                {
                    MessageBox.Show("Passive Safety Check Failed");
                }
            }
        }
コード例 #25
0
ファイル: SARSYS.cs プロジェクト: wt201501/STKSIMUL2
        /// <summary>
        /// 读出当前sc文件中已经存在的SARSYS
        /// </summary>
        public void readsarsys()
        {

            AGI.STKX.IAgExecCmdResult resultmsg = rootapp.ExecuteCommand("GetDescription * long");


            dimensions = root.UnitPreferences;
            scene = (IAgScenario)root.CurrentScenario;
            tdrs = (IAgSatellite)root.CurrentScenario.Children["TDRS"];
            
            twobody = (IAgVePropagatorTwoBody)tdrs.Propagator;
            classical = (IAgOrbitStateClassical)twobody.InitialState.Representation.ConvertTo(AgEOrbitStateType.eOrbitStateClassical);

            cruise = (IAgAircraft)root.CurrentScenario.Children["Cruise"];
            greatArc = (IAgVePropagatorGreatArc)cruise.Route;

            radar_t = (IAgSensor)root.CurrentScenario.Children["TDRS"].Children["radar_t"];

            radar_r = (IAgSensor)root.CurrentScenario.Children["Cruise"].Children["radar_r"];

            target = (IAgSensor)root.CurrentScenario.Children["TDRS"].Children["target"];

            simstarttime = scene.StartTime;
            simstoptime = scene.StopTime;
            simstep = scene.Animation.AnimStepValue;
            IAgClassicalSizeShapeSemimajorAxis semi = (IAgClassicalSizeShapeSemimajorAxis)classical.SizeShape;
            sasem = semi.SemiMajorAxis;
            saecc = semi.Eccentricity;
            saaop = classical.Orientation.ArgOfPerigee;
            sainc = classical.Orientation.Inclination;
            salan = ((IAgOrientationAscNodeLAN)classical.Orientation.AscNode).Value;
            satra = ((IAgClassicalLocationTrueAnomaly)classical.Location).Value;
            racoang = ((IAgSnSimpleConicPattern)radar_t.Pattern).ConeAngle;

            IAgSnPtFixed fixedPt = (IAgSnPtFixed)radar_t.Pointing;
            IAgOrientationAzEl azEl = (IAgOrientationAzEl)fixedPt.Orientation.ConvertTo(AgEOrientationType.eAzEl);
            raeleva = azEl.Elevation;

            plwaypoints = new double[5 * greatArc.Waypoints.Count];
            for(int ii=0;ii<greatArc.Waypoints.Count;ii++)
            {
                plwaypoints[ii * 5] = greatArc.Waypoints[ii].Latitude;
                plwaypoints[ii * 5 + 1] = greatArc.Waypoints[ii].Longitude;
                plwaypoints[ii * 5 + 2] = greatArc.Waypoints[ii].Altitude;
                plwaypoints[ii * 5 + 3] = greatArc.Waypoints[ii].Speed;
                plwaypoints[ii * 5 + 4] = greatArc.Waypoints[ii].TurnRadius;
            }




        }
コード例 #26
0
ファイル: SARSYS.cs プロジェクト: wt201501/STKSIMUL2
        /// <summary>
        /// 新建一个SARSYS在当前sc文件中
        /// 需要建立最基础的系统
        /// 参数大多数有默认值
        /// </summary>
        public void newsarsys()
        {
            #region 写入信息
            AGI.STKX.IAgExecCmdResult resultmsg = rootapp.ExecuteCommand("SetDescription * long SARSYS");
            #endregion


            #region 设定单位、仿真时间
            // Reset the units to the STK defaults
            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");

            scene = (IAgScenario)root.CurrentScenario;
            scene.StartTime = simstarttime;
            scene.StopTime = simstoptime;
            scene.Epoch = simstarttime;

            //rootapp.ExecuteCommand("MapTracking * UTM");

            // Set new preference for Temperature
            dimensions.SetCurrentUnit("Temperature", "degC");
            #endregion

            #region 放置发射站
            //SATELLITE #1: TDRS
            //Assign a two-body propagator to propagate it
            tdrs = (IAgSatellite)root.CurrentScenario.Children.New(AgESTKObjectType.
                eSatellite, "TDRS");
            tdrs.SetPropagatorType(AgEVePropagatorType.ePropagatorTwoBody);
            twobody = (IAgVePropagatorTwoBody)tdrs.Propagator;

            //Define the TDRS satellite's orbit using
            //classical (Keplerian) orbital elements
            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(simstarttime, simstoptime);
            twobody.Step = 60;

            //定义半主轴长度,离心率
            //Use period and eccentricity to define the size
            //and shape of the orbit
            classical.SizeShapeType = AgEClassicalSizeShape.eSizeShapeSemimajorAxis;
            IAgClassicalSizeShapeSemimajorAxis semi = (IAgClassicalSizeShapeSemimajorAxis)classical.SizeShape;
            semi.SemiMajorAxis = sasem;
            semi.Eccentricity = saecc;


            //定义轨道倾角,升交点赤经,近地点幅角
            //Use argument of perigee, inclination
            //and longitude of ascending node to
            //define the orientation of the orbit
            classical.Orientation.ArgOfPerigee = saaop;
            classical.Orientation.Inclination = sainc;
            classical.Orientation.AscNodeType = AgEOrientationAscNode.eAscNodeLAN;
            IAgOrientationAscNodeLAN lan = (IAgOrientationAscNodeLAN)classical.Orientation.AscNode;
            lan.Value = salan;

            //定义真近点角(?)来定义初始位置
            //Use true anomaly to specify the position of
            //the satellite in orbit
            classical.LocationType = AgEClassicalLocation.eLocationTrueAnomaly;
            IAgClassicalLocationTrueAnomaly trueAnomaly = (IAgClassicalLocationTrueAnomaly)classical.Location;
            trueAnomaly.Value = satra;


            //Assign the orbital elements to the TDRS
            //satellite's propagator and propagate the orbit	
            twobody.InitialState.Representation.Assign(classical);
            twobody.Propagate();

            root.Rewind();

            #endregion

            
            #region 放置接收站
            cruise = (IAgAircraft)root.CurrentScenario.Children.New(AgESTKObjectType.eAircraft, "Cruise");
            cruise.SetRouteType(AgEVePropagatorType.ePropagatorGreatArc);
            greatArc = (IAgVePropagatorGreatArc)cruise.Route;
            greatArc.EphemerisInterval.SetStartAndStopTimes(simstarttime, simstoptime);
            greatArc.Method = AgEVeWayPtCompMethod.eDetermineTimeAccFromVel;

            ((IAgVOModelFile)cruise.VO.Model.ModelData).Filename = @"\STKData\VO\Models\Air\rq-4a_globalhawk.mdl";
            cruise.VO.Offsets.Rotational.Enable = true;
            cruise.VO.Offsets.Rotational.X = 180;

            //Use the convenience method defined above
            //to add waypoints specifying the ship's route
            for (int ii = 0; ii < plwaypoints.Length; ii += 5)
            {
                AddWaypoint(greatArc.Waypoints, plwaypoints[ii], plwaypoints[ii + 1], plwaypoints[ii + 2], plwaypoints[ii + 3], plwaypoints[ii + 4]);
            }
              
            
            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();


            #endregion

            #region 放置发射站雷达
            radar_t = (IAgSensor)root.CurrentScenario.Children["TDRS"].Children.New(AgESTKObjectType.eSensor, "radar_t");
            radar_t.SetPatternType(AgESnPattern.eSnSimpleConic);
            ((IAgSnSimpleConicPattern)radar_t.Pattern).ConeAngle = racoang;



            //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
            radar_t.SetPointingType(AgESnPointing.eSnPtFixed);
            IAgSnPtFixed fixedPt = (IAgSnPtFixed)radar_t.Pointing;
            IAgOrientationAzEl azEl = (IAgOrientationAzEl)fixedPt.Orientation.ConvertTo(AgEOrientationType.eAzEl);
            azEl.Elevation = raeleva;
            azEl.AboutBoresight = AgEAzElAboutBoresight.eAzElAboutBoresightRotate;
            fixedPt.Orientation.Assign(azEl);

            radar_t.Graphics.FillVisible = true;
            radar_t.VO.FillVisible = true;
            

            root.Rewind();


            #endregion


            #region 放置接收站雷达


            target = (IAgSensor)root.CurrentScenario.Children["TDRS"].Children.New(AgESTKObjectType.eSensor, "target");

            target.SetLocationType(AgESnLocation.eSnLocationCrdnPoint);
            IAgLocationCrdnPoint vgtPoint = target.LocationData as IAgLocationCrdnPoint;
            //vgtPoint.PointPath = "TDRS/radar_t BoresightIntersection(Terrain)";
            vgtPoint.PointPath = "Satellite/TDRS/Sensor/radar_t BoresightIntersection(Terrain)";
            target.SetPatternType(AgESnPattern.eSnSimpleConic);
            ((IAgSnSimpleConicPattern)target.Pattern).ConeAngle = 0.00001;
           
            

            IAgSnPtTargeted targetedSensor1 = target.CommonTasks.SetPointingTargetedTracking(
   AgETrackModeType.eTrackModeTranspond, AgEBoresightType.eBoresightRotate, "*/Aircraft/Cruise");


            target.SetPointingType(AgESnPointing.eSnPtTargeted);
            IAgSnPtTargeted rpt1 = (IAgSnPtTargeted)target.Pointing;
            rpt1.Boresight = AgESnPtTrgtBsightType.eSnPtTrgtBsightTracking;
            root.Rewind();
            rootapp.ExecuteCommand("Graphics */Satellite/TDRS/Sensor/target Show Off");


            /////////////////////////
            radar_r = (IAgSensor)root.CurrentScenario.Children["Cruise"].Children.New(AgESTKObjectType.eSensor, "radar_r");
            radar_r.SetPatternType(AgESnPattern.eSnSimpleConic);
            ((IAgSnSimpleConicPattern)radar_r.Pattern).ConeAngle = 3;
        

            IAgSnPtTargeted targetedSensor = radar_r.CommonTasks.SetPointingTargetedTracking(
    AgETrackModeType.eTrackModeTranspond, AgEBoresightType.eBoresightRotate, "*/Satellite/TDRS/Sensor/target");   

            
            radar_r.SetPointingType(AgESnPointing.eSnPtTargeted);
            IAgSnPtTargeted rpt = (IAgSnPtTargeted)radar_r.Pointing;
            rpt.Boresight = AgESnPtTrgtBsightType.eSnPtTrgtBsightTracking;
            

            root.Rewind();
            #endregion
        }
コード例 #27
0
        private void scenarioCheck()
        {
            try
            {
                if (this.m_oApplication.CurrentScenario == null)
                {//scenario doesn't exist
                    this.m_oApplication.CloseScenario();
                    this.m_oApplication.NewScenario("NPAS_Schedule_to_STK");
                }
            }catch
            {
                find_STK();

                if (this.m_oApplication.CurrentScenario == null)
                {//scenario doesn't exist
                    this.m_oApplication.CloseScenario();
                    this.m_oApplication.NewScenario("NPAS_Schedule_to_STK");
                }
            }
            IAgUnitPrefsDimCollection dimensions = this.m_oApplication.UnitPreferences;

            dimensions.ResetUnits();
            dimensions.SetCurrentUnit("DateFormat", "UTCG"); //DD/MM/YYYY
            //dimensions.SetCurrentUnit("DateFormat", "DD/MM/YYYY"); //DD/MM/YYYY
            IAgScenario scene = (IAgScenario)this.m_oApplication.CurrentScenario;

            //#TODO times should be set by the user
            DateTime start, stop;

            start = Convert.ToDateTime(startdate);
            stop  = Convert.ToDateTime(enddate);

            Console.Write("start/end=" + start.ToString("dd MMM yyyy") + " 00:00:00.000 /" + stop.ToString("dd MMM yyyy") + " 00:00:00.000\n");
            try
            {
                scene.StopTime  = stop.ToString("dd MMM yyyy");          // + " 00:00:00";
                scene.StartTime = start.ToString(format: "dd MMM yyyy"); // + " 00:00:00";
            }
            catch
            {
                scene.StartTime = start.ToString(format: "dd MMM yyyy"); // + " 00:00:00";
                scene.StopTime  = stop.ToString("dd MMM yyyy");          // + " 00:00:00";
            }



            dimensions.SetCurrentUnit("DistanceUnit", "km");
            dimensions.SetCurrentUnit("TimeUnit", "sec");
            dimensions.SetCurrentUnit("AngleUnit", "deg");
            dimensions.SetCurrentUnit("MassUnit", "kg");
            dimensions.SetCurrentUnit("PowerUnit", "dbw");
            dimensions.SetCurrentUnit("FrequencyUnit", "ghz");
            dimensions.SetCurrentUnit("SmallDistanceUnit", "m");
            dimensions.SetCurrentUnit("latitudeUnit", "deg");
            dimensions.SetCurrentUnit("longitudeunit", "deg");
            dimensions.SetCurrentUnit("DurationUnit", "HMS");
            dimensions.SetCurrentUnit("Temperature", "K");
            dimensions.SetCurrentUnit("SmallTimeUnit", "sec");
            dimensions.SetCurrentUnit("RatioUnit", "db");
            dimensions.SetCurrentUnit("rcsUnit", "dbsm");
            dimensions.SetCurrentUnit("DopplerVelocityUnit", "m/s");
            dimensions.SetCurrentUnit("Percent", "unitValue");
        }
コード例 #28
0
 private void ConnectToStk()
 {
     app  = System.Runtime.InteropServices.Marshal.GetActiveObject("STK12.Application");
     root = app.GetType().InvokeMember("Personality2", System.Reflection.BindingFlags.GetProperty, null, app, null) as AgStkObjectRoot;
     scen = (IAgScenario)root.CurrentScenario;
 }
コード例 #29
0
        private void Apply_Click(object sender, EventArgs e)
        {
            ViewData current   = new ViewData();
            string   className = null;

            current.WindowName               = WindowSelect.Text;
            current.ViewType                 = "GEODrift";
            current.Name                     = GEOViewName.Text;
            className                        = SmartViewFunctions.GetClassName(GEOViewTarget.Text);
            current.ViewTarget               = className + "/" + GEOViewTarget.Text;
            current.EnableGeoBox             = UseGEOBox.Checked;
            current.GeoLongitude             = GEOLongitude.Text;
            current.GeoNorthSouth            = GeoNorthSouth.Text;
            current.GeoEastWest              = GEOEastWest.Text;
            current.GeoRadius                = GEORadius.Text;
            current.GeoDataDisplayActive     = GEOUseDataDisplay.Checked;
            className                        = SmartViewFunctions.GetClassName(GEODisplayObject.Text);
            current.GeoDataDisplayObject     = className + "/" + GEODisplayObject.Text;
            current.GeoDataDisplayReportName = GEODisplayReport.Text;
            current.GeoDataDisplayLocation   = GEODisplayLocation.Text;

            if (UseCurrentTime.Checked)
            {
                IAgAnimation animationRoot = (IAgAnimation)CommonData.StkRoot;
                double       currentTime   = animationRoot.CurrentTime;
                current.UseAnimationTime = true;
                current.AnimationTime    = CurrentTime.Text;
            }
            else
            {
                current.UseAnimationTime = false;
                IAgScenario scenario = (IAgScenario)(CommonData.StkRoot.CurrentScenario);
                current.AnimationTime = scenario.StartTime;
            }

            if (ObjectHideShow.Checked)
            {
                current.ObjectHideShow = true;
                List <ObjectData> data = new List <ObjectData>();
                data = CommonData.CurrentViewObjectData;
                current.ViewObjectData = data;
            }
            else
            {
                current.ObjectHideShow = false;
            }

            CommonData.SavedViewList[CommonData.SelectedIndex] = current;

            try
            {
                ReadWrite.WriteSavedViews(CommonData.DirectoryStr + "\\StoredViewData.json");
            }
            catch (Exception)
            {
                MessageBox.Show("Could not Write Stored Views File");
            }

            //try
            //{
            //    ReadWrite.WriteObjectData(CommonData.DirectoryStr + "\\StoredObjectData.txt");
            //}
            //catch (Exception)
            //{

            //    MessageBox.Show("Could not Write Object Data File");
            //}
            CommonData.NewView = true;
            this.Close();
        }
コード例 #30
0
        public List <Waypoint> RasterSearchWaypointGenerator(
            string areaTargetPath, string heading, double speed, double altitude, double turnRadius,
            SwathWidthType swathType, double swathParameter)
        {
            List <Waypoint> waypoints = new List <Waypoint>();

            IAgStkObject areaTarget = root.GetObjectFromPath(areaTargetPath);

            IAgAreaTarget areaTargetObj      = (IAgAreaTarget)areaTarget;
            bool          areaTargetElActive = areaTarget.AccessConstraints.IsConstraintActive(AgEAccessConstraints.eCstrElevationAngle);
            double        restoreAngle       = 0;

            if (!areaTargetElActive)
            {
                IAgAccessCnstrAngle elevationMin = areaTarget.AccessConstraints.AddConstraint(AgEAccessConstraints.eCstrElevationAngle) as IAgAccessCnstrAngle;
                root.UnitPreferences["Angle"].SetCurrentUnit("deg");
                elevationMin.Angle = 90;
            }
            else
            {
                IAgAccessCnstrAngle elevationMin = areaTarget.AccessConstraints.GetActiveConstraint(AgEAccessConstraints.eCstrElevationAngle) as IAgAccessCnstrAngle;
                root.UnitPreferences["Angle"].SetCurrentUnit("deg");
                restoreAngle       = (double)elevationMin.Angle;
                elevationMin.Angle = 90;
            }

            double minLat = 90;
            double maxLat = -90;
            double minLon = 180;
            double maxLon = -180;

            root.UnitPreferences["Angle"].SetCurrentUnit("deg");
            switch (areaTargetObj.AreaType)
            {
            case AgEAreaType.eEllipse:
                IAgDataProviderGroup boundingProvider = areaTarget.DataProviders["Bounding Rectangle"] as IAgDataProviderGroup;
                IAgDataPrvFixed      dpElements       = boundingProvider.Group["Corner Points"] as IAgDataPrvFixed;
                IAgDrResult          atDataPrvResult  = dpElements.Exec();

                Array atLats = atDataPrvResult.DataSets.GetDataSetByName("Geodetic-Lat").GetValues();
                Array atLons = atDataPrvResult.DataSets.GetDataSetByName("Geodetic-Lon").GetValues();
                foreach (object item in atLats)
                {
                    if ((double)item > maxLat)
                    {
                        maxLat = (double)item;
                    }
                    if ((double)item < minLat)
                    {
                        minLat = (double)item;
                    }
                }
                foreach (object item in atLons)
                {
                    if ((double)item > maxLon)
                    {
                        maxLon = (double)item;
                    }
                    if ((double)item < minLon)
                    {
                        minLon = (double)item;
                    }
                }
                break;

            case AgEAreaType.ePattern:
                IAgAreaTypePatternCollection boundary = areaTargetObj.AreaTypeData as IAgAreaTypePatternCollection;

                foreach (IAgAreaTypePattern item in boundary)
                {
                    if ((double)item.Lat > maxLat)
                    {
                        maxLat = (double)item.Lat;
                    }
                    if ((double)item.Lat < minLat)
                    {
                        minLat = (double)item.Lat;
                    }

                    if ((double)item.Lon > maxLon)
                    {
                        maxLon = (double)item.Lon;
                    }
                    if ((double)item.Lon < minLon)
                    {
                        minLon = (double)item.Lon;
                    }
                }

                break;

            default:
                break;
            }
            double deltaLat = maxLat - minLat;
            double deltaLon = maxLon - minLon;

            IAgExecCmdResult cmdResult;

            switch (heading)
            {
            case "NorthSouth":
                cmdResult = root.ExecuteCommand("MeasureSurfaceDistance * " +
                                                minLat + " " + minLon + " " + minLat + " " + maxLon);
                break;

            case "EastWest":
                cmdResult = root.ExecuteCommand("MeasureSurfaceDistance * " +
                                                minLat + " " + minLon + " " + maxLat + " " + minLon);
                break;

            default:
                cmdResult = root.ExecuteCommand("MeasureSurfaceDistance * " +
                                                minLat + " " + minLon + " " + maxLat + " " + minLon);
                break;
            }



            double regionWidth = double.Parse(cmdResult[0]);

            int numPasses = DetermineNumPasses(swathType, swathParameter, altitude, regionWidth, null);

            if (numPasses < 1)
            {
                MessageBox.Show("No Passes.  Try Adjusting Swath Width Parameters");
                return(waypoints);
            }
            root.BeginUpdate();

            string           gvName        = uniqueName("gridTester", AgESTKObjectType.eGroundVehicle);
            IAgGroundVehicle groundVehicle = root.CurrentScenario.Children.New(AgESTKObjectType.eGroundVehicle, gvName) as IAgGroundVehicle;

            groundVehicle.Graphics.SetAttributesType(AgEVeGfxAttributes.eAttributesBasic);
            IAgVeGfxAttributesBasic gvGfx = groundVehicle.Graphics.Attributes as IAgVeGfxAttributesBasic;

            gvGfx.Inherit   = false;
            gvGfx.IsVisible = false;

            IAgVePropagatorGreatArc route = groundVehicle.Route as IAgVePropagatorGreatArc;

            //route.ArcGranularity = 51.333;
            route.SetAltitudeRefType(AgEVeAltitudeRef.eWayPtAltRefWGS84);
            route.Method = AgEVeWayPtCompMethod.eDetermineTimeAccFromVel;

            Waypoint waypoint1 = new Waypoint();
            Waypoint waypoint2 = new Waypoint();
            bool     headEast  = true;


            double loopMin;
            double loopMax;
            double gridAngleStep;

            switch (heading)
            {
            case "NorthSouth":
                loopMin       = minLon;
                loopMax       = maxLon;
                gridAngleStep = (maxLon - minLon) / numPasses;
                break;

            case "EastWest":
                loopMin       = minLat;
                loopMax       = maxLat;
                gridAngleStep = (maxLat - minLat) / numPasses;
                break;

            default:
                loopMin       = minLat;
                loopMax       = maxLat;
                gridAngleStep = .95 * (maxLat - minLat) / numPasses;
                break;
            }

            for (double eval = loopMin; eval <= loopMax; eval += gridAngleStep)
            {
                route.Waypoints.RemoveAll();
                IAgVeWaypointsElement thisWaypoint1;
                IAgVeWaypointsElement thisWaypoint2;
                switch (heading)
                {
                case "NorthSouth":
                    thisWaypoint1           = route.Waypoints.Add();
                    thisWaypoint1.Latitude  = minLat - gridAngleStep;
                    thisWaypoint1.Longitude = eval;
                    thisWaypoint1.Altitude  = 0;

                    thisWaypoint2           = route.Waypoints.Add();
                    thisWaypoint2.Latitude  = maxLat + gridAngleStep;
                    thisWaypoint2.Longitude = eval;
                    thisWaypoint2.Altitude  = 0;
                    break;

                case "EastWest":
                default:
                    thisWaypoint1           = route.Waypoints.Add();
                    thisWaypoint1.Latitude  = eval;
                    thisWaypoint1.Longitude = minLon - gridAngleStep;
                    thisWaypoint1.Altitude  = 0;

                    thisWaypoint2           = route.Waypoints.Add();
                    thisWaypoint2.Latitude  = eval;
                    thisWaypoint2.Longitude = maxLon + gridAngleStep;
                    thisWaypoint2.Altitude  = 0;
                    break;
                }
                route.Propagate();

                IAgStkAccess access = areaTarget.GetAccessToObject((IAgStkObject)groundVehicle);
                access.ComputeAccess();

                IAgDataPrvInterval dpAccess = access.DataProviders["Access Data"] as IAgDataPrvInterval;
                IAgScenario        scen     = root.CurrentScenario as IAgScenario;
                IAgDrResult        result   = dpAccess.Exec(scen.StartTime, scen.StopTime);


                if (result.DataSets.Count > 0)
                {
                    Array startTimes = result.DataSets.GetDataSetByName("Start Time").GetValues();
                    Array stopTimes  = result.DataSets.GetDataSetByName("Stop Time").GetValues();

                    string startTime = (string)startTimes.GetValue(0);
                    string stopTime  = (string)stopTimes.GetValue(stopTimes.GetLength(0) - 1);

                    IAgDataProviderGroup dpLLA         = ((IAgStkObject)groundVehicle).DataProviders["LLA State"] as IAgDataProviderGroup;
                    IAgDataPrvTimeVar    dpElements    = dpLLA.Group["Fixed"] as IAgDataPrvTimeVar;
                    IAgDrResult          DataPrvResult = dpElements.ExecSingle(startTime);

                    Array Lats = DataPrvResult.DataSets.GetDataSetByName("Lat").GetValues();
                    Array Lons = DataPrvResult.DataSets.GetDataSetByName("Lon").GetValues();

                    waypoint1                 = new Waypoint();
                    waypoint1.Latitude        = (double)Lats.GetValue(0);
                    waypoint1.Longitude       = (double)Lons.GetValue(0);
                    waypoint1.Altitude        = altitude;
                    waypoint1.SurfaceAltitude = 0;
                    waypoint1.Speed           = speed;
                    waypoint1.TurnRadius      = turnRadius;


                    IAgDataProviderGroup dpLLA1         = ((IAgStkObject)groundVehicle).DataProviders["LLA State"] as IAgDataProviderGroup;
                    IAgDataPrvTimeVar    dpElements1    = dpLLA1.Group["Fixed"] as IAgDataPrvTimeVar;
                    IAgDrResult          DataPrvResult1 = dpElements1.ExecSingle(stopTime);

                    Array Lats1 = DataPrvResult1.DataSets.GetDataSetByName("Lat").GetValues();
                    Array Lons1 = DataPrvResult1.DataSets.GetDataSetByName("Lon").GetValues();

                    waypoint2                 = new Waypoint();
                    waypoint2.Latitude        = (double)Lats1.GetValue(0);
                    waypoint2.Longitude       = (double)Lons1.GetValue(0);
                    waypoint2.Altitude        = altitude;
                    waypoint2.SurfaceAltitude = 0;
                    waypoint2.Speed           = speed;
                    waypoint2.TurnRadius      = turnRadius;


                    if (headEast)
                    {
                        waypoints.Add(waypoint1);
                        waypoints.Add(waypoint2);
                    }
                    else
                    {
                        waypoints.Add(waypoint2);
                        waypoints.Add(waypoint1);
                    }
                    headEast = !headEast;
                }
                access.RemoveAccess();
            }

            ((IAgStkObject)groundVehicle).Unload();

            if (!areaTargetElActive)
            {
                areaTarget.AccessConstraints.RemoveConstraint(AgEAccessConstraints.eCstrElevationAngle);
            }
            else
            {
                IAgAccessCnstrAngle elevationMin = areaTarget.AccessConstraints.GetActiveConstraint(AgEAccessConstraints.eCstrElevationAngle) as IAgAccessCnstrAngle;
                root.UnitPreferences["Angle"].SetCurrentUnit("deg");
                elevationMin.Angle = restoreAngle;
            }

            root.EndUpdate();
            root.UnitPreferences.ResetUnits();
            return(waypoints);
        }
コード例 #31
0
        private void Generate_Click(object sender, EventArgs e)
        {
            CommonData.StkRoot.ExecuteCommand("BatchGraphics * On");
            IAgConstellation myConst;

            if ((string)ImportType.SelectedItem == "TLE/TCE")
            {
                string      filepath      = TCEFile.Text;
                IAgScenario scenario      = (IAgScenario)CommonData.StkRoot.CurrentScenario;
                string      startTime     = scenario.StartTime;
                string      stopTime      = scenario.StopTime;
                string      constellation = null;
                string      cmd;

                try
                {
                    IAgExecCmdResult result = CommonData.StkRoot.ExecuteCommand("DoesObjExist / */Constellation/Assets");
                    if ((string)ConstType.SelectedItem == "Default Constellation")
                    {
                        if (result[0] == "0")
                        {
                            IAgConstellation assets = (IAgConstellation)CommonData.StkRoot.CurrentScenario.Children.New(AgESTKObjectType.eConstellation, "Assets");
                        }
                        constellation = "Assets";
                    }
                    else if ((string)ConstType.SelectedItem == "Existing Constellation")
                    {
                        result = CommonData.StkRoot.ExecuteCommand("DoesObjExist / */Constellation/" + ExistingConst.Text);
                        if (result[0] == "0")
                        {
                            IAgConstellation assets = (IAgConstellation)CommonData.StkRoot.CurrentScenario.Children.New(AgESTKObjectType.eConstellation, ExistingConst.Text);
                        }
                        constellation = ExistingConst.Text;
                    }
                    else if ((string)ConstType.SelectedItem == "New Constellation")
                    {
                        result = CommonData.StkRoot.ExecuteCommand("DoesObjExist / */Constellation/" + ConstName.Text);
                        if (result[0] == "0")
                        {
                            IAgConstellation assets = (IAgConstellation)CommonData.StkRoot.CurrentScenario.Children.New(AgESTKObjectType.eConstellation, ConstName.Text);
                        }
                        constellation = ConstName.Text;
                    }
                    //must parse satellites into constellation because of bug associated with ImportTLEFile connect command
                    //Get list of sats prior to import
                    result = CommonData.StkRoot.ExecuteCommand("ShowNames * Class Satellite");
                    string[] prevSatArray = null;
                    if (result[0] != "None")
                    {
                        prevSatArray = result[0].Split(null);
                    }

                    //Import TLE
                    cmd = "ImportTLEFile * " + "\"" + filepath + "\"" + " AutoPropagate On TimeStep 30.0 StartStop " + "\"" + startTime + "\" " + "\"" + stopTime + "\"";
                    CommonData.StkRoot.ExecuteCommand(cmd);

                    myConst = CommonData.StkRoot.GetObjectFromPath("Constellation/" + constellation) as IAgConstellation;
                    IAgSatellite sat;
                    //Compare prev satellite list to new satellite list
                    result = CommonData.StkRoot.ExecuteCommand("ShowNames * Class Satellite");
                    string[] newSatArray = null;
                    if (result[0] != "None")
                    {
                        newSatArray = result[0].Split(null);
                    }
                    if (prevSatArray == null)
                    {
                        if (newSatArray != null)
                        {
                            foreach (var item in newSatArray)
                            {
                                if (item != "")
                                {
                                    string newItem = item.Split('/').Last();
                                    string objPath = "Satellite/" + newItem;
                                    myConst.Objects.Add(objPath);
                                    sat = CommonData.StkRoot.GetObjectFromPath(item.ToString()) as IAgSatellite;
                                    if (CoordSystem.SelectedIndex == 0)
                                    {
                                        sat.VO.OrbitSystems.FixedByWindow.IsVisible    = true;
                                        sat.VO.OrbitSystems.InertialByWindow.IsVisible = false;
                                    }
                                    cmd = "VO */" + item.ToString() + " ModelDetail Set ModelLabel 2000000000 MarkerLabel 2000000000";
                                    CommonData.StkRoot.ExecuteCommand(cmd);
                                }
                            }
                        }
                    }
                    else
                    {
                        bool exists = false;
                        foreach (var newSat in newSatArray)
                        {
                            if (newSat != "")
                            {
                                exists = false;
                                foreach (var prevSat in prevSatArray)
                                {
                                    if (prevSat == newSat)
                                    {
                                        exists = true;
                                    }
                                }
                                if (exists != true)
                                {
                                    string newItem = newSat.Split('/').Last();
                                    string objPath = "Satellite/" + newItem;
                                    myConst.Objects.Add(objPath);
                                    sat = CommonData.StkRoot.GetObjectFromPath(objPath) as IAgSatellite;
                                    if (CoordSystem.SelectedIndex == 0)
                                    {
                                        sat.VO.OrbitSystems.FixedByWindow.IsVisible    = true;
                                        sat.VO.OrbitSystems.InertialByWindow.IsVisible = false;
                                    }
                                    cmd = "VO */" + objPath + " ModelDetail Set ModelLabel 2000000000 MarkerLabel 2000000000";
                                    CommonData.StkRoot.ExecuteCommand(cmd);
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Could not load asset(s)");
                }
            }
            else if ((string)ImportType.SelectedItem == "Orbital Elements")
            {
                int check = FieldCheck();
                if (check == 0)
                {
                    int errorNum = 0;
                    try
                    {
                        errorNum = 1;
                        IAgStkObject sat   = CreatorFunctions.GetCreateSatellite(NameValue.Text);
                        IAgSatellite mySat = sat as IAgSatellite;
                        if (CoordSystem.SelectedIndex == 0)
                        {
                            mySat.VO.OrbitSystems.FixedByWindow.IsVisible    = true;
                            mySat.VO.OrbitSystems.InertialByWindow.IsVisible = false;
                            string cmd = "VO */Satellite/" + NameValue.Text + " ModelDetail Set ModelLabel 2000000000 MarkerLabel 2000000000";
                            CommonData.StkRoot.ExecuteCommand(cmd);
                        }
                        ((IAgSatellite)mySat).SetPropagatorType(AgEVePropagatorType.ePropagatorJ2Perturbation);
                        IAgOrbitStateClassical keplerian;
                        keplerian = ((IAgOrbitStateClassical)((IAgVePropagatorJ2Perturbation)((IAgSatellite)mySat).Propagator).InitialState.Representation.ConvertTo(AgEOrbitStateType.eOrbitStateClassical));
                        keplerian.SizeShapeType = AgEClassicalSizeShape.eSizeShapeSemimajorAxis;
                        ((IAgVePropagatorJ2Perturbation)((IAgSatellite)mySat).Propagator).InitialState.Representation.AssignClassical(AgECoordinateSystem.eCoordinateSystemICRF, Double.Parse(SMAValue.Text), Double.Parse(EccValue.Text), Double.Parse(IncValue.Text), Double.Parse(AoPValue.Text), Double.Parse(RAANValue.Text), Double.Parse(TAValue.Text));
                        ((IAgVePropagatorJ2Perturbation)((IAgSatellite)mySat).Propagator).Propagate();
                        IAgExecCmdResult result = CommonData.StkRoot.ExecuteCommand("DoesObjExist / */Constellation/Assets");
                        errorNum = 2;
                        if ((string)ConstType.SelectedItem == "Default Constellation")
                        {
                            IAgStkObject     conste = CreatorFunctions.GetCreateConstellation("Assets");
                            IAgConstellation assets = conste as IAgConstellation;

                            string objPath = "Satellite/" + NameValue.Text;
                            assets.Objects.Add(objPath);
                        }
                        else if ((string)ConstType.SelectedItem == "Existing Constellation")
                        {
                            IAgConstellation assets  = (IAgConstellation)CommonData.StkRoot.GetObjectFromPath("Constellation/" + ExistingConst.Text);
                            string           objPath = "Satellite/" + NameValue.Text;
                            assets.Objects.Add(objPath);
                        }
                        else if ((string)ConstType.SelectedItem == "New Constellation")
                        {
                            IAgConstellation assets  = (IAgConstellation)CommonData.StkRoot.CurrentScenario.Children.New(AgESTKObjectType.eConstellation, ConstName.Text);
                            string           objPath = "Satellite/" + NameValue.Text;
                            assets.Objects.Add(objPath);
                        }
                    }
                    catch (Exception)
                    {
                        string errorMes = null;
                        if (errorNum == 1)
                        {
                            errorMes = "Could not load satellite- Improper Orbital Elements";
                        }
                        else if (errorNum == 2)
                        {
                            errorMes = "Could not add satellite to constellation";
                        }
                        MessageBox.Show(errorMes);
                    }
                }
            }
            else if ((string)ImportType.SelectedItem == "Satellite Database")
            {
                string           sscString = null;
                string           satName   = null;
                int              errorNum  = 0;
                string           errorSsc  = null;
                string           objPath   = null;
                IAgSatellite     mySat     = null;
                IAgConstellation assets    = null;
                IAgScenario      scenario  = CommonData.StkRoot.CurrentScenario as IAgScenario;
                string           startTime = scenario.StartTime;
                string           stopTime  = scenario.StopTime;
                string           cmd;
                int              errorId = 0;
                CommonData.StkRoot.ExecuteCommand("BatchGraphics * On");
                foreach (var item in _selectedSatList)
                {
                    //Determine the proper satellite name based on catalog
                    errorId = 5;
                    int        index      = CommonData.SatCatItemList.IndexOf(CommonData.SatCatItemList.Where(p => p.Ssc == item).FirstOrDefault());
                    SatCatItem currentSat = CommonData.SatCatItemList[index];
                    if (currentSat.OtherName != "Unspecified")
                    {
                        string otherName = currentSat.OtherName.Replace(" ", "_");
                        otherName = Regex.Replace(otherName, @"[^0-9a-zA-Z_]+", "");
                        //CommonData.StkRoot.ExecuteCommand("Rename */" + objPath + " " + otherName);
                        objPath = "Satellite/" + otherName;
                        satName = otherName;
                    }
                    else if (currentSat.CommonName != "Unspecified")
                    {
                        string commonName = currentSat.CommonName.Replace(" ", "_");
                        commonName = Regex.Replace(commonName, @"[^0-9a-zA-Z_]+", "");
                        objPath    = "Satellite/" + commonName;
                        satName    = commonName;
                    }
                    else
                    {
                        objPath = "Satellite/" + item;
                        satName = item;
                    }

                    //SSCString = "SSCNumber " + item + " ";
                    //cmd = "ImportTLEFile * " + "\"" + CommonData.SatDatabaseLocation + "\"" +SSCString+ "AutoPropagate On TimeStep 30.0 StartStop " + "\"" + startTime + "\" " + "\"" + stopTime + "\"";
                    try
                    {
                        errorId = 1;
                        //Create or get handle to satellite based on given name
                        mySat = (IAgSatellite)CreatorFunctions.GetCreateSatellite(satName);
                        //Erase old TLE data and replace it with new data from specified file
                        mySat.SetPropagatorType(AgEVePropagatorType.ePropagatorSGP4);
                        IAgVePropagatorSGP4 tleprop = mySat.Propagator as IAgVePropagatorSGP4;
                        tleprop.Segments.RemoveAllSegs();//clear before adding new
                        tleprop.CommonTasks.AddSegsFromFile(item, CommonData.Preferences.SatDatabaseLocation);
                        tleprop.Propagate();
                        mySat.Graphics.Resolution.Orbit = 20;
                        //Change trajectory representation to fixed if required. Inertial by default
                        if (CoordSystem.SelectedIndex == 0)
                        {
                            mySat.VO.OrbitSystems.FixedByWindow.IsVisible    = true;
                            mySat.VO.OrbitSystems.InertialByWindow.IsVisible = false;
                            string cmd1 = "VO */Satellite/" + satName + " ModelDetail Set ModelLabel 2000000000 MarkerLabel 2000000000";
                            CommonData.StkRoot.ExecuteCommand(cmd1);
                        }
                        else if (CoordSystem.SelectedIndex == 1)
                        {
                            mySat.VO.OrbitSystems.FixedByWindow.IsVisible    = false;
                            mySat.VO.OrbitSystems.InertialByWindow.IsVisible = true;
                            string cmd1 = "VO */Satellite/" + satName + " ModelDetail Set ModelLabel 2000000000 MarkerLabel 2000000000";
                            CommonData.StkRoot.ExecuteCommand(cmd1);
                        }

                        //Get handle to constellation or create if necessary. Add satellite to constellation
                        if ((string)ConstType.SelectedItem == "Default Constellation")
                        {
                            errorId = 2;
                            assets  = CreatorFunctions.GetCreateConstellation("Assets") as IAgConstellation;
                        }
                        else if ((string)ConstType.SelectedItem == "Existing Constellation")
                        {
                            errorId = 3;
                            assets  = CreatorFunctions.GetCreateConstellation(ExistingConst.Text) as IAgConstellation;
                        }
                        else if ((string)ConstType.SelectedItem == "New Constellation")
                        {
                            errorId = 4;
                            assets  = CreatorFunctions.GetCreateConstellation(ConstName.Text) as IAgConstellation;
                        }

                        if (!assets.Objects.Contains("Satellite/" + satName))
                        {
                            objPath = "Satellite/" + satName;
                            assets.Objects.Add(objPath);
                        }

                        errorId = 8;
                        CreatorFunctions.ChangeSatColor(objPath, index);

                        //Create sensor if applicable. Place sensor in appropiate constellation for sensors
                        if (currentSat.Fov != 0 && SensorToggle.Checked)
                        {
                            try
                            {
                                errorId = 6;
                                IAgStkObject assetsObject = assets as IAgStkObject;
                                IAgStkObject sat          = CommonData.StkRoot.GetObjectFromPath(objPath);
                                IAgSensor    sensor       = CreatorFunctions.GetCreateSensor(sat, sat.InstanceName + "_Sensor") as IAgSensor;
                                IAgStkObject sensorObject = sensor as IAgStkObject;
                                sensor.CommonTasks.SetPatternSimpleConic(currentSat.Fov / 2, 1);
                                sensor.VO.ProjectionType      = AgESnVOProjectionType.eProjectionEarthIntersections;
                                sensor.VO.PercentTranslucency = 70;

                                errorId = 7;
                                assets  = CreatorFunctions.GetCreateConstellation(assetsObject.InstanceName + "_Sensors") as IAgConstellation;
                                try
                                {
                                    assets.Objects.AddObject(sensorObject);
                                }
                                catch (Exception)
                                {
                                    //Likely already in the constellation
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }
                    catch (Exception)
                    {
                        string errorIdString = null;
                        if (errorId == 1)
                        {
                            errorIdString = "- Could not load from database";
                        }
                        else if (errorId == 2)
                        {
                            errorIdString = "- Could not add to Default constellation";
                        }
                        else if (errorId == 3)
                        {
                            errorIdString = "- Could not add to existing constellation";
                        }
                        else if (errorId == 4)
                        {
                            errorIdString = "- Could not add to new constellation";
                        }
                        else if (errorId == 5)
                        {
                            errorIdString = "- Could not change satellite name";
                        }
                        else if (errorId == 6)
                        {
                            errorIdString = "- Could not load sensor or update sensor properties";
                        }
                        else if (errorId == 7)
                        {
                            errorIdString = "- Could not add sensor to constellation";
                        }
                        else if (errorId == 8)
                        {
                            errorIdString = "- Could not change satellite color";
                        }
                        errorSsc = errorSsc + item + errorIdString + "\n\r";
                        errorNum++;
                    }
                }
                if (errorNum != 0)
                {
                    MessageBox.Show("Error loading the following satellites: \n\r" + errorSsc);
                }
                CommonData.StkRoot.ExecuteCommand("BatchGraphics * Off");
            }
            else if ((string)ImportType.SelectedItem == "Ephemeris")
            {
                try
                {
                    IAgConstellation assets        = null;
                    string           constellation = null;
                    if ((string)ConstType.SelectedItem == "Default Constellation")
                    {
                        IAgStkObject obj = CreatorFunctions.GetCreateConstellation("Assets");
                        assets        = obj as IAgConstellation;
                        constellation = "Assets";
                    }
                    else if ((string)ConstType.SelectedItem == "Existing Constellation")
                    {
                        IAgStkObject obj = CreatorFunctions.GetCreateConstellation(ExistingConst.Text);
                        assets        = obj as IAgConstellation;
                        constellation = ExistingConst.Text;
                    }
                    else if ((string)ConstType.SelectedItem == "New Constellation")
                    {
                        IAgStkObject obj = CreatorFunctions.GetCreateConstellation(ConstName.Text);
                        assets        = obj as IAgConstellation;
                        constellation = ConstName.Text;
                    }
                    string   filepath   = TCEFile.Text;
                    string[] separator1 = { "\\" };
                    string[] separator2 = { "." };
                    string   fileName   = filepath.Split(separator1, StringSplitOptions.None).Last();
                    string   satName    = fileName.Split(separator2, StringSplitOptions.None).First();
                    satName = Regex.Replace(satName, @"[^0-9a-zA-Z_]+", "");
                    IAgStkObject satObj = CreatorFunctions.GetCreateSatellite(satName);
                    IAgSatellite sat    = satObj as IAgSatellite;
                    sat.SetPropagatorType(AgEVePropagatorType.ePropagatorStkExternal);
                    IAgVePropagatorStkExternal prop = sat.Propagator as IAgVePropagatorStkExternal;
                    prop.Filename = filepath;
                    if (TimeSlip.Checked)
                    {
                        try
                        {
                            prop.Override = true;
                            prop.EphemerisStartEpoch.SetExplicitTime(SlipTime.Text);
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Could not apply time slip");
                        }
                    }
                    prop.Propagate();
                    try
                    {
                        assets.Objects.AddObject(satObj);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Could not add to constellation");
                    }

                    if (CoordSystem.SelectedIndex == 0)
                    {
                        sat.VO.OrbitSystems.FixedByWindow.IsVisible    = true;
                        sat.VO.OrbitSystems.InertialByWindow.IsVisible = false;
                        string cmd = "VO */Satellite/" + satName + " ModelDetail Set ModelLabel 2000000000 MarkerLabel 2000000000";
                        CommonData.StkRoot.ExecuteCommand(cmd);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Error loading ephemeris");
                }
            }
            CommonData.StkRoot.ExecuteCommand("BatchGraphics * Off");
            PopulateExistingConstellations();
        }
コード例 #32
0
        private void Apply_Click(object sender, EventArgs e)
        {
            int check = FieldCheck3D();

            if (check == 0)
            {
                current.WindowName = WindowSelect.Text;
                current.WindowId   = SmartViewFunctions.GetWindowId(WindowSelect.Text, 1);
                current.Name       = ViewName3D.Text;
                current.ViewType   = "3D";
                string className = SmartViewFunctions.GetClassName(FocusedItem.Text);
                current.ViewTarget = className + "/" + FocusedItem.Text;
                current.ViewAxes   = "Inertial";

                if (EnableUniversalOrbitTrack.Checked)
                {
                    if (UniversalLeadTrail.Checked)
                    {
                        current.EnableUniversalOrbitTrack = true;
                        current.UniqueLeadTrail           = false;
                        if (LeadType3D.Text == "Time")
                        {
                            current.LeadType = LeadType3D.Text + " " + OrbitLeadTime.Text;
                            current.LeadTime = OrbitLeadTime.Text;
                        }
                        else
                        {
                            current.LeadType = LeadType3D.Text;
                        }

                        if (TrailType3D.Text == "Time")
                        {
                            current.TrailType = TrailType3D.Text + " " + OrbitTrailTime.Text;
                            current.TrailTime = OrbitTrailTime.Text;
                        }
                        else
                        {
                            current.TrailType = TrailType3D.Text;
                        }
                    }
                    else if (UniqueLeadTrail.Checked)
                    {
                        current.UniqueLeadTrail           = true;
                        current.EnableUniversalOrbitTrack = true;
                    }
                }
                else
                {
                    current.EnableUniversalOrbitTrack = false;
                    current.LeadType  = "None";
                    current.TrailType = "None";
                }

                if (UseDataDisplay.Checked)
                {
                    current.PrimaryDataDisplay.DataDisplayActive   = true;
                    current.PrimaryDataDisplay.DataDisplayLocation = DisplayLocation.Text;
                    className = SmartViewFunctions.GetClassName(DisplayObject.Text);
                    current.PrimaryDataDisplay.DataDisplayObject     = className + "/" + DisplayObject.Text;
                    current.PrimaryDataDisplay.DataDisplayReportName = DisplayReport.Text;
                    className = SmartViewFunctions.GetClassName(PredataObject.Text);
                    current.PrimaryDataDisplay.PredataObject = className + "/" + PredataObject.Text;
                }
                else
                {
                    current.PrimaryDataDisplay.DataDisplayActive   = false;
                    current.PrimaryDataDisplay.DataDisplayLocation = DisplayLocation.Text;
                    className = SmartViewFunctions.GetClassName(DisplayObject.Text);
                    current.PrimaryDataDisplay.DataDisplayObject     = className + "/" + DisplayObject.Text;
                    current.PrimaryDataDisplay.DataDisplayReportName = DisplayReport.Text;
                    current.PrimaryDataDisplay.PredataObject         = PredataObject.Text;
                }

                if (UseCurrentTime.Checked)
                {
                    current.UseAnimationTime = true;
                    current.AnimationTime    = CurrentTime.Text;
                }
                else
                {
                    current.UseAnimationTime = false;
                    IAgScenario scenario = (IAgScenario)(CommonData.StkRoot.CurrentScenario);
                    current.AnimationTime = scenario.StartTime;
                }

                if (UseCurrentViewPoint.Checked)
                {
                    //only refresh view if not previously active. you can also refresh using the 'refresh' button on the screen
                    if (!current.UseStoredView)
                    {
                        current.StoredViewName = ViewName3D.Text;
                        CommonData.StkRoot.ExecuteCommand("VO * SaveStoredView \"" + ViewName3D.Text + "\" " + current.WindowId);
                    }
                    current.UseStoredView = true;
                }
                else
                {
                    current.UseStoredView  = false;
                    current.StoredViewName = "None";
                }

                if (ObjectHideShow.Checked)
                {
                    current.ObjectHideShow = true;
                    List <ObjectData> data = new List <ObjectData>();
                    data = CommonData.CurrentViewObjectData;
                    current.ViewObjectData = data;
                }
                else
                {
                    current.ObjectHideShow = false;
                }

                if (UseVectorHideShow.Checked)
                {
                    current.VectorHideShow = true;
                }
                else
                {
                    current.VectorHideShow = false;
                }

                if (UseCameraPath.Checked)
                {
                    current.UseCameraPath  = true;
                    current.CameraPathName = CameraPathName.Text;
                }
                else
                {
                    current.UseCameraPath = false;
                }

                CommonData.SavedViewList[CommonData.SelectedIndex] = current;
                CommonData.UpdatedView = true;
                try
                {
                    ReadWrite.WriteSavedViews(CommonData.DirectoryStr + "\\StoredViewData.json");
                }
                catch (Exception)
                {
                    MessageBox.Show("Could not Write Stored Views File");
                }
                this.Close();
            }
        }
コード例 #33
0
        private void Create_Click(object sender, EventArgs e)
        {
            string   className;
            ViewData current = new ViewData();
            int      check;

            if (TypeSelect.SelectedIndex == 0) //3D
            {
                check = FieldCheck3D();
                if (check == 0)
                {
                    current.WindowName = WindowSelect.Text;
                    current.WindowId   = SmartViewFunctions.GetWindowId(WindowSelect.Text, 1);
                    current.Name       = ViewName3D.Text;
                    current.ViewType   = TypeSelect.Text;
                    className          = SmartViewFunctions.GetClassName(FocusedItem.Text);
                    current.ViewTarget = className + "/" + FocusedItem.Text;
                    current.ViewAxes   = ViewType.Text;

                    if (EnableUniversalOrbitTrack.Checked)
                    {
                        current.EnableUniversalOrbitTrack = true;
                        if (LeadType3D.Text == "Time")
                        {
                            current.LeadType = LeadType3D.Text + " " + OrbitLeadTime.Text;
                            current.LeadTime = OrbitLeadTime.Text;
                        }
                        else
                        {
                            current.LeadType = LeadType3D.Text;
                        }

                        if (TrailType3D.Text == "Time")
                        {
                            current.TrailType = TrailType3D.Text + " " + OrbitTrailTime.Text;
                            current.TrailTime = OrbitTrailTime.Text;
                        }
                        else
                        {
                            current.TrailType = TrailType3D.Text;
                        }
                    }
                    else
                    {
                        current.LeadType  = "None";
                        current.TrailType = "None";
                    }

                    if (UseDataDisplay.Checked)
                    {
                        current.DataDisplayActive   = true;
                        current.DataDisplayLocation = DisplayLocation.Text;
                        className = SmartViewFunctions.GetClassName(DisplayObject.Text);
                        current.DataDisplayObject     = className + "/" + DisplayObject.Text;
                        current.DataDisplayReportName = DisplayReport.Text;
                    }
                    else
                    {
                        current.DataDisplayActive   = false;
                        current.DataDisplayLocation = DisplayLocation.Text;
                        className = SmartViewFunctions.GetClassName(DisplayObject.Text);
                        current.DataDisplayObject     = className + "/" + DisplayObject.Text;
                        current.DataDisplayReportName = DisplayReport.Text;
                    }

                    if (UseCurrentViewPoint.Checked)
                    {
                        current.UseStoredView  = true;
                        current.StoredViewName = ViewName3D.Text;
                        CommonData.StkRoot.ExecuteCommand("VO * SaveStoredView \"" + ViewName3D.Text + "\" " + current.WindowId);
                    }
                    else
                    {
                        current.UseStoredView  = false;
                        current.StoredViewName = "None";
                    }
                }
            }
            else if (TypeSelect.SelectedIndex == 1) //2D
            {
                check = FieldCheck2D();
                if (check == 0)
                {
                    current.WindowName      = WindowSelect.Text;
                    current.WindowId        = SmartViewFunctions.GetWindowId(WindowSelect.Text, 0);
                    current.Name            = ViewName2D.Text;
                    current.ViewType        = TypeSelect.Text;
                    current.ViewType2D      = TypeSelect2D.Text;
                    className               = SmartViewFunctions.GetClassName(ObjectName2D.Text);
                    current.ViewTarget      = className + "/" + ObjectName2D.Text;
                    current.ZoomCenterLat   = ZoomCenterLat.Text;
                    current.ZoomCenterLong  = ZoomCenterLong.Text;
                    current.ZoomCenterDelta = ZoomDelta.Text;

                    if (EnableUniversalGroundTrack.Checked)
                    {
                        if (LeadType2D.Text == "Time")
                        {
                            current.LeadType = LeadType2D.Text + " " + GroundLeadTime.Text;
                            current.LeadTime = GroundLeadTime.Text;
                        }
                        else
                        {
                            current.LeadType = LeadType2D.Text;
                        }

                        if (TrailType2D.Text == "Time")
                        {
                            current.TrailType = TrailType2D.Text + " " + GroundTrailTime.Text;
                            current.TrailTime = GroundTrailTime.Text;
                        }
                        else
                        {
                            current.TrailType = TrailType2D.Text;
                        }
                    }
                    else
                    {
                        current.LeadType  = "None";
                        current.TrailType = "None";
                    }

                    current.ShowAerialSensors = false;

                    current.ShowGroundSensors = false;
                }
            }
            else if (TypeSelect.SelectedIndex == 2) //Target/Threat
            {
                current.WindowName     = WindowSelect.Text;
                current.ViewType       = "Target/Threat";
                current.ThreatSatNames = _threatNames;
                className = SmartViewFunctions.GetClassName(TargetSatellite.Text);
                current.TargetSatellite = className + "/" + TargetSatellite.Text;
                current.Name            = TTViewName.Text;

                if (TTUseDataDisplay.Checked)
                {
                    current.TtDataDisplayActive   = true;
                    current.DataDisplayActive     = true;
                    current.TtDataDisplayLocation = TTDisplayLocation.Text;
                    if (TTDisplayObject.SelectedIndex == 0)
                    {
                        className = SmartViewFunctions.GetClassName(TargetSatellite.Text);
                        current.TtDataDisplayObject     = className + "/" + TargetSatellite.Text;
                        current.TtDataDisplayReportName = TTDisplayReport.Text;
                    }
                    else if (TTDisplayObject.SelectedIndex == 1)
                    {
                        current.TtDataDisplayObject     = "AllThreat";
                        current.TtDataDisplayReportName = TTDisplayReport.Text;
                    }
                    else
                    {
                        className = SmartViewFunctions.GetClassName(TTDisplayObject.Text);
                        current.TtDataDisplayObject     = className + "/" + TTDisplayObject.Text;
                        current.TtDataDisplayReportName = TTDisplayReport.Text;
                    }
                }
                else
                {
                    current.TtDataDisplayActive   = false;
                    current.DataDisplayActive     = false;
                    current.TtDataDisplayLocation = TTDisplayLocation.Text;
                    className = SmartViewFunctions.GetClassName(TTDisplayObject.Text);
                    current.TtDataDisplayObject     = className + "/" + TTDisplayObject.Text;
                    current.TtDataDisplayReportName = TTDisplayReport.Text;
                }

                if (UseProxBox.Checked)
                {
                    current.EnableProximityBox = true;
                }
                else
                {
                    current.EnableProximityBox = false;
                }

                if (EnableEllipsoid.Checked)
                {
                    current.EnableProximityEllipsoid = true;
                    current.EllipsoidX = EllipsoidX.Text;
                    current.EllipsoidY = EllipsoidX.Text;
                    current.EllipsoidZ = EllipsoidX.Text;
                }
                else
                {
                    current.EnableProximityEllipsoid = false;
                    current.EllipsoidX = "100";
                    current.EllipsoidY = "100";
                    current.EllipsoidZ = "100";
                }
            }
            else if (TypeSelect.SelectedIndex == 3) //GEO Drift
            {
                current.WindowName               = WindowSelect.Text;
                current.ViewType                 = "GEODrift";
                current.Name                     = GEOViewName.Text;
                className                        = SmartViewFunctions.GetClassName(GEOViewTarget.Text);
                current.ViewTarget               = className + "/" + GEOViewTarget.Text;
                current.EnableGeoBox             = UseGEOBox.Checked;
                current.GeoLongitude             = GEOLongitude.Text;
                current.GeoNorthSouth            = GeoNorthSouth.Text;
                current.GeoEastWest              = GEOEastWest.Text;
                current.GeoRadius                = GEORadius.Text;
                current.GeoDataDisplayActive     = GEOUseDataDisplay.Checked;
                className                        = SmartViewFunctions.GetClassName(GEODisplayObject.Text);
                current.GeoDataDisplayObject     = className + "/" + GEODisplayObject.Text;
                current.GeoDataDisplayReportName = GEODisplayReport.Text;
                current.GeoDataDisplayLocation   = GEODisplayLocation.Text;
            }

            if (UseCurrentTime.Checked)
            {
                IAgAnimation animationRoot = (IAgAnimation)CommonData.StkRoot;
                double       currentTime   = animationRoot.CurrentTime;
                current.AnimationTime = currentTime.ToString();
            }
            else
            {
                current.UseAnimationTime = false;
                IAgScenario scenario = (IAgScenario)(CommonData.StkRoot.CurrentScenario);
                current.AnimationTime = scenario.StartTime;
            }
            if (ObjectHideShow.Checked)
            {
                current.ObjectHideShow = true;
                List <ObjectData> data = new List <ObjectData>();
                data = CommonData.CurrentViewObjectData;
                current.ViewObjectData = data;
            }
            else
            {
                current.ObjectHideShow = false;
            }
            CommonData.SavedViewList.Add(current);
            try
            {
                ReadWrite.WriteSavedViews(CommonData.DirectoryStr + "\\StoredViewData.json");
            }
            catch (Exception)
            {
                MessageBox.Show("Could not Write Stored Views File");
            }

            //try
            //{
            //    ReadWrite.WriteObjectData(CommonData.DirectoryStr + "\\StoredObjectData.txt");
            //}
            //catch (Exception)
            //{

            //    MessageBox.Show("Could not Write Object Data File");
            //}
            CommonData.NewView = true;
            this.Close();
        }