//loads stations and TDRS into the station file #TODO should upgrade to use a configuration file to load TDRSs; public void load_Station_File() { var format = new NumberFormatInfo(); format.NegativeSign = "-"; format.NumberDecimalSeparator = "."; stationcount = numberoflines(NPAS_Mask_File, true); stationdata = new station_str[stationcount + 12]; StreamReader reader = File.OpenText(NPAS_Mask_File); string line; int pos = 0; while ((line = reader.ReadLine()) != null) { line = Regex.Replace(line, @"\s+", " "); string[] items = line.Split(); int errorCounter = Regex.Matches(items[0], @"[a-zA-z]").Count; if (errorCounter > 0) { try { stationdata[pos].name = items[0]; stationdata[pos].lat = double.Parse(items[1], format); stationdata[pos].lon = double.Parse(items[2], format); stationdata[pos].altitude = (double.Parse(items[3], format) / 1000); stationdata[pos].used = false; stationdata[pos].tdrs = false; ++pos; } catch { MessageBox.Show("Error file format invalid"); return; } } } reader.Close(); stationdata[stationcount].name = "T012"; stationdata[stationcount].lon = 12; stationdata[stationcount].used = false; stationdata[stationcount++].tdrs = true; stationdata[stationcount].name = "T018"; stationdata[stationcount].lon = 18; stationdata[stationcount].used = false; stationdata[stationcount++].tdrs = true; stationdata[stationcount].name = "T041"; stationdata[stationcount].lon = 40.9; stationdata[stationcount].used = false; stationdata[stationcount++].tdrs = true; stationdata[stationcount].name = "T046"; stationdata[stationcount].lon = 46; stationdata[stationcount].used = false; stationdata[stationcount++].tdrs = true; stationdata[stationcount].name = "T049"; stationdata[stationcount].lon = 49; stationdata[stationcount].used = false; stationdata[stationcount++].tdrs = true; stationdata[stationcount].name = "T062"; stationdata[stationcount].lon = 62.4; stationdata[stationcount].used = false; stationdata[stationcount++].tdrs = true; stationdata[stationcount].name = "T150"; stationdata[stationcount].lon = 150; stationdata[stationcount].used = false; stationdata[stationcount++].tdrs = true; stationdata[stationcount].name = "T168"; stationdata[stationcount].lon = 167.5; stationdata[stationcount].used = false; stationdata[stationcount++].tdrs = true; stationdata[stationcount].name = "T171"; stationdata[stationcount].lon = 171; stationdata[stationcount].used = false; stationdata[stationcount++].tdrs = true; stationdata[stationcount].name = "T174"; stationdata[stationcount].lon = 174; stationdata[stationcount].used = false; stationdata[stationcount++].tdrs = true; stationdata[stationcount].name = "T271"; stationdata[stationcount].lon = 271; stationdata[stationcount].used = false; stationdata[stationcount++].tdrs = true; stationdata[stationcount].name = "T275"; stationdata[stationcount].lon = 275; stationdata[stationcount].used = false; stationdata[stationcount++].tdrs = true; }
//added selected TDRSs into the model private void add_tdrs(station_str passed) { IAgSatellite localtdrs; localtdrs = (IAgSatellite)m_oApplication.CurrentScenario.Children.New(AGI.STKObjects.AgESTKObjectType.eSatellite, passed.name); //AGI.STKObjects.IAgSatellite sat = (IAgSatellite)m_oApplication.CurrentScenario.Children.NewOnCentralBody(AGI.STKObjects.AgESTKObjectType.eSatellite, orbitdata[i].name, centerbodyname); //disable the leading ground track localtdrs.Graphics.PassData.GroundTrack.SetLeadDataType(AgELeadTrailData.eDataNone); //disable trailing ground track localtdrs.Graphics.PassData.GroundTrack.SetTrailDataType(AgELeadTrailData.eDataNone); localtdrs.VO.Pass.TrackData.PassData.GroundTrack.SetLeadDataType(AgELeadTrailData.eDataNone); localtdrs.VO.Pass.TrackData.PassData.GroundTrack.SetTrailDataType(AgELeadTrailData.eDataNone); localtdrs.VO.Pass.TrackData.PassData.Orbit.SetLeadDataType(AgELeadTrailData.eDataNone); localtdrs.VO.Pass.TrackData.PassData.Orbit.SetTrailDataType(AgELeadTrailData.eDataNone); //set the propagator type to HPOP localtdrs.SetPropagatorType(AGI.STKObjects.AgEVePropagatorType.ePropagatorJ2Perturbation); AGI.STKObjects.IAgVePropagatorJ2Perturbation hpop = (AGI.STKObjects.IAgVePropagatorJ2Perturbation)localtdrs.Propagator; IAgOrbitState orbit = hpop.InitialState.Representation; //create the string to hold the missions epoch date & time string cmb_epoch = startdate, cmb_end = enddate; cmb_epoch += " 00:00:00"; DateTime epochDT = Convert.ToDateTime(cmb_epoch); DateTime endepochDT = Convert.ToDateTime(cmb_end); //hpop.InitialState.Representation.Assign(orbit); Console.Write("epochtime = " + epochDT.ToString("dd MMM yyyy ") + "00:00:00" + "\n"); hpop.InitialState.Representation.Epoch = (epochDT.ToString("dd MMM yyyy ") + "00:00:00"); // hpop.InitialState.Representation.Assign(ia) //hpop.InitialState.Representation.AssignClassical(AgECoordinateSystem.eCoordinateSystemJ2000, orbitdata[i].sma, orbitdata[i].ecc, orbitdata[i].inc, orbitdata[i].aop, orbitdata[i].raan, orbitdata[i].ma); //hpop.Propagate(); IAgOrbitStateClassical classical = (IAgOrbitStateClassical)hpop.InitialState.Representation.ConvertTo(AgEOrbitStateType.eOrbitStateClassical); classical.CoordinateSystemType = AGI.STKUtil.AgECoordinateSystem.eCoordinateSystemJ2000; IAgCrdnEventIntervalSmartInterval interval = hpop.EphemerisInterval; interval.SetExplicitInterval((epochDT.ToString("dd MMM yyyy ") + "00:00:00"), (endepochDT.ToString("dd MMM yyyy ") + "00:00:00")); hpop.Step = 60; classical.LocationType = AgEClassicalLocation.eLocationTrueAnomaly; IAgClassicalLocationTrueAnomaly trueAnomaly = (IAgClassicalLocationTrueAnomaly)classical.Location; trueAnomaly.Value = 178.845262; classical.SizeShapeType = AgEClassicalSizeShape.eSizeShapePeriod; IAgClassicalSizeShapePeriod period = (IAgClassicalSizeShapePeriod)classical.SizeShape; period.Eccentricity = 0.0; period.Period = 86164.090540; classical.Orientation.ArgOfPerigee = 0.0; classical.Orientation.Inclination = 0.0; classical.Orientation.AscNodeType = AgEOrientationAscNode.eAscNodeLAN; IAgOrientationAscNodeLAN lan = (IAgOrientationAscNodeLAN)classical.Orientation.AscNode; lan.Value = (360 - passed.lon); hpop.InitialState.Representation.Assign(classical); hpop.Propagate(); }