Example #1
0
        private void computeAccess_Click(object sender, EventArgs e)
        {
            string accessToName   = cbAccessTo.GetItemText(cbAccessTo.SelectedItem);
            string accessFromName = cbAccessTo.GetItemText(cbAccessFrom.SelectedItem);

            IAgStkObject toObj   = CommonData.StkRoot.GetObjectFromPath(accessToName);
            IAgStkObject fromObj = CommonData.StkRoot.GetObjectFromPath(accessFromName);
            IAgStkAccess access  = toObj.GetAccessToObject(fromObj);

            access.ComputeAccess();

            // Get access results from data provider
            IAgIntervalCollection accessIntervals    = access.ComputedAccessIntervalTimes;
            IAgDataPrvTimeVar     accessDataProvider = access.DataProviders.GetDataPrvTimeVarFromPath("AER Data//Default");
            Array dataProviderElements = new object[] { "Time", "Azimuth", "Elevation", "Range" };

            dataGridViewAccess.Rows.Clear();
            dataGridViewAccess.Rows.Add();
            for (int i = 0; i < accessIntervals.Count; i++)
            {
                object startTime = null, stopTime = null;
                accessIntervals.GetInterval(i, out startTime, out stopTime);
                IAgDrResult dataProviderResult = accessDataProvider.ExecElements(startTime, stopTime, 1, ref dataProviderElements);
                Array       timeValues         = dataProviderResult.DataSets[0].GetValues();
                Array       azimuthValues      = dataProviderResult.DataSets[1].GetValues();
                Array       elevationValues    = dataProviderResult.DataSets[2].GetValues();
                Array       rangeValues        = dataProviderResult.DataSets[3].GetValues();


                for (int j = 0; j < timeValues.Length; j++)
                {
                    DataGridViewRow row = (DataGridViewRow)dataGridViewAccess.Rows[0].Clone();
                    row.Cells[0].Value = timeValues.GetValue(j).ToString();
                    row.Cells[1].Value = azimuthValues.GetValue(j).ToString();
                    row.Cells[2].Value = elevationValues.GetValue(j).ToString();
                    row.Cells[3].Value = rangeValues.GetValue(j).ToString();
                    dataGridViewAccess.Rows.Add(row);
                }
            }


            ////Get built in Calucation object from Analysis Workbench
            //// Could put into another dataGridView
            //var parameterSets = access.Vgt.ParameterSets["From-To-AER(Body)"];

            ////Get magnitude vector
            //IAgCrdnCalcScalar magnitude = ((IAgCrdn)parameterSets).EmbeddedComponents["From-To-AER(Body).Cartesian.Magnitude"] as IAgCrdnCalcScalar;

            ////Get times of the minimum value for each access interval
            //AgCrdnEventArrayExtrema minTimes = ((IAgCrdn)parameterSets).EmbeddedComponents["From-To-AER(Body).Cartesian.Magnitude.TimesOfLocalMin"] as AgCrdnEventArrayExtrema;
            //Array timeArray = minTimes.FindTimes().Times;
            //for (int i = 0; i < timeArray.Length; i++)
            //{
            //    double result = magnitude.Evaluate(timeArray.GetValue(i)).Value;
            //}
        }
