private void Generate_Click(object sender, EventArgs e) { if (CadanceList.FocusedItem != null && CadanceList.FocusedItem.Index != -1) { IAgStkObject facObj; IAgFacility fac; IAgConstellation optAssets = null; IAgConstellation radAssets = null; IAgStkObject constObj; IAgStkObject sensor; if (_cadances[CommonData.CadenceSelected].NumOptical > 0) { constObj = CreatorFunctions.GetCreateConstellation(_cadances[CommonData.CadenceSelected].Name + "_Opt"); optAssets = constObj as IAgConstellation; optAssets.Objects.RemoveAll(); } if (_cadances[CommonData.CadenceSelected].NumRadars > 0) { constObj = CreatorFunctions.GetCreateConstellation(_cadances[CommonData.CadenceSelected].Name + "_Rad"); radAssets = constObj as IAgConstellation; radAssets.Objects.RemoveAll(); } foreach (var item in _cadances[CommonData.CadenceSelected].FacilityList) { facObj = CreatorFunctions.GetCreateFacility(item.Name); fac = facObj as IAgFacility; fac.Position.AssignGeodetic(Double.Parse(item.Latitude), Double.Parse(item.Longitude), Double.Parse(item.Altitude)); fac.AltRef = AgEAltRefType.eWGS84; CreatorFunctions.ChangeObjectColor(facObj.Path, (CustomUserInterface.ColorOptions)Enum.Parse(typeof(CustomUserInterface.ColorOptions), _cadances[CommonData.CadenceSelected].CadenceColor)); if (item.IsOpt) { foreach (FCSensor fsensor in item.Sensors) { sensor = FacilityCreatorFunctions.AttachFacilityOptical(facObj, item.Name + "_" + fsensor.SensorName, fsensor.OParams); if (!optAssets.Objects.Contains(sensor.Path)) { optAssets.Objects.AddObject(sensor); } } } else { foreach (FCSensor fsensor in item.Sensors) { sensor = FacilityCreatorFunctions.AttachFacilityRadar(facObj, item.Name + "_" + fsensor.SensorName, fsensor.RParams); if (!optAssets.Objects.Contains(sensor.Path)) { radAssets.Objects.AddObject(sensor); } } } } } }
private void Generate_Click(object sender, EventArgs e) { if (CadanceList.FocusedItem != null && CadanceList.FocusedItem.Index != -1) { IAgStkObject facObj; IAgFacility fac; IAgConstellation optAssets = null; IAgConstellation radAssets = null; IAgStkObject constObj; IAgStkObject sensor; if (_cadances[CommonData.CadenceSelected].NumOptical > 0) { constObj = CreatorFunctions.GetCreateConstellation(_cadances[CommonData.CadenceSelected].Name + "_Opt"); optAssets = constObj as IAgConstellation; optAssets.Objects.RemoveAll(); } if (_cadances[CommonData.CadenceSelected].NumRadars > 0) { constObj = CreatorFunctions.GetCreateConstellation(_cadances[CommonData.CadenceSelected].Name + "_Rad"); radAssets = constObj as IAgConstellation; radAssets.Objects.RemoveAll(); } foreach (var item in _cadances[CommonData.CadenceSelected].FacilityList) { facObj = CreatorFunctions.GetCreateFacility(item.Name); fac = facObj as IAgFacility; fac.Position.AssignGeodetic(Double.Parse(item.Latitude), Double.Parse(item.Longitude), Double.Parse(item.Altitude)); fac.AltRef = AgEAltRefType.eWGS84; if (item.IsOpt) { sensor = CreatorFunctions.AttachFacilityOptical(facObj, item.Name + "_Opt", item.OParams); optAssets.Objects.AddObject(sensor); } else { sensor = CreatorFunctions.AttachFacilityRadar(facObj, item.Name + "_Radar", item.RParams); radAssets.Objects.AddObject(sensor); } } } }
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 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 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); } }