Opc.Ua.Com.Client.ComDaClient.UpdateElement C# (CSharp) Method

UpdateElement() private method

Updates a element.
private UpdateElement ( DaElement element, string name, string parentId ) : void
element DaElement The element.
name string The name.
parentId string The parent id.
return void
        private void UpdateElement(DaElement element, string name, string parentId)
        {      
            // only update the name if specified.         
            if (name != null)
            {
                element.Name = name;
            }

            // same for the parent id.
            if (parentId != null)
            {
                element.ParentId = parentId;
            }

            // read item property values.
            DaValue[] values = ReadPropertyValues(element.ItemId, m_CoreProperties);

            // handle errors gracefully.
            if (values == null || values.Length == 0)
            {
                element.ElementType = DaElementType.Branch;
                return;
            }

            // must be an item if the data type property exists.
            if (values[0].Error >= 0)
            {
                element.ElementType = DaElementType.Item;
                element.DataType = values[0].GetValue<short>();
                element.AccessRights = values[1].GetValue<int>();
                element.ScanRate = values[2].GetValue<float>();
                element.Description = values[3].GetValue<string>();
                element.EngineeringUnits = values[4].GetValue<string>();
                element.EuInfo = values[5].GetValue<string[]>();
                element.EuType = values[6].GetValue<int>();
                element.HighEU = values[7].GetValue<double>();
                element.LowEU = values[8].GetValue<double>();
                element.OpenLabel = values[9].GetValue<string>();
                element.CloseLabel = values[10].GetValue<string>();
                element.HighIR = values[11].GetValue<double>();
                element.LowIR = values[12].GetValue<double>();

                // check if the time zone is specified.
                if (values[13].Error >= 0)
                {
                    element.TimeZone = values[13].GetValue<int>();
                }

                // check for analog item (checks for HighEU if EuType property not supported).
                if ((values[6].Error < 0 && values[7].Error >= 0) || element.EuType == (int)OPCEUTYPE.OPC_ANALOG)
                {
                    element.ElementType = DaElementType.AnalogItem;
                }

                // check for enumerated item.
                else if (element.EuType == (int)OPCEUTYPE.OPC_ENUMERATED)
                {
                    element.ElementType = DaElementType.EnumeratedItem;
                }

                // check for digital item (checks for CloseLabel property).
                else if (values[10].Error >= 0)
                {
                    element.ElementType = DaElementType.DigitalItem;
                }
            }

            // the element must be a branch. 
            else
            {
                element.ElementType = DaElementType.Branch;

                // branches could have description property.
                element.Description = values[3].GetValue<string>();
            }
        }