/// <summary>
        /// Replaces the generic node with a node specific to the model.
        /// </summary>
        protected override NodeState AddBehaviourToPredefinedNode(ISystemContext context, NodeState predefinedNode)
        {
            BaseObjectState passiveNode = predefinedNode as BaseObjectState;

            if (passiveNode == null)
            {
                return(predefinedNode);
            }

            NodeId typeId = passiveNode.TypeDefinitionId;

            if (!IsNodeIdInNamespace(typeId) || typeId.IdType != IdType.Numeric)
            {
                return(predefinedNode);
            }

            switch ((uint)typeId.Identifier)
            {
            case ObjectTypes.TestSystemConditionType:
            {
                if (passiveNode is TestSystemConditionState)
                {
                    break;
                }

                TestSystemConditionState activeNode = new TestSystemConditionState(passiveNode.Parent);
                activeNode.Create(context, passiveNode);

                if (passiveNode.Parent != null)
                {
                    passiveNode.Parent.ReplaceChild(context, activeNode);
                }

                return(activeNode);
            }

            case ObjectTypes.ScalarValueObjectType:
            {
                if (passiveNode is ScalarValueObjectState)
                {
                    break;
                }

                ScalarValueObjectState activeNode = new ScalarValueObjectState(passiveNode.Parent);
                activeNode.Create(context, passiveNode);

                if (passiveNode.Parent != null)
                {
                    passiveNode.Parent.ReplaceChild(context, activeNode);
                }

                return(activeNode);
            }

            case ObjectTypes.AnalogScalarValueObjectType:
            {
                if (passiveNode is AnalogScalarValueObjectState)
                {
                    break;
                }

                AnalogScalarValueObjectState activeNode = new AnalogScalarValueObjectState(passiveNode.Parent);
                activeNode.Create(context, passiveNode);

                if (passiveNode.Parent != null)
                {
                    passiveNode.Parent.ReplaceChild(context, activeNode);
                }

                return(activeNode);
            }

            case ObjectTypes.ArrayValueObjectType:
            {
                if (passiveNode is ArrayValueObjectState)
                {
                    break;
                }

                ArrayValueObjectState activeNode = new ArrayValueObjectState(passiveNode.Parent);
                activeNode.Create(context, passiveNode);

                if (passiveNode.Parent != null)
                {
                    passiveNode.Parent.ReplaceChild(context, activeNode);
                }

                return(activeNode);
            }

            case ObjectTypes.AnalogArrayValueObjectType:
            {
                if (passiveNode is AnalogArrayValueObjectState)
                {
                    break;
                }

                AnalogArrayValueObjectState activeNode = new AnalogArrayValueObjectState(passiveNode.Parent);
                activeNode.Create(context, passiveNode);

                if (passiveNode.Parent != null)
                {
                    passiveNode.Parent.ReplaceChild(context, activeNode);
                }

                return(activeNode);
            }

            case ObjectTypes.UserScalarValueObjectType:
            {
                if (passiveNode is UserScalarValueObjectState)
                {
                    break;
                }

                UserScalarValueObjectState activeNode = new UserScalarValueObjectState(passiveNode.Parent);
                activeNode.Create(context, passiveNode);

                if (passiveNode.Parent != null)
                {
                    passiveNode.Parent.ReplaceChild(context, activeNode);
                }

                return(activeNode);
            }

            case ObjectTypes.UserArrayValueObjectType:
            {
                if (passiveNode is UserArrayValueObjectState)
                {
                    break;
                }

                UserArrayValueObjectState activeNode = new UserArrayValueObjectState(passiveNode.Parent);
                activeNode.Create(context, passiveNode);

                if (passiveNode.Parent != null)
                {
                    passiveNode.Parent.ReplaceChild(context, activeNode);
                }

                return(activeNode);
            }

            case ObjectTypes.MethodTestType:
            {
                if (passiveNode is MethodTestState)
                {
                    break;
                }

                MethodTestState activeNode = new MethodTestState(passiveNode.Parent);
                activeNode.Create(context, passiveNode);

                if (passiveNode.Parent != null)
                {
                    passiveNode.Parent.ReplaceChild(context, activeNode);
                }

                return(activeNode);
            }
            }

            return(predefinedNode);
        }
