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 ExecutionEngine(IProcedureFunctionChart pfc, ExecutionEngineConfiguration eec) { m_executionEngineConfiguration = eec; m_model = pfc.Model; m_stepStateMachines = new Dictionary <IPfcStepNode, StepStateMachine>(); m_transitionStateMachines = new Dictionary <IPfcTransitionNode, TransitionStateMachine>(); foreach (IPfcStepNode pfcStepNode in pfc.Steps) { StepStateMachine ssm = new StepStateMachine(pfcStepNode); ssm.StructureLocked = m_executionEngineConfiguration.StructureLockedDuringRun; m_stepStateMachines.Add(pfcStepNode, ssm); ssm.MyStep = pfcStepNode; ((PfcStep)pfcStepNode).MyStepStateMachine = ssm; } foreach (IPfcTransitionNode pfcTransNode in pfc.Transitions) { TransitionStateMachine tsm = new TransitionStateMachine(pfcTransNode); tsm.ScanningPeriod = m_executionEngineConfiguration.ScanningPeriod; m_transitionStateMachines.Add(pfcTransNode, tsm); tsm.MyTransition = pfcTransNode; ((PfcTransition)pfcTransNode).MyTransitionStateMachine = tsm; } StepStateMachineEvent ssme = new StepStateMachineEvent(anSSM_StepStateChanged); foreach (IPfcStepNode step in pfc.Steps) { step.MyStepStateMachine.StepStateChanged += ssme; foreach (IPfcTransitionNode transNode in step.SuccessorNodes) { step.MyStepStateMachine.SuccessorStateMachines.Add(transNode.MyTransitionStateMachine); } if (step.MyStepStateMachine.SuccessorStateMachines.Count == 0) { string message = $"Step {step.Name} in PFC {step.Parent.Name} has no successor transition. A PFC must end with a termination transition. (Did you acquire an Execution Engine while the Pfc was still under construction?)"; throw new ApplicationException(message); } } TransitionStateMachineEvent tsme = new TransitionStateMachineEvent(aTSM_TransitionStateChanged); foreach (IPfcTransitionNode trans in pfc.Transitions) { TransitionStateMachine thisTsm = m_transitionStateMachines[trans]; thisTsm.TransitionStateChanged += tsme; foreach (IPfcStepNode stepNode in trans.SuccessorNodes) { thisTsm.SuccessorStateMachines.Add(m_stepStateMachines[stepNode]); } foreach (IPfcStepNode stepNode in trans.PredecessorNodes) { thisTsm.PredecessorStateMachines.Add(m_stepStateMachines[stepNode]); } } List <IPfcStepNode> startSteps = pfc.GetStartSteps(); _Debug.Assert(startSteps.Count == 1); m_startStep = m_stepStateMachines[startSteps[0]]; }
void anSSM_StepStateChanged(StepStateMachine ssm, object userData) { StepStateChanged?.Invoke(ssm, userData); }
private void RunSuccessor(StepStateMachine ssm, IDictionary graphContext) { m_myTransition.Model.Executive.RequestEvent(new ExecEventReceiver(_RunSuccessor), m_myTransition.Model.Executive.Now, 0.0, new object[] { ssm, graphContext }, ExecEventType.Detachable); }
public abstract void Run(PfcExecutionContext parameters, StepStateMachine ssm);
public abstract void GetPermissionToStart(PfcExecutionContext myPfcec, StepStateMachine ssm);