Ejemplo n.º 1
0
        //#####################################################################
        /// <summary>
        /// 创建新场景(若已有场景,则保存并关闭)
        /// </summary>
        public static void CreateScenario(string SceneName)
        {
            try
            {
                //首先保存并关闭当前场景
                SaveCloseScenario();

                //创建新场景
                StkObjectHelper.stkRoot.NewScenario(SceneName);
                Application.DoEvents();

                // Reset the units to the STKpara defaults
                IAgUnitPrefsDimCollection dimensions = StkObjectHelper.stkRoot.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");
                IAgScenario scene = (IAgScenario)StkObjectHelper.stkRoot.CurrentScenario;

                scene.StartTime           = "1 Jul 2011 06:00:00.000";
                scene.StopTime            = "2 Jul 2011 00:00:00.000";
                scene.Epoch               = "1 Jan 2011 06:00:00.000";
                scene.Animation.StartTime = "1 Jan 2011 06:00:00.000";

                StkObjectHelper.stkRoot.Rewind();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "创建场景出错!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Ejemplo n.º 2
0
        /// <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
        }
Ejemplo n.º 3
0
        /// <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;
            }




        }
Ejemplo n.º 4
0
        /// <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
        }
Ejemplo n.º 5
0
        private void scenarioCheck()
        {
            try
            {
                if (this.m_oApplication.CurrentScenario == null)
                {//scenario doesn't exist
                    this.m_oApplication.CloseScenario();
                    this.m_oApplication.NewScenario("NPAS_Schedule_to_STK");
                }
            }catch
            {
                find_STK();

                if (this.m_oApplication.CurrentScenario == null)
                {//scenario doesn't exist
                    this.m_oApplication.CloseScenario();
                    this.m_oApplication.NewScenario("NPAS_Schedule_to_STK");
                }
            }
            IAgUnitPrefsDimCollection dimensions = this.m_oApplication.UnitPreferences;

            dimensions.ResetUnits();
            dimensions.SetCurrentUnit("DateFormat", "UTCG"); //DD/MM/YYYY
            //dimensions.SetCurrentUnit("DateFormat", "DD/MM/YYYY"); //DD/MM/YYYY
            IAgScenario scene = (IAgScenario)this.m_oApplication.CurrentScenario;

            //#TODO times should be set by the user
            DateTime start, stop;

            start = Convert.ToDateTime(startdate);
            stop  = Convert.ToDateTime(enddate);

            Console.Write("start/end=" + start.ToString("dd MMM yyyy") + " 00:00:00.000 /" + stop.ToString("dd MMM yyyy") + " 00:00:00.000\n");
            try
            {
                scene.StopTime  = stop.ToString("dd MMM yyyy");          // + " 00:00:00";
                scene.StartTime = start.ToString(format: "dd MMM yyyy"); // + " 00:00:00";
            }
            catch
            {
                scene.StartTime = start.ToString(format: "dd MMM yyyy"); // + " 00:00:00";
                scene.StopTime  = stop.ToString("dd MMM yyyy");          // + " 00:00:00";
            }



            dimensions.SetCurrentUnit("DistanceUnit", "km");
            dimensions.SetCurrentUnit("TimeUnit", "sec");
            dimensions.SetCurrentUnit("AngleUnit", "deg");
            dimensions.SetCurrentUnit("MassUnit", "kg");
            dimensions.SetCurrentUnit("PowerUnit", "dbw");
            dimensions.SetCurrentUnit("FrequencyUnit", "ghz");
            dimensions.SetCurrentUnit("SmallDistanceUnit", "m");
            dimensions.SetCurrentUnit("latitudeUnit", "deg");
            dimensions.SetCurrentUnit("longitudeunit", "deg");
            dimensions.SetCurrentUnit("DurationUnit", "HMS");
            dimensions.SetCurrentUnit("Temperature", "K");
            dimensions.SetCurrentUnit("SmallTimeUnit", "sec");
            dimensions.SetCurrentUnit("RatioUnit", "db");
            dimensions.SetCurrentUnit("rcsUnit", "dbsm");
            dimensions.SetCurrentUnit("DopplerVelocityUnit", "m/s");
            dimensions.SetCurrentUnit("Percent", "unitValue");
        }