コード例 #1
0
        /// <summary>
        /// static function that read item property collection for selected item
        /// </summary>
        /// <param name="ItemName">item name to be read</param>
        /// <param name="ds">data set with settings</param>
        /// <returns>collection of properties</returns>
        public static ItemPropertyCollection GetItemPropertiesCollection(string ItemName, ItemDecriberDataSet ds)
        {
            ItemPropertyCollection _ret = null;

            if (ds != null)
            {
                _ret = new ItemPropertyCollection();
                foreach (ItemDecriberDataSet.ItemsRow _row in ds.Items.Rows)
                {
                    if (_row.ItemName == ItemName)
                    {
                        foreach (ItemDecriberDataSet.ItemPropertyRow row_property in _row.GetItemPropertyRows())
                        {
                            PropertyDescription prop_dsc = PropertyDescription.Find(new PropertyID(row_property.PropertyCode));
                            ItemProperty        itemprop = new ItemProperty
                            {
                                ID    = prop_dsc.ID,
                                Value = row_property.Value
                            };
                            _ret.Add(itemprop);
                        }
                        break;
                    }
                }
            }
            return(_ret);
        }
コード例 #2
0
      /// <summary>
      /// Tag constructor
      /// </summary>
      /// <param name="myDSC">parameters from Tags table</param>
      /// <param name="myStation">pointer to interface that allow to change priority of the station</param>
      internal Tag(ComunicationNet.TagsRow myDSC, IStationState myStation)
          : base(myDSC.Name, null, qualityBits.badNotConnected, (ItemAccessRights)myDSC.AccessRights, GetDataTypeFromConfig(myDSC))
      {
        switch ((StateTrigger)myDSC.StateTrigger)
        {
          case StateTrigger.StateHigh:
            stateHihgTriger = true;
            break;

          case StateTrigger.StateLow:
            stateLowTriger = true;
            break;

          default:
            break;
        }
        stateMask = (int)myDSC.StateMask;
        this.myStation = myStation;
        this.EuType = Opc.Da.euType.noEnum;
        ItemPropertyCollection itemPropertyCollection = new ItemPropertyCollection();
        foreach (ComunicationNet.ItemPropertiesTableRow row_property in myDSC.GetItemPropertiesTableRows())
        {
          try
          {
            PropertyDescription prop_dsc =
                PropertyDescription.Find(
                new PropertyID(
                    new XmlQualifiedName(row_property.ID_Name_Name, row_property.ID_Name_Namespace)
                    ));
            ItemProperty _itemProperty = new ItemProperty
            {
              ID = prop_dsc.ID,
              Value = row_property.Value
            };
            if (prop_dsc.ID != Opc.Da.Property.DATATYPE) //this property is managed differently
                                                         // as GetDataTypeFromConfig( myDSC )
                                                         // at the constructor
            {
              if (prop_dsc.ID == Opc.Da.Property.HI_LIMIT ||
                 prop_dsc.ID == Opc.Da.Property.LO_LIMIT ||
                  prop_dsc.ID == Opc.Da.Property.HIHI_LIMIT ||
                 prop_dsc.ID == Opc.Da.Property.LOLO_LIMIT ||
                 prop_dsc.ID == Opc.Da.Property.LOWEU ||
                  prop_dsc.ID == Opc.Da.Property.HIGHEU ||
                 prop_dsc.ID == Opc.Da.Property.SCANRATE
                )
              {
                // this property contains double value
                if (double.TryParse(row_property.Value, out double prop_value))
                  _itemProperty.Value = prop_value;
              }
              if (prop_dsc.ID == Opc.Da.Property.EUTYPE)
              {
                _itemProperty.Value = Opc.Da.euType.noEnum;
                // this property contains vale from enum: Opc.Da.euType
                foreach (Opc.Da.euType NEWeuType in Enum.GetValues(typeof(Opc.Da.euType)))
                {
                  if (NEWeuType.ToString() == row_property.Value)
                    _itemProperty.Value = NEWeuType;
                }
              }
              if (prop_dsc.ID == Opc.Da.Property.EUINFO)
              {
                //I assume that this is table of strings spited by ;
                _itemProperty.Value = row_property.Value.Split(';');
              }
              itemPropertyCollection.Add(_itemProperty);
            }
          }
          catch (Exception ex)
          {
            CommServerComponent.Tracer.TraceInformation(290, "DataBlock.Tag",
            "Problem with property for item : " + myDSC.Name + ": " +
              TraceEvent.GetMessageWithExceptionNameFromExceptionIncludingInnerException(ex));
          }
        }
        try
        {
          this.AddProperties(itemPropertyCollection);
        }
        catch (Exception ex)
        {
          CommServerComponent.Tracer.TraceInformation(290, "DataBlock.Tag",
          "Problem with many properties for item : " + myDSC.Name + ": " +
            TraceEvent.GetMessageWithExceptionNameFromExceptionIncludingInnerException(ex));
        }
      }
