static void ReadTag(LogixProcessor processor) { //Reading a tag is very easy. First, create a tag... string address = GetTagAddress(); if (string.IsNullOrEmpty(address)) { return; } //Now we have to create the tag on the processor. The easiest way to //do this without knowing the underlying type is to use the //LogixTagFactory class. LogixTag userTag = LogixTagFactory.CreateTag(address, processor); if (userTag == null) { Console.WriteLine("Could not create the tag " + address + " on the processor"); return; } //The tag is automatically read when it is created. The LogixProcessor does this //to verify the tag exists and to get type information about the tag. From this //point on you can read/write the tag all you want, either by using tag groups //or by directly writing it with the LogixProcessor.WriteTag() function. //We'll demonstrate a read anyway... if (!processor.ReadTag(userTag)) { Console.WriteLine("Could not read the tag: " + userTag.LastError); } //Print the value out with our handy helper function PrintTagValue(userTag); //And go back to the main menu }
static void ReadTag(LogixProcessor processor) { //Reading a tag is very easy. First, create a tag... string address = GetTagAddress(); if (string.IsNullOrEmpty(address)) return; //Now we have to create the tag on the processor. The easiest way to //do this without knowing the underlying type is to use the //LogixTagFactory class. LogixTag userTag = LogixTagFactory.CreateTag(address, processor); if (userTag == null) { Console.WriteLine("Could not create the tag " + address + " on the processor"); return; } //The tag is automatically read when it is created. The LogixProcessor does this //to verify the tag exists and to get type information about the tag. From this //point on you can read/write the tag all you want, either by using tag groups //or by directly writing it with the LogixProcessor.WriteTag() function. //We'll demonstrate a read anyway... if (!processor.ReadTag(userTag)) Console.WriteLine("Could not read the tag: " + userTag.LastError); //Print the value out with our handy helper function PrintTagValue(userTag); //And go back to the main menu }