Ejemplo n.º 1
0
        //#####################################################################
        /// <summary>
        /// 初始化STK 10 桌面程序
        /// <para>1 启动STK桌面程序(若已有场景,则关联当前场景)</para>
        /// <para>2 为uiApp,stkRoot赋值</para>
        /// </summary>
        public static void InitialSTK10Desktop()
        {
            try
            {
                try
                {
                    //  关联已打开的STK桌面程序
                    uiApp = Marshal.GetActiveObject("STK10.Application") as AgUiApplication;
                }
                catch
                {
                    //  创建新的STK桌面程序
                    uiApp = new AgUiApplication();
                    uiApp.LoadPersonality("STK");
                    uiApp.Visible     = true;
                    uiApp.UserControl = true;
                }

                // Retrieve the root of the StkEngine Automation Object Model.
                _stkRoot = uiApp.Personality2 as AGI.STKObjects.AgStkObjectRoot;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "初始化STK 10出错!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Ejemplo n.º 2
0
        //#####################################################################
        /// <summary>
        /// 初始化STK 11 桌面程序
        /// <para>1 启动STK桌面程序(若已有场景,则关联当前场景)</para>
        /// <para>2 为uiApp,stkRoot赋值</para>
        /// </summary>
        public static void InitialSTK11Desktop()
        {
            try
            {
                try
                {
                    //  关联已打开的STK桌面程序
                    uiApp = Marshal.GetActiveObject("STK11.Application") as AgUiApplication;
                }
                catch
                {
                    //  创建新的STK桌面程序
                    //Guid clsID = typeof(AgUiApplicationClass).GUID;
                    //Type t = Type.GetTypeFromCLSID(clsID);
                    //uiApp = Activator.CreateInstance(t) as AGI.Ui.Application.AgUiApplication;
                    uiApp = new AgUiApplication();
                    uiApp.LoadPersonality("STK");
                    uiApp.Visible     = true;
                    uiApp.UserControl = true;
                }

                // Retrieve the root of the StkEngine Automation Object Model.
                _stkRoot = uiApp.Personality2 as AGI.STKObjects.AgStkObjectRoot;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "初始化STK 11出错!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Ejemplo n.º 3
0
        private void createScenarioTleDoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            app = new AgUiApplication();
            app.LoadPersonality("STK");
            root      = (AgStkObjectRoot)app.Personality2;
            initState = new InitialState();
            satData   = new Data(Convert.ToDouble(tbMass.Text), Convert.ToDouble(tbDragArea.Text), Convert.ToDouble(tbCd.Text), Convert.ToDouble(tbSolarArea.Text), Convert.ToDouble(tbCr.Text));
            STK.CreateScenarioFromTle(ref root, Convert.ToDouble(this.nudDuration.Value), ref initState, currentTle);
            STK.ConfigurePropagator(root);
            root.Rewind();
        }
Ejemplo n.º 4
0
        private void createScenarioSatcatDoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            app = new AgUiApplication();
            app.LoadPersonality("STK");
            root      = (AgStkObjectRoot)app.Personality2;
            initState = new InitialState();
            satData   = new Data(Convert.ToDouble(tbMass.Text), Convert.ToDouble(tbDragArea.Text), Convert.ToDouble(tbCd.Text), Convert.ToDouble(tbSolarArea.Text), Convert.ToDouble(tbCr.Text));
            string satelliteID = this.dgvSatList.SelectedRows[0].Cells[1].Value.ToString();

            currentTle = STK.CreateScenarioFromSatcat(ref root, Convert.ToDouble(this.nudDuration.Value), ref initState, satelliteID);

            STK.ConfigurePropagator(root);
            root.Rewind();
        }
Ejemplo n.º 5
0
        private void ConnectToSTK()
        {
            // Try to connect to existing STK instance, otherwise open a new one
            try
            {
                m_stkApplication = Marshal.GetActiveObject("STK12.Application") as AgUiApplication;
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
                m_stkApplication = new AgUiApplication();

                m_stkApplication.LoadPersonality("STK");
                m_stkApplication.Visible = true;
            }

            m_stkRoot = (AgStkObjectRoot)m_stkApplication.Personality2;
        }
Ejemplo n.º 6
0
        public NPAS_To_STK()
        {
            missionindex = new string[200];

            try
            {
                m_oSTK = Marshal.GetActiveObject("STK11.Application") as AGI.Ui.Application.AgUiApplication;
                Console.Write("Looking for an instance of STK... ");
            }
            catch
            {
                Console.Write("Creating a new STK 11 instance... ");
                Guid clsID = typeof(AgUiApplicationClass).GUID;
                Type oType = Type.GetTypeFromCLSID(clsID);
                m_oSTK = Activator.CreateInstance(oType) as AGI.Ui.Application.AgUiApplication;
                try
                {
                    m_oSTK.LoadPersonality("STK");
                }
                catch (System.Runtime.InteropServices.COMException ex)
                {
                    Console.WriteLine("Error");
                    Console.WriteLine(ex.Message);
                    //  Console.WriteLine("Press any key to continue . . .");
                    //  Console.ReadKey();
                    Environment.Exit(0);
                }
            }
            try
            {
                m_oApplication = (IAgStkObjectRoot)m_oSTK.Personality2;
                Console.WriteLine("done.");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error");
                Console.WriteLine(ex.Message);
                Console.WriteLine("Press any key to continue . . .");
                Console.ReadKey();
                Environment.Exit(0);
            }
        }
Ejemplo n.º 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            AgUiApplication uiApplication = new AgUiApplication();

            uiApplication.LoadPersonality("STK");
            uiApplication.Visible = false;
            IAgStkObjectRoot root = uiApplication.Personality2 as IAgStkObjectRoot;

            root.NewScenario("scenario");
            IAgStar star = root.CurrentScenario.Children.New(AgESTKObjectType.eStar, "MyStar") as IAgStar;

            //wait();

            run();

            //wait();

            AgFacility facility = root.CurrentScenario.Children.New(AgESTKObjectType.eFacility, "MyFacility") as AgFacility;

            button1.Text = root.CurrentScenario.Children.Count.ToString();
            uiApplication.Quit();
        }