A class that builds NodeIds used by the DataAccess NodeManager
Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DaItemState"/> class.
        /// </summary>
        /// <param name="itemId">The item id.</param>
        /// <param name="name">The name.</param>
        /// <param name="namespaceIndex">Index of the namespace.</param>
        public HdaItemState(
            string itemId,
            string name,
            ushort namespaceIndex)
            :
            base(null)
        {
            m_itemId = itemId;

            if (String.IsNullOrEmpty(name))
            {
                name = itemId;
            }

            this.NodeId                  = HdaModelUtils.ConstructIdForHdaItem(itemId, namespaceIndex);
            this.BrowseName              = new QualifiedName(name, namespaceIndex);
            this.DisplayName             = new LocalizedText(name);
            this.TypeDefinitionId        = Opc.Ua.VariableTypeIds.DataItemType;
            this.Description             = null;
            this.WriteMask               = 0;
            this.UserWriteMask           = 0;
            this.DataType                = DataTypeIds.BaseDataType;
            this.ValueRank               = ValueRanks.Any;
            this.Historizing             = false;
            this.MinimumSamplingInterval = MinimumSamplingIntervals.Indeterminate;
            this.AccessLevel             = AccessLevels.HistoryRead;
            this.UserAccessLevel         = AccessLevels.HistoryRead;
        }
