Пример #1
0
            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();
                    }
                }
            }
Пример #2
0
 private static bool DEFAULT_EXECUTABLE_EXPRESSION(IDictionary execContext, TransitionStateMachine tsm)
 {
     return(true);
 }
Пример #3
0
        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]];
        }
Пример #4
0
 void aTSM_TransitionStateChanged(TransitionStateMachine tsm, object userData)
 {
     TransitionStateChanged?.Invoke(tsm, userData);
 }