Ejemplo n.º 1
0
 private void Duplicate_Click(object sender, EventArgs e)
 {
     if (SensorList.SelectedIndex != -1 && SensorList.SelectedItem != null)
     {
         FCSensor newSensor = new FCSensor(sensors[SensorList.SelectedIndex]);
         bool     exists    = SensorList.Items.Contains(newSensor.SensorName + "1");
         if (exists)
         {
             for (int i = 0; i < 99; i++)
             {
                 exists = SensorList.Items.Contains("Sensor" + i.ToString());
                 if (!exists)
                 {
                     newSensor.SensorName = newSensor.SensorName + i.ToString();
                     break;
                 }
             }
         }
         else
         {
             newSensor.SensorName = newSensor.SensorName + "1";
         }
         sensors.Add(newSensor);
         SensorList.Items.Add(newSensor.SensorName);
         SensorList.SelectedIndex = SensorList.Items.Count - 1;
     }
 }
Ejemplo n.º 2
0
        private void AddFacility_Click(object sender, EventArgs e)
        {
            FcFacility facility = new FcFacility();
            FCSensor   sensor   = new FCSensor();

            facility.Name = "New_Facility";
            bool exists = CommonData.StkRoot.ObjectExists("Facility/Sensor1");

            if (exists)
            {
                for (int i = 0; i < 99; i++)
                {
                    exists = CommonData.StkRoot.ObjectExists("Facility/Sensor" + i.ToString());
                    if (!exists)
                    {
                        sensor.SensorName = "Sensor" + i.ToString();
                        break;
                    }
                }
            }
            else
            {
                sensor.SensorName = "Sensor1";
            }
            facility.Latitude  = "0";
            facility.Longitude = "0";
            facility.Altitude  = "0";
            facility.Type      = "Optical";
            facility.IsOpt     = true;
            RadarParams rParams = new RadarParams();

            rParams.MinEl        = "0";
            rParams.MaxEl        = "90";
            rParams.MinRange     = "300";
            rParams.MaxRange     = "40000";
            rParams.SolarExAngle = "10";
            rParams.HalfAngle    = "85";
            rParams.MinAz        = "0";
            rParams.MaxAz        = "360";
            sensor.RParams       = rParams;
            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.OParams          = oParams;
            facility.UseDefaultCnst = true;
            facility.Sensors.Add(sensor);
            CurFacilityList.Add(facility);
            PopulateCadance();
            CadanceList.FocusedItem = CadanceList.Items[CadanceList.Items.Count - 1];
            PopulateNumSensors();
        }
Ejemplo n.º 3
0
        private void AddSensor_Click(object sender, EventArgs e)
        {
            FCSensor newSensor = new FCSensor();
            bool     exists    = SensorList.Items.Contains("Sensor1");

            if (exists)
            {
                for (int i = 0; i < 99; i++)
                {
                    exists = SensorList.Items.Contains("Sensor" + i.ToString());
                    if (!exists)
                    {
                        newSensor.SensorName = "Sensor" + i.ToString();
                        break;
                    }
                }
            }
            else
            {
                newSensor.SensorName = "Sensor1";
            }
            RadarParams rParams = new RadarParams();

            rParams.MinEl        = "0";
            rParams.MaxEl        = "90";
            rParams.MinRange     = "300";
            rParams.MaxRange     = "40000";
            rParams.SolarExAngle = "10";
            rParams.HalfAngle    = "85";
            rParams.MinAz        = "0";
            rParams.MaxAz        = "360";
            rParams.Az           = "0";
            rParams.El           = "90";
            newSensor.RParams    = rParams;
            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";
            oParams.Az           = "0";
            oParams.El           = "90";
            newSensor.OParams    = oParams;

            sensors.Add(newSensor);
            SensorList.Items.Add(newSensor.SensorName);
            SensorList.SelectedIndex = SensorList.Items.Count - 1;
        }
        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);
            }
        }
Ejemplo n.º 5
0
 public FCSensor(FCSensor sensor)
 {
     RParams    = new RadarParams(sensor.RParams);
     OParams    = new OpticalParams(sensor.OParams);
     SensorName = sensor.SensorName;
 }