Пример #1
0
        /// <summary>
        /// Posts itself
        /// </summary>
        private void Post()
        {
            IComponentCollection cc = this.GetDependentCollection();

            cc.GetAll <IMeasurements>(childMeasurements);
            cc.GetAll <IUpdatableObject>(updatable);
            if (updatable.Count == 0)
            {
                update = UpdateChildren;
            }
            else
            {
                update = () =>
                {
                    UpdateChildren();
                    foreach (IUpdatableObject uo in updatable)
                    {
                        if (uo.Update != null)
                        {
                            uo.Update();
                        }
                    }
                    UpdateChildren();
                };
            }
            SetAliases();
            SetMea();
            Process();
        }
Пример #2
0
        /// <summary>
        /// Event backup
        /// </summary>
        /// <param name="tuple">Tuple</param>
        /// <param name="events">Events</param>
        /// <param name="reason">Reason</param>
        public EventBackup(Tuple <IDataConsumer, IComponentCollection, ITimeMeasureProvider,
                                  IAsynchronousCalculation> tuple,
                           IEvent[] events, string reason)
        {
            this.events = events;
            collection  = tuple.Item2;
            IDesktop desktop            = collection.Desktop.Root;
            IList <ICategoryObject> l   = collection.GetAll <ICategoryObject>();
            IRealtimeStart          rst = null;

            desktop.ForEach((BelongsToCollection arrow) =>
            {
                if (!l.Contains(arrow.Target))
                {
                    return;
                }
                ICategoryObject s = arrow.Source;
                if (s is IRealtimeStart)
                {
                    IRealtimeStart rs = s as IRealtimeStart;
                    if (rs.IsEnabled)
                    {
                        if (rst != null)
                        {
                            throw new Exception("Start already exists");
                        }
                        rst = rs;
                    }
                }
            });
            if (rst != null)
            {
                dictionary = rst.StartAlias;
                dictionary.Get();
            }
            Tuple <string, Tuple <IDataConsumer, IComponentCollection, ITimeMeasureProvider,
                                  IAsynchronousCalculation> > tt = new Tuple <string, Tuple <IDataConsumer, IComponentCollection,
                                                                                             ITimeMeasureProvider, IAsynchronousCalculation> >
                                                                       (reason, tuple);
            IActionFactory       f        = StaticExtensionEventPortable.ActionFactoryCreator[tt];
            List <INativeEvent>  lnative  = new List <INativeEvent>();
            List <INativeReader> lnativeR = new List <INativeReader>();

            if (events != null)
            {
                foreach (IEvent ev in events)
                {
                    Action a = f[ev];
                    actions[ev] = a;
                    ev.Event   += a;
                }
            }
            else
            {
                collection.ForEach(
                    (IEvent ev) =>
                {
                    Action a    = f[ev];
                    actions[ev] = a;
                    ev.Event   += a;
                });
            }
            if (reason.IsRealtimeAnalysis())
            {
                collection.ForEach((INativeEvent ne) => {
                    lnative.Add(ne);
                    lno.Add(ne);
                    if (ne is ICalculationReason)
                    {
                        (ne as ICalculationReason).CalculationReason = reason;
                    }
                    if (ne is IEvent)
                    {
                        (ne as IEvent).IsEnabled = true;
                    }
                });
                collection.ForEach(
                    (INativeReader re) =>
                {
                    lnativeR.Add(re);
                    lno.Add(re);
                    if (re is ICalculationReason)
                    {
                        (re as ICalculationReason).CalculationReason = reason;
                    }
                    if (re is IEventReader)
                    {
                        (re as IEventReader).IsEnabled = true;
                    }
                });
            }

            collection.ForEach(
                (IEvent ev) =>
            {
                ev.IsEnabled = true;
            });
            List <IEventReader> ler = new List <IEventReader>();

            collection.ForEach((IEventReader r) => {
                ler.Add(r);

                r.IsEnabled = true;
            });
            readers      = ler.ToArray();
            nativeEvents = lnative.ToArray();
        }