示例#1
0
        /// <summary>
        /// Start
        /// </summary>
        /// <param name="collection">Components</param>
        /// <param name="timeUnit">Time unit</param>
        /// <param name="isAbsoluteTime">The "is absolute time" sign</param>
        /// <param name="stepAction">Step Action</param>
        /// <param name="dataConsumer">Data Consumer</param>
        /// <param name="log">log</param>
        /// <param name="reason">Reason</param>
        IRealtime IRealtime.Start(IComponentCollection collection,
                                  TimeType timeUnit, bool isAbsoluteTime, IAsynchronousCalculation stepAction,
                                  IDataConsumer dataConsumer, IEventLog log, string reason)
        {
            this.reason = reason;
            StaticExtensionEventPortable.StartRealtime(collection);
            StandardEventRuntime rt = new StandardEventRuntime();

            rt.collection = collection;
            try
            {
                ITimeMeasureProvider realTime = RealtimeProvider.Create(isAbsoluteTime, timeUnit, reason);
                Tuple <IDataConsumer, IComponentCollection, ITimeMeasureProvider, IAsynchronousCalculation> tuple =
                    new Tuple <IDataConsumer, IComponentCollection,
                               ITimeMeasureProvider, IAsynchronousCalculation>
                        (dataConsumer, collection, realTime, stepAction);
                rt.timeProvider = realTime;
                rt.timeBackup   =
                    new DataPerformer.TimeProviderBackup(dataConsumer, realTime, null,
                                                         reason, 0);
                IEvent[] events = (dataConsumer as IEventHandler).Events.EnumerableToArray();
                if (log != null)
                {
                    foreach (IEvent ev in events)
                    {
                        string name = (dataConsumer as
                                       IAssociatedObject).GetRelativeName(ev as IAssociatedObject);
                        ev.ConnectLog(log, name);
                    }
                    collection.ForEach((IEventReader reader) =>
                    {
                        string name = (dataConsumer as
                                       IAssociatedObject).GetRelativeName(reader as IAssociatedObject);
                        reader.ConnectLog(log, name);
                    });
                }
                collection.ForEach((ICalculationReason cr) => { cr.CalculationReason = reason; });
                collection.ForEach((IRealTimeStartStop ss) =>
                {
                    ss.Start();
                });
                rt.eventBackup = new EventBackup(tuple, events, reason);
            }
            catch (Exception exception)
            {
                onError(exception);
                (rt as IRealtime).Stop();
                rt = null;
            }
            return(rt);
        }
示例#2
0
        IRealtime StartRealtime()
        {
            IAsynchronousCalculation animation =
                collection.StartAnimation(new string[] { StaticExtensionEventInterfaces.Realtime,
                                                         AnimationType.GetReason() }, AnimationType, new TimeSpan(0), 1, true, isAbsoluteTime);

            if (animation != null)
            {
                StaticExtensionEventPortable.OnceStop(animation.Interrupt);
            }
            return(StaticExtensionEventPortable.StartRealtime(collection, timeUnit, isAbsoluteTime, animation,
                                                              dataConsumer, StaticExtensionEventInterfaces.NewLog,
                                                              StaticExtensionEventInterfaces.Realtime));
        }