Ejemplo n.º 1
0
        public static List <double> GetGroundLocation(string path)
        {
            List <double> location = new List <double>();
            object        lat      = 0.0;
            object        longi    = 0.0;
            double        alt      = 0.0;

            if (path.Contains("Place"))
            {
                IAgPlace place = CommonData.StkRoot.GetObjectFromPath(path) as IAgPlace;
                place.Position.QueryPlanetodetic(out lat, out longi, out alt);
            }
            else if (path.Contains("Facility"))
            {
                IAgFacility place = CommonData.StkRoot.GetObjectFromPath(path) as IAgFacility;
                place.Position.QueryPlanetodetic(out lat, out longi, out alt);
            }
            else if (path.Contains("Target"))
            {
                IAgTarget place = CommonData.StkRoot.GetObjectFromPath(path) as IAgTarget;
                place.Position.QueryPlanetodetic(out lat, out longi, out alt);
            }
            location.Add(Double.Parse(lat.ToString()));
            location.Add(Double.Parse(longi.ToString()));
            location.Add(alt);
            return(location);
        }
Ejemplo n.º 2
0
 private void PopulateDisplayReports(ComboBox box, ComboBox ddObject)
 {
     if (ddObject.SelectedIndex != -1)
     {
         string className = SmartViewFunctions.GetClassName(ddObject.Text);
         IAgVODataDisplayCollection ddCollection = null;
         if (className == "Satellite")
         {
             IAgSatellite myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + ddObject.Text) as IAgSatellite;
             ddCollection = myObject.VO.DataDisplay;
         }
         else if (className == "Aircraft")
         {
             IAgAircraft myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + ddObject.Text) as IAgAircraft;
             ddCollection = myObject.VO.DataDisplay;
         }
         else if (className == "Facility")
         {
             IAgFacility myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + ddObject.Text) as IAgFacility;
             ddCollection = myObject.VO.DataDisplays;
         }
         else if (className == "Missile")
         {
             IAgMissile myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + ddObject.Text) as IAgMissile;
             ddCollection = myObject.VO.DataDisplay;
         }
         else if (className == "GroundVehicle")
         {
             IAgGroundVehicle myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + ddObject.Text) as IAgGroundVehicle;
             ddCollection = myObject.VO.DataDisplay;
         }
         else if (className == "LaunchVehicle")
         {
             IAgLaunchVehicle myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + ddObject.Text) as IAgLaunchVehicle;
             ddCollection = myObject.VO.DataDisplay;
         }
         else if (className == "Place")
         {
             IAgPlace myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + ddObject.Text) as IAgPlace;
             ddCollection = myObject.VO.DataDisplays;
         }
         else if (className == "Target")
         {
             IAgTarget myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + ddObject.Text) as IAgTarget;
             ddCollection = myObject.VO.DataDisplays;
         }
         box.Items.Clear();
         Array reportNames = ddCollection.AvailableData;
         foreach (var name in reportNames)
         {
             box.Items.Add(name);
         }
         box.SelectedIndex = 0;
     }
 }
Ejemplo n.º 3
0
 private void DisplayObject_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (DisplayObject.SelectedIndex != -1)
     {
         string className = SmartViewFunctions.GetClassName(DisplayObject.Text);
         IAgVODataDisplayCollection ddCollection = null;
         if (className == "Satellite")
         {
             IAgSatellite myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + DisplayObject.Text) as IAgSatellite;
             ddCollection = myObject.VO.DataDisplay;
         }
         else if (className == "Aircraft")
         {
             IAgAircraft myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + DisplayObject.Text) as IAgAircraft;
             ddCollection = myObject.VO.DataDisplay;
         }
         else if (className == "Facility")
         {
             IAgFacility myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + DisplayObject.Text) as IAgFacility;
             ddCollection = myObject.VO.DataDisplays;
         }
         else if (className == "Missile")
         {
             IAgMissile myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + DisplayObject.Text) as IAgMissile;
             ddCollection = myObject.VO.DataDisplay;
         }
         else if (className == "GroundVehicle")
         {
             IAgGroundVehicle myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + DisplayObject.Text) as IAgGroundVehicle;
             ddCollection = myObject.VO.DataDisplay;
         }
         DisplayReport.Items.Clear();
         Array reportNames = ddCollection.AvailableData;
         foreach (var name in reportNames)
         {
             DisplayReport.Items.Add(name);
             if (name.ToString() == CommonData.SavedViewList[CommonData.SelectedIndex].DataDisplayReportName)
             {
                 DisplayReport.SelectedIndex = DisplayReport.Items.Count - 1;
             }
         }
         if (DisplayReport.SelectedIndex == -1)
         {
             DisplayReport.SelectedIndex = 0;
         }
     }
 }
