示例#1
0
        /// <summary>
        /// Prepares itself
        /// </summary>
        protected virtual void Prepare()
        {
            ClearAll();
            prepareAll(collection);
            IEnumerable <object> comp = collection.AllComponents;

            foreach (object o in comp)
            {
                IUpdatableObject up = o.GetLabelObject <IUpdatableObject>();
                if (up == null)
                {
                    continue;
                }
                if (up is IDynamical)
                {
                    continue;
                }
                if (up.ShouldUpdate)
                {
                    if (up.SatisfiesReason(reason))
                    {
                        if (up.Update != null)
                        {
                            updatable.Add(up.Update);
                        }
                    }
                }
            }
            foreach (object obj in comp)
            {
                IDynamical dyn = obj.GetLabelObject <IDynamical>();
                if (dyn == null)
                {
                    continue;
                }
                dynamical.Add(dyn);
            }
            collection.ForEach <IMeasurements>(

                (IMeasurements m) => { measurements.Add(m); }
                );
            collection.ForEach <IStep>((IStep s) => { steps.Add(s); });
            if (updatable.Count == 0)
            {
                updateAll = UpdateMeasurements;
            }
            else
            {
                updateAll = () =>
                {
                    UpdateMeasurements();
                    foreach (Action up in updatable)
                    {
                        up();
                    }
                    UpdateMeasurements();
                };
            }
            measurements.SortMeasurements();
        }
示例#2
0
 void Add(object o)
 {
     if (o == null)
     {
         return;
     }
     if (o is IDataConsumer)
     {
         IDataConsumer c = o as IDataConsumer;
         if (!consumers.Contains(c))
         {
             consumers.Add(c);
         }
     }
     if (o is IUpdatableObject)
     {
         IUpdatableObject u = o as IUpdatableObject;
         if (!upd.Contains(u))
         {
             upd.Add(u);
         }
     }
     if (o is IDynamical)
     {
         IDynamical d = o as IDynamical;
         if (!dyn.Contains(d))
         {
             dyn.Add(d);
         }
     }
     if (o is IStep)
     {
         IStep s = o as IStep;
         s.Step = 0;
         if (!steps.Contains(s))
         {
             steps.Add(s);
         }
     }
     if (o is IChildrenObject)
     {
         IChildrenObject     ch   = o as IChildrenObject;
         IAssociatedObject[] objs = ch.Children;
         foreach (object obj in objs)
         {
             Add(obj);
         }
     }
     if (o is MeasurementsWrapper)
     {
         MeasurementsWrapper mw = o as MeasurementsWrapper;
         int n = mw.Count;
         for (int i = 0; i < n; i++)
         {
             Add(mw[i]);
         }
     }
 }
示例#3
0
        /// <summary>
        /// Prepares itself
        /// </summary>
        protected override void Prepare()
        {
            ClearAll();
            IComponentCollection cc = factory.CreateCollection(consumer, 0, null);
            IEnumerable <object> en = cc.AllComponents;

            foreach (object o in en)
            {
                if (o is IRuntimeUpdate)
                {
                    runtimeUpdate.Add(o as IRuntimeUpdate);
                }
                if (o is IDataConsumer)
                {
                    IDataConsumer dc = o as IDataConsumer;
                    for (int i = 0; i < dc.Count; i++)
                    {
                        IMeasurements m = dc[i];
                        if (m is RelativeMeasurements)
                        {
                            RelativeMeasurements rm = m as RelativeMeasurements;
                            AddFrameDependent(rm.Source);
                            AddFrameDependent(rm.Target);
                        }
                        if (m is IRuntimeUpdate)
                        {
                            IRuntimeUpdate st = m as IRuntimeUpdate;
                            if (!st.ShouldRuntimeUpdate)
                            {
                                if (!runtimeUpdate.Contains(st))
                                {
                                    runtimeUpdate.Add(st);
                                }
                            }
                        }
                    }
                }
                if (o is IPosition)
                {
                    frames.Add(o as IPosition);
                }
                if (o is IMeasurements)
                {
                    IMeasurements m = o as IMeasurements;
                    if (!measurements.Contains(m))
                    {
                        measurements.Add(m);
                    }
                }
                if (o is IStep)
                {
                    steps.Add(o as IStep);
                }
                if (o is IUpdatableObject)
                {
                    IUpdatableObject up = o as IUpdatableObject;
                    if (up == null)
                    {
                        continue;
                    }
                    if (up is IDynamical)
                    {
                        continue;
                    }
                    if (up.ShouldUpdate)
                    {
                        if (up.Update != null)
                        {
                            updatable.Add(up.Update);
                        }
                    }
                }
            }
            foreach (object obj in en)
            {
                if (obj is IDynamical)
                {
                    IDynamical dyn = obj as IDynamical;
                    if (dyn == null)
                    {
                        continue;
                    }
                    dynamical.Add(dyn);
                }
            }
            measurements.SortMeasurements();
            updateAll = null;
            Action um = UpdateMeasurements;
            Action uu = () =>
            {
                foreach (Action up in updatable)
                {
                    up();
                }
            };
            Action upd = null;

            if (updatable.Count > 0)
            {
                upd = () =>
                {
                    foreach (Action up in updatable)
                    {
                        up();
                    }
                };
            }
            frames.SortPositions();
            Action uf = null;

            if (frames != null)
            {
                if (frames.Count > 0)
                {
                    uf = () =>
                    {
                        frames.UpdateFrames();
                    };
                }
            }
            if (uf == null & upd == null)
            {
                updateAll = UpdateMeasurements;
            }
            else if (upd == null)
            {
                updateAll = UpdateMeasurements + uf;
            }
            else if (uf == null)
            {
                updateAll = UpdateMeasurements + upd + UpdateMeasurements;
            }
            else
            {
                updateAll = UpdateMeasurements + upd + uf + UpdateMeasurements + upd;
            }
        }