Exemplo n.º 1
0
        public static void SetAnalogEngineeringUnits(DemoDaAddressSpaceElement daElement,
                                                     Double lowLimit,
                                                     Double highLimit,
                                                     EnumAccessRights accessRights)
        {
            ValueQT            val    = new ValueQT(EnumEUType.ANALOG, EnumQuality.GOOD, DateTime.Now);
            DaConstantProperty euType = new DaConstantProperty(
                7,
                "EUType",
                "7",
                val);

            daElement.AddProperty(euType);

            DaProperty euHigh = new DaProperty();

            euHigh.Id           = 102;
            euHigh.Name         = "High EU";
            euHigh.Description  = "High EU Description";
            euHigh.ItemId       = "102";
            euHigh.Datatype     = typeof(System.Double);
            euHigh.AccessRights = accessRights;
            daElement.AddProperty(euHigh);

            DaProperty euLow = new DaProperty();

            euLow.Id           = 103;
            euLow.Name         = "Low EU";
            euLow.Description  = "Low EU Description";
            euLow.ItemId       = "103";
            euLow.Datatype     = typeof(System.Double);
            euLow.AccessRights = accessRights;
            daElement.AddProperty(euLow);
        }
		} //	end CreateInternalDaAddressSpaceElement


		/// <summary>
		/// Creates a new instance of DaAddressSpaceElement for string based address space only (extended version).
		/// <br/>Must return a valid <see cref="DaAddressSpaceElement"/> object in order to have the Toolkit CORE use this extended method.
		/// <br/>If <see cref="CreateInternalDaAddressSpaceElementEx"/> method is correctly implemented, <see cref="CreateInternalDaAddressSpaceElement"/>
		/// will be ignored (will never be called unless <see cref="CreateInternalDaAddressSpaceElementEx"/> fails.
		/// </summary>
		/// <param name="anItemId">Item ID of the element to be created</param>
		/// <param name="aName">Iten name of the element to be created</param>
		/// <param name="anUserData">User data for the element to be created</param>
		/// <param name="anObjectHandle">Toolkit CORE object handle of the element to be created</param>
		/// <param name="aParentHandle">Toolkit CORE object handle of the parent of the element to be created</param>
		/// <param name="elementDataFilter">Type of element data which is not set in the parameters below</param>
		/// <param name="accessRights">Element`s access rights, valid if <see cref="EnumAddressSpaceElementData.ACCESSRIGHTS"/> flag is not set in elementDataFilter</param>
		/// <param name="ioMode">Element`s IO mode, valid if <see cref="EnumAddressSpaceElementData.IOMODE"/> is not set in elementDataFilter</param>
		/// <param name="hasChildren">Whether the element has children or not (is node or tag), valid if <see cref="EnumAddressSpaceElementData.HASCHILDREN"/> is not set in elementDataFilter</param>
		/// <param name="isBrowsable">Whether the elementis browsable, valid if <see cref="EnumAddressSpaceElementData.ISBROWSABLE"/> is not set in elementDataFilter</param>
		/// <param name="dataType">Element`s data type, valid if <see cref="EnumAddressSpaceElementData.DATATYPE"/> flag is not set in elementDataFilter</param>
		/// <returns></returns>
		/// <include
		///		file='TBNS.doc.xml'
		///		path='//class[@name="Creator"]/
		///		method[@name="CreateInternalDaAddressSpaceElementEx"]/doc/*'
		///	/>
		public virtual DaAddressSpaceElement CreateInternalDaAddressSpaceElementEx(
			string anItemId,
			string aName,
			uint anUserData,
			uint anObjectHandle,
			uint aParentHandle,
			EnumAddressSpaceElementData elementDataFilter,
			EnumAccessRights accessRights,
			EnumIoMode ioMode,
			bool hasChildren, // aka isNode
			bool isBrowsable,
			Type dataType)
		{
			return null;
		} //	end CreateInternalDaAddressSpaceElement
Exemplo n.º 3
0
        public static void CreateAngle(DemoDaAddressSpaceElement daElement,
                                       String name,
                                       String description,
                                       String itemId,
                                       EnumAccessRights accessRights)
        {
            DaProperty angleProperty = new DaProperty();

            angleProperty.Id           = 6020;
            angleProperty.Name         = name;
            angleProperty.Description  = description;
            angleProperty.ItemId       = itemId;
            angleProperty.Datatype     = typeof(System.Int16);
            angleProperty.AccessRights = accessRights;
            daElement.AddProperty(angleProperty);
        }
        /// <summary>
        /// Write Address Space Element
        /// </summary>
        /// <param name="session"></param>
        /// <param name="itemId"></param>
        public void WriteAddresSpaceItem(DaSession session, string itemId, object selectedObject, bool isAddSpaceElem)
        {
            Helper.DataTypes dataTypeHelper = new DataTypes();
            this.panelBottom.Visible = true;

            isDaItem     = false;
            this.session = session;

            ValueQT[] itemValues;
            int[]     itemResults;
            int       result = session.Read(MAX_AGE_DEVICE, new string[] { itemId }, null, out itemValues, out itemResults, null);

            if (itemResults.Length == 0)
            {
                return;
            }
            if (itemValues.Length == 0)
            {
                return;
            }

            Type             itemDataType    = typeof(short);
            EnumAccessRights itemAccessRighs = EnumAccessRights.READWRITEABLE;
            bool             hasWriteAccess  = true;

            if (ResultCode.SUCCEEDED(result) && ResultCode.SUCCEEDED(itemResults[0]))
            {
                DaGetPropertiesOptions propertyGetOptions = new DaGetPropertiesOptions();
                propertyGetOptions.WhatPropertyData = EnumPropertyData.ALL;

                DaProperty[] properties = null;
                if (isAddSpaceElem)
                {
                    if (ResultCode.SUCCEEDED(session.GetDaProperties(itemId,
                                                                     null,
                                                                     propertyGetOptions,
                                                                     out properties,
                                                                     null)))
                    {
                        if (properties == null)
                        {
                            this.propertyGrid.SelectedObject = FillEmptyValueQT(itemId, null);
                            return;
                        }
                        if (properties.Length < 5)
                        {
                            this.propertyGrid.SelectedObject = FillEmptyValueQT(itemId, null);
                            return;
                        }
                        itemDataType    = DataTypeConverter.GetSysType((short)properties[0].ValueQT.Data);
                        itemAccessRighs = ObjToAccesssRights(properties[4].ValueQT.Data);
                    }
                }
                else
                {
                    itemDataType = (selectedObject as DaProperty).DataType;
                }

                //the item value is null
                if (itemValues[0] == null)
                {
                    this.propertyGrid.SelectedObject = FillEmptyValueQT(itemId, itemDataType);
                    return;
                }

                if (itemAccessRighs == EnumAccessRights.READABLE)
                {
                    hasWriteAccess = false;
                }
            }
            this.propertyGrid.SelectedObject = FillWriteService(itemId, itemDataType, hasWriteAccess, itemValues[0]);
        }