Ejemplo n.º 1
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 IAgStkObjectRoot;
                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);
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
0
        public void OnStartup(IAgUiPluginSite PluginSite)
        {
            m_pSite = PluginSite;
            IAgUiApplication AgUiApp = m_pSite.Application;

            m_root = AgUiApp.Personality2 as IAgStkObjectRoot;
            m_root.Isolate();
            m_root.UnitPreferences.ResetUnits();
            ((AgStkObjectRoot)m_root).OnScenarioClose += new IAgStkObjectRootEvents_OnScenarioCloseEventHandler(m_root_OnScenarioClose);
        }
Ejemplo n.º 4
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.º 5
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();
        }
 public StkObjectsLibrary(IAgStkObjectRoot root)
 {
     m_root = root;
 }
Ejemplo n.º 7
0
 public void OnStartup(IAgUiPluginSite PluginSite)
 {
     m_psite = PluginSite;
     m_root  = (IAgStkObjectRoot)m_psite.Application.Personality2;
 }