How to use value of a tag some seconds ago in an alarm?

This is my problem:

  1. I have tag A created. I want to check whether value of tag A is smaller or equal to the value of tag A ‘n’ seconds/samples ago.

  2. I have tag B. I want to check whether tag B’s value is between 200 and 1000 for more than 30 seconds.

  3. I plan to create a boolean tag C as an expression tag whose value will become 1 if both the above conditions become true.

  4. If the tag C value becomes 1, I want to issue an alarm.

However, I am having problem creating the first condition with tag A. How can I write an expression for tag C that will check if current value of tag A is smaller or equal to the the value of tag A 5 seconds/data samples ago?

Thanks,

Shreyas

I think you’ll have to write some scripting to pull out this value using something like system.tag.queryTagHistory and then use runScript to get its value.