Пример #2
0
        /// <summary>
        /// Gets the item annotations node.
        /// </summary>
        /// <param name="itemId">The item id.</param>
        /// <param name="namespaceIndex">Index of the namespace.</param>
        /// <returns></returns>
        public static PropertyState GetItemAnnotationsNode(string itemId, ushort namespaceIndex)
        {
            if (itemId == null)
            {
                return(null);
            }

            PropertyState component = new PropertyState(null);

            component.NodeId                  = HdaParsedNodeId.Construct(HdaModelUtils.HdaItemAnnotations, itemId, null, namespaceIndex);
            component.SymbolicName            = Opc.Ua.BrowseNames.Annotations;
            component.BrowseName              = new QualifiedName(component.SymbolicName);
            component.DisplayName             = component.BrowseName.Name;
            component.DataType                = DataTypeIds.Annotation;
            component.ValueRank               = ValueRanks.Scalar;
            component.MinimumSamplingInterval = MinimumSamplingIntervals.Indeterminate;
            component.Historizing             = false;
            component.AccessLevel             = AccessLevels.HistoryRead;
            component.UserAccessLevel         = AccessLevels.HistoryRead;
            component.ReferenceTypeId         = Opc.Ua.ReferenceTypeIds.HasProperty;
            component.TypeDefinitionId        = Opc.Ua.VariableTypeIds.PropertyType;

            component.AddReference(ReferenceTypeIds.HasProperty, true, HdaModelUtils.ConstructIdForHdaItem(itemId, namespaceIndex));

            return(component);
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HdaBranchState"/> class.
        /// </summary>
        /// <param name="itemId">The qualified name for the area.</param>
        /// <param name="name">The name of the area.</param>
        /// <param name="namespaceIndex">Index of the namespace.</param>
        public HdaBranchState(
            string itemId,
            string name,
            ushort namespaceIndex)
            :
            base(null)
        {
            m_itemId = itemId;

            this.SymbolicName     = name;
            this.TypeDefinitionId = Opc.Ua.ObjectTypeIds.FolderType;
            this.NodeId           = HdaModelUtils.ConstructIdForHdaBranch(itemId, namespaceIndex);
            this.BrowseName       = new QualifiedName(name, namespaceIndex);
            this.DisplayName      = this.BrowseName.Name;
            this.Description      = null;
            this.WriteMask        = 0;
            this.UserWriteMask    = 0;
            this.EventNotifier    = EventNotifiers.None;
        }
Пример #4
0
        /// <summary>
        /// Gets the item configuration node.
        /// </summary>
        /// <param name="itemId">The item id.</param>
        /// <param name="namespaceIndex">Index of the namespace.</param>
        /// <returns></returns>
        public static BaseInstanceState GetItemConfigurationNode(string itemId, ushort namespaceIndex)
        {
            if (itemId == null)
            {
                return(null);
            }

            FolderState component = new FolderState(null);

            component.NodeId           = HdaParsedNodeId.Construct(HdaModelUtils.HdaItemConfiguration, itemId, null, namespaceIndex);
            component.SymbolicName     = Opc.Ua.BrowseNames.HAConfiguration;
            component.BrowseName       = new QualifiedName(component.SymbolicName);
            component.DisplayName      = component.BrowseName.Name;
            component.ReferenceTypeId  = Opc.Ua.ReferenceTypeIds.HasComponent;
            component.TypeDefinitionId = Opc.Ua.ObjectTypeIds.HistoricalDataConfigurationType;
            component.EventNotifier    = EventNotifiers.None;

            component.AddReference(ReferenceTypeIds.HasHistoricalConfiguration, true, HdaModelUtils.ConstructIdForHdaItem(itemId, namespaceIndex));
            component.AddReference(ReferenceTypeIds.HasComponent, false, HdaModelUtils.ConstructIdForInternalNode(Opc.Ua.BrowseNames.AggregateConfiguration, namespaceIndex));

            return(component);
        }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DaItemState"/> class.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="itemId">The item id.</param>
        /// <param name="attribute">The attribute.</param>
        /// <param name="namespaceIndex">Index of the namespace.</param>
        public HdaAttributeState(
            ComHdaClientConfiguration configuration,
            string itemId,
            HdaAttribute attribute,
            ushort namespaceIndex)
            :
            base(null)
        {
            m_itemId    = itemId;
            m_attribute = attribute;

            this.NodeId                  = HdaModelUtils.ConstructIdForHdaItemAttribute(itemId, attribute.Id, namespaceIndex);
            this.SymbolicName            = attribute.Id.ToString();
            this.Description             = attribute.Description;
            this.AccessLevel             = AccessLevels.CurrentRead;
            this.UserAccessLevel         = AccessLevels.CurrentRead;
            this.MinimumSamplingInterval = MinimumSamplingIntervals.Indeterminate;
            this.Historizing             = false;
            this.ReferenceTypeId         = Opc.Ua.ReferenceTypeIds.HasProperty;
            this.TypeDefinitionId        = Opc.Ua.VariableTypeIds.PropertyType;
            this.Value      = null;
            this.StatusCode = StatusCodes.BadWaitingForInitialData;

            bool isConfigItem = false;

            // handle built-in properties.
            switch (attribute.Id)
            {
            default:
            {
                bool isArray = false;
                this.BrowseName  = new QualifiedName(this.SymbolicName, namespaceIndex);
                this.DisplayName = attribute.Name;
                this.DataType    = ComUtils.GetDataTypeId(attribute.DataType, out isArray);
                this.ValueRank   = (isArray)?ValueRanks.OneDimension:ValueRanks.Scalar;
                break;
            }

            case Constants.OPCHDA_ENG_UNITS:
            {
                this.BrowseName  = Opc.Ua.BrowseNames.EngineeringUnits;
                this.DisplayName = this.BrowseName.Name;
                this.DataType    = Opc.Ua.DataTypeIds.EUInformation;
                this.ValueRank   = ValueRanks.Scalar;
                break;
            }

            case Constants.OPCHDA_NORMAL_MAXIMUM:
            {
                this.BrowseName  = Opc.Ua.BrowseNames.EURange;
                this.DisplayName = this.BrowseName.Name;
                this.DataType    = Opc.Ua.DataTypeIds.Range;
                this.ValueRank   = ValueRanks.Scalar;
                break;
            }

            case Constants.OPCHDA_HIGH_ENTRY_LIMIT:
            {
                this.BrowseName  = Opc.Ua.BrowseNames.InstrumentRange;
                this.DisplayName = this.BrowseName.Name;
                this.DataType    = Opc.Ua.DataTypeIds.Range;
                this.ValueRank   = ValueRanks.Scalar;
                break;
            }

            case Constants.OPCHDA_STEPPED:
            {
                this.BrowseName  = Opc.Ua.BrowseNames.Stepped;
                this.DisplayName = this.BrowseName.Name;
                this.DataType    = Opc.Ua.DataTypeIds.Boolean;
                this.ValueRank   = ValueRanks.Scalar;
                isConfigItem     = true;
                break;
            }

            case Constants.OPCHDA_DERIVE_EQUATION:
            {
                this.BrowseName  = Opc.Ua.BrowseNames.Definition;
                this.DisplayName = this.BrowseName.Name;
                this.DataType    = Opc.Ua.DataTypeIds.String;
                this.ValueRank   = ValueRanks.Scalar;
                isConfigItem     = true;
                break;
            }

            case Constants.OPCHDA_MIN_TIME_INT:
            {
                this.BrowseName  = Opc.Ua.BrowseNames.MinTimeInterval;
                this.DisplayName = this.BrowseName.Name;
                this.DataType    = Opc.Ua.DataTypeIds.Duration;
                this.ValueRank   = ValueRanks.Scalar;
                isConfigItem     = true;
                break;
            }

            case Constants.OPCHDA_MAX_TIME_INT:
            {
                this.BrowseName  = Opc.Ua.BrowseNames.MaxTimeInterval;
                this.DisplayName = this.BrowseName.Name;
                this.DataType    = Opc.Ua.DataTypeIds.Duration;
                this.ValueRank   = ValueRanks.Scalar;
                isConfigItem     = true;
                break;
            }

            case Constants.OPCHDA_EXCEPTION_DEV:
            {
                this.BrowseName  = Opc.Ua.BrowseNames.ExceptionDeviation;
                this.DisplayName = this.BrowseName.Name;
                this.DataType    = Opc.Ua.DataTypeIds.Double;
                this.ValueRank   = ValueRanks.Scalar;
                isConfigItem     = true;
                break;
            }

            case Constants.OPCHDA_EXCEPTION_DEV_TYPE:
            {
                this.BrowseName  = Opc.Ua.BrowseNames.ExceptionDeviationFormat;
                this.DisplayName = this.BrowseName.Name;
                this.DataType    = Opc.Ua.DataTypeIds.ExceptionDeviationFormat;
                this.ValueRank   = ValueRanks.Scalar;
                isConfigItem     = true;
                break;
            }
            }

            // set the parent id.
            NodeId parentId = null;

            if (isConfigItem)
            {
                parentId = HdaParsedNodeId.Construct(HdaModelUtils.HdaItemConfiguration, itemId, null, namespaceIndex);
            }
            else
            {
                parentId = HdaModelUtils.ConstructIdForHdaItem(itemId, namespaceIndex);
            }

            this.AddReference(ReferenceTypeIds.HasProperty, true, parentId);
        }
        /// <summary>
        /// Finds the children for hda item.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="children">The children.</param>
        /// <param name="attributes">The attribute values.</param>
        private void FindChildrenForHdaItem(ComHdaClient client, List <BaseInstanceState> children, HdaAttributeValue[] attributes)
        {
            BaseInstanceState child = null;

            if (IsRequired(ReferenceTypeIds.HasHistoricalConfiguration, false))
            {
                child = HdaModelUtils.GetItemConfigurationNode(m_itemId, m_namespaceIndex);

                if (child != null)
                {
                    children.Add(child);
                }
            }

            if (IsRequired(ReferenceTypeIds.HasProperty, false))
            {
                child = client.FindItemAnnotations(m_itemId, m_namespaceIndex);

                if (child != null)
                {
                    children.Add(child);
                }

                if (attributes != null)
                {
                    for (int ii = 0; ii < attributes.Length; ii++)
                    {
                        if (attributes[ii].Error < 0 || attributes[ii].Error == ResultIds.S_NODATA)
                        {
                            continue;
                        }

                        bool skip = false;

                        switch (attributes[ii].AttributeId)
                        {
                        case Constants.OPCHDA_DATA_TYPE:
                        case Constants.OPCHDA_DESCRIPTION:
                        case Constants.OPCHDA_ITEMID:
                        case Constants.OPCHDA_ARCHIVING:
                        case Constants.OPCHDA_DERIVE_EQUATION:
                        case Constants.OPCHDA_STEPPED:
                        case Constants.OPCHDA_MAX_TIME_INT:
                        case Constants.OPCHDA_MIN_TIME_INT:
                        case Constants.OPCHDA_EXCEPTION_DEV:
                        case Constants.OPCHDA_EXCEPTION_DEV_TYPE:
                        {
                            skip = true;
                            break;
                        }
                        }

                        if (skip)
                        {
                            continue;
                        }

                        child = client.FindItemAttribute(m_itemId, attributes[ii].AttributeId, m_namespaceIndex);

                        if (child != null)
                        {
                            children.Add(child);
                        }
                    }
                }
            }
        }