Пример #1
0
        /// <summary>
        /// Converts the flow matrix to a sequence of timed dataflows
        /// </summary>
        /// <returns>sequence of timed dataflows</returns>
        public IEnumerable <ITimedFlow> GetTimedFlows()
        {
            var result  = new List <ITimedFlow>();
            var tempMap = new Dictionary <int, ITimedFlow>();

            for (int cstep = 0; cstep < _graphs.Count; cstep++)
            {
                var g     = _graphs[cstep];
                var flows = g.ToFlow().Flows;
                foreach (var f in flows)
                {
                    var sf = f as SignalFlow;
                    var vf = f as ValueFlow;
                    if (sf != null)
                    {
                        ITimedFlow tf;
                        if (sf.Source.IsTemporary())
                        {
                            tf = tempMap[sf.Source.GetTemporaryIndex()];
                            var tsf = tf as TimedSignalFlow;
                            var tvf = tf as TimedValueFlow;
                            if (tsf != null)
                            {
                                tf = new TimedSignalFlow(tsf.Source, sf.Target, tf.Time, 0);
                            }
                            else
                            {
                                tf = new TimedValueFlow(tvf.Value, sf.Target, cstep);
                            }
                        }
                        else
                        {
                            tf = new TimedSignalFlow(sf.Source, sf.Target, cstep, 0);
                        }
                        if (f.Target.IsTemporary())
                        {
                            tempMap[f.Target.GetTemporaryIndex()] = tf;
                        }
                        else
                        {
                            var tsf = tf as TimedSignalFlow;
                            var tvf = tf as TimedValueFlow;
                            if (tsf != null)
                            {
                                tf = new TimedSignalFlow(tsf.Source, tf.Target, tf.Time, cstep - tf.Time);
                            }
                            else
                            {
                                tf = new TimedValueFlow(tvf.Value, tf.Target, cstep);
                            }
                            result.Add(tf);
                        }
                    }
                    else
                    {
                        var tf = new TimedValueFlow(vf.Value, f.Target, cstep);
                        if (f.Target.IsTemporary())
                        {
                            tempMap[f.Target.GetTemporaryIndex()] = tf;
                        }
                        else
                        {
                            result.Add(tf);
                        }
                    }
                }
            }
            return(result);
        }
Пример #2
0
 /// <summary>
 /// Converts the flow matrix to a sequence of timed dataflows
 /// </summary>
 /// <returns>sequence of timed dataflows</returns>
 public IEnumerable<ITimedFlow> GetTimedFlows()
 {
     var result = new List<ITimedFlow>();
     var tempMap = new Dictionary<int, ITimedFlow>();
     for (int cstep = 0; cstep < _graphs.Count; cstep++)
     {
         var g = _graphs[cstep];
         var flows = g.ToFlow().Flows;
         foreach (var f in flows)
         {
             var sf = f as SignalFlow;
             var vf = f as ValueFlow;
             if (sf != null)
             {
                 ITimedFlow tf;
                 if (sf.Source.IsTemporary())
                 {
                     tf = tempMap[sf.Source.GetTemporaryIndex()];
                     var tsf = tf as TimedSignalFlow;
                     var tvf = tf as TimedValueFlow;
                     if (tsf != null)
                         tf = new TimedSignalFlow(tsf.Source, sf.Target, tf.Time, 0);
                     else
                         tf = new TimedValueFlow(tvf.Value, sf.Target, cstep);
                 }
                 else
                 {
                     tf = new TimedSignalFlow(sf.Source, sf.Target, cstep, 0);
                 }
                 if (f.Target.IsTemporary())
                 {
                     tempMap[f.Target.GetTemporaryIndex()] = tf;
                 }
                 else
                 {
                     var tsf = tf as TimedSignalFlow;
                     var tvf = tf as TimedValueFlow;
                     if (tsf != null)
                         tf = new TimedSignalFlow(tsf.Source, tf.Target, tf.Time, cstep - tf.Time);
                     else
                         tf = new TimedValueFlow(tvf.Value, tf.Target, cstep);
                     result.Add(tf);
                 }
             }
             else
             {
                 var tf = new TimedValueFlow(vf.Value, f.Target, cstep);
                 if (f.Target.IsTemporary())
                 {
                     tempMap[f.Target.GetTemporaryIndex()] = tf;
                 }
                 else
                 {
                     result.Add(tf);
                 }
             }
         }
     }
     return result;
 }