Simulate Demand Polling

This example simulates demand polling. In order for it to function, the following tags must be created.

TagDescription
Polled TagA polled tag with a collection interval of the longest period you want between raw samples. Do not enable collector or archive compression. This tag should point to the same source address as the UnsolicitedTag.
Unsolicited TagAn unsolicited tag with a 0 or 1 second collection interval. This tag ensures you will be notified whenever changes occur. This tag should point to the same source address as the PolledTag.
Combined TagAn unsolicited calculation tag that is triggered by either the Polled Tag or Unsolicited Tag, and combines the raw samples of both into a single tag. Use a 0 or 1 second collection interval and use the following formula:
dim timetag1 
dim timetag2 
dim tag1
dim tag2
Dim x
tag1 = "T20.di-1.F_CV"
tag2 = "t20.T20.DI-1.F_CV"
x = DateAdd("s", 1,CurrentTime) ' add 1 second to calc time
' Get the timestamp of the newest raw sample for tag1:
timetag1 = previousTime(tag1, x)
' Get the timestamp of the newest raw sample for tag2:
timetag2 = previousTime(tag2, x)
if timetag1 > timetag2 then
' If tag1 triggered me, then:
result = PreviousValue(tag1,CurrentTime)
else
' If tag2 triggered me, then:
result = PreviousValue(Tag1, CurrentTime)
end if