Пример #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
 public TimeStampInfoIterator(TimeStampInfo timeStampInfo)
 {
     this.timeStampInfo = timeStampInfo;
     currentIindex      = 0;
     current            = timeStampInfo.ElementAt(0);
 }
Пример #3
0
        /// <summary>
        /// Используется для разделения информации о моменте времени составного типа
        /// на набор информаций об момоенте времени его составляющих
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public static List <TimeStampInfo> SplitTimestamps(ModellingType groupModellingType, TimeStampInfo info)
        {
            if (groupModellingType.Type is VHDL.type.RecordType)
            {
                List <TimeStampInfo> res = new List <TimeStampInfo>();
                foreach (var el in (groupModellingType.Type as VHDL.type.RecordType).Elements)
                {
                    foreach (string s in el.Identifiers)
                    {
                        res.Add(new TimeStampInfo());
                    }
                }

                foreach (var val in info)
                {
                    if (val.Value is CompositeValue)
                    {
                        int index = 0;
                        foreach (AbstractValue v in (val.Value as CompositeValue).GetChilds())
                        {
                            if ((res[index].Count == 0) || (res[index].LastValue != v))
                            {
                                res[index].info.Add(val.Key, v);
                            }
                            index++;
                        }
                    }
                    else
                    {
                        throw new ArgumentException("Invalid type", "info");
                    }
                }

                return(res);
            }

            if (groupModellingType.Type is VHDL.type.ArrayType)
            {
                List <TimeStampInfo> res = new List <TimeStampInfo>();
                for (int i = 0; i < groupModellingType.SizeOf; i++)
                {
                    res.Add(new TimeStampInfo());
                }

                foreach (var val in info)
                {
                    if (val.Value is CompositeValue)
                    {
                        int index = 0;
                        foreach (AbstractValue v in (val.Value as CompositeValue).GetChilds())
                        {
                            if ((res[index].Count == 0) || (res[index].LastValue != v))
                            {
                                res[index].info.Add(val.Key, v);
                            }
                            index++;
                        }
                    }
                    else
                    {
                        throw new ArgumentException("Invalid type", "info");
                    }
                }

                return(res);
            }

            throw new ArgumentException("Invalid type", "groupModellingType");
        }