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 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); } }