Exemple #1
0
        /// <summary>
        /// Displays the dialog until the user enters valid data or clicks cancel.
        /// </summary>
        private TsCHdaBrowseFilter PromptUser()
        {
            while (ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Technosoftware.DaAeHdaClient.Hda.TsCHdaAttribute attribute = (Technosoftware.DaAeHdaClient.Hda.TsCHdaAttribute)attributeCb_.SelectedItem;

                    if (attribute == null)
                    {
                        continue;
                    }

                    TsCHdaBrowseFilter filter = new TsCHdaBrowseFilter();

                    filter.AttributeID = attribute.ID;
                    filter.Operator    = (TsCHdaOperator)operatorCtrl_.Value;
                    filter.FilterValue = filterValueCtrl_.Value;

                    return(filter);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }
            }

            return(null);
        }
        /// <summary>
        /// Displays a dialog with more detailed view of the current selection.
        /// </summary>
        private void ViewMI_Click(object sender, System.EventArgs e)
        {
            try
            {
                // check for valid selection.
                if (attributesLv_.SelectedItems.Count != 1)
                {
                    return;
                }

                ListViewItem selection = attributesLv_.SelectedItems[0];

                // show values if an attribute collection.
                if (typeof(Technosoftware.DaAeHdaClient.Hda.TsCHdaAttributeValueCollection).IsInstanceOfType(selection.Tag))
                {
                    new AttributesViewDlg().ShowDialog(mServer_, (Technosoftware.DaAeHdaClient.Hda.TsCHdaAttributeValueCollection)selection.Tag);
                }

                // show description of attribute.
                else if (typeof(Technosoftware.DaAeHdaClient.Hda.TsCHdaAttribute).IsInstanceOfType(selection.Tag))
                {
                    Technosoftware.DaAeHdaClient.Hda.TsCHdaAttribute attribute = (Technosoftware.DaAeHdaClient.Hda.TsCHdaAttribute)selection.Tag;
                    MessageBox.Show(attribute.Description, attribute.Name, MessageBoxButtons.OK);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
        /// <summary>
        /// Edits an item from the list.
        /// </summary>
        private void ViewMI_Click(object sender, System.EventArgs e)
        {
            try
            {
                // check for valid selection.
                if (attributesLv_.SelectedItems.Count != 1)
                {
                    return;
                }

                Technosoftware.DaAeHdaClient.Hda.TsCHdaAttribute attribute = (Technosoftware.DaAeHdaClient.Hda.TsCHdaAttribute)attributesLv_.SelectedItems[0].Tag;

                // view an attribute.
                MessageBox.Show(attribute.Description, attribute.Name);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Exemple #4
0
        /// <summary>
        /// Handles a change to the selected attribute.
        /// </summary>
        private void AttributeCB_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            try
            {
                // get current selection.
                Technosoftware.DaAeHdaClient.Hda.TsCHdaAttribute attribute = (Technosoftware.DaAeHdaClient.Hda.TsCHdaAttribute)attributeCb_.SelectedItem;

                if (attribute == null)
                {
                    descriptionLb_.Text = "";
                    return;
                }

                // convert filter value to correct data type.
                object value = filterValueCtrl_.Value;

                if (value == null || value.GetType() != attribute.DataType)
                {
                    try
                    {
                        filterValueCtrl_.Value = Technosoftware.DaAeHdaClient.OpcConvert.ChangeType(value, attribute.DataType);
                    }
                    catch
                    {
                        filterValueCtrl_.Value = Technosoftware.DaAeHdaClient.OpcConvert.ChangeType(null, attribute.DataType);
                    }
                }

                // update description.
                descriptionLb_.Text = attribute.Description;
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
        /// <summary>
        /// Returns the value of the specified field.
        /// </summary>
        private object GetFieldValue(object attribute, int fieldId)
        {
            // display result code.
            if (typeof(IOpcResult).IsInstanceOfType(attribute))
            {
                switch (fieldId)
                {
                case NumberResult: { return(((Technosoftware.DaAeHdaClient.Hda.TsCHdaAttributeValueCollection)attribute).Result); }
                }
            }

            // displaying attribute descriptions.
            if (typeof(Technosoftware.DaAeHdaClient.Hda.TsCHdaAttribute).IsInstanceOfType(attribute))
            {
                if (attributesLv_.CheckBoxes)
                {
                    switch (fieldId)
                    {
                    case NumberName: { return(((Technosoftware.DaAeHdaClient.Hda.TsCHdaAttribute)attribute).Name); }
                    }
                }
                else
                {
                    switch (fieldId)
                    {
                    case NumberName:        { return(((Technosoftware.DaAeHdaClient.Hda.TsCHdaAttribute)attribute).Name); }

                    case NumberDataType:   { return(((Technosoftware.DaAeHdaClient.Hda.TsCHdaAttribute)attribute).DataType); }

                    case NumberDescription: { return(((Technosoftware.DaAeHdaClient.Hda.TsCHdaAttribute)attribute).Description); }
                    }
                }
            }

            // displaying attribute results.
            if (typeof(Technosoftware.DaAeHdaClient.Hda.TsCHdaAttributeValueCollection).IsInstanceOfType(attribute))
            {
                Technosoftware.DaAeHdaClient.Hda.TsCHdaAttributeValueCollection collection = (Technosoftware.DaAeHdaClient.Hda.TsCHdaAttributeValueCollection)attribute;

                switch (fieldId)
                {
                case NumberName:
                {
                    Technosoftware.DaAeHdaClient.Hda.TsCHdaAttribute description = mServer_.Attributes.Find(collection.AttributeID);

                    if (description != null)
                    {
                        return(description.Name);
                    }

                    return(null);
                }

                case NumberNumValues:
                {
                    if (collection.Count > 1)
                    {
                        return(collection.Count);
                    }

                    return(null);
                }

                case NumberValue:
                {
                    if (collection.Count == 1)
                    {
                        return(collection[0].Value);
                    }

                    return(null);
                }
                }
            }

            // displaying attribute values.
            if (typeof(Technosoftware.DaAeHdaClient.Hda.TsCHdaAttributeValue).IsInstanceOfType(attribute))
            {
                switch (fieldId)
                {
                case NumberTimestamp: { return(((Technosoftware.DaAeHdaClient.Hda.TsCHdaAttributeValue)attribute).Timestamp); }

                case NumberValue:     { return(((Technosoftware.DaAeHdaClient.Hda.TsCHdaAttributeValue)attribute).Value); }
                }
            }

            return(null);
        }
Exemple #6
0
 /// <summary>
 /// Initializes object with the specified ItemIdentifier object.
 /// </summary>
 public TsCHdaAttributeValueCollection(TsCHdaAttribute attribute)
 {
     AttributeID = attribute.ID;
 }