Example #2
0
        //public STKDataProvider(IAgStkObject object0,string Name, bool needPreData)
        //{
        //    m_selectedObject = object0;
        //    m_providerGroup = m_selectedObject.DataProviders["Cartesian Velocity"] as IAgDataProviderGroup;
        //    IAgDataProvider CartVel_provider= (m_providerGroup.Group["J2000"] as IAgDataProvider);

        //    ///Cast Appropiate Data Pro
        //    IAgDataPrvTimeVar Velocity = CartVel_provider as IAgDataPrvTimeVar;
        //    Array elem = new object[] { "x" };
        //    IAgDrResult Speed = Velocity.ExecElements("19 May 2019 22:00:00.000", "19 May 2019 22:10:00.000", 60, ref elem );

        //    m_dataSe = Speed.DataSets[0].GetValues();
        //    ///update_Dataset(26667, "Name", speed);
        //    ///Console.WriteLine(CartVel_providers)
        //}

        public System.Array acquireDataset(string startTime, string stopTime, double timeStep)
        {
            IAgDataProvider provider = null;

            if (m_parent != m_superParent)
            {
                m_providerGroup = m_StkObj.DataProviders[m_superParent] as IAgDataProviderGroup;
                provider        = (m_providerGroup.Group[m_parent] as IAgDataProvider); //m_parent
            }
            else if (m_parent == m_superParent)
            {
                provider = m_StkObj.DataProviders[m_parent] as IAgDataProvider;
            }
            ///Cast Appropiate Data Pro
            try
            {
                IAgDataPrvTimeVar Velocity = provider as IAgDataPrvTimeVar;
                Array             elem     = new object[] { m_DP2 };
                IAgDrResult       result   = Velocity.ExecElements(startTime, stopTime, timeStep, ref elem);
                m_dataArray = result.DataSets[0].GetValues();
            }
            catch
            {
                IAgDataPrvInterval Velocity = provider as IAgDataPrvInterval;
                if (Velocity != null)
                {
                    Array       elem   = new object[] { m_DP2 };
                    IAgDrResult result = Velocity.ExecElements(startTime, stopTime, ref elem);
                    m_dataArray = result.DataSets[0].GetValues();
                }
                else
                {
                    m_Error = true;
                }
            }



            return(m_dataArray);
        }
Example #3
0
        private void ExportUMTFile()
        {
            SaveFileDialog saveDialog = new SaveFileDialog();

            saveDialog.Filter           = "UMT files (*.umt)|*.umt";
            saveDialog.FilterIndex      = 0;
            saveDialog.RestoreDirectory = true;
            string fileName = "";

            if (saveDialog.ShowDialog() == DialogResult.OK)
            {
                fileName = saveDialog.FileName;
            }

            if (fileName == "")
            {
                return;
            }

            //
            // init
            //
            m_root.UnitPreferences.SetCurrentUnit("Time", "sec");
            m_root.UnitPreferences.SetCurrentUnit("DateFormat", "EpSec");
            m_root.UnitPreferences.SetCurrentUnit("LatitudeUnit", "rad");
            m_root.UnitPreferences.SetCurrentUnit("LongitudeUnit", "rad");
            m_root.UnitPreferences.SetCurrentUnit("AngleUnit", "rad");
            m_root.UnitPreferences.SetCurrentUnit("DistanceUnit", "m");
            m_root.ExecuteCommand("SetUnits / EpSec");

            //
            // get select obj
            //
            IAgStkObject mySelObj = m_root.GetObjectFromPath(m_psite.Selection[0].Path);


            //
            // get obj class, and roll-offset
            //
            double rOffset = 0.0;

            if ((mySelObj.ClassName == "Ship") || (mySelObj.ClassName == "GroundVehicle"))
            {
                rOffset = Math.PI;
            }


            Console.WriteLine("Create times..." + DateTime.Now.ToString());
            //
            // get object start/stop times
            //
            // If I use ObjModel properties, this would be class specific, so I will use connect
            //
            string[] times = m_root.ExecuteCommand("GetTimePeriod " + mySelObj.Path)[0].Replace("\"", "").Split(',');
            //step = 1; // set = 0 to use native ephemeris time step

            //DAN - Changing this to UTCG times
            string startTime = m_root.ConversionUtility.ConvertDate("EpSec", "UTCG", times[0]);
            string stopTime  = m_root.ConversionUtility.ConvertDate("EpSec", "UTCG", times[1]);

            //DAN - Update the object model to expect UTCG dates
            m_root.UnitPreferences.SetCurrentUnit("DateFormat", "UTCG");


            IAgDataPrvTimeVar dp         = mySelObj.DataProviders.GetDataPrvTimeVarFromPath("Cartesian Position/Fixed");
            Array             elements   = new object[] { "Time" };
            IAgDrResult       result     = dp.ExecElements(startTime, stopTime, 1.0, elements);
            Array             timesArray = result.DataSets.GetDataSetByName("Time").GetValues();


            Console.WriteLine("Data Providers..." + DateTime.Now.ToString());
            //
            // get position data
            //
            elements = new object[] { "x", "y", "z" };
            dp       = mySelObj.DataProviders.GetDataPrvTimeVarFromPath("Cartesian Position/Fixed");
            IAgDrResult results = dp.ExecElements(startTime, stopTime, 1.0, ref elements);
            Array       x       = results.DataSets.GetDataSetByName("x").GetValues();
            Array       y       = results.DataSets.GetDataSetByName("y").GetValues();
            Array       z       = results.DataSets.GetDataSetByName("z").GetValues();



            //
            // get velocity
            //
            elements = new object[] { "x", "y", "z" };
            dp       = mySelObj.DataProviders.GetDataPrvTimeVarFromPath("Cartesian Velocity/Fixed");
            results  = dp.ExecElements(startTime, stopTime, 1.0, ref elements);
            Array xd = results.DataSets.GetDataSetByName("x").GetValues();
            Array yd = results.DataSets.GetDataSetByName("y").GetValues();
            Array zd = results.DataSets.GetDataSetByName("z").GetValues();



            //
            // get acceleration
            //
            dp      = mySelObj.DataProviders.GetDataPrvTimeVarFromPath("Cartesian Acceleration/Fixed");
            results = dp.ExecElements(startTime, stopTime, 1.0, ref elements);
            Array xdd = results.DataSets.GetDataSetByName("x").GetValues();
            Array ydd = results.DataSets.GetDataSetByName("y").GetValues();
            Array zdd = results.DataSets.GetDataSetByName("z").GetValues();


            //
            // get jerk - need to calcualate this: dA/dT
            //
            List <string> xddd = new List <string>();
            List <string> yddd = new List <string>();
            List <string> zddd = new List <string>();

            for (int j = 0; j <= timesArray.Length - 1; j++)
            {
                xddd.Add("0");
                yddd.Add("0");
                zddd.Add("0");
            }


            //
            // get heading, elevation, bank (rad)
            //
            dp = mySelObj.DataProviders.GetDataPrvTimeVarFromPath("Body Axes Orientation/NorthEastDown");
            Array eulerElements = new object[] { "Euler321 precession", "Euler321 nutation", "Euler321 spin" };

            results = dp.ExecElements(startTime, stopTime, 1.0, ref eulerElements);
            Array h = results.DataSets.GetDataSetByName("Euler321 precession").GetValues();
            Array e = results.DataSets.GetDataSetByName("Euler321 nutation").GetValues();
            Array b = results.DataSets.GetDataSetByName("Euler321 spin").GetValues();



            //
            // get angular vel about x,y,z body axes (rad/s)
            //
            dp = mySelObj.DataProviders.GetDataPrvTimeVarFromPath("Body Axes Orientation/Earth Fixed");
            Array avElements = new object[] { "wx", "wy", "wz" };

            results = dp.ExecElements(startTime, stopTime, 1.0, ref avElements);
            Array avel_x = results.DataSets.GetDataSetByName("wx").GetValues();
            Array avel_y = results.DataSets.GetDataSetByName("wy").GetValues();
            Array avel_z = results.DataSets.GetDataSetByName("wz").GetValues();



            //
            // calcualate angular acc about x,y,z body axes (rad/s^2) - from angVel
            //
            List <string> aacc_x = new List <string>();
            List <string> aacc_y = new List <string>();
            List <string> aacc_z = new List <string>();

            for (int j = 0; j <= timesArray.Length - 1; j++)
            {
                aacc_x.Add("0");
                aacc_y.Add("0");
                aacc_z.Add("0");
            }


            //
            // calcualate angular jerk about x,y,z body axes (rad/s^3)  - from angAcc
            //
            List <string> ajerk_x = new List <string>();;
            List <string> ajerk_y = new List <string>();;
            List <string> ajerk_z = new List <string>();;

            for (int j = 0; j <= timesArray.Length - 1; j++)
            {
                ajerk_x.Add("0");
                ajerk_y.Add("0");
                ajerk_z.Add("0");
            }



            //
            // format data (convert time from secs to hh:mm:ss.sss)
            //
            Console.WriteLine("Data Loop... " + DateTime.Now.ToString());
            string[] data = new string[timesArray.Length];
            for (int j = 0; j <= timesArray.Length - 1; j++)
            {
                DateTime iTime = DateTime.Parse(timesArray.GetValue(j).ToString());

                string t = iTime.ToString("HH:mm:ss.fff");
                data[j] = t + ",mot,V1_M1," + Convert.ToString(x.GetValue(j)) + "," + Convert.ToString(y.GetValue(j)) + "," + Convert.ToString(z.GetValue(j)) + "," + Convert.ToString(xd.GetValue(j)) + "," + Convert.ToString(yd.GetValue(j)) + "," + Convert.ToString(zd.GetValue(j)) + "," + Convert.ToString(xdd.GetValue(j)) + "," + Convert.ToString(ydd.GetValue(j)) + "," + Convert.ToString(zdd.GetValue(j)) + "," + xddd[j] + "," + yddd[j] + "," + zddd[j] + "," + Convert.ToString(h.GetValue(j)) + "," + Convert.ToString(e.GetValue(j)) + "," + Convert.ToString(((double)b.GetValue(j) + rOffset)) + "," + Convert.ToString(avel_x.GetValue(j)) + "," + Convert.ToString(avel_y.GetValue(j)) + "," + Convert.ToString(avel_z.GetValue(j)) + "," + aacc_x[j] + "," + aacc_y[j] + "," + aacc_z[j] + "," + ajerk_x[j] + "," + ajerk_y[j] + "," + ajerk_z[j];
            }
            Console.WriteLine("Writing File..." + DateTime.Now.ToString());
            System.IO.File.WriteAllLines(fileName, data);
            Console.WriteLine("Complete. " + DateTime.Now.ToString());
        }
