Click here to Skip to main content
15,886,786 members
Articles / Programming Languages / C#

Universal Framework for Science and Engineering - Part 6: Determination of Orbits of Artificial Satellites

Rate me:
Please Sign up or sign in to vote.
4.88/5 (28 votes)
8 Jul 2011CPOL19 min read 82.4K   6.6K   82  
An article on framework applications to determine the orbits of artificial satellites
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;

using CategoryTheory;
using DiagramUI;
using DiagramUI.Interfaces;

using DataPerformer.Interfaces;
using DiagramUI.Labels;

/*
namespace DataPerformer
{
    /// <summary>
    /// Standard strategy
    /// </summary>
    public class DataPerformerStrategy : IDataPerformerRuntimeFactory, IStep, ITimeMeasureProvider
    {

        #region Fields

        /// <summary>
        /// Time type
        /// </summary>
        const Double a = 0;

        /// <summary>
        /// Associated object
        /// </summary>
        public static DataPerformerStrategy Object = new DataPerformerStrategy();

        /// <summary>
        /// All components
        /// </summary>
         protected List<object> components = new List<object>();

        /// <summary>
        /// Objects
        /// </summary>
        protected List<ICategoryObject> objects = new List<ICategoryObject>();

        /// <summary>
        /// Arrows
        /// </summary>
        protected List<ICategoryArrow> arrows = new List<ICategoryArrow>();

        /// <summary>
        /// Updatable objects
        /// </summary>
        protected List<IUpdatableObject> updatable = new List<IUpdatableObject>();

        /// <summary>
        /// Step
        /// </summary>
        protected int step;

        /// <summary>
        /// Dynamical objects
        /// </summary>
        protected ArrayList dynamical = new ArrayList();

        /// <summary>
        /// Measurements
        /// </summary>
        protected ArrayList measurements = new ArrayList();

        /// <summary>
        /// Current time
        /// </summary>
        protected double time;

        /// <summary>
        /// Step
        /// </summary>
        protected double dstep;

 
        IMeasure timeMeasure;// = new MeasureDerivation(a, GetTime, new ConstantMeasure(1), "Time");

        /// <summary>
        /// Global state
        /// </summary>
        protected List<string[]> globalState = new List<string[]>();

        /// <summary>
        /// State
        /// </summary>
        protected double[] state;

        #endregion

        #region Ctor

        /// <summary>
        /// Default constructor
        /// </summary>
        protected DataPerformerStrategy()
        {
            timeMeasure = new MeasureDerivation(a, GetTime, new ConstantMeasure(1), "Time");
        }


        #endregion

        #region IDataPerformerStrategy Members


        /// <summary>
        /// Updates all elements
        /// </summary>
        public virtual void UpdateAll(IComponentCollection collection)
        {
            foreach (IUpdatableObject up in updatable)
            {
                up.UpdateObject();
            }
        }


        /// <summary>
        /// Starts all components
        /// </summary>
        /// <param name="coll">collectio</param>
        /// <param name="time">Start time</param>
        public virtual void StartAll(IComponentCollection coll, double time)
        {
            this.time = time;
            List<IStarted> ls = new List<IStarted>();
            coll.ForEach<IStarted>((IStarted s) => { ls.Add(s); s.Start(time); });
            IDifferentialEquationProcessor pr = DifferentialEquationProcessor.Processor;
            if (pr == null)
            {
                return;
            }
            ICollection<IDifferentialEquationSolver> de = pr.Equations;
            foreach (IDifferentialEquationSolver deq in de)
            {
                if (deq is IStarted)
                {
                    IStarted s = deq as IStarted;
                    if (!ls.Contains(s))
                    {
                        s.Start(time);
                    }
                }
            }
        }

        /// <summary>
        /// Provider of time measure
        /// </summary>
        public virtual ITimeMeasureProvider TimeProvider
        {
            get
            {
                return this;
            }
        }


        /// <summary>
        /// Prepares all
        /// </summary>
        /// <param name="coll"></param>
        public virtual void PrepareAll(IComponentCollection coll)
        {
            ClearAll();
            prepareAll(coll.AllComponents);
            updatable.Clear();
            foreach (object o in components)
            {
                if (o == null)
                {
                    continue;
                }
                if (o is IDynamical)
                {
                    continue;
                }
                if (!(o is IUpdatableObject))
                {
                    continue;
                }
                IUpdatableObject up = o as IUpdatableObject;
                if (up.ShouldUpdate)
                {
                    updatable.Add(up);
                }
            }
            foreach (object obj in components)
            {
                IDynamical dyn = null;
                if (!(obj is IDynamical))
                {
                    continue;
                }
                dyn = obj as IDynamical;
                dynamical.Add(dyn);
            }
            foreach (object obj in components)
            {
               if (!(obj is IMeasurements))
                {
                    continue;
                }
                IMeasurements m = obj as IMeasurements;
                measurements.Add(m);
            }
        }


        /// <summary>
        /// Clears all components
        /// </summary>
        public void ClearAll()
        {
            if (components != null)
            {
                components.Clear();
            }
            if (objects != null)
            {
                objects.Clear();
            }
            if (arrows != null)
            {
                arrows.Clear();
            }
            updatable.Clear();
            dynamical.Clear();
            measurements.Clear();
            globalState.Clear();
            GC.Collect();
        }

        /// <summary>
        /// Gets differential equation solver from object
        /// </summary>
        /// <param name="obj">Object</param>
        /// <returns>Solver</returns>
        public virtual IDifferentialEquationSolver GetDifferentialEquationSolver(object obj)
        {
            return null;
        }


        /// <summary>
        /// Time
        /// </summary>
        public double Time
        {
            get
            {
                return time;
            }
            set
            {
                time = value;
                foreach (IDynamical dyn in dynamical)
                {
                    dyn.Time = value;
                }
                UpdateAll(null);
                ResetUpdatedMeasurements();
            }
        }

        /// <summary>
        /// Strategy clone
        /// </summary>
        IDataPerformerRuntimeFactory IDataPerformerRuntimeFactory.Clone
        {
            get
            {
                return Create();
            }

        }

  
 


        #endregion

        #region IStep Members

        /// <summary>
        /// Step
        /// </summary>
        public int Step
        {
            get
            {
                return step;
            }
            set
            {
                step = value;
                foreach (object o in components)
                {
                    if (!(o is IStep))
                    {
                        continue;
                    }
                    IStep s = o as IStep;
                    s.Step = value;
                }
            }
        }

        /// <summary>
        /// Resets updated measurements
        /// </summary>
        public void ResetUpdatedMeasurements()
        {
            foreach (IMeasurements m in measurements)
            {
                m.IsUpdated = false;
            }
        }

        #endregion

        #region ITimeMeasureProvider Members

        IMeasure ITimeMeasureProvider.TimeMeasure
        {
            get { return timeMeasure; }
        }


        double ITimeMeasureProvider.Step
        {
            get
            {
                return dstep;
            }
            set
            {
                dstep = value;
            }
        }


        #endregion


        #region Specific Members

        /// <summary>
        /// Creates strategy
        /// </summary>
        /// <returns>Strategy</returns>
        protected virtual IDataPerformerRuntimeFactory Create()
        {
            return new DataPerformerStrategy();
        }

        /// <summary>
        /// All components
        /// </summary>
        public ICollection Components
        {
            get
            {
                return components;
            }
        }

        /// <summary>
        /// Preparation
        /// </summary>
        /// <param name="d">Desktop</param>
        private void prepareAll(ICollection<object> coll)
        {
            components.Clear();
            components.AddRange(coll);
            coll.ForEach<ICategoryObject>((ICategoryObject l) => { objects.Add(l); });
            arrows.Clear();
            coll.ForEach<ICategoryArrow>((ICategoryArrow l) => { arrows.Add(l); });
            IDifferentialEquationProcessor processor = DifferentialEquationProcessor.Processor;
            if (processor != null)
            {
               //globalState.AddRange(processor.Set(coll.GetDataConsumers()));
            }

        }

        object GetTime()
        {
            return time;
        }



        #endregion
 
    }
}*/

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
Russian Federation Russian Federation
Ph. D. Petr Ivankov worked as scientific researcher at Russian Mission Control Centre since 1978 up to 2000. Now he is engaged by Aviation training simulators http://dinamika-avia.com/ . His additional interests are:

1) Noncommutative geometry

http://front.math.ucdavis.edu/author/P.Ivankov

2) Literary work (Russian only)

http://zhurnal.lib.ru/editors/3/3d_m/

3) Scientific articles
http://arxiv.org/find/all/1/au:+Ivankov_Petr/0/1/0/all/0/1

Comments and Discussions