コード例 #2
0
        /// <summary>
        /// Replaces the generic node with a node specific to the model.
        /// </summary>
        protected override NodeState AddBehaviourToPredefinedNode(ISystemContext context, NodeState predefinedNode)
        {
            BaseObjectState passiveNode = predefinedNode as BaseObjectState;

            if (passiveNode == null)
            {
                return predefinedNode;
            }

            NodeId typeId = passiveNode.TypeDefinitionId;

            if (!IsNodeIdInNamespace(typeId) || typeId.IdType != IdType.Numeric)
            {
                return predefinedNode;
            }

            switch ((uint)typeId.Identifier)
            {
                case ObjectTypes.TestSystemConditionType:
                {
                    if (passiveNode is TestSystemConditionState)
                    {
                        break;
                    }

                    TestSystemConditionState activeNode = new TestSystemConditionState(passiveNode.Parent);
                    activeNode.Create(context, passiveNode);

                    if (passiveNode.Parent != null)
                    {
                        passiveNode.Parent.ReplaceChild(context, activeNode);
                    }

                    return activeNode;
                }

                case ObjectTypes.ScalarValueObjectType:
                {
                    if (passiveNode is ScalarValueObjectState)
                    {
                        break;
                    }

                    ScalarValueObjectState activeNode = new ScalarValueObjectState(passiveNode.Parent);
                    activeNode.Create(context, passiveNode);

                    if (passiveNode.Parent != null)
                    {
                        passiveNode.Parent.ReplaceChild(context, activeNode);
                    }

                    return activeNode;
                }

                case ObjectTypes.AnalogScalarValueObjectType:
                {
                    if (passiveNode is AnalogScalarValueObjectState)
                    {
                        break;
                    }

                    AnalogScalarValueObjectState activeNode = new AnalogScalarValueObjectState(passiveNode.Parent);
                    activeNode.Create(context, passiveNode);

                    if (passiveNode.Parent != null)
                    {
                        passiveNode.Parent.ReplaceChild(context, activeNode);
                    }

                    return activeNode;
                }

                case ObjectTypes.ArrayValueObjectType:
                {
                    if (passiveNode is ArrayValueObjectState)
                    {
                        break;
                    }

                    ArrayValueObjectState activeNode = new ArrayValueObjectState(passiveNode.Parent);
                    activeNode.Create(context, passiveNode);

                    if (passiveNode.Parent != null)
                    {
                        passiveNode.Parent.ReplaceChild(context, activeNode);
                    }

                    return activeNode;
                }

                case ObjectTypes.AnalogArrayValueObjectType:
                {
                    if (passiveNode is AnalogArrayValueObjectState)
                    {
                        break;
                    }

                    AnalogArrayValueObjectState activeNode = new AnalogArrayValueObjectState(passiveNode.Parent);
                    activeNode.Create(context, passiveNode);

                    if (passiveNode.Parent != null)
                    {
                        passiveNode.Parent.ReplaceChild(context, activeNode);
                    }

                    return activeNode;
                }

                case ObjectTypes.UserScalarValueObjectType:
                {
                    if (passiveNode is UserScalarValueObjectState)
                    {
                        break;
                    }

                    UserScalarValueObjectState activeNode = new UserScalarValueObjectState(passiveNode.Parent);
                    activeNode.Create(context, passiveNode);

                    if (passiveNode.Parent != null)
                    {
                        passiveNode.Parent.ReplaceChild(context, activeNode);
                    }

                    return activeNode;
                }

                case ObjectTypes.UserArrayValueObjectType:
                {
                    if (passiveNode is UserArrayValueObjectState)
                    {
                        break;
                    }

                    UserArrayValueObjectState activeNode = new UserArrayValueObjectState(passiveNode.Parent);
                    activeNode.Create(context, passiveNode);

                    if (passiveNode.Parent != null)
                    {
                        passiveNode.Parent.ReplaceChild(context, activeNode);
                    }

                    return activeNode;
                }

                case ObjectTypes.MethodTestType:
                {
                    if (passiveNode is MethodTestState)
                    {
                        break;
                    }

                    MethodTestState activeNode = new MethodTestState(passiveNode.Parent);
                    activeNode.Create(context, passiveNode);

                    if (passiveNode.Parent != null)
                    {
                        passiveNode.Parent.ReplaceChild(context, activeNode);
                    }

                    return activeNode;
                }
            }

            return predefinedNode;
        }