Beispiel #1
0
 /// <summary>
 /// 从场景中卸载(如果有的话)
 /// </summary>
 /// <param name="type"></param>
 /// <param name="objName"></param>
 public static void UnloadObjectFromScenario(AgESTKObjectType type, string objName)
 {
     if (stkRoot.CurrentScenario.Children.Contains(type, objName))
     {
         stkRoot.CurrentScenario.Children.Unload(type, objName);
     }
 }
        private void CreateNew(AgESTKObjectType ephemObjType, string objScenName, string objectPath, string ephemObjName, string filePath)
        {
            IAgStkObject newEphObj;

            if (CommonData.StkRoot.CurrentScenario.Children.Contains(ephemObjType, objScenName + "_FromEphem"))
            {
                newEphObj = CommonData.StkRoot.GetObjectFromPath(objectPath + "_FromEphem");
            }
            else
            {
                newEphObj = CommonData.StkRoot.CurrentScenario.Children.New(ephemObjType, objScenName + "_FromEphem");
            }

            var propExt = AgEVePropagatorType.ePropagatorStkExternal;

            if (ephemObjName == "Satellite")
            {
                ((IAgSatellite)newEphObj).SetPropagatorType(propExt);
                ((IAgVePropagatorStkExternal)((IAgSatellite)newEphObj).Propagator).Filename = filePath;
                ((IAgVePropagatorStkExternal)((IAgSatellite)newEphObj).Propagator).Propagate();
            }
            else if (ephemObjName == "Missile")
            {
                ((IAgMissile)newEphObj).SetTrajectoryType(propExt);
                ((IAgVePropagatorStkExternal)((IAgMissile)newEphObj).Trajectory).Filename = filePath;
                ((IAgVePropagatorStkExternal)((IAgMissile)newEphObj).Trajectory).Propagate();
            }
            else if (ephemObjName == "LaunchVehicle")
            {
                ((IAgLaunchVehicle)newEphObj).SetTrajectoryType(propExt);
                ((IAgVePropagatorStkExternal)((IAgLaunchVehicle)newEphObj).Trajectory).Filename = filePath;
                ((IAgVePropagatorStkExternal)((IAgLaunchVehicle)newEphObj).Trajectory).Propagate();
            }
            else if (ephemObjName == "Aircraft")
            {
                ((IAgAircraft)newEphObj).SetRouteType(propExt);
                ((IAgVePropagatorStkExternal)((IAgAircraft)newEphObj).Route).Filename = filePath;
                ((IAgVePropagatorStkExternal)((IAgAircraft)newEphObj).Route).Propagate();
            }
            else if (ephemObjName == "GroundVehicle")
            {
                ((IAgGroundVehicle)newEphObj).SetRouteType(propExt);
                ((IAgVePropagatorStkExternal)((IAgGroundVehicle)newEphObj).Route).Filename = filePath;
                ((IAgVePropagatorStkExternal)((IAgGroundVehicle)newEphObj).Route).Propagate();
            }
            else if (ephemObjName == "Ship")
            {
                ((IAgShip)newEphObj).SetRouteType(propExt);
                ((IAgVePropagatorStkExternal)((IAgShip)newEphObj).Route).Filename = filePath;
                ((IAgVePropagatorStkExternal)((IAgShip)newEphObj).Route).Propagate();
            }
        }
Beispiel #3
0
 /// <summary>
 /// 从场景中获取对象
 /// </summary>
 /// <param name="type">对象类型</param>
 /// <param name="SateName">对象名称(部分名称即可)</param>
 /// <returns></returns>
 public static IAgStkObject GetObjectFromScenario(AgESTKObjectType type, string objName)
 {
     try
     {
         foreach (IAgStkObject obj in stkRoot.CurrentScenario.Children)
         {
             if (obj.InstanceName.Contains(objName) && obj.ClassType == type)
             {
                 return(obj);
             }
         }
         return(null);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
        private void AddStkObjects(ComboBox comboBox, AgESTKObjectType objectType)
        {
            try
            {
                // Save the current selection
                object currentItem = comboBox.SelectedItem;
                comboBox.Items.Clear();

                foreach (IAgStkObject stkObject in m_root.CurrentScenario.Children.GetElements(objectType))
                {
                    // Add item by name as everyone will be unique and this list only has satellites
                    comboBox.Items.Add(stkObject.InstanceName);
                }

                // Keep the previous selection, unless there wasn't one or it was deleted.
                if (currentItem == null)
                {
                    try
                    {
                        comboBox.SelectedIndex = 0;
                    }
                    catch { }
                }
                else
                {
                    if (comboBox.Items.Contains(currentItem))
                    {
                        comboBox.SelectedItem = currentItem;
                    }
                    else
                    {
                        try
                        {
                            comboBox.SelectedIndex = 0;
                        }
                        catch { }
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Error");
            }
        }
        private string uniqueName(string inputName, AgESTKObjectType objectType)
        {
            string outputName = inputName.Replace(' ', '_');

            bool nameExists = true;
            int  counter    = 1;

            while (nameExists)
            {
                if (root.CurrentScenario.Children.Contains(objectType, outputName))
                {
                    outputName = inputName + "_" + counter.ToString();
                    ++counter;
                }
                else
                {
                    nameExists = false;
                }
            }
            return(outputName);
        }
Beispiel #6
0
        /// <summary>
        /// 从场景中获取对象列表
        /// </summary>
        /// <param name="type">对象类型</param>
        /// <param name="SateName">对象名称(部分名称即可)</param>
        /// <returns></returns>
        public static List <IAgStkObject> GetObjectCollectionFromScenario(AgESTKObjectType type, string objName)
        {
            try
            {
                List <IAgStkObject> allobj = new List <IAgStkObject>();

                foreach (IAgStkObject obj in stkRoot.CurrentScenario.Children)
                {
                    if (obj.InstanceName.Contains(objName) && obj.ClassType == type)
                    {
                        allobj.Add(obj);
                    }
                }

                return(allobj);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }