An instance of the AeAttribute class describes a variant value which an OPC Client may request to be transmitted together with an event notification.
コード例 #1
0
		} //	end GetConditionDefinition


		//-
		#endregion

		#region //	Protected Methods
		//---------------------------

		/// <summary>
		///	Adds an existing attribute object to the category internal hashtable
		/// </summary>
		/// <param name="anAttribute"> an already created instance of the attribute</param>
		/// <returns>
		/// S_OK - if succeeded
		/// E_FAIL - if failure
		/// </returns>
		/// <include
		///		file='TBNS.doc.xml'
		///			path='//class[@name="AeCategory"]/
		///			method[@name="AddAttribute.existing"]/doc/*'
		///	/>
		protected virtual int AddAttribute(AeAttribute anAttribute)
		{
			try
			{
				if (anAttribute == null)
				{
					return (int) EnumResultCode.E_FAIL;
				} //	end if

				if (Handle == 0)
				{
					return (int) EnumResultCode.E_FAIL;
				} //	end if

				int result = OTBFunctions.OTSAddEventAttribute(
					this.Handle,
					anAttribute.Id,
					anAttribute.Name,
					ValueQT.GetVartype(anAttribute.DataType));

				if (ResultCode.SUCCEEDED(result))
				{
					Hashtable syncAttributeList = Hashtable.Synchronized(this.m_attributes);
					syncAttributeList.Add(anAttribute.Id, anAttribute);
				} //	end if

				return result;
			}
			catch (Exception e)
			{
				Application.Instance.Trace(EnumTraceLevel.ERR,
				                           EnumTraceGroup.OPCSERVER,
				                           "Category.AddAttribute",
				                           "Exception caught:" + e.ToString());
				return (int) EnumResultCode.E_FAIL;
			} //	end try ... catch
		} //	end AddAttribute
コード例 #2
0
		} //	end Handle


		//-
		#endregion

		#region //	Public Methods
		//------------------------

		/// <summary>
		/// Creates and adds a new attribute to the category hashtable.
		/// </summary>
		/// <param name="anId"> new attribute ID</param>
		/// <param name="aName"> new attribute </param>
		/// <param name="aDataType"></param>
		/// <returns>
		/// S_OK - if succeeded
		/// E_FAIL - if failure
		/// </returns>
		/// <include
		///		file='TBNS.doc.xml'
		///			path='//class[@name="AeCategory"]/
		///			method[@name="AddAttribute.create"]/doc/*'
		///	/>
		public virtual int AddAttribute(uint anId, string aName, Type aDataType)
		{
			AeAttribute attribute = new AeAttribute(anId, aName, aDataType);
			return this.AddAttribute(attribute);
		} //	end AddAttribute