using System.Collections.Generic;
public static void Main()
List<ITag> tagList = new List<ITag>();
tagList.Add(new Tag("0", null, true));
tagList.Add(new Tag("1", null, true));
tagList.Add(new Tag("2", null, true));
tagList.Add(new Tag("3", null, true));
tagList.Add(new Tag("4", null, true));
Console.WriteLine("Tag list 1");
foreach (Tag t in tagList)
Console.WriteLine("Address: " + t.Address + ", Value: " + t.Value + ", Functional: " + t.Status);
PLCInterface2.setPLCTagValues(tagList);
string Address { get; set; }
string Value { get; set; }
bool Status { get; set; }
public string Address { get; set; }
public string Value { get; set; }
public bool Status { get; set; }
public Tag(string address, string val, bool status)
public class PLCInterface2
public static List<ITag> PLCTagList = new List<ITag>();
public static List<ITag> setPLCTagValues(List<ITag> tagList)
List<ITag> returnList = new List<ITag>();
foreach (ITag addTag in tagList)
if (!(PLCTagList.Exists(tag => tag.Address == addTag.Address)))
foreach (ITag UITag in tagList)
foreach (ITag PLCTag in PLCTagList)
if (UITag.Address == PLCTag.Address)
PLCTag.Value = UITag.Value;
foreach (ITag PLCTag in PLCTagList)
if (PLCTag.Value == null)
public static List<ITag> getPLCTagValues(List<ITag> tagList)
List<ITag> returnList = new List<ITag>();
foreach (ITag addTag in tagList)
if (!(PLCTagList.Exists(PLCTag => PLCTag.Address == addTag.Address)))
foreach (ITag PLCTag in PLCTagList)
if (PLCTag.Value == null)
foreach (ITag UITag in tagList)
foreach (ITag PLCTag in PLCTagList)
if (UITag.Address == PLCTag.Address)