Nightf1y wrote:You need to do the following...
add...
using Interfaces.Tag;
and then access the tag as below.
((IBasicTag)Globals.Tags.Auto_BatchEndOkToSaveData).Read();
Regards
Hi Nightf1y
I am using below script to get dynamic tag value
public string Str2Tags(string TagName)
{
//string to tagName and get relative value, if unavilable return NaN
string strb;
try
{
double bb = double.Parse(getVal(TagName).Value.ToString());
strb = bb.ToString("0.##");
return strb;
}
catch(Exception)
{
return "NaN";
}
}
public static T StringToTag<T>(string tagName) where T : class
{
Type type = typeof(T);
FieldInfo[] props = Globals.Tags.GetType().GetFields();
foreach (FieldInfo prop in props) {
if (prop.FieldType.Equals(type)) {
if (prop.Name.Equals(tagName, StringComparison.CurrentCultureIgnoreCase)) {
return (T)prop.GetValue(Globals.Tags);
}
}
}
return null;
}
public VariantValue getVal(string tagName)
{
GlobalDataItem GDI = StringToTag<GlobalDataItem>(tagName);
if (GDI == null)
{
LightweightTag LWT = StringToTag<LightweightTag>(tagName);
if (LWT == null)
return null;
else
{
return LWT.Value;
}
}
else
{
GDI.Read();
return GDI.Value;
}
}
I used GDI.Read(); to get actual value in plc. But I don't know how to get LWT value when screen is not openned which has lightweighttag.