/// <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 }
/// <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 }