Exemplo n.º 1
0
        public List<Tag> ReadItems(List<Tag> itemList)
        {
            if (this.ConnectionState != ConnectionStates.Online)
            {
                throw new Exception("Can't read, the client is disconnected.");
            }

            List<Tag> tags = new List<Tag>();
            foreach (var item in itemList)
            {
                Tag tag = new Tag(item.ItemName);
                var result = client.Read(item.ItemName);
                if (result is ErrorCode && (ErrorCode)result != ErrorCode.NoError)
                {
                    throw new Exception(((ErrorCode)result).ToString() + "\n" + "Tag: " + tag.ItemName);
                }
                tag.ItemValue = result;
                tags.Add(tag);
            }
            return tags;
        }
Exemplo n.º 2
0
 public void Write(string name, object value)
 {
     if (plcDriver == null || plcDriver.ConnectionState != ConnectionStates.Online)
     {
         return;
     }
     Tag tag = new Tag(name, value);
     List<Tag> tagList = new List<Tag>();
     tagList.Add(tag);
     plcDriver.WriteItems(tagList);
 }