Example #4
0
        public static RICResults GetRICDifferenceOverTime(string sat1Path, string sat2Path, string epochISOYMD)
        {
            IAgDate tca = StkAssistant.Root.ConversionUtility.NewDate("ISO-YMD", epochISOYMD);

            IAgStkObject primary, secondary;

            try
            {
                primary   = StkAssistant.Root.GetObjectFromPath(sat1Path);
                secondary = StkAssistant.Root.GetObjectFromPath(sat2Path);
            }
            catch
            {
                return(new RICResults());
            }

            double period1 = StkAssistant.GetSatellitePeriod(primary.Path, epochISOYMD);
            double period2 = StkAssistant.GetSatellitePeriod(secondary.Path, epochISOYMD);

            double period = (period1 + period2) / 2;

            IAgDataProviderInfo dpInfo = primary.DataProviders["RIC Coordinates"];

            IAgDataProvider dataProvider = primary.DataProviders["RIC Coordinates"] as IAgDataProvider;

            dataProvider.PreData = secondary.Path.Replace(StkAssistant.Root.CurrentScenario.Path, "");
            IAgDataPrvTimeVar dpTimeVarying = dataProvider as IAgDataPrvTimeVar;
            Array             elements      = new object[] { "Time", "Radial", "In-Track", "Cross-Track", "Range" };
            IAgDrResult       dpResult      = dpTimeVarying.ExecElements(
                tca.Subtract("sec", .5 * period).Format("ISO-YMD"),
                tca.Add("sec", .5 * period).Format("ISO-YMD"),
                10, elements);
            RICResults ricResults = new RICResults();

            foreach (IAgDrDataSet dataset in dpResult.DataSets)
            {
                if (dataset.ElementName.Equals("Time"))
                {
                    List <string> times = new List <string>();
                    foreach (object item in dataset.GetValues())
                    {
                        times.Add(item.ToString());
                    }
                    ricResults.Times = times.ToArray();
                }
                else
                {
                    List <double> values = new List <double>();
                    foreach (object item in dataset.GetValues())
                    {
                        values.Add((double)item);
                    }

                    switch (dataset.ElementName)
                    {
                    case "Radial":
                        ricResults.R = values.ToArray();
                        break;

                    case "In-Track":
                        ricResults.I = values.ToArray();
                        break;

                    case "Cross-Track":
                        ricResults.C = values.ToArray();
                        break;

                    case "Range":
                        ricResults.Range = values.ToArray();
                        break;

                    default:
                        break;
                    }
                }
            }

            return(ricResults);
        }