If I understand correctly, under normal circumstances you want the strategy to use the average of the two level sensors. If the difference between them ever exceeds 5% of full scale, you want the strategy only to use the sensor that an operator designates as reliable. Once the readings are back within range, the strategy resumes using the average.
I’m not sure how I would go about handling your alarm condition. How does the strategy know which of the two readings is reliable? How does the operator know? However, if you are able to answer those questions, it might make sense to implement this with a pointer. I’ve found that if PAC Display is involved in choosing what a pointer is supposed to reference, a pointer table makes it easier.
If you create the following tags:
aiLevel_Sensor_1 (your analog input point)
aiLevel_Sensor_2 (your analog input point)
fLevel_Sensor_Average (a float variable)
nLevel_Source_Index (an I32 variable)
pLevel_Reading (a pointer to a float variable)
ptLevel_Reading_Source (a pointer table)
Somewhere in your powerup chart, you would initialize the pointer table like this:
ptLevel_Reading_Source = &fLevel_Sensor_Average;
ptLevel_Reading_Source = &aiLevel_Sensor_1;
ptLevel_Reading_Source = &aiLevel_Sensor_2;
and you would initialize the pointer as well. If you want to use the average by default, that is element 0.
nLevel_Source_Index = 0;
pLevel_Reading = ptLevel_Reading_Source[nLevel_Source_Index];
Your strategy would have sections of code that includes the following:
Main flowchart activity that always looks at the pLevel_Reading pointer if it needs to know the level.
A continuously running flowchart that updates the fLevel_Sensor_Average tag by averaging the two analog inputs.
A continuously running flowchart that looks for changes to the nLevel_Source_Index tag and updates the pointer when detected.
The alarm handling section would change the nLevel_Source_Index based on rules you define, and default back to 0 whenever things are running well.
Your PAC Display program would allow the operator to choose which signal source to use, and the dynamic attribute would the send the corresponding value (0 for average, 1 for sensor 1, 2 for sensor 2) to the nLevel_Source_Index tag.