Read group of tags "on demand"

Read group of tags "on demand"

Hello everybody,

I'm trying to read around 250 tags of different types (boolen, int, string, decimal... ) for 10 different PLCs. This values only need to read it when each PLC send a boolean signal. However, it are too much tags to keep it "advice" all the time. Also, at end of the year I will add another 10 PLCs with same amount of tags each one.

Is possible to put in "advice" the online variables container of each PLC when respective boolean signal change to TRUE, "on demand"? Already create the online container of each PLC inside if Active event handler, and also I created a event handler when boolean signal change then I check if the boolean signal is true to "advice" (.Define()) the online container, but all the tags return it that aren't Online when try to get the value of each one. When I try a second time and now the tags are online.

When I need "advice" the online containers?
Could use ".Undefine()" when I finish to process de tags in the online container? To not keep "advice" all containers
Is possible only "advice" when I need to read the values of the tags and then "unadvice" the tags? On demand
Are a steps to follow when "Define()" the online container in order to when try to get the value of tags already are online?

void ThisProject_Active()
{
myOnlineContainerSKID = this.OnlineVariables().CreateOnlineVariables("myOnlineVariablesSKID");
//procedure to read tags from a CSV file
string station = "2019101";
ReadVariablesfromFileToOnlineContainer(station);
mOCV = this.OnlineVariables().CreateOnlineVariables("testbool");
if (mOCV == null)
mOCV = this.OnlineVariables().CreateOnlineVariables("testbool");
mOCV.Add("testbool");
}
void mOCV_VariableChange(zenOn.IVariable obVar)
{
try
{
zenOn.IVariable tt = this.Variables().Item("testbool");
if (Convert.ToBoolean(tt.get_Value(0)))
{
myOnlineContainerSKID.Define();
tt.set_Value(0, false);
//Procedure to add the tags to array of IVariable and get each value
ReadVariablesfromFile(S_aname);
}
}
catch (Exception ex)
{
MessageBox.Show("No se pudo " + ex.Message);
throw;
}
throw new NotImplementedException();
}

At the moment I don't "Undefine()" the online container because the issue first try the tags aren't online.

Thanks in advance.




This is a migrated post! Originally posted on 15.07.2021 by user isays15. Please be aware that information can be outdated.