Esempio n. 1
0
        public ItemIdentifier[] GetItemIDs(object[] itemClientHandles)
        {
            // create an invalid server handle.
            int invalidHandle = GetInvalidHandle();

            // copy the items.
            ItemIdentifier[] itemIDs = new ItemIdentifier[itemClientHandles.Length];

            for (int ii = 0; ii < itemClientHandles.Length; ii++)
            {
                // lookup server handle.
                ItemIdentifier itemID = this[itemClientHandles[ii].GetHashCode()];

                // copy the item id.
                if (itemID != null)
                {
                    itemIDs[ii] = (ItemIdentifier)itemID.Clone();
                }

                // create an invalid item id.
                else
                {
                    itemIDs[ii] = new ItemIdentifier();
                    itemIDs[ii].ServerHandle = invalidHandle;
                }

                // store the internal handle as the client handle.
                //itemIDs[ii].ClientHandle = items[ii].ServerHandle;
            }

            // return the item copies.
            return(itemIDs);
        }
Esempio n. 2
0
        /// <summary>
        /// Updates a result list based on the request options and sets the handles for use by the client.
        /// </summary>
        public ItemIdentifier[] ApplyFilters(int filters, ItemIdentifier[] results)
        {
            if (results == null)
            {
                return(null);
            }

            foreach (ItemIdentifier result in results)
            {
                ItemIdentifier itemID = this[result.ClientHandle];

                if (itemID != null)
                {
                    result.ItemName     = ((filters & (int)ResultFilter.ItemName) != 0) ? itemID.ItemName : null;
                    result.ItemPath     = ((filters & (int)ResultFilter.ItemPath) != 0) ? itemID.ItemPath : null;
                    result.ServerHandle = result.ClientHandle;
                    result.ClientHandle = ((filters & (int)ResultFilter.ClientHandle) != 0) ? itemID.ClientHandle : null;
                }

                if ((filters & (int)ResultFilter.ItemTime) == 0)
                {
                    if (result.GetType() == typeof(ItemValueResult))
                    {
                        ((ItemValueResult)result).Timestamp          = DateTime.MinValue;
                        ((ItemValueResult)result).TimestampSpecified = false;
                    }
                }
            }

            return(results);
        }
Esempio n. 3
0
 /// <summary>
 /// Initializes the object with the specified item identifier.
 /// </summary>
 public ItemIdentifier(ItemIdentifier itemID)
 {
     if (itemID != null)
     {
         ItemPath     = itemID.ItemPath;
         ItemName     = itemID.ItemName;
         ClientHandle = itemID.ClientHandle;
         ServerHandle = itemID.ServerHandle;
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Initializes the object with and OpcItem object.
 /// </summary>
 public ItemValue(ItemIdentifier item)
 {
     if (item != null)
     {
         ItemName     = item.ItemName;
         ItemPath     = item.ItemPath;
         ClientHandle = item.ClientHandle;
         ServerHandle = item.ServerHandle;
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Creates a item result list from a set of items and sets the handles for use by the server.
        /// </summary>
        public ItemResult[] CreateItems(OpcItem[] items)
        {
            if (items == null)
            {
                return(null);
            }

            ItemResult[] results = new ItemResult[items.Length];

            for (int ii = 0; ii < items.Length; ii++)
            {
                // initialize result with the item
                results[ii] = new ItemResult((OpcItem)items[ii]);

                // lookup the cached identifier.
                ItemIdentifier itemID = this[items[ii].ServerHandle];

                if (itemID != null)
                {
                    results[ii].ItemName     = itemID.ItemName;
                    results[ii].ItemPath     = itemID.ItemName;
                    results[ii].ServerHandle = itemID.ServerHandle;

                    // update the client handle.
                    itemID.ClientHandle = items[ii].ClientHandle;
                }

                // check if handle not found.
                if (results[ii].ServerHandle == null)
                {
                    results[ii].ResultID       = ResultID.Da.E_INVALIDHANDLE;
                    results[ii].DiagnosticInfo = null;
                    continue;
                }

                // replace client handle with internal handle.
                results[ii].ClientHandle = items[ii].ServerHandle;
            }

            return(results);
        }
Esempio n. 6
0
 /// <summary>
 /// Initializes the object with an ItemIdentifier object and ResultID.
 /// </summary>
 public ItemResult(ItemIdentifier item, ResultID resultID)
     : base(item)
 {
     ResultID = ResultID;
 }
Esempio n. 7
0
 /// <summary>
 /// Initializes the object with an ItemIdentifier object.
 /// </summary>
 public ItemResult(ItemIdentifier item) : base(item)
 {
 }
Esempio n. 8
0
 /// <summary>
 /// Initializes the object with the specified ItemIdentifier, result code and diagnostic info.
 /// </summary>
 public ItemValueResult(ItemIdentifier item, ResultID resultID, string diagnosticInfo)
     : base(item)
 {
     ResultID       = resultID;
     DiagnosticInfo = diagnosticInfo;
 }