예제 #1
0
        /// <summary>
        /// Используется для объединения дельтациклов в один объект TimeStampInfo
        /// </summary>
        /// <param name="elements"></param>
        /// <returns></returns>
        public static TimeStampInfo CombineTimestamps(ModellingType groupModellingType, IList <TimeStampInfo> elements)
        {
            TimeStampInfo res = new TimeStampInfo();

            List <AbstractValue>         values    = new List <AbstractValue>();
            List <TimeStampInfoIterator> iterators = new List <TimeStampInfoIterator>();
            int currentDeltaCycle = int.MaxValue;

            foreach (TimeStampInfo inf in elements)
            {
                if (inf != null)
                {
                    values.Add(inf[0]);
                    iterators.Add(new TimeStampInfoIterator(inf));
                    if (inf.ElementAt(0).Key < currentDeltaCycle)
                    {
                        currentDeltaCycle = inf.ElementAt(0).Key;
                    }
                }
            }

            bool IsDone = false;

            while (IsDone == false)
            {
                IsDone = true;
                foreach (TimeStampInfoIterator i in iterators)
                {
                    if (i.IsDone == false)
                    {
                        IsDone = false;
                        break;
                    }
                }

                if (IsDone == true)
                {
                    break;
                }

                currentDeltaCycle = int.MaxValue;

                foreach (TimeStampInfoIterator i in iterators)
                {
                    if ((i.IsDone == false) && (i.Current.Key < currentDeltaCycle))
                    {
                        currentDeltaCycle = i.Current.Key;
                    }
                }

                CompositeValue compValue = CompositeValue.CreateCompositeValue(groupModellingType, values);
                res.info.Add(currentDeltaCycle, compValue);

                for (int i = 0; i < iterators.Count; i++)
                {
                    TimeStampInfoIterator iter = iterators[i];
                    if (iter.Current.Key == currentDeltaCycle)
                    {
                        iter.MoveNext();
                        values[i] = iter.Current.Value;
                    }
                }
            }

            return(res);
        }
예제 #2
0
        /// <summary>
        /// Используется при выводе информации в табличном виде
        /// из набора объектов TimeStampInfo формируется словарь
        /// ключ - номер дельта цикла
        /// значение - список значений элементов
        /// </summary>
        /// <param name="elements"></param>
        /// <returns></returns>
        public static SortedDictionary <int, List <AbstractValue> > CombineTimestamps(IList <TimeStampInfo> elements)
        {
            SortedDictionary <int, List <AbstractValue> > res = new SortedDictionary <int, List <AbstractValue> >();

            List <AbstractValue>         values    = new List <AbstractValue>();
            List <TimeStampInfoIterator> iterators = new List <TimeStampInfoIterator>();
            int currentDeltaCycle = int.MaxValue;

            foreach (TimeStampInfo inf in elements)
            {
                values.Add(inf[0]);
                iterators.Add(new TimeStampInfoIterator(inf));
                if (inf.ElementAt(0).Key < currentDeltaCycle)
                {
                    currentDeltaCycle = inf.ElementAt(0).Key;
                }
            }

            bool IsDone = false;

            while (IsDone == false)
            {
                IsDone = true;
                foreach (TimeStampInfoIterator i in iterators)
                {
                    if (i.IsDone == false)
                    {
                        IsDone = false;
                        break;
                    }
                }

                if (IsDone == true)
                {
                    break;
                }

                currentDeltaCycle = int.MaxValue;

                List <AbstractValue> compValue = new List <AbstractValue>();
                compValue.AddRange(values);
                foreach (TimeStampInfoIterator i in iterators)
                {
                    if ((i.IsDone == false) && (i.Current.Key < currentDeltaCycle))
                    {
                        currentDeltaCycle = i.Current.Key;
                    }
                }


                res.Add(currentDeltaCycle, compValue);

                for (int i = 0; i < iterators.Count; i++)
                {
                    TimeStampInfoIterator iter = iterators[i];
                    if (iter.Current.Key == currentDeltaCycle)
                    {
                        iter.MoveNext();
                        values[i] = iter.Current.Value;
                    }
                }
            }

            return(res);
        }