How can I use the historic’s Average() function?
Solution:
This function returns the average value of a set of data in the historic. The complete command is: Average (src, type, startTime [, endTime])
Where:
– src: name of the tag recorded in the historic.
– type: determines the time interval to be considered when calculating the average (0: year; 1: month; 2: week; 3: day; 4: hour; 5: minute).
– startTime: determines the average’s start time.
– endTime (optional): determines the average’s end time. If used, type parameter is ignored.
Example of script:
Hist1.Open()
resul = Hist1.Average(“tagDemo001”, 5, IniDate, FinDate)
Hist1.Close()
In this example, result, IniDate and FinDate (optional) are RAM tags, and tagDemo001 is the name of the Historic’s field whose average value must be calculated.