Opc.Ua.Server.StateMachine.AddTransition C# (CSharp) Method

AddTransition() protected method

Called to process a transition that was found in the machine.
protected AddTransition ( ILocalNode source ) : void
source ILocalNode
return void
        protected virtual void AddTransition(ILocalNode source)
        {
            Transition transition = new Transition(source);

            // save the transition.
            m_transitions.Add(transition);
            
            // add the from state.
            ILocalNode fromState = NodeManager.GetTargetNode(source.NodeId, ReferenceTypes.FromState, false, true, null);
            
            if (fromState != null)
            {
                transition.FromState = m_states[fromState.BrowseName];
            }

            // add the to state.
            ILocalNode toState = NodeManager.GetTargetNode(source.NodeId, ReferenceTypes.ToState, false, true, null);
            
            if (fromState != null)
            {
                transition.ToState = m_states[toState.BrowseName];
            }

            // find all causes.
            foreach (ILocalNode cause in NodeManager.GetLocalNodes(source.NodeId, ReferenceTypes.HasCause, false, true))
            {
                MethodSource method = null;
 
                if (m_causes.TryGetValue(cause.BrowseName, out method))
                {
                    transition.Causes.Add(method);
                }
            }

            // find all effects.
            foreach (ILocalNode effect in NodeManager.GetLocalNodes(source.NodeId, ReferenceTypes.HasEffect, false, true))
            {
                transition.Effects.Add(effect.NodeId);
            }
        }
        #endregion