示例#1
0
 /// <summary>
 /// Creates a new instance of a FilterDeclarationField.
 /// </summary>
 public FilterDeclarationField(FilterDeclarationField field)
 {
     Selected            = field.Selected;
     DisplayInList       = field.DisplayInList;
     FilterEnabled       = field.FilterEnabled;
     FilterOperator      = field.FilterOperator;
     FilterValue         = field.FilterValue;
     InstanceDeclaration = field.InstanceDeclaration;
 }
示例#2
0
        /// <summary>
        /// Creates a new instance of a FilterDeclaration.
        /// </summary>
        public FilterDeclaration(TypeDeclaration eventType, FilterDeclaration template)
        {
            EventTypeId = eventType.NodeId;
            Fields      = new List <FilterDeclarationField>( );

            foreach (InstanceDeclaration instanceDeclaration in eventType.Declarations)
            {
                if (instanceDeclaration.NodeClass == NodeClass.Method)
                {
                    continue;
                }

                if (NodeId.IsNull(instanceDeclaration.ModellingRule))
                {
                    continue;
                }

                FilterDeclarationField element = new FilterDeclarationField(instanceDeclaration);
                Fields.Add(element);

                // set reasonable defaults.
                if (template == null)
                {
                    if (instanceDeclaration.RootTypeId == Opc.Ua.ObjectTypeIds.BaseEventType && instanceDeclaration.BrowseName != Opc.Ua.BrowseNames.EventId)
                    {
                        element.DisplayInList = true;
                    }
                }

                // preserve filter settings.
                else
                {
                    foreach (FilterDeclarationField field in template.Fields)
                    {
                        if (field.InstanceDeclaration.BrowsePathDisplayText == element.InstanceDeclaration.BrowsePathDisplayText)
                        {
                            element.DisplayInList  = field.DisplayInList;
                            element.FilterEnabled  = field.FilterEnabled;
                            element.FilterOperator = field.FilterOperator;
                            element.FilterValue    = field.FilterValue;
                            break;
                        }
                    }
                }
            }
        }
示例#3
0
        /// <summary>
        /// Adds a simple field to the declaration.
        /// </summary>
        public void AddSimpleField(QualifiedName[] browseNames, NodeClass nodeClass, BuiltInType dataType, int valueRank, bool displayInList)
        {
            FilterDeclarationField field = new FilterDeclarationField( );

            field.DisplayInList                 = displayInList;
            field.InstanceDeclaration           = new InstanceDeclaration( );
            field.InstanceDeclaration.NodeClass = nodeClass;

            if (browseNames != null)
            {
                field.InstanceDeclaration.BrowseName = browseNames[browseNames.Length - 1];
                field.InstanceDeclaration.BrowsePath = new QualifiedNameCollection( );

                StringBuilder path = new StringBuilder( );

                for (int ii = 0; ii < browseNames.Length; ii++)
                {
                    if (path.Length > 0)
                    {
                        path.Append('/');
                    }

                    path.Append(browseNames[ii]);
                    field.InstanceDeclaration.BrowsePath.Add(browseNames[ii]);
                }

                field.InstanceDeclaration.BrowsePathDisplayText = path.ToString( );
            }

            field.InstanceDeclaration.BuiltInType         = dataType;
            field.InstanceDeclaration.DataType            = (uint)dataType;
            field.InstanceDeclaration.ValueRank           = valueRank;
            field.InstanceDeclaration.DataTypeDisplayText = dataType.ToString( );

            if (valueRank >= 0)
            {
                field.InstanceDeclaration.DataTypeDisplayText += "[]";
            }

            field.InstanceDeclaration.DisplayName = field.InstanceDeclaration.BrowseName.Name;
            field.InstanceDeclaration.DisplayPath = field.InstanceDeclaration.BrowsePathDisplayText;
            field.InstanceDeclaration.RootTypeId  = ObjectTypeIds.BaseEventType;
            Fields.Add(field);
        }