Beispiel #1
0
        /// <summary>
        /// Gets permission from the step to transition to run.
        /// </summary>
        /// <param name="myPfcec">My pfcec.</param>
        /// <param name="ssm">The StepStateMachine that will govern this run.</param>
        public virtual void GetPermissionToStart(PfcExecutionContext myPfcec, StepStateMachine ssm)
        {
            IExecutive exec = myPfcec.Model.Executive;

            Debug.Assert(exec.CurrentEventType == ExecEventType.Detachable);
            if (EarliestStart != null && EarliestStart > exec.Now)
            {
                exec.CurrentEventController.SuspendUntil(EarliestStart.Value);
            }

            m_precondition?.Invoke(myPfcec, ssm);
        }
Beispiel #2
0
        protected void GetPermissionToStart(PfcExecutionContext myPfcec, StepStateMachine ssm)
        {
            PfcExecutionContext root = myPfcec;
            int ascents = m_rootHeight;

            while (ascents > 0)
            {
                root = (PfcExecutionContext)myPfcec.Parent.Payload;
                ascents--;
            }

            Exchange exchange = null;

            if (m_myIndex == 0)
            {
                //Console.WriteLine(myPfcec.Name + " is creating an exchange and injecting it into pfcec " + root.Name + " under key " + m_sequenceKey);
                exchange = new Exchange(myPfcec.Model.Executive);
                root.Add(m_sequenceKey, exchange);
            }
            else
            {
                //Console.WriteLine(myPfcec.Name + " is looking for an exchange in pfcec " + root.Name + " under key " + m_sequenceKey);
                DictionaryChange dc = new DictionaryChange(myPfcec_EntryAdded);
                while (true)
                {
                    exchange = (Exchange)root[m_sequenceKey];
                    if (exchange == null)
                    {
                        root.EntryAdded += dc;
                        m_idec           = myPfcec.Model.Executive.CurrentEventController;
                        m_idec.Suspend();
                    }
                    else
                    {
                        root.EntryAdded -= dc;
                        break;
                    }
                }
                exchange.Take(m_myKey, true); // Only indices 1,2, ... take (and wait?). Index 0 only posts.
                //Console.WriteLine(myPfcec.Name + " got the key I was looking for!");
            }
            Guid nextGuysKey = GuidOps.Increment(m_myKey);

            exchange.Post(nextGuysKey, nextGuysKey, false);
            //Console.WriteLine(myPfcec.Name + " posted the key the next guy is looking for!");
        }
Beispiel #3
0
        public override void Run(PfcExecutionContext pfcec, StepStateMachine ssm)
        {
            IExecutive exec = Model.Executive;

            exec.CurrentEventController.SuspendUntil(exec.Now + m_tsd.GetNext());
        }
Beispiel #4
0
 public override void GetPermissionToStart(PfcExecutionContext myPfcec, StepStateMachine ssm)
 {
 }