コード例 #3
0
        /// <summary>
        /// Returns the specified properties for the specified item.
        /// </summary>
        public Opc.Da.ItemPropertyCollection GetAvailableProperties(
            PropertyID[] propertyIDs,
            bool returnValues)
        {
            // initialize property collection.
            ItemPropertyCollection properties = new ItemPropertyCollection();

            properties.ItemName       = m_itemID;
            properties.ItemPath       = null;
            properties.ResultID       = ResultID.S_OK;
            properties.DiagnosticInfo = null;

            // fetch information for each requested property.
            foreach (PropertyID propertyID in propertyIDs)
            {
                ItemProperty property = new ItemProperty();

                property.ID = propertyID;

                // read the property value.
                if (returnValues)
                {
                    ItemValueResult result = Read(propertyID);

                    if (result.ResultID.Succeeded())
                    {
                        property.Value = result.Value;
                    }

                    property.ResultID       = result.ResultID;
                    property.DiagnosticInfo = result.DiagnosticInfo;
                }

                // just validate the property id.
                else
                {
                    property.ResultID = ValidatePropertyID(propertyID, accessRights.readWritable);
                }

                // set status if one or more errors occur.
                if (property.ResultID.Failed())
                {
                    properties.ResultID = ResultID.S_FALSE;
                }

                else
                {
                    // set property description.
                    PropertyDescription description = PropertyDescription.Find(propertyID);

                    if (description != null)
                    {
                        property.Description = description.Name;
                        property.DataType    = description.Type;
                    }

                    // set property item id.
                    if (propertyID.Code >= ENGINEERINGUINTS && propertyID.Code <= TIMEZONE)
                    {
                        property.ItemName = m_itemID + ":" + propertyID.Code.ToString();
                        property.ItemPath = null;
                    }
                }

                // add to collection.
                properties.Add(property);
            }

            // return collection.
            return(properties);
        }
コード例 #4
0
        /// <summary>
        /// Returns the specified properties for the specified item.
        /// </summary>
        public Opc.Da.ItemPropertyCollection GetAvailableProperties(
            PropertyID[] propertyIDs,
            bool         returnValues)
        {
            // initialize property collection.
            ItemPropertyCollection properties = new ItemPropertyCollection();

            properties.ItemName       = m_itemID;
            properties.ItemPath       = null;
            properties.ResultID       = ResultID.S_OK;
            properties.DiagnosticInfo = null;

            // fetch information for each requested property.
            foreach (PropertyID propertyID in propertyIDs)
            {
                ItemProperty property = new ItemProperty();

                property.ID = propertyID;

                // read the property value.
                if (returnValues)
                {
                    ItemValueResult result = Read(propertyID);

                    if (result.ResultID.Succeeded())
                    {
                        property.Value = result.Value;
                    }

                    property.ResultID       = result.ResultID;
                    property.DiagnosticInfo = result.DiagnosticInfo;
                }

                // just validate the property id.
                else
                {
                    property.ResultID = ValidatePropertyID(propertyID, accessRights.readWritable);
                }

                // set status if one or more errors occur.
                if (property.ResultID.Failed())
                {
                    properties.ResultID = ResultID.S_FALSE;
                }

                else
                {
                    // set property description.
                    PropertyDescription description = PropertyDescription.Find(propertyID);

                    if (description != null)
                    {
                        property.Description = description.Name;
                        property.DataType    = description.Type;
                    }

                    // set property item id.
                    if (propertyID.Code >= ENGINEERINGUINTS && propertyID.Code <= TIMEZONE)
                    {
                        property.ItemName = m_itemID + ":" + propertyID.Code.ToString();
                        property.ItemPath = null;
                    }
                }

                // add to collection.
                properties.Add(property);
            }

            // return collection.
            return properties;
        }