Ejemplo n.º 4
0
        public static IAgVORefCrdnCollection GetRefCrdns(IAgStkObject stkObject)
        {
            switch (stkObject.ClassType)
            {
            case AgESTKObjectType.eAircraft:
                IAgAircraft _aircraft = stkObject as IAgAircraft;
                return(_aircraft.VO.Vector.RefCrdns);

            case AgESTKObjectType.eFacility:
                IAgFacility fac = stkObject as IAgFacility;
                return(fac.VO.Vector.RefCrdns);

            case AgESTKObjectType.eGroundVehicle:
                IAgGroundVehicle gv = stkObject as IAgGroundVehicle;
                return(gv.VO.Vector.RefCrdns);

            case AgESTKObjectType.eMissile:
                IAgMissile miss = stkObject as IAgMissile;
                return(miss.VO.Vector.RefCrdns);

            case AgESTKObjectType.ePlace:
                IAgPlace place = stkObject as IAgPlace;
                return(place.VO.Vector.RefCrdns);

            case AgESTKObjectType.eSatellite:
                IAgSatellite sat = stkObject as IAgSatellite;
                return(sat.VO.Vector.RefCrdns);

            case AgESTKObjectType.eSensor:
                IAgSensor sensor = stkObject as IAgSensor;
                return(sensor.VO.Vector.RefCrdns);

            case AgESTKObjectType.eShip:
                IAgShip ship = stkObject as IAgShip;
                return(ship.VO.Vector.RefCrdns);

            case AgESTKObjectType.eTarget:
                IAgTarget target = stkObject as IAgTarget;
                return(target.VO.Vector.RefCrdns);

            default:
                return(null);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 创建单个地面站(采用大地纬度(deg)、经度(deg)、高程(m))
        /// </summary>
        /// <param name="facilityName"></param>
        /// <param name="Lat">大地纬度(deg)</param>
        /// <param name="Lon">经度(deg)</param>
        /// <param name="Alt">高程(m)</param>
        public static void AddFacility(string facilityName, double Lat, double Lon, double Alt)
        {
            IAgFacility facility = null;

            try
            {
                //  如果存在则卸载
                if (stkRoot.CurrentScenario.Children.Contains(AgESTKObjectType.eFacility, facilityName))
                {
                    stkRoot.CurrentScenario.Children.Unload(AgESTKObjectType.eFacility, facilityName);
                }
                facility = (IAgFacility)stkRoot.CurrentScenario.Children.New(AgESTKObjectType.eFacility, facilityName);
                facility.Position.AssignGeodetic(Lat, Lon, Alt / 1000.0);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + "\n" + "无法创建地面站: " + facilityName);
            }
        }
        public bool Evaluate(AgCrdnCalcScalarPluginResultEval Result)
        {
            // If the constraint facility object hasn't been linked to yet, do that here:
            if (m_cnstrFacility == null)
            {
                // The plugin returns the truncated object path, so split the string to get the base name:
                string   cnstrFacPath      = Result.ObjectPath;
                string[] cnstrFacPathSplit = cnstrFacPath.Split('/');
                string   cnstrFacName      = cnstrFacPathSplit[cnstrFacPathSplit.Length - 1];
                m_cnstrFacility = m_StkScenario.Children[cnstrFacName] as IAgFacility;
            }

            double facilityLatitude  = 0.0;
            double facilityLongitude = 0.0;

            try
            {
                Array facilityPosition = m_cnstrFacility.Position.QueryPlanetodeticArray();
                facilityLatitude  = Convert.ToDouble(facilityPosition.GetValue(0).ToString());
                facilityLongitude = Convert.ToDouble(facilityPosition.GetValue(1).ToString());
                if (facilityLongitude < 0)
                {
                    facilityLongitude = facilityLongitude + 360;
                }
            }
            catch (Exception)
            {
                Debug.WriteLine("Unable to retrieve grid constraint facility position.");
            }

            foreach (ExternalDataItems item in _inputValueList)
            {
                if (Math.Abs(item.Latitude - facilityLatitude) < Tolerance &&
                    Math.Abs(item.Longitude - facilityLongitude) < Tolerance)
                {
                    Result.SetValue(item.Value);
                    break;
                }
            }

            return(true);
        }
Ejemplo n.º 7
0
 private void Select_Click(object sender, EventArgs e)
 {
     if (FacilityList.Items.Count == 0)
     {
         MessageBox.Show("Please create a facility prior to selection");
         this.Close();
     }
     else if (FacilityList.SelectedIndex == -1)
     {
         MessageBox.Show("Please select a facility");
     }
     else
     {
         CommonData.FacilitySelected = true;
         IAgFacility  facility    = CommonData.StkRoot.GetObjectFromPath("Facility/" + FacilityList.SelectedItem.ToString()) as IAgFacility;
         IAgStkObject facilityObj = facility as IAgStkObject;
         CommonData.FacilityName = facilityObj.InstanceName;
         Array position = facility.Position.QueryPlanetodeticArray();
         CommonData.FacilityLat  = position.GetValue(0).ToString();
         CommonData.FacilityLong = position.GetValue(1).ToString();
         this.Close();
     }
 }
        private void GenerateSingle_Click(object sender, EventArgs e)
        {
            Tuple <int, string> check = FieldCheck();

            if (check.Item1 == 0)
            {
                if (ManualInput.Checked)
                {
                    try
                    {
                        IAgStkObject facObj = CreatorFunctions.GetCreateFacility(FacilityName.Text);
                        IAgFacility  fac    = facObj as IAgFacility;
                        IAgStkObject sensor = null;
                        fac.Position.AssignGeodetic(Double.Parse(Latitude.Text), Double.Parse(Longitude.Text), Double.Parse(Altitude.Text));
                        fac.AltRef = AgEAltRefType.eWGS84;
                        if (SensorType.SelectedIndex == 1)
                        {
                            OpticalParams oParams = new OpticalParams();
                            oParams.MinEl        = "0";
                            oParams.MaxEl        = "90";
                            oParams.MinRange     = "4800";
                            oParams.MaxRange     = "90000";
                            oParams.LunarExAngle = "10";
                            oParams.SunElAngle   = "-12";
                            oParams.HalfAngle    = "70";
                            oParams.MinAz        = "0";
                            oParams.MaxAz        = "360";
                            sensor = FacilityCreatorFunctions.AttachFacilityOptical(facObj, FacilityName.Text + "_Opt", oParams);
                        }
                        else if (SensorType.SelectedIndex == 2)
                        {
                            RadarParams rParams = new RadarParams();
                            rParams.MinEl        = "0";
                            rParams.MaxEl        = "90";
                            rParams.MinRange     = "1600";
                            rParams.MaxRange     = "40000";
                            rParams.SolarExAngle = "10";
                            rParams.HalfAngle    = "85";
                            rParams.MinAz        = "0";
                            rParams.MaxAz        = "360";
                            sensor = FacilityCreatorFunctions.AttachFacilityRadar(facObj, FacilityName.Text + "_Radar", rParams);
                        }
                        else
                        {
                        }
                        if (ConstType.SelectedIndex != 0)
                        {
                            IAgStkObject     constObj = null;
                            IAgConstellation constel  = null;
                            if (ConstType.SelectedIndex == 1)
                            {
                                constObj = CreatorFunctions.GetCreateConstellation(ExistingConst.Text);
                                constel  = constObj as IAgConstellation;
                            }
                            else if (ConstType.SelectedIndex == 2)
                            {
                                constObj = CreatorFunctions.GetCreateConstellation(ConstName.Text);
                                constel  = constObj as IAgConstellation;
                            }
                            if (SensorType.SelectedIndex == 0)
                            {
                                constel.Objects.AddObject(facObj);
                            }
                            else if (SensorType.SelectedIndex == 1 || SensorType.SelectedIndex == 2)
                            {
                                constel.Objects.AddObject(sensor);
                            }
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Could not create facility");
                    }
                }
                else if (ImportFromFile.Checked)
                {
                    if (!String.IsNullOrEmpty(FilenameText.Text))
                    {
                        IAgStkObject          facObj;
                        IAgFacility           fac;
                        IAgStkObject          sensor;
                        List <GroundLocation> locations = ReadWrite.ReadFacilityFile(FilenameText.Text);
                        foreach (GroundLocation loc in locations)
                        {
                            facObj = CreatorFunctions.GetCreateFacility(loc.LocationName);
                            fac    = facObj as IAgFacility;
                            sensor = null;
                            fac.Position.AssignGeodetic(loc.Latitude, loc.Longitude, loc.Altitude);
                            fac.AltRef = AgEAltRefType.eWGS84;
                            if (SensorType.SelectedIndex == 1)
                            {
                                OpticalParams oParams = new OpticalParams();
                                oParams.MinEl        = "0";
                                oParams.MaxEl        = "90";
                                oParams.MinRange     = "4800";
                                oParams.MaxRange     = "90000";
                                oParams.LunarExAngle = "10";
                                oParams.SunElAngle   = "-12";
                                oParams.HalfAngle    = "70";
                                oParams.MinAz        = "0";
                                oParams.MaxAz        = "360";
                                sensor = FacilityCreatorFunctions.AttachFacilityOptical(facObj, FacilityName.Text + "_Opt", oParams);
                            }
                            else if (SensorType.SelectedIndex == 2)
                            {
                                RadarParams rParams = new RadarParams();
                                rParams.MinEl        = "0";
                                rParams.MaxEl        = "90";
                                rParams.MinRange     = "1600";
                                rParams.MaxRange     = "40000";
                                rParams.SolarExAngle = "10";
                                rParams.HalfAngle    = "85";
                                rParams.MinAz        = "0";
                                rParams.MaxAz        = "360";
                                sensor = FacilityCreatorFunctions.AttachFacilityRadar(facObj, FacilityName.Text + "_Radar", rParams);
                            }
                            else
                            {
                            }
                            if (ConstType.SelectedIndex != 0)
                            {
                                IAgStkObject     constObj = null;
                                IAgConstellation constel  = null;
                                if (ConstType.SelectedIndex == 1)
                                {
                                    constObj = CreatorFunctions.GetCreateConstellation(ExistingConst.Text);
                                    constel  = constObj as IAgConstellation;
                                }
                                else if (ConstType.SelectedIndex == 2)
                                {
                                    constObj = CreatorFunctions.GetCreateConstellation(ConstName.Text);
                                    constel  = constObj as IAgConstellation;
                                }
                                if (SensorType.SelectedIndex == 0)
                                {
                                    constel.Objects.AddObject(facObj);
                                }
                                else if (SensorType.SelectedIndex == 1 || SensorType.SelectedIndex == 2)
                                {
                                    constel.Objects.AddObject(sensor);
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please choose a valid input file");
                    }
                }
            }
            else
            {
                MessageBox.Show(check.Item2);
            }
        }
        private void GenerateSingle_Click(object sender, EventArgs e)
        {
            Tuple <int, string> check = FieldCheck();

            if (check.Item1 == 0)
            {
                if (ManualInput.Checked)
                {
                    try
                    {
                        IAgStkObject facObj = CreatorFunctions.GetCreateFacility(FacilityName.Text);
                        IAgFacility  fac    = facObj as IAgFacility;
                        IAgStkObject sensor = null;
                        fac.Position.AssignGeodetic(Double.Parse(Latitude.Text), Double.Parse(Longitude.Text), Double.Parse(Altitude.Text));
                        fac.AltRef = AgEAltRefType.eWGS84;
                        if (SensorType.SelectedIndex == 1)
                        {
                            OpticalParams oParams = new OpticalParams();
                            oParams.MinEl        = "0";
                            oParams.MaxEl        = "90";
                            oParams.MinRange     = "4800";
                            oParams.MaxRange     = "90000";
                            oParams.LunarExAngle = "10";
                            oParams.SunElAngle   = "-12";
                            oParams.HalfAngle    = "70";
                            oParams.MinAz        = "0";
                            oParams.MaxAz        = "360";
                            sensor = FacilityCreatorFunctions.AttachFacilityOptical(facObj, FacilityName.Text + "_Opt", oParams);
                        }
                        else if (SensorType.SelectedIndex == 2)
                        {
                            RadarParams rParams = new RadarParams();
                            rParams.MinEl        = "0";
                            rParams.MaxEl        = "90";
                            rParams.MinRange     = "1600";
                            rParams.MaxRange     = "40000";
                            rParams.SolarExAngle = "10";
                            rParams.HalfAngle    = "85";
                            rParams.MinAz        = "0";
                            rParams.MaxAz        = "360";
                            sensor = FacilityCreatorFunctions.AttachFacilityRadar(facObj, FacilityName.Text + "_Radar", rParams);
                        }
                        else
                        {
                        }
                        if (ConstType.SelectedIndex != 0)
                        {
                            IAgStkObject     constObj = null;
                            IAgConstellation constel  = null;
                            if (ConstType.SelectedIndex == 1)
                            {
                                constObj = CreatorFunctions.GetCreateConstellation(ExistingConst.Text);
                                constel  = constObj as IAgConstellation;
                            }
                            else if (ConstType.SelectedIndex == 2)
                            {
                                constObj = CreatorFunctions.GetCreateConstellation(ConstName.Text);
                                constel  = constObj as IAgConstellation;
                            }
                            if (SensorType.SelectedIndex == 0)
                            {
                                constel.Objects.AddObject(facObj);
                            }
                            else if (SensorType.SelectedIndex == 1 || SensorType.SelectedIndex == 2)
                            {
                                constel.Objects.AddObject(sensor);
                            }
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Could not create facility");
                    }
                }
                else if (ImportFromFile.Checked)
                {
                    if (!String.IsNullOrEmpty(FilenameText.Text))
                    {
                        SensorCadance cad = new SensorCadance();
                        cad.FacilityList = new List <FcFacility>();
                        cad.CadenceColor = "Custom";
                        cad.Name         = "NewCadence";
                        IAgStkObject          facObj;
                        IAgFacility           fac;
                        IAgStkObject          sensor;
                        List <GroundLocation> locations = null;
                        if (FilenameText.Text.Contains(".json"))
                        {
                            try
                            {
                                List <SensorCadance> tempCadences = ReadWrite.ReadCadences(FilenameText.Text);
                                if (SaveData.Checked)
                                {
                                    foreach (var item in tempCadences)
                                    {
                                        CommonData.Cadences.Add(item);
                                    }
                                    ReadWrite.WriteCadenceDatabase();
                                    PopulateCadanceList();
                                }
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("Json Error");
                            }
                        }
                        else
                        {
                            locations = ReadWrite.ReadFacilityFile(FilenameText.Text);
                            foreach (GroundLocation loc in locations)
                            {
                                FcFacility fcFac = new FcFacility();
                                fcFac.Name      = loc.LocationName;
                                fcFac.Latitude  = loc.Latitude.ToString();
                                fcFac.Longitude = loc.Longitude.ToString();
                                fcFac.Altitude  = loc.Altitude.ToString();
                                facObj          = CreatorFunctions.GetCreateFacility(loc.LocationName);
                                fac             = facObj as IAgFacility;
                                sensor          = null;
                                fac.Position.AssignGeodetic(loc.Latitude, loc.Longitude, loc.Altitude);
                                fac.AltRef = AgEAltRefType.eWGS84;

                                FCSensor fcSensor = new FCSensor();
                                fcSensor.SensorName = loc.LocationName + "_Opt";
                                if (SensorType.SelectedIndex == 0 || SensorType.SelectedIndex == 1)
                                {
                                    OpticalParams oParams = new OpticalParams();
                                    cad.Type             = "Opt";
                                    cad.NumOptical       = locations.Count;
                                    cad.NumRadars        = 0;
                                    fcFac.Type           = "Optical";
                                    fcFac.IsOpt          = true;
                                    oParams.MinEl        = "0";
                                    oParams.MaxEl        = "90";
                                    oParams.MinRange     = "4800";
                                    oParams.MaxRange     = "90000";
                                    oParams.LunarExAngle = "10";
                                    oParams.SunElAngle   = "-12";
                                    oParams.HalfAngle    = "70";
                                    oParams.MinAz        = "0";
                                    oParams.MaxAz        = "360";
                                    oParams.Az           = "0";
                                    oParams.El           = "90";
                                    fcSensor.OParams     = oParams;
                                    if (SensorType.SelectedIndex == 1)
                                    {
                                        sensor = FacilityCreatorFunctions.AttachFacilityOptical(facObj, loc.LocationName + "_Opt", oParams);
                                    }
                                }
                                else if (SensorType.SelectedIndex == 2)
                                {
                                    RadarParams rParams = new RadarParams();
                                    fcSensor.SensorName  = loc.LocationName + "_Rad";
                                    cad.Type             = "Rad";
                                    cad.NumOptical       = 0;
                                    cad.NumRadars        = locations.Count;
                                    fcFac.Type           = "Radar";
                                    fcFac.IsOpt          = false;
                                    rParams.MinEl        = "0";
                                    rParams.MaxEl        = "90";
                                    rParams.MinRange     = "1600";
                                    rParams.MaxRange     = "40000";
                                    rParams.SolarExAngle = "10";
                                    rParams.HalfAngle    = "85";
                                    rParams.MinAz        = "0";
                                    rParams.MaxAz        = "360";
                                    rParams.Az           = "0";
                                    rParams.El           = "90";
                                    fcSensor.RParams     = rParams;
                                    sensor = FacilityCreatorFunctions.AttachFacilityRadar(facObj, loc.LocationName + "_Radar", rParams);
                                }
                                else
                                {
                                }
                                fcFac.Sensors.Add(fcSensor);
                                cad.FacilityList.Add(fcFac);
                                if (ConstType.SelectedIndex != 0)
                                {
                                    IAgStkObject     constObj = null;
                                    IAgConstellation constel  = null;
                                    if (ConstType.SelectedIndex == 1)
                                    {
                                        constObj = CreatorFunctions.GetCreateConstellation(ExistingConst.Text);
                                        constel  = constObj as IAgConstellation;
                                    }
                                    else if (ConstType.SelectedIndex == 2)
                                    {
                                        constObj = CreatorFunctions.GetCreateConstellation(ConstName.Text);
                                        constel  = constObj as IAgConstellation;
                                    }
                                    if (SensorType.SelectedIndex == 0)
                                    {
                                        constel.Objects.AddObject(facObj);
                                    }
                                    else if (SensorType.SelectedIndex == 1 || SensorType.SelectedIndex == 2)
                                    {
                                        constel.Objects.AddObject(sensor);
                                    }
                                }
                            }
                            if (SaveData.Checked)
                            {
                                CommonData.Cadences.Add(cad);
                                ReadWrite.WriteCadenceDatabase();
                                PopulateCadanceList();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please choose a valid input file");
                    }
                }
            }
            else
            {
                MessageBox.Show(check.Item2);
            }
        }
        private void GenerateSingle_Click(object sender, EventArgs e)
        {
            Tuple <int, string> check = FieldCheck();

            if (check.Item1 == 0)
            {
                try
                {
                    IAgStkObject facObj = CreatorFunctions.GetCreateFacility(FacilityName.Text);
                    IAgFacility  fac    = facObj as IAgFacility;
                    IAgStkObject sensor = null;
                    fac.Position.AssignGeodetic(Double.Parse(Latitude.Text), Double.Parse(Longitude.Text), Double.Parse(Altitude.Text));
                    fac.AltRef = AgEAltRefType.eWGS84;
                    if (SensorType.SelectedIndex == 1)
                    {
                        OpticalParams oParams = new OpticalParams();
                        oParams.MinEl        = "0";
                        oParams.MaxEl        = "90";
                        oParams.MinRange     = "4800";
                        oParams.MaxRange     = "90000";
                        oParams.LunarExAngle = "10";
                        oParams.SunElAngle   = "-12";
                        oParams.HalfAngle    = "70";
                        sensor = CreatorFunctions.AttachFacilityOptical(facObj, FacilityName.Text + "_Opt", oParams);
                    }
                    else if (SensorType.SelectedIndex == 2)
                    {
                        RadarParams rParams = new RadarParams();
                        rParams.MinEl        = "0";
                        rParams.MaxEl        = "90";
                        rParams.MinRange     = "1600";
                        rParams.MaxRange     = "40000";
                        rParams.SolarExAngle = "10";
                        rParams.HalfAngle    = "85";
                        sensor = CreatorFunctions.AttachFacilityRadar(facObj, FacilityName.Text + "_Radar", rParams);
                    }
                    else
                    {
                    }
                    if (ConstType.SelectedIndex != 0)
                    {
                        IAgStkObject     constObj = null;
                        IAgConstellation constel  = null;
                        if (ConstType.SelectedIndex == 1)
                        {
                            constObj = CreatorFunctions.GetCreateConstellation(ExistingConst.Text);
                            constel  = constObj as IAgConstellation;
                        }
                        else if (ConstType.SelectedIndex == 2)
                        {
                            constObj = CreatorFunctions.GetCreateConstellation(ConstName.Text);
                            constel  = constObj as IAgConstellation;
                        }
                        if (SensorType.SelectedIndex == 0)
                        {
                            constel.Objects.AddObject(facObj);
                        }
                        else if (SensorType.SelectedIndex == 1 || SensorType.SelectedIndex == 2)
                        {
                            constel.Objects.AddObject(sensor);
                        }
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Could not create facility");
                }
            }
            else
            {
                MessageBox.Show(check.Item2);
            }
        }
Ejemplo n.º 11
0
        public static void SetObjectVisibility(ObjectData objectData)
        {
            string className  = objectData.ClassName;
            string simplePath = objectData.SimplePath;

            if (className == "Satellite")
            {
                IAgSatellite myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgSatellite;
                if (objectData.HideShow)
                {
                    myObject.Graphics.IsObjectGraphicsVisible = true;
                }
                else
                {
                    myObject.Graphics.IsObjectGraphicsVisible = false;
                }
            }
            else if (className == "Aircraft")
            {
                IAgAircraft myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgAircraft;
                if (objectData.HideShow)
                {
                    myObject.Graphics.IsObjectGraphicsVisible = true;
                }
                else
                {
                    myObject.Graphics.IsObjectGraphicsVisible = false;
                }
            }
            else if (className == "Facility")
            {
                IAgFacility myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgFacility;
                if (objectData.HideShow)
                {
                    myObject.Graphics.IsObjectGraphicsVisible = true;
                }
                else
                {
                    myObject.Graphics.IsObjectGraphicsVisible = false;
                }
            }
            else if (className == "Missile")
            {
                IAgMissile myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgMissile;
                if (objectData.HideShow)
                {
                    myObject.Graphics.IsObjectGraphicsVisible = true;
                }
                else
                {
                    myObject.Graphics.IsObjectGraphicsVisible = false;
                }
            }
            else if (className == "GroundVehicle")
            {
                IAgGroundVehicle myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgGroundVehicle;
                if (objectData.HideShow)
                {
                    myObject.Graphics.IsObjectGraphicsVisible = true;
                }
                else
                {
                    myObject.Graphics.IsObjectGraphicsVisible = false;
                }
            }
            else if (className == "Sensor")
            {
                IAgSensor myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgSensor;
                if (objectData.HideShow)
                {
                    myObject.Graphics.IsObjectGraphicsVisible = true;
                }
                else
                {
                    myObject.Graphics.IsObjectGraphicsVisible = false;
                }
            }
            else if (className == "Transmitter")
            {
                IAgTransmitter myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgTransmitter;
                //Try/Catch for when object above it is already turned off
                try
                {
                    if (objectData.HideShow)
                    {
                        myObject.Graphics.Show = true;
                    }
                    else
                    {
                        myObject.Graphics.Show = false;
                    }
                }
                catch (Exception e)
                {
                }
            }
            else if (className == "Receiver")
            {
                IAgReceiver myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgReceiver;
                //Try/Catch for when object above it is already turned off
                try
                {
                    if (objectData.HideShow)
                    {
                        myObject.Graphics.Show = true;
                    }
                    else
                    {
                        myObject.Graphics.Show = false;
                    }
                }
                catch (Exception e)
                {
                }
            }
            else if (className == "CoverageDefinition")
            {
                IAgCoverageDefinition myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgCoverageDefinition;
                if (objectData.HideShow)
                {
                    myObject.Graphics.IsObjectGraphicsVisible = true;
                }
                else
                {
                    myObject.Graphics.IsObjectGraphicsVisible = false;
                }
            }
            else if (className == "FigureOfMerit")
            {
                IAgFigureOfMerit myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgFigureOfMerit;
                if (objectData.HideShow)
                {
                    myObject.Graphics.IsObjectGraphicsVisible = true;
                }
                else
                {
                    myObject.Graphics.IsObjectGraphicsVisible = false;
                }
            }
            else if (className == "CommSystem")
            {
                IAgCommSystem myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgCommSystem;
                if (objectData.HideShow)
                {
                    myObject.Graphics.Show = true;
                }
                else
                {
                    myObject.Graphics.Show = false;
                }
            }
            else if (className == "Chain")
            {
                IAgChain myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgChain;
                if (objectData.HideShow)
                {
                    myObject.Graphics.IsObjectGraphicsVisible = true;
                }
                else
                {
                    myObject.Graphics.IsObjectGraphicsVisible = false;
                }
            }
            else if (className == "Place")
            {
                IAgPlace myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgPlace;
                if (objectData.HideShow)
                {
                    myObject.Graphics.IsObjectGraphicsVisible = true;
                }
                else
                {
                    myObject.Graphics.IsObjectGraphicsVisible = false;
                }
            }
            else if (className == "AreaTarget")
            {
                IAgAreaTarget myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgAreaTarget;
                if (objectData.HideShow)
                {
                    myObject.Graphics.IsObjectGraphicsVisible = true;
                }
                else
                {
                    myObject.Graphics.IsObjectGraphicsVisible = false;
                }
            }
        }
Ejemplo n.º 12
0
        public static bool GetObjectVisibility(string className, string simplePath)
        {
            bool visible = false;

            if (className == "Satellite")
            {
                IAgSatellite myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgSatellite;
                visible = myObject.Graphics.IsObjectGraphicsVisible;
            }
            else if (className == "Aircraft")
            {
                IAgAircraft myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgAircraft;
                visible = myObject.Graphics.IsObjectGraphicsVisible;
            }
            else if (className == "Facility")
            {
                IAgFacility myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgFacility;
                visible = myObject.Graphics.IsObjectGraphicsVisible;
            }
            else if (className == "Missile")
            {
                IAgMissile myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgMissile;
                visible = myObject.Graphics.IsObjectGraphicsVisible;
            }
            else if (className == "GroundVehicle")
            {
                IAgGroundVehicle myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgGroundVehicle;
                visible = myObject.Graphics.IsObjectGraphicsVisible;
            }
            else if (className == "Sensor")
            {
                IAgSensor myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgSensor;
                visible = myObject.Graphics.IsObjectGraphicsVisible;
            }
            else if (className == "Transmitter")
            {
                IAgTransmitter myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgTransmitter;
                visible = myObject.Graphics.Show;
            }
            else if (className == "Receiver")
            {
                IAgReceiver myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgReceiver;
                visible = myObject.Graphics.Show;
            }
            else if (className == "CoverageDefinition")
            {
                IAgCoverageDefinition myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgCoverageDefinition;
                visible = myObject.Graphics.IsObjectGraphicsVisible;
            }
            else if (className == "FigureOfMerit")
            {
                IAgFigureOfMerit myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgFigureOfMerit;
                visible = myObject.Graphics.IsObjectGraphicsVisible;
            }
            else if (className == "CommSystem")
            {
                IAgCommSystem myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgCommSystem;
                visible = myObject.Graphics.Show;
            }
            else if (className == "Chain")
            {
                IAgChain myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgChain;
                visible = myObject.Graphics.IsObjectGraphicsVisible;
            }
            else if (className == "Place")
            {
                IAgPlace myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgPlace;
                visible = myObject.Graphics.IsObjectGraphicsVisible;
            }
            else if (className == "AreaTarget")
            {
                IAgAreaTarget myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgAreaTarget;
                visible = myObject.Graphics.IsObjectGraphicsVisible;
            }

            return(visible);
        }
Ejemplo n.º 13
0
        private void get_Location(IAgFacility thisFacility)
        {
            var depth = 1;

            #region List Header
            l_SegObj.Add(null);
            l_Names.Add("Position");
            l_unit.Add("");
            l_Values.Add(double.PositiveInfinity);
            l_types.Add(" ");
            l_depth.Add(depth);
            l_isQuantity.Add(false);
            l_implemClass.Add(implem_Classes.NULL);
            #endregion
            AgEPositionType Postype = (thisFacility.Position as IAgPosition).PosType;
            m_thisPosition.access_object = thisFacility;
            Unit units = new Unit();
            if (Postype == AgEPositionType.eCartesian)
            {
                (thisFacility.Position).QueryCartesian(out m_thisPosition.X, out m_thisPosition.Y, out m_thisPosition.Z);
                m_thisPosition.ofType = Postype;
                Location.Add("Cartesian:X", m_thisPosition.X); l_unit.Add(units.u_Distance);
                Location.Add("Cartesian:Y", m_thisPosition.Y); l_unit.Add(units.u_Distance);
                Location.Add("Cartesian:Z", m_thisPosition.Z); l_unit.Add(units.u_Distance);
                update_Lists(Location, depth, thisFacility, implem_Classes.Facility_Location);
            }
            else if (Postype == AgEPositionType.eGeodetic || Postype == AgEPositionType.ePlanetodetic)
            {
                var geodetic = (thisFacility.Position.QueryPlanetodeticArray());
                updatefromArray(geodetic);
                m_thisPosition.ofType = Postype;
                Location.Add("Geodetic:Latitude", m_thisPosition.X); l_unit.Add(units.u_Angle);
                Location.Add("Geodetic:Longitude", m_thisPosition.Y); l_unit.Add(units.u_Angle);
                Location.Add("Geodetic:Altitude", m_thisPosition.Z); l_unit.Add(units.u_Distance);
                update_Lists(Location, depth, thisFacility, implem_Classes.Facility_Location);
            }
            else if (Postype == AgEPositionType.eCylindrical)
            {
                var cylindrical = (thisFacility.Position).QueryCylindricalArray();
                updatefromArray(cylindrical);
                Location.Add("Cylindrical:Radius", m_thisPosition.X); l_unit.Add(units.u_Distance);
                Location.Add("Cylindrical:Longitude", m_thisPosition.Y); l_unit.Add(units.u_Distance);
                Location.Add("Cylindrical:Z", m_thisPosition.Z); l_unit.Add(units.u_Distance);
                update_Lists(Location, depth, thisFacility, implem_Classes.Facility_Location);
            }
            else if (Postype == AgEPositionType.eSpherical)
            {
                var spherical = (thisFacility.Position).QuerySphericalArray();
                updatefromArray(spherical);
                Location.Add("Spherical:Latitude", m_thisPosition.X); l_unit.Add(units.u_Distance);
                Location.Add("Spherical:Longitude", m_thisPosition.Y); l_unit.Add(units.u_Distance);
                Location.Add("Spherical:Radius", m_thisPosition.Z); l_unit.Add(units.u_Distance);
                update_Lists(Location, depth, thisFacility, implem_Classes.Facility_Location);
            }
            else if (Postype == AgEPositionType.ePlanetocentric)
            {
                var planetocentric = (thisFacility.Position).QueryPlanetocentricArray();
                updatefromArray(planetocentric);
                Location.Add("Spherical:Latitude", m_thisPosition.X); l_unit.Add(units.u_Distance);
                Location.Add("Spherical:Longitude", m_thisPosition.Y); l_unit.Add(units.u_Distance);
                Location.Add("Spherical:Radius", m_thisPosition.Z); l_unit.Add(units.u_Distance);
                update_Lists(Location, depth, thisFacility, implem_Classes.Facility_Location);
            }
        }
Ejemplo n.º 14
0
        public Facility_Data(IAgStkObject object0)
        {
            IAgFacility thisFacility = object0 as IAgFacility;

            get_Location(thisFacility);
        }
Ejemplo n.º 15
0
        public void Station_generation()
        {
            //load_Station_File();
            scenarioCheck();
            IAgConstellation localconstellation;

            try
            {
                localconstellation = (IAgConstellation)m_oApplication.CurrentScenario.Children.New(AgESTKObjectType.eConstellation, "Stations");
            }
            catch
            {
                if (failure == false)
                {
                    failure = true;
                    //failed to add constellation close the currently opened scenario and attempt to open a new scenario;
                    this.m_oApplication.CloseScenario();
                    this.Station_generation();
                }
                return;
            }

            //currently there is no way to set the 2d graphics properties for the scenario listed in the tutorial
            for (int i = 0; i < stationcount; i++)
            {
                if (stationdata[i].used == true)
                {
                    if (stationdata[i].tdrs == false)
                    {
                        //debug infomation///////
                        Console.Write(stationdata[i].name + " " + stationdata[i].lat + " " + stationdata[i].lon + " " + stationdata[i].altitude + "\n");
                        ////////////////////////////
                        IAgFacility agistationdata = (IAgFacility)m_oApplication.CurrentScenario.Children.New(AgESTKObjectType.eFacility, stationdata[i].name);
                        agistationdata.UseTerrain = false;
                        IAgPlanetodetic planetodetic = (IAgPlanetodetic)agistationdata.Position.ConvertTo(AgEPositionType.ePlanetodetic);
                        //set lat lon and hight of ground station;
                        planetodetic.Lat = stationdata[i].lat;
                        planetodetic.Lon = stationdata[i].lon;
                        planetodetic.Alt = stationdata[i].altitude;
                        agistationdata.Position.Assign(planetodetic);
                        Random r = new Random();
                        //randomly generate colors for each station
                        agistationdata.Graphics.Color = Color.FromArgb(r.Next(10000000, 99999999));



                        string localobjectname = "Facility/" + stationdata[i].name;
                        Console.Write(" localobjectname=" + localobjectname + "\n");

                        localconstellation.Objects.Add(localobjectname);
                    }
                    else
                    {
                        add_tdrs(stationdata[i]);
                        string localobjectname = "Satellite/" + stationdata[i].name;
                        localconstellation.Objects.Add(localobjectname);
                    }
                }
            }

            //((IAgStkObject)perth).ShortDescription = "Australian Tracking Station";

            //			IAgFacility santiago = (IAgFacility)m_oApplication.CurrentScenario.Children["Santiago"];
            //baikonur.Graphics.Color = Color.Black;
            //perth.Graphics.Color = Color.FromArgb(16777215);

            ((IAgAnimation)this.m_oApplication).Rewind();

            //Console.Write("Press Enter to exit application:");
            //Console.ReadLine();
        }
Ejemplo n.º 16
0
        private void createVectorButton_Click(object sender, EventArgs e)
        {
            //Create vector between objects
            string accessFromName = cbAccessFrom.GetItemText(cbAccessFrom.SelectedItem);
            string accessToName   = cbAccessTo.GetItemText(cbAccessTo.SelectedItem);

            IAgStkObject fromObj = CommonData.StkRoot.GetObjectFromPath(accessFromName);
            IAgStkObject toObj   = CommonData.StkRoot.GetObjectFromPath(accessToName);

            IAgCrdnVectorGroup        vectors = fromObj.Vgt.Vectors;
            IAgCrdnVectorDisplacement vector  = null;
            string vectorName = "From" + fromObj.InstanceName + "To" + toObj.InstanceName;

            if (vectors.Contains(vectorName))
            {
                vector = (IAgCrdnVectorDisplacement)vectors[vectorName];
            }
            else
            {
                vector = (IAgCrdnVectorDisplacement)vectors.Factory.Create(vectorName, "description", AGI.STKVgt.AgECrdnVectorType.eCrdnVectorTypeDisplacement);
            }
            vector.Destination.SetPoint(toObj.Vgt.Points["Center"]);
            vector.Origin.SetPoint(fromObj.Vgt.Points["Center"]);

            // Visualize

            //if (fromObj.ClassName == "Facility")
            //{
            //    fromObj2 = fromObj as IAgFacility;
            //}
            //else if (fromObj.ClassName == "Satellite")
            //{
            //    fromObj2 = fromObj as IAgSatellite;
            //}
            //else if (fromObj.ClassName == "Sensor")
            //{
            //    fromObj2 = fromObj as IAgSensor;
            //}
            //else if (fromObj.ClassName == "Aircraft")
            //{
            //    fromObj2 = fromObj as IAgAircraft;
            //}
            //else
            //{
            //    return;
            //}

            try
            {
                IAgFacility        fromObj2        = fromObj as IAgFacility;
                IAgVORefCrdnVector boresightVector = fromObj2.VO.Vector.RefCrdns.Add(AgEGeometricElemType.eVectorElem, fromObj.ClassName + "/" + fromObj.InstanceName + " " + vectorName + " Vector") as IAgVORefCrdnVector;
                fromObj2.VO.Vector.VectorSizeScale = 4.0;
            }
            catch
            {
            }

            try
            {
                IAgSatellite       fromObj2        = fromObj as IAgSatellite;
                IAgVORefCrdnVector boresightVector = fromObj2.VO.Vector.RefCrdns.Add(AgEGeometricElemType.eVectorElem, fromObj.ClassName + "/" + fromObj.InstanceName + " " + vectorName + " Vector") as IAgVORefCrdnVector;
                fromObj2.VO.Vector.VectorSizeScale = 4.0;
            }
            catch
            {
            }

            try
            {
                IAgAircraft        fromObj2        = fromObj as IAgAircraft;
                IAgVORefCrdnVector boresightVector = fromObj2.VO.Vector.RefCrdns.Add(AgEGeometricElemType.eVectorElem, fromObj.ClassName + "/" + fromObj.InstanceName + " " + vectorName + " Vector") as IAgVORefCrdnVector;
                fromObj2.VO.Vector.VectorSizeScale = 4.0;
            }
            catch
            {
            }

            try
            {
                IAgSensor          fromObj2        = fromObj as IAgSensor;
                IAgVORefCrdnVector boresightVector = fromObj2.VO.Vector.RefCrdns.Add(AgEGeometricElemType.eVectorElem, fromObj.ClassName + "/" + fromObj.InstanceName + " " + vectorName + " Vector") as IAgVORefCrdnVector;
                fromObj2.VO.Vector.VectorSizeScale = 4.0;
            }
            catch
            {
            }
        }