private void Group_DataChange(object sender, DataChangeEventArgs eventArgs)
        {
            _itemAccessMutex.WaitOne();

            for (int i = 0; i < eventArgs.Status.Length; ++i)
            {
                try
                {
                    var itemProps = new Dictionary <string, string>();
                    var item      = _serverModel.GetItemFromClientHandle(eventArgs.Status[i].HandleClient);

                    itemProps.Add(ServerModel.ItemPropValueKey, OpcUtility.ValueToString(item.Type, eventArgs.Status[i].DataValue));
                    itemProps.Add(ServerModel.ItemPropQualityKey, OpcUtility.QualityToString(eventArgs.Status[i].Quality));
                    itemProps.Add(ServerModel.ItemPropTimestampKey, OpcUtility.TimeStampToString(eventArgs.Status[i].Timestamp));

                    _serverModel.UpdateItem(eventArgs.Status[i].HandleClient, itemProps);
                }
                catch (Exception ex)
                {
                    ErrorLog errorLog = ErrorLog.GetInstance();
                    errorLog.WriteToErrorLog(ex.Message, ex.StackTrace, "Error during OPC group update");
                }
            }

            _itemAccessMutex.ReleaseMutex();
        }
        public void ReadItems()
        {
            _itemAccessMutex.WaitOne();

            try
            {
                int            l_Index = 0;
                OpcItemState[] l_ItemStateArray;
                List <int>     l_ServerHandleList = _serverModel.GetServerHandleList();

                _group.Read(OpcDataSource.OPC_DS_DEVICE, l_ServerHandleList.ToArray(), out l_ItemStateArray);

                foreach (int l_ServerHandle in l_ServerHandleList)
                {
                    if (l_ItemStateArray[l_Index].Error == HResults.S_OK)
                    {
                        int l_ClientHandle = _serverModel.GetClientHandleFromServerHandle(l_ServerHandle);
                        Dictionary <string, string> l_ItemProps = new Dictionary <string, string>();
                        IOPCItem l_Item = _serverModel.GetItemFromClientHandle(l_ClientHandle);

                        l_ItemProps.Add(CModel.ServerModel.ItemPropValueKey, OpcUtility.ValueToString(l_Item.Type, l_ItemStateArray[l_Index].DataValue));
                        l_ItemProps.Add(CModel.ServerModel.ItemPropQualityKey, OpcUtility.QualityToString(l_ItemStateArray[l_Index].Quality));
                        l_ItemProps.Add(CModel.ServerModel.ItemPropTimestampKey, OpcUtility.TimeStampToString(l_ItemStateArray[l_Index].Timestamp));

                        _serverModel.UpdateItem(l_ClientHandle, l_ItemProps);
                    }

                    l_Index++;
                }
            }
            catch (Exception l_Ex)
            {
                Disconnect();

                throw l_Ex;
            }
            finally
            {
                _itemAccessMutex.ReleaseMutex();
            }
        }