public void Start(PfcExecutionContext parentPfcec) { Debug.Assert(!parentPfcec.IsStepCentric); // Must be called with parent. Debug.Assert(parentPfcec.PFC.Equals(MyStep.Parent)); #region Create a context under the parent PFCEC to run this iteration of this step. SsmData ssmData = GetSsmData(parentPfcec); // This will create a new SSMData element. if (ssmData.ExecutionInstanceCount == 0) { ssmData.InitializeExecutionInstanceUid(parentPfcec.Guid, MyStep.Guid); } Guid myExecutionInstanceGuid = ssmData.GetNextExecutionInstanceUid(); PfcExecutionContext myPfcec = new PfcExecutionContext(m_myStep, m_myStep.Name, null, myExecutionInstanceGuid, parentPfcec); myPfcec.InstanceCount = ssmData.ExecutionInstanceCount - 1; ssmData.ActiveStepInstanceEc = myPfcec; if (s_diagnostics) { Console.WriteLine("PFCEC " + myPfcec.Name + "(instance " + myPfcec.InstanceCount + ") created."); } #endregion if (s_diagnostics) { Console.WriteLine("Starting step " + m_myStep.Name + " with ec " + myPfcec.Name + "."); } GetStartPermission(myPfcec); // Once we have permission to start (based on state), we will create a new execContext for this execution. DoTransition(StepState.Running, myPfcec); }
private void EvaluateCondition(IExecutive exec, object userData) { PfcExecutionContext pfcec = (PfcExecutionContext)userData; TsmData tsmData = GetTsmData(pfcec); tsmData.NextExpressionEvaluation = 0L; if (tsmData.State == TransitionState.Active && ExecutableCondition(pfcec, this)) { PredecessorStateMachines.ForEach(delegate(StepStateMachine ssm) { if (ssm.GetState(pfcec) != StepState.Complete) { ssm.Stop(pfcec); } ssm.Reset(pfcec); }); // When the last predecessor goes to Idle, I will go to Inactive. Debug.Assert(AllPredsAreIdle(pfcec)); Debug.Assert(tsmData.State == TransitionState.Inactive); if (s_diagnostics) { Console.WriteLine("Done condition-scanning on transition " + m_myTransition.Name + " in EC " + pfcec.Name + "."); } SuccessorStateMachines.ForEach(delegate(StepStateMachine ssm) { RunSuccessor(ssm, pfcec); }); } else { // Either I'm NotBeingEvaluated, or the evaluation came out false. // NOTE: Must halt event stream when "NotBeingEvaluated". tsmData.NextExpressionEvaluation = exec.RequestEvent(new ExecEventReceiver(EvaluateCondition), exec.Now + m_scanningPeriod, 0.0, pfcec, ExecEventType.Synchronous); } }
private bool AnyPredIsQuiescent(PfcExecutionContext parentPfcec) { bool anyPredIsQuiescent = false; PredecessorStateMachines.ForEach(delegate(StepStateMachine ssm) { anyPredIsQuiescent |= ssm.IsInQuiescentState(parentPfcec); }); return(anyPredIsQuiescent); }
private void _RunSuccessor(IExecutive exec, object userData) { StepStateMachine ssm = ((object[])userData)[0] as StepStateMachine; PfcExecutionContext parentPfcec = ((object[])userData)[1] as PfcExecutionContext; Debug.Assert(!parentPfcec.IsStepCentric); ssm.Start(parentPfcec);// Must run ones' successor in the context of out parent, not the predecessor step. }
public TransitionState GetState(PfcExecutionContext pfcec) { if (pfcec.IsStepCentric) { pfcec = (PfcExecutionContext)pfcec.Parent; } return(GetTsmData(pfcec).State); }
private void DoTransition(StepState toState, PfcExecutionContext myPfcec) { SsmData ssmData = GetSsmData(myPfcec); StepState fromState = ssmData.State; if (s_transition_Matrix[(int)fromState, (int)toState]) { ssmData.State = toState; bool timePeriodContainer = myPfcec.TimePeriod is Scheduling.TimePeriodEnvelope; if (!timePeriodContainer) { if (fromState == StepState.Running && toState == StepState.Complete) { myPfcec.TimePeriod.EndTime = myPfcec.Model.Executive.Now; } } // Get permission from Step to run. if (fromState == StepState.Idle && toState == StepState.Running) { m_myStep.GetPermissionToStart(myPfcec, this); } //Console.WriteLine("{2} from {0} to {1}", fromState, toState, this.Name); if (!timePeriodContainer) { if (fromState == StepState.Idle && toState == StepState.Running) { myPfcec.TimePeriod.StartTime = myPfcec.Model.Executive.Now; } } if (fromState == StepState.Complete && toState == StepState.Idle) { ssmData.ActiveStepInstanceEc = null; } StateChangeCompleted(myPfcec); if (fromState == StepState.Idle && toState == StepState.Running) { DoRunning(myPfcec); } StepState followOnState = s_follow_On_States[(int)toState]; if (followOnState != toState) { DoTransition(followOnState, myPfcec); } } else { string msg = string.Format("Illegal attempt to transition from {0} to {1} in step state machine for {2}.", fromState, toState, Name); throw new ApplicationException(msg); } }
private TsmData GetTsmData(PfcExecutionContext parentPfcec) { Debug.Assert(!parentPfcec.IsStepCentric); // State is stored in the parent of the trans, a PFC. if (!parentPfcec.Contains(this)) { parentPfcec.Add(this, new TsmData()); } return((TsmData)parentPfcec[this]); }
private void HaltConditionScanning(PfcExecutionContext pfcec) { TsmData tsmData = GetTsmData(pfcec); if (tsmData.NextExpressionEvaluation != 0L) { m_myTransition.Model.Executive.UnRequestEvent(tsmData.NextExpressionEvaluation); tsmData.NextExpressionEvaluation = 0L; } }
internal void PredecessorStateChange(PfcExecutionContext pfcec) { if (pfcec.IsStepCentric) { pfcec = (PfcExecutionContext)pfcec.Parent; } else { Debugger.Break(); // Only step-centrics should call this. } switch (GetState(pfcec)) { case TransitionState.Active: if (AnyPredIsQuiescent(pfcec)) { SetState(TransitionState.NotBeingEvaluated, pfcec); HaltConditionScanning(pfcec); } else if (AllPredsAreIdle(pfcec)) { SetState(TransitionState.Inactive, pfcec); HaltConditionScanning(pfcec); } break; case TransitionState.Inactive: if (AllPredsAreNotIdle(pfcec)) { if (NoPredIsQuiescent(pfcec)) { SetState(TransitionState.Active, pfcec); StartConditionScanning(pfcec); } else { SetState(TransitionState.NotBeingEvaluated, pfcec); HaltConditionScanning(pfcec); } } break; case TransitionState.NotBeingEvaluated: if (NoPredIsQuiescent(pfcec)) { SetState(TransitionState.Active, pfcec); StartConditionScanning(pfcec); } break; default: break; } }
public PfcStepJoiner(PfcExecutionContext rootStepPfcec, IProcedureFunctionChart[] childPfCs) { Debug.Assert(rootStepPfcec.IsStepCentric); m_rootStepEc = rootStepPfcec; m_model = m_rootStepEc.Model; m_idec = null; m_onTransitionStateChanged = new TransitionStateMachineEvent(OnTransitionStateChanged); m_pendingActions = new List <IProcedureFunctionChart>(childPfCs); m_pendingActions.ForEach(delegate(IProcedureFunctionChart kid) { kid.GetFinishTransition().MyTransitionStateMachine.TransitionStateChanged += m_onTransitionStateChanged; }); }
private void StartConditionScanning(PfcExecutionContext pfcec) { if (s_diagnostics) { Console.WriteLine("Starting condition-scanning on transition " + m_myTransition.Name + " in EC " + pfcec.Name + "."); } HaltConditionScanning(pfcec); IExecutive exec = m_myTransition.Model.Executive; TsmData tsmData = GetTsmData(pfcec); tsmData.NextExpressionEvaluation = exec.RequestEvent(new ExecEventReceiver(EvaluateCondition), exec.Now + m_scanningPeriod, 0.0, pfcec, ExecEventType.Synchronous); }
public void Reset(PfcExecutionContext parentPfcec) { Debug.Assert(!parentPfcec.IsStepCentric); // Must be called with parent. Debug.Assert(parentPfcec.PFC.Equals(MyStep.Parent)); PfcExecutionContext pfcec = GetActiveInstanceExecutionContext(parentPfcec); if (s_diagnostics) { Console.WriteLine("Resetting step " + m_myStep.Name + " with ec " + pfcec.Name + "."); } DoTransition(StepState.Idle, pfcec); }
private void OnTransitionStateChanged(TransitionStateMachine tsm, object userData) { PfcExecutionContext completedStepsParentPfcec = (PfcExecutionContext)userData; if (completedStepsParentPfcec.Parent.Payload.Equals(m_rootStepEc) && tsm.GetState(completedStepsParentPfcec) == TransitionState.Inactive) { tsm.TransitionStateChanged -= m_onTransitionStateChanged; m_pendingActions.Remove(tsm.MyTransition.Parent); if (m_pendingActions.Count == 0) { m_idec.Resume(); } } }
private SsmData GetSsmData(PfcExecutionContext pfcec) { if (MyStep.Equals(pfcec.Step)) { pfcec = (PfcExecutionContext)pfcec.Parent; } if (!pfcec.Contains(this)) { SsmData retval = new SsmData(); pfcec.Add(this, retval); } return((SsmData)pfcec[this]); }
private void StateChangeCompleted(PfcExecutionContext pfcec) { if (StepStateChanged != null) { StepStateChanged(this, pfcec); } SuccessorStateMachines.ForEach(delegate(TransitionStateMachine tsm) { tsm.PredecessorStateChange(pfcec); }); SsmData ssmData = GetSsmData(pfcec); if ((ssmData.State == StepState.Idle) && (ssmData.QueueIdec.Count > 0)) { ssmData.QueueIdec.Dequeue().Resume(); } }
private void DoRunning(PfcExecutionContext pfcec) { if (s_diagnostics) { string msg = "Starting to run {0} action{1} under step {2} with ec {3}."; string nKids = "1"; string plural = ""; string stepName = m_myStep.Name; string ecName = pfcec.Name; int nActions = (m_myStep.Actions?.Count ?? 0) + m_myStep.LeafLevelAction.GetInvocationList().Length; nKids = nActions.ToString(); plural = nActions == 1 ? "" : "s"; if (nActions == 0) { msg = "There are no actions to run under step {2} with ec {3}."; } Console.WriteLine(msg, nKids, plural, stepName, ecName); } IModel model = m_myStep.Model; SsmData ssmData = GetSsmData(pfcec); Debug.Assert(model.Executive.CurrentEventType == ExecEventType.Detachable); if (model != null && model.Executive != null) { if (m_myStep.Actions != null && m_myStep.Actions.Count > 0) { IProcedureFunctionChart[] kids; PfcExecutionContext[] kidContexts; CreateChildContexts(ssmData.ActiveStepInstanceEc, out kids, out kidContexts); foreach (IProcedureFunctionChart action in m_myStep.Actions.Values) { for (int i = 0; i < kidContexts.Length; i++) { model.Executive.RequestEvent(new ExecEventReceiver(kids[i].Run), model.Executive.Now, 0.0, kidContexts[i], ExecEventType.Detachable); } } new PfcStepJoiner(ssmData.ActiveStepInstanceEc, kids).RunAndWait(); } else { //PfcExecutionContext iterPfc = CreateIterationContext(pfcec); m_myStep.LeafLevelAction(pfcec, this); } } DoTransition(StepState.Complete, pfcec); }
public void TestCreationOfABazillionEECs() { Assert.Fail(); DateTime start = DateTime.Now; ExecutionEngineConfiguration eec = new ExecutionEngineConfiguration(); IProcedureFunctionChart pfc = CreatePfc(new Model(), "RootPfc", 15.0, eec); PfcExecutionContext pfcec = new PfcExecutionContext(pfc, "MyPfcExecutionContext_0", "", Guid.NewGuid(), null); while (nECs < nSteps) { Propagate(pfc, pfcec); } DateTime finish = DateTime.Now; Console.WriteLine("The test took " + ((TimeSpan)(finish - start)) + " to create " + nECs + " execution contexts."); }
private void SetState(TransitionState transitionState, PfcExecutionContext parentPfcec) { if (SuccessorStateMachines.Count == 0 && transitionState == TransitionState.Inactive) { ((ProcedureFunctionChart)m_myTransition.Parent).FirePfcCompleting(parentPfcec); } Debug.Assert(!parentPfcec.IsStepCentric); // State is stored in the parent of the trans, a PFC. TsmData tsmData = GetTsmData(parentPfcec); if (tsmData.State != transitionState) { tsmData.State = transitionState; if (TransitionStateChanged != null) { TransitionStateChanged(this, parentPfcec); } } }
internal void GetStartPermission(PfcExecutionContext pfcec) { IDetachableEventController currentEventController = m_myStep.Model.Executive.CurrentEventController; SsmData ssmData = GetSsmData(pfcec); if (!ssmData.State.Equals(StepState.Idle)) { ssmData.QueueIdec.Enqueue(currentEventController); if (s_diagnostics) { Console.WriteLine(m_myStep.Model.Executive.Now + " : suspending awaiting start of " + m_myStep.Name + " ..."); } currentEventController.Suspend(); if (s_diagnostics) { Console.WriteLine(m_myStep.Model.Executive.Now + " : resuming the starting of " + m_myStep.Name + " ..."); } } }
private void Propagate(IProcedureFunctionChart pfc, PfcExecutionContext pfcec) { List <PfcExecutionContext> readyToProcreate = new List <PfcExecutionContext>(); foreach (PfcExecutionContext node in pfcec.DescendantNodesDepthFirst(true)) { if (node.Children.Count() == 0) { readyToProcreate.Add(node); } } foreach (PfcExecutionContext kid in readyToProcreate) { for (int i = 1; i < nAvgKids && nECs < nSteps; i++) { PfcExecutionContext kidEC = new PfcExecutionContext(pfc, "MyPfcExecutionContext_" + (nECs++), "", Guid.NewGuid(), pfcec); } } }
/// <summary> /// Creates pfc execution contexts, one per action under the step that is currently running. Each /// is given an instance count of zero, as a step can run its action only once, currently. /// </summary> /// <param name="parentContext">The parent context, that of the step that is currently running.</param> /// <param name="kids">The procedure function charts that live in the actions under the step that is currently running.</param> /// <param name="kidContexts">The pfc execution contexts that will correspond to the running of each of the child PFCs.</param> protected virtual void CreateChildContexts(PfcExecutionContext parentContext, out IProcedureFunctionChart[] kids, out PfcExecutionContext[] kidContexts) { int kidCount = MyStep.Actions.Count; kids = new ProcedureFunctionChart[kidCount]; kidContexts = new PfcExecutionContext[kidCount]; int i = 0; foreach (KeyValuePair <string, IProcedureFunctionChart> kvp in MyStep.Actions) { IProcedureFunctionChart kid = kvp.Value; kids[i] = kid; Guid kidGuid = GuidOps.XOR(parentContext.Guid, kid.Guid); while (parentContext.Contains(kidGuid)) { kidGuid = GuidOps.Increment(kidGuid); } kidContexts[i] = new PfcExecutionContext(kid, kvp.Key, null, kidGuid, parentContext); kidContexts[i].InstanceCount = 0; i++; } }
public void TestSmallLoopbackHierarchical() { DateTime start = DateTime.Now; Model model = new Model("MyTestModel"); ExecutionEngineConfiguration eec = new ExecutionEngineConfiguration(); eec.ScanningPeriod = TimeSpan.FromSeconds(60.0); IProcedureFunctionChart pfc = CreatePfc(model, "RootPfc", 15.0, eec); IProcedureFunctionChart pfcChild1 = CreatePfc(model, "Step1Child", 15.0, eec); ((PfcStep)pfc.Nodes["RootPfc" + "Step1"]).AddAction("Alice", pfcChild1); IProcedureFunctionChart pfcGrandChild1 = CreatePfc(model, "Step1GrandChild", 15.0, eec); ((PfcStep)pfcChild1.Nodes["Step1Child" + "Step1"]).AddAction("Bob", pfcGrandChild1); PfcExecutionContext dictionary = new PfcExecutionContext(pfc, "MyPfcExecutionContext", "", Guid.NewGuid(), null); dictionary.Add("StringBuilder", new StringBuilder()); pfc.Model.Executive.RequestEvent(new ExecEventReceiver(pfc.Run), DateTime.MinValue, 0.0, dictionary, ExecEventType.Detachable); pfc.Model.Start(); int resultHashCode = dictionary["StringBuilder"].ToString().GetHashCode(); foreach (object obj in dictionary.Values) { if (obj is PfcExecutionContext) { Console.WriteLine(obj.ToString() + " contains " + ((PfcExecutionContext)obj).Values.Count + " members."); } } Console.WriteLine(dictionary["StringBuilder"]); DateTime finish = DateTime.Now; Console.WriteLine("The test took " + ((TimeSpan)(finish - start))); }
/// <summary> /// Gets a value indicating whether this step state machine is in a final state - Aborted, Stopped or Complete. /// </summary> /// <value> /// <c>true</c> if this instance is in final state; otherwise, <c>false</c>. /// </value> public bool IsInFinalState(PfcExecutionContext pfcec) { SsmData ssmData = GetSsmData(pfcec); return(ssmData.State == StepState.Complete || ssmData.State == StepState.Aborted || ssmData.State == StepState.Stopped); }
private void TestStateMachine_DoTransition(StepState fromState, StepState toState, PfcExecutionContext myPfcec) { switch (fromState) { case StepState.Idle: switch (toState) { case StepState.Running: break; default: break; } break; case StepState.Running: switch (toState) { case StepState.Complete: break; case StepState.Aborting: break; case StepState.Stopping: break; case StepState.Pausing: break; case StepState.Holding: break; default: break; } break; case StepState.Complete: switch (toState) { case StepState.Idle: break; default: break; } break; case StepState.Aborting: switch (toState) { case StepState.Aborted: break; default: break; } break; case StepState.Aborted: switch (toState) { case StepState.Idle: break; default: break; } break; case StepState.Stopping: switch (toState) { case StepState.Stopped: break; default: break; } break; case StepState.Stopped: switch (toState) { case StepState.Idle: break; default: break; } break; case StepState.Pausing: switch (toState) { case StepState.Paused: break; default: break; } break; case StepState.Paused: switch (toState) { case StepState.Running: break; default: break; } break; case StepState.Holding: switch (toState) { case StepState.Held: break; default: break; } break; case StepState.Held: switch (toState) { case StepState.Restarting: break; default: break; } break; case StepState.Restarting: switch (toState) { case StepState.Running: break; default: break; } break; default: break; } }
private IProcedureFunctionChart CreatePfc(IModel model, string pfcName, double minutesPerTask, ExecutionEngineConfiguration eec) { // Start // | // +T1 ---- // | | | // ------- | // | | // Step1 | // | | // +T2 | // | | // Step2 | // | | // ------- | // T3+ +T4 | // | |--- // Finish // | // T5+ ProcedureFunctionChart pfc = new ProcedureFunctionChart(model, pfcName); pfc.ExecutionEngineConfiguration = eec; pfc.CreateStep(pfcName + "Start", "", Guid.NewGuid()); pfc.CreateStep(pfcName + "Step1", "", Guid.NewGuid()); pfc.CreateStep(pfcName + "Step2", "", Guid.NewGuid()); pfc.CreateStep(pfcName + "Finish", "", Guid.NewGuid()); pfc.CreateTransition(pfcName + "T1", "", Guid.NewGuid()); pfc.CreateTransition(pfcName + "T2", "", Guid.NewGuid()); pfc.CreateTransition(pfcName + "T3", "", Guid.NewGuid()); pfc.CreateTransition(pfcName + "T4", "", Guid.NewGuid()); pfc.CreateTransition(pfcName + "T5", "", Guid.NewGuid()); pfc.Bind(pfc.Nodes[pfcName + "Start"], pfc.Nodes[pfcName + "T1"]); pfc.Bind(pfc.Nodes[pfcName + "T1"], pfc.Nodes[pfcName + "Step1"]); pfc.Bind(pfc.Nodes[pfcName + "Step1"], pfc.Nodes[pfcName + "T2"]); pfc.Bind(pfc.Nodes[pfcName + "T2"], pfc.Nodes[pfcName + "Step2"]); pfc.Bind(pfc.Nodes[pfcName + "Step2"], pfc.Nodes[pfcName + "T3"]); pfc.Bind(pfc.Nodes[pfcName + "Step2"], pfc.Nodes[pfcName + "T4"]); pfc.Bind(pfc.Nodes[pfcName + "T4"], pfc.Nodes[pfcName + "Step1"]); pfc.Bind(pfc.Nodes[pfcName + "T3"], pfc.Nodes[pfcName + "Finish"]); pfc.Bind(pfc.Nodes[pfcName + "Finish"], pfc.Nodes[pfcName + "T5"]); pfc.Steps.ForEach(delegate(IPfcStepNode psn) { psn.LeafLevelAction = new PfcAction(delegate(PfcExecutionContext pfcec, StepStateMachine ssm) { StringBuilder sb = (StringBuilder)pfcec.Root.Payload["StringBuilder"]; string stepName = pfc.Name + "." + psn.Name; IExecutive exec = psn.Model.Executive; sb.AppendLine(string.Format("{0} : {1} is running its intrinsic action.", exec.Now, stepName)); exec.CurrentEventController.SuspendUntil(exec.Now + TimeSpan.FromMinutes(minutesPerTask)); }); }); pfc.Transitions[pfcName + "T1"].ExpressionExecutable = new Highpoint.Sage.Graphs.PFC.Execution.ExecutableCondition( delegate(object userData, Highpoint.Sage.Graphs.PFC.Execution.TransitionStateMachine tsm) { PfcExecutionContext execContext = (PfcExecutionContext)userData; string countKey = pfc.Guid.ToString() + ".Count"; if (!execContext.Contains(countKey)) { execContext.Add(countKey, 1); } else { execContext[countKey] = 1; } return(DEFAULT_EXECUTABLE_EXPRESSION(execContext, tsm)); }); pfc.Transitions[pfcName + "T3"].ExpressionExecutable = new Highpoint.Sage.Graphs.PFC.Execution.ExecutableCondition( delegate(object userData, Highpoint.Sage.Graphs.PFC.Execution.TransitionStateMachine tsm) { PfcExecutionContext execContext = (PfcExecutionContext)userData; string countKey = pfc.Guid.ToString() + ".Count"; return(DEFAULT_EXECUTABLE_EXPRESSION(execContext, tsm) && (((int)execContext[countKey]) >= 5)); }); pfc.Transitions[pfcName + "T4"].ExpressionExecutable = new Highpoint.Sage.Graphs.PFC.Execution.ExecutableCondition( delegate(object userData, Highpoint.Sage.Graphs.PFC.Execution.TransitionStateMachine tsm) { PfcExecutionContext execContext = (PfcExecutionContext)userData; string countKey = pfc.Guid.ToString() + ".Count"; if ((DEFAULT_EXECUTABLE_EXPRESSION(execContext, tsm) && (((int)execContext[countKey]) < 5))) { execContext[countKey] = ((int)execContext[countKey]) + 1; return(true); } else { return(false); } }); pfc.UpdateStructure(); return(pfc); }
/// <summary> /// Gets a value indicating whether this step state machine is in a quiescent state - Held or Paused. /// </summary> /// <value> /// <c>true</c> if this instance is in quiescent state; otherwise, <c>false</c>. /// </value> public bool IsInQuiescentState(PfcExecutionContext pfcec) { SsmData ssmData = GetSsmData(pfcec); return(ssmData.State == StepState.Held || ssmData.State == StepState.Paused); }
public PfcExecutionContext(IPfcStepNode stepNode, string name, string description, Guid guid, PfcExecutionContext parent) : base(stepNode.Parent.Model, name, description, guid, parent) { if (s_diagnostics) { Console.WriteLine("Creating PfcEC \"" + name + "\" under PfcEC \"" + parent.Name + "\" For parent " + stepNode.Name + " and numbered " + guid); } m_pfc = stepNode.Parent; m_step = stepNode; if (stepNode.Actions.Count == 0) { m_timePeriod = new TimePeriod(name, GuidOps.XOR(guid, s_time_Period_Mask), TimeAdjustmentMode.InferDuration); m_timePeriod.Subject = this; ((TimePeriodEnvelope)parent.TimePeriod).AddTimePeriod(m_timePeriod); } else { m_timePeriod = new TimePeriodEnvelope(name, GuidOps.XOR(guid, s_time_Period_Mask)); m_timePeriod.Subject = this; ((TimePeriodEnvelope)parent.TimePeriod).AddTimePeriod(m_timePeriod); } m_timePeriod.ChangeEvent += new ObservableChangeHandler(m_timePeriod_ChangeEvent); }
public PfcExecutionContext(IProcedureFunctionChart pfc, string name, string description, Guid guid, PfcExecutionContext parent) : base(pfc.Model, name, description, guid, parent) { if (s_diagnostics) { string parentName = (parent == null ? "<null>" : parent.Name); Console.WriteLine("Creating PFCEC \"" + name + "\" under PFCEC \"" + parentName + "\" For parent " + pfc.Name + " and numbered " + guid); } m_pfc = pfc; m_step = null; m_timePeriod = new TimePeriodEnvelope(name, GuidOps.XOR(guid, s_time_Period_Mask)); m_timePeriod.Subject = this; if (parent != null) { ((TimePeriodEnvelope)parent.TimePeriod).AddTimePeriod(m_timePeriod); } m_timePeriod.ChangeEvent += new ObservableChangeHandler(m_timePeriod_ChangeEvent); }
private bool AllPredsAreNotIdle(PfcExecutionContext parentPfcec) { return(PredecessorStateMachines.TrueForAll(delegate(StepStateMachine ssm) { return ssm.GetState(parentPfcec) != StepState.Idle; })); }
private bool NoPredIsQuiescent(PfcExecutionContext parentPfcec) { return(PredecessorStateMachines.TrueForAll(delegate(StepStateMachine ssm) { return !ssm.IsInQuiescentState(parentPfcec); })); }