Ejemplo n.º 1
0
 private void Reset(IDataConsumer consumer)
 {
     if (consumer is ITimeMeasureConsumer)
     {
         ITimeMeasureConsumer tc = consumer as ITimeMeasureConsumer;
         if (dictionary.ContainsKey(tc))
         {
             tc.Time = dictionary[tc];
         }
     }
     for (int i = 0; i < consumer.Count; i++)
     {
         IMeasurements m = consumer[i];
         if (m is ITimeMeasureConsumer)
         {
             ITimeMeasureConsumer mc = m as ITimeMeasureConsumer;
             if (dictionary.ContainsKey(mc))
             {
                 mc.Time = dictionary[mc];
             }
         }
         if (m is IDataConsumer)
         {
             IDataConsumer dc = m as IDataConsumer;
             Reset(dc);
         }
     }
 }
Ejemplo n.º 2
0
        static void SetTimeProvider(object o, ITimeMeasureProvider provider, IDictionary <ITimeMeasureConsumer, IMeasurement> dictionary)
        {
            ITimeMeasureConsumer tc = o.GetLabelObject <ITimeMeasureConsumer>();

            if (tc != null)
            {
                if (dictionary.ContainsKey(tc))
                {
                    if (tc.Time != provider.TimeMeasurement)
                    {
                        dictionary[tc] = tc.Time;
                        tc.Time        = provider.TimeMeasurement;
                    }
                }
                else
                {
                    dictionary[tc] = tc.Time;
                    tc.Time        = provider.TimeMeasurement;
                }
            }
            IChildrenObject co = o.GetLabelObject <IChildrenObject>();

            if (co != null)
            {
                IAssociatedObject[] ch = co.Children;
                if (ch != null)
                {
                    foreach (object ob in ch)
                    {
                        SetTimeProvider(ob, provider, dictionary);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 static void SetTimeProvider(IMeasurements m, ITimeMeasureProvider provider, IDictionary <ITimeMeasureConsumer, IMeasurement> dictionary)
 {
     if (m is ITimeMeasureConsumer)
     {
         ITimeMeasureConsumer mc = m as ITimeMeasureConsumer;
         if (dictionary.ContainsKey(mc))
         {
             if (mc.Time != provider.TimeMeasurement)
             {
                 dictionary[mc] = mc.Time;
                 mc.Time        = provider.TimeMeasurement;
             }
         }
         else
         {
             dictionary[mc] = mc.Time;
             mc.Time        = provider.TimeMeasurement;
         }
     }
     if (m is IDataConsumer)
     {
         IDataConsumer dc = m as IDataConsumer;
         SetTimeProvider(dc, provider, dictionary);
     }
     if (m is MeasurementsWrapper)
     {
         MeasurementsWrapper mw = m as MeasurementsWrapper;
         int n = mw.Count;
         for (int i = 0; i < n; i++)
         {
             SetTimeProvider(mw[i], provider, dictionary);
         }
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Sets time provider to data consumer and all dependent objects
 /// </summary>
 /// <param name="consumer">Data consumer</param>
 /// <param name="provider">Data provider</param>
 /// <param name="dictionary">Backup dictionary</param>
 private static void SetTimeProvider(IDataConsumer consumer,
                                     ITimeMeasureProvider provider, IDictionary <ITimeMeasureConsumer, IMeasurement> dictionary)
 {
     if (consumer is ITimeMeasureConsumer)
     {
         ITimeMeasureConsumer tc = consumer as ITimeMeasureConsumer;
         IMeasurement         timeMeasurement = provider.TimeMeasurement;
         if (!(timeMeasurement is TimeMeasurement))
         {
             throw new Exception();
         }
         Func <object> f = provider.TimeMeasurement.Parameter;
         if (dictionary.ContainsKey(tc))
         {
             if (tc.Time != provider.TimeMeasurement)
             {
                 dictionary[tc] = tc.Time;
                 (tc.Time as TimeMeasurement).TimeParameter = provider.TimeMeasurement.Parameter;
             }
         }
         else
         {
             dictionary[tc] = tc.Time;
             (tc.Time as TimeMeasurement).TimeParameter = provider.TimeMeasurement.Parameter;
         }
     }
 }
Ejemplo n.º 5
0
        static void SetTimeProvider(object o, ITimeMeasureProvider provider, IDictionary <ITimeMeasureConsumer, IMeasurement> dictionary)
        {
            ITimeMeasureConsumer tc = o.GetLabelObject <ITimeMeasureConsumer>();
            IMeasurement         timeMeasurement = provider.TimeMeasurement;

            if (!(timeMeasurement is TimeMeasurement))
            {
                throw new Exception();
            }
            Func <object> f = timeMeasurement.Parameter;

            if (tc != null)
            {
                TimeMeasurement tmr = tc.Time as TimeMeasurement;
                if (tmr == null)
                {
                    tc.Time = new TimeMeasurement(() => { return((double)0); });
                }
                tmr = tc.Time as TimeMeasurement;
                if (dictionary.ContainsKey(tc))
                {
                    if (tc.Time != provider.TimeMeasurement)
                    {
                        dictionary[tc] = tc.Time;
                        if (tmr != null)
                        {
                            tmr.TimeParameter = f;
                        }
                    }
                }
                else
                {
                    dictionary[tc] = tc.Time;
                    if (tmr != null)
                    {
                        tmr.TimeParameter = f;
                    }
                }
            }
            IChildrenObject co = o.GetLabelObject <IChildrenObject>();

            if (co != null)
            {
                IAssociatedObject[] ch = co.Children;
                if (ch != null)
                {
                    foreach (object ob in ch)
                    {
                        SetTimeProvider(ob, provider, dictionary);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public BufferReadWrite()
        {
            consumer = this;
            iterator = this;
            tc       = this;

            // !!! The event is added to ensure that the list of inputs is changed as soon as a measurement provider is disconnected; may cause bugs
            // !!! Did cause bugs, because object removal is present in such innocent operation as saving the file.
            // For that reason, VerifyInput was made non-functional
            onChangeInput += VerifyInput;

            timeMeasurementProvider = new TimeMeasurement(() => { return(time); });
        }
Ejemplo n.º 7
0
 private void Reset(object o)
 {
     if (o is ITimeMeasureConsumer)
     {
         ITimeMeasureConsumer tc = o as ITimeMeasureConsumer;
         if (dictionary.ContainsKey(tc))
         {
             tc.Time = dictionary[tc];
         }
     }
     if (o is IChildrenObject)
     {
         IChildrenObject     co = o as IChildrenObject;
         IAssociatedObject[] ch = co.Children;
         foreach (object ob in ch)
         {
             Reset(ob);
         }
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Sets time provider to data consumer and all dependent objects
 /// </summary>
 /// <param name="consumer">Data consumer</param>
 /// <param name="provider">Data provider</param>
 /// <param name="dictionary">Backup dictionary</param>
 private static void SetTimeProvider(IDataConsumer consumer,
                                     ITimeMeasureProvider provider, IDictionary <ITimeMeasureConsumer, IMeasurement> dictionary)
 {
     if (consumer is ITimeMeasureConsumer)
     {
         ITimeMeasureConsumer tc = consumer as ITimeMeasureConsumer;
         if (dictionary.ContainsKey(tc))
         {
             if (tc.Time != provider.TimeMeasurement)
             {
                 dictionary[tc] = tc.Time;
                 tc.Time        = provider.TimeMeasurement;
             }
         }
         else
         {
             dictionary[tc] = tc.Time;
             tc.Time        = provider.TimeMeasurement;
         }
     }
     // IDataRuntime dr = consumer.CreateRuntime();
 }
Ejemplo n.º 9
0
 private void Reset(object o)
 {
     if (o is ITimeMeasureConsumer)
     {
         ITimeMeasureConsumer tc = o as ITimeMeasureConsumer;
         IMeasurement         m  = tc.Time;
         if (m != null)
         {
             if (dictionary.ContainsKey(tc))
             {
                 (tc.Time as TimeMeasurement).TimeParameter = dictionary[tc].Parameter;
             }
         }
     }
     if (o is IChildrenObject)
     {
         IChildrenObject     co = o as IChildrenObject;
         IAssociatedObject[] ch = co.Children;
         foreach (object ob in ch)
         {
             Reset(ob);
         }
     }
 }
 /// <summary>
 /// Gets the time
 /// </summary>
 /// <param name="Consumer">Consumer</param>
 /// <returns>Time</returns>
 public static double GetTime(this ITimeMeasureConsumer consumer)
 {
     return((double)consumer.Time.Parameter());
 }