示例#1
0
        /// <summary>
        /// Adds a simple field to the declaration.
        /// </summary>
        public void AddSimpleField(QualifiedName browseName, BuiltInType dataType, int valueRank, bool displayInList)
        {
            FilterDeclarationField field = new FilterDeclarationField();

            field.DisplayInList                  = displayInList;
            field.InstanceDeclaration            = new InstanceDeclaration();
            field.InstanceDeclaration.BrowseName = browseName;
            field.InstanceDeclaration.BrowsePath = new QualifiedNameCollection();
            field.InstanceDeclaration.BrowsePath.Add(field.InstanceDeclaration.BrowseName);
            field.InstanceDeclaration.BrowsePathDisplayText = browseName.Name;

            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 = browseName.Name;
            field.InstanceDeclaration.DisplayPath = browseName.Name;
            field.InstanceDeclaration.RootTypeId  = ObjectTypeIds.BaseEventType;
            Fields.Add(field);
        }
示例#2
0
 /// <summary>
 /// Creates a new instance of a FilterDeclarationField.
 /// </summary>
 public FilterDeclarationField(FilterDeclarationField field)
 {
     DisplayInList       = field.DisplayInList;
     FilterEnabled       = field.FilterEnabled;
     FilterOperator      = field.FilterOperator;
     FilterValue         = field.FilterValue;
     InstanceDeclaration = field.InstanceDeclaration;
 }
示例#3
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;
                        }
                    }
                }
            }
        }