public static IAgStkObject AttachFacilityOptical(IAgStkObject parent, string radarName, OpticalParams rParams) { IAgStkObject sensorObj = CreatorFunctions.GetCreateSensor(parent, radarName); IAgSensor sensor = sensorObj as IAgSensor; sensor.Graphics.IsObjectGraphicsVisible = false; IAgSnSimpleConicPattern pattern = sensor.Pattern as IAgSnSimpleConicPattern; pattern.ConeAngle = Double.Parse(rParams.HalfAngle); IAgAccessConstraintCollection constraints = sensor.AccessConstraints; IAgAccessCnstrMinMax elConstraint; IAgAccessCnstrMinMax azConstraint; IAgAccessCnstrMinMax rangeConstraint; IAgAccessCnstrMinMax sunElConstraint; IAgAccessCnstrAngle lunExConstraint; elConstraint = CreatorFunctions.GetElCnst(constraints); CreatorFunctions.SetCnstMinMax(elConstraint, Double.Parse(rParams.MinEl), Double.Parse(rParams.MaxEl)); azConstraint = CreatorFunctions.GetAzCnst(constraints); CreatorFunctions.SetCnstMinMax(azConstraint, Double.Parse(rParams.MinAz), Double.Parse(rParams.MaxAz)); sunElConstraint = CreatorFunctions.GetSunElCnst(constraints); CreatorFunctions.SetCnstMinMax(sunElConstraint, -90, Double.Parse(rParams.SunElAngle)); rangeConstraint = CreatorFunctions.GetRangeCnst(constraints); CreatorFunctions.SetCnstMinMax(rangeConstraint, Double.Parse(rParams.MinRange), Double.Parse(rParams.MaxRange)); lunExConstraint = CreatorFunctions.GetLunExCnst(constraints); lunExConstraint.Angle = rParams.LunarExAngle; SetOpticalGraphics(sensor); return(sensorObj); }
public SensorViewClass(AgStkObjectRoot root, IAgStkObject selectedSensor) { _root = root; _sensor = (IAgSensor)selectedSensor; _pluginInstallDir = Path.Combine(@CommonData.InstallDir, "Plugin Files\\SensorBoresightPlugin"); }
public SensorViewClass(AgStkObjectRoot root, IAgStkObject selectedSensor) { _root = root; _sensor = (IAgSensor)selectedSensor; _pluginInstallDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); }
private void SensorGraphics_CheckedChanged(object sender, EventArgs e) { if (!_onStart) { IAgExecCmdResult result; result = CommonData.StkRoot.ExecuteCommand("ShowNames * Class Sensor"); if (result[0] != "None") { string[] sensorArray = result[0].Split(null); foreach (var item in sensorArray) { if (item != null && item != "") { string path = _library.SimplifiedObjectPath(item); IAgSensor sensor = CommonData.StkRoot.GetObjectFromPath(path) as IAgSensor; if (SensorGraphics.Checked) { sensor.Graphics.InheritFromScenario = false; sensor.Graphics.IsObjectGraphicsVisible = true; CommonData.Preferences.SensorGraphicsDisplay = true; } else { sensor.Graphics.InheritFromScenario = false; CommonData.Preferences.SensorGraphicsDisplay = false; sensor.Graphics.IsObjectGraphicsVisible = false; } } } } } }
public static IAgStkObject AttachFacilityRadar(IAgStkObject parent, string radarName, RadarParams rParams) { IAgStkObject sensorObj = CreatorFunctions.GetCreateSensor(parent, radarName); IAgSensor sensor = sensorObj as IAgSensor; sensor.Graphics.IsObjectGraphicsVisible = false; IAgSnSimpleConicPattern pattern = sensor.Pattern as IAgSnSimpleConicPattern; pattern.ConeAngle = Double.Parse(rParams.HalfAngle); IAgSnPtFixed pointing = sensor.Pointing as IAgSnPtFixed; pointing.Orientation.AssignAzEl(Double.Parse(rParams.Az), Double.Parse(rParams.El), AGI.STKUtil.AgEAzElAboutBoresight.eAzElAboutBoresightRotate); IAgAccessConstraintCollection constraints = sensor.AccessConstraints; IAgAccessCnstrMinMax elConstraint; IAgAccessCnstrMinMax azConstraint; IAgAccessCnstrMinMax rangeConstraint; IAgAccessCnstrAngle solarExConstraint; elConstraint = CreatorFunctions.GetElCnst(constraints); CreatorFunctions.SetCnstMinMax(elConstraint, Double.Parse(rParams.MinEl), Double.Parse(rParams.MaxEl)); azConstraint = CreatorFunctions.GetAzCnst(constraints); CreatorFunctions.SetCnstMinMax(azConstraint, Double.Parse(rParams.MinAz), Double.Parse(rParams.MaxAz)); rangeConstraint = CreatorFunctions.GetRangeCnst(constraints); CreatorFunctions.SetCnstMinMax(rangeConstraint, Double.Parse(rParams.MinRange), Double.Parse(rParams.MaxRange)); solarExConstraint = CreatorFunctions.GetSunExCnst(constraints); solarExConstraint.Angle = rParams.SolarExAngle; SetRadarGraphics(sensor); return(sensorObj); }
public SensorViewClass(AgStkObjectRoot root, IAgStkObject selectedSensor) { m_root = root; sensor = (IAgSensor)selectedSensor; IAgExecCmdResult result = m_root.ExecuteCommand("GetDirectory / STKHome"); installDir = result[0]; pluginInstallDir = installDir + @"Plugins\SensorBoresightView"; }
private void createSensorButton_Click(object sender, EventArgs e) { AgFacility facility = null; if (CommonData.StkRoot.CurrentScenario.Children.Contains(AgESTKObjectType.eFacility, facilityName.Text)) { facility = (AgFacility)CommonData.StkRoot.GetObjectFromPath("Facility/" + facilityName.Text); } else { facility = CommonData.StkRoot.CurrentScenario.Children.New(AgESTKObjectType.eFacility, facilityName.Text) as AgFacility; } //Add child object (sensor) IAgSensor sensor = null; if (facility.Children.Contains(AgESTKObjectType.eSensor, "MySensor")) { sensor = (IAgSensor)CommonData.StkRoot.GetObjectFromPath("*/Facility/" + facilityName.Text + "/Sensor/MySensor"); } else { sensor = facility.Children.New(AgESTKObjectType.eSensor, "MySensor") as IAgSensor; } // Set Sensor type and shape double InnerConeHalfAngle = 50; double OuterConeHalfAngle = 90; double MinimumClockAngle = 0; double MaximumClockAngle = 90; sensor.SetPatternType(AgESnPattern.eSnComplexConic); sensor.CommonTasks.SetPatternComplexConic(InnerConeHalfAngle, OuterConeHalfAngle, MinimumClockAngle, MaximumClockAngle); //Add range constraint to sensor double rangeConstraintValue = 40; IAgAccessCnstrMinMax rangeConstraint = null; if (!sensor.AccessConstraints.IsConstraintActive(AgEAccessConstraints.eCstrRange)) { rangeConstraint = sensor.AccessConstraints.AddConstraint(AgEAccessConstraints.eCstrRange) as IAgAccessCnstrMinMax; } else { rangeConstraint = sensor.AccessConstraints.GetActiveConstraint(AgEAccessConstraints.eCstrRange) as IAgAccessCnstrMinMax; } rangeConstraint.EnableMax = true; rangeConstraint.Max = rangeConstraintValue; }
public static void SetRadarGraphics(IAgSensor sensor) { try { sensor.Graphics.Projection.UseConstraints = true; sensor.Graphics.Projection.EnableConstraint("ElevationAngle"); sensor.Graphics.Projection.EnableConstraint("AzimuthAngle"); sensor.Graphics.Projection.EnableConstraint("LOSSunExclusion"); CommonData.StkRoot.ExecuteCommand("Animate * Refresh"); } catch (Exception) { } }
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); } }
private int DetermineNumPasses(SwathWidthType swathType, double swathParameter, double altitude, double regionWidth, IAgAircraft aircraft) { int numPasses; double swathWidth; switch (swathType) { case SwathWidthType.NumberOfPasses: numPasses = (int)swathParameter; break; case SwathWidthType.SensorFOV: swathWidth = altitude * Math.Tan((Math.PI / 180.0) * swathParameter) * 1000 * 2 * .9; if (aircraft != null) { IAgSensor sensor = ((IAgStkObject)aircraft).Children.New(AgESTKObjectType.eSensor, "Sensor") as IAgSensor; sensor.SetPatternType(AgESnPattern.eSnSimpleConic); IAgSnSimpleConicPattern simplecone = sensor.Pattern as IAgSnSimpleConicPattern; simplecone.ConeAngle = swathParameter; } numPasses = (int)(regionWidth / swathWidth); break; case SwathWidthType.GroundElev: swathWidth = altitude / Math.Tan((Math.PI / 180.0) * swathParameter) * 1000 * 2 * .9; numPasses = (int)(regionWidth / swathWidth); break; case SwathWidthType.SlantRange: swathWidth = Math.Sqrt((swathParameter * swathParameter) - (altitude * altitude)) * 1000 * 2 * .9; numPasses = (int)(regionWidth / swathWidth); break; default: numPasses = 10; break; } return(numPasses); }
public IAgAircraft CreateAircraft(string seed, bool createSensor, double sensorFOV, double speedKnots) { string aircraftName = uniqueName(seed, AgESTKObjectType.eAircraft); IAgAircraft aircraft = root.CurrentScenario.Children.New(AgESTKObjectType.eAircraft, aircraftName) as IAgAircraft; root.ExecuteCommand("SetAttitude */Aircraft/" + aircraftName + " Profile AircraftCoordTurn 10"); IAgVOModel acModel = aircraft.VO.Model; acModel.ModelType = AgEModelType.eModelFile; IAgVOModelFile modelFile = acModel.ModelData as IAgVOModelFile; if (speedKnots < 200) { modelFile.Filename = installDir + @"STKData\VO\Models\Air\single_engine.mdl"; } else if (speedKnots > 200 & speedKnots < 500) { modelFile.Filename = installDir + @"STKData\VO\Models\Air\uav.mdl"; } else if (speedKnots > 300 & speedKnots < 500) { modelFile.Filename = installDir + @"STKData\VO\Models\Air\e-3a_sentry_awacs.mdl"; } else if (speedKnots > 500 & speedKnots < 1200) { modelFile.Filename = installDir + @"STKData\VO\Models\Air\f-117a_nighthawk.mdl"; } else { modelFile.Filename = installDir + @"STKData\VO\Models\Air\f-35_jsf_stovl.mdl"; } if (createSensor) { IAgSensor sensor = ((IAgStkObject)aircraft).Children.New(AgESTKObjectType.eSensor, "Sensor_" + sensorFOV.ToString() + "deg") as IAgSensor; sensor.SetPatternType(AgESnPattern.eSnSimpleConic); AgSnSimpleConicPattern conic = sensor.Pattern as AgSnSimpleConicPattern; conic.ConeAngle = sensorFOV; } return(aircraft); }
private void Generate_Click(object sender, EventArgs e) { if (ExistingVolumes.SelectedIndex != -1 && ExistingVolumes.Items.Count > 0 && LocationList.SelectedIndex != -1) { IAgFacility place; IAgStkObject placeObj; placeObj = CreatorFunctions.GetCreateFacility(CommonData.LocationList[CommonData.LocationIndex].Name); place = placeObj as IAgFacility; place.Position.AssignGeodetic(Double.Parse(CommonData.LocationList[CommonData.LocationIndex].Latitude), Double.Parse(CommonData.LocationList[CommonData.LocationIndex].Longitude), 0); place.AltRef = AgEAltRefType.eWGS84; //Create complex conic sensor IAgStkObject sensorObj = CreatorFunctions.GetCreateSensor(placeObj, CommonData.VolumeList[CommonData.TvSelectedIndex].Name + "_" + CommonData.LocationList[CommonData.LocationIndex].Name); IAgSensor sensor = sensorObj as IAgSensor; sensor.SetPatternType(AgESnPattern.eSnComplexConic); IAgSnComplexConicPattern pattern = sensor.Pattern as IAgSnComplexConicPattern; pattern.OuterConeHalfAngle = 180.0; sensor.VO.PercentTranslucency = 70.0; IAgAccessConstraintCollection constraints = sensor.AccessConstraints; IAgAccessCnstrMinMax elConstraint; IAgAccessCnstrMinMax rangeConstraint; IAgAccessCnstrMinMax altConstraint; //Add elevation angle constraint if (constraints.IsConstraintActive(AgEAccessConstraints.eCstrElevationAngle)) { elConstraint = constraints.GetActiveConstraint(AgEAccessConstraints.eCstrElevationAngle) as IAgAccessCnstrMinMax; } else { elConstraint = constraints.AddConstraint(AgEAccessConstraints.eCstrElevationAngle) as IAgAccessCnstrMinMax; } elConstraint.EnableMin = true; elConstraint.Min = Double.Parse(CommonData.VolumeList[CommonData.TvSelectedIndex].MinEl); elConstraint.EnableMax = true; elConstraint.Max = Double.Parse(CommonData.VolumeList[CommonData.TvSelectedIndex].MaxEl); //Add range constraint if (constraints.IsConstraintActive(AgEAccessConstraints.eCstrRange)) { rangeConstraint = constraints.GetActiveConstraint(AgEAccessConstraints.eCstrRange) as IAgAccessCnstrMinMax; } else { rangeConstraint = constraints.AddConstraint(AgEAccessConstraints.eCstrRange) as IAgAccessCnstrMinMax; } rangeConstraint.EnableMin = true; rangeConstraint.Min = Double.Parse(CommonData.VolumeList[CommonData.TvSelectedIndex].MinRange); rangeConstraint.EnableMax = true; rangeConstraint.Max = Double.Parse(CommonData.VolumeList[CommonData.TvSelectedIndex].MaxRange); //Add altitude constraint if (constraints.IsConstraintActive(AgEAccessConstraints.eCstrAltitude)) { altConstraint = constraints.GetActiveConstraint(AgEAccessConstraints.eCstrAltitude) as IAgAccessCnstrMinMax; } else { altConstraint = constraints.AddConstraint(AgEAccessConstraints.eCstrAltitude) as IAgAccessCnstrMinMax; } altConstraint.EnableMin = true; altConstraint.Min = Double.Parse(CommonData.VolumeList[CommonData.TvSelectedIndex].MinAlt); altConstraint.EnableMax = true; altConstraint.Max = Double.Parse(CommonData.VolumeList[CommonData.TvSelectedIndex].MaxAlt); //Add Azimuth Constraint IAgAccessCnstrMinMax azConstraint = CreatorFunctions.GetAzCnst(constraints); CreatorFunctions.SetCnstMinMax(azConstraint, Double.Parse(CommonData.VolumeList[CommonData.TvSelectedIndex].MinAz), Double.Parse(CommonData.VolumeList[CommonData.TvSelectedIndex].MaxAz)); try { sensor.Graphics.Projection.UseConstraints = true; sensor.Graphics.Projection.EnableConstraint("ElevationAngle"); sensor.Graphics.Projection.EnableConstraint("AzimuthAngle"); CommonData.StkRoot.ExecuteCommand("Animate * Refresh"); } catch (Exception) { } CreatorFunctions.ChangeObjectColor(sensorObj.Path, (CustomUserInterface.ColorOptions)Enum.Parse(typeof(CustomUserInterface.ColorOptions), ColorSelection.Text)); } }
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 { } }
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); }
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; } } }
/// <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 }
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(); }
/// <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; } }
/// <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 }