Stores information about an HDA attribute.
コード例 #1
0
ファイル: HdaAttributeState.cs プロジェクト: yuriik83/UA-.NET
        /// <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);
        }
コード例 #2
0
ファイル: ComHdaClient.cs プロジェクト: OPCFoundation/UA-.NET
        /// <summary>
        /// Gets the supported attributes.
        /// </summary>
        public HdaAttribute[] GetSupportedAttributes()
        {
            string methodName = "IOPCHDA_Server.GetItemAttributes";

            int pdwCount;
            IntPtr ppdwAttrID;
            IntPtr ppszAttrName;
            IntPtr ppszAttrDesc;
            IntPtr ppvtAttrDataType;

            try
            {
                IOPCHDA_Server server = BeginComCall<IOPCHDA_Server>(methodName, true);

                server.GetItemAttributes(
                    out pdwCount,
                    out ppdwAttrID,
                    out ppszAttrName,
                    out ppszAttrDesc,
                    out ppvtAttrDataType);
            }
            catch (Exception e)
            {
                ComCallError(methodName, e);
                return null;
            }
            finally
            {
                EndComCall(methodName);
            }

            int[] attributeIds = ComUtils.GetInt32s(ref ppdwAttrID, pdwCount, true);
            string[] names = ComUtils.GetUnicodeStrings(ref ppszAttrName, pdwCount, true);
            string[] descriptions = ComUtils.GetUnicodeStrings(ref ppszAttrDesc, pdwCount, true);
            short[] datatypes = ComUtils.GetInt16s(ref ppvtAttrDataType, pdwCount, true);

            HdaAttribute[] results = new HdaAttribute[pdwCount];

            for (int ii = 0; ii < results.Length; ii++)
            {
                HdaAttribute result = results[ii] = new HdaAttribute();

                result.Id = Utils.ToUInt32(attributeIds[ii]);
                result.Name = names[ii];
                result.Description = descriptions[ii];
                result.DataType = datatypes[ii];
            }

            return results;
        }
コード例 #3
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);
        }