Beispiel #1
0
 private void AdvanceChannel(CbmData data)
 {
     data.ActiveChannel++;
     if (data.ActiveChannel == m_channels.Length)
     {
         data.ActiveChannel = 0;
     }
     data.Remaining = m_counts[data.ActiveChannel];
 }
Beispiel #2
0
        /// <summary>
        /// This is fired once at the beginning of this branch manager's being asked to review a set of edges,
        /// which happens immediately after a vertex is satisfied. After that, FireIfAppropriate(...) is called
        /// once for each outbound edge.
        /// </summary>
        /// <param name="graphContext">The graph context in which we are currently running.</param>
        public void Start(IDictionary graphContext)
        {
            CbmData data = (CbmData)graphContext[_cbmDataKey];

            if (data == null)
            {
                data = new CbmData();
                graphContext.Add(_cbmDataKey, data);
            }
            data.CurrentPriority = m_model.Executive.CurrentPriorityLevel;
            data.Now             = m_model.Executive.Now;
            if (data.Remaining == 0)
            {
                AdvanceChannel(data);
            }
            data.Remaining--;
            //Console.WriteLine("CountedBranchManager.Start: Active channel " + m_channels[data.ActiveChannel].ToString() + ", " + data.Remaining + " iterations.");
        }
Beispiel #3
0
        /// <summary>
        /// Schedules the presented edge to be fired if the edge's channel matches the currently active channel.
        /// </summary>
        /// <param name="graphContext">The graph context in which we are currently running.</param>
        /// <param name="edge">The edge being considered for execution.</param>
        public void FireIfAppropriate(IDictionary graphContext, Edge edge)
        {
            //System.Diagnostics.Debugger.Break();
            //Console.Write("Reviewing edge " + edge.Name + " for firing. Its channel marker is  " + edge.Channel.ToString());
            CbmData data = (CbmData)graphContext[_cbmDataKey];

            // If data is null, here, it is probably because the vertex did not call Start before firing branch edges.

            if (m_channels[data.ActiveChannel].Equals(edge.Channel))
            {
                //Console.WriteLine(" Scheduling it to fire.");
                m_model.Executive.RequestEvent(s_launchEdge, data.Now, data.CurrentPriority, new EdgeLaunchData(edge, graphContext));
            }
            else
            {
                //Console.WriteLine(" Nope, not this time.");
                // We're not going to fire it this time around.
            }
        }