
Re: Running total of tags
xwang Oct 18, 2013 3:25 AM (in response to Darren.Metcalfe)Hi Darren,
I believe tagtot you used should be from PI PE function. However, in the description of this function in PEReference, it says this function is used to "Find the totalized value (time integral) of a point over a given time, according to values stored in the Archive." The red words, time integral, in the description means this function used timeweighted way to calculate total. If you need the eventweighted way to do the calculation, PI SDK / AF SDK function should be considered. Please see the help menu of PI SDK. The function is under PI DATA part named as Summary method.
Please see the following code as the reference:
PISDK.PISDK pi_sdk = new PISDK.PISDK(); Server pi_server = pi_sdk.Servers["WIN01ARJPPGTEJ"]; PIPoint point = pi_server.PIPoints["cdt158"]; PITimeFormat start_time = new PITimeFormat(); start_time.InputString = "*30d"; PITimeFormat end_time = new PITimeFormat(); end_time.InputString = "*"; PIValue value = point.Data.Summary(start_time, end_time, ArchiveSummaryTypeConstants.astTotal, CalculationBasisConstants.cbEventWeighted);
Xi Wang
vCampus team

Re: Running total of tags
hanyong Oct 18, 2013 3:44 AM (in response to xwang)Hi Darren,
As Xi mentioned, the tagtot() function is really finding the time integral value for the given time range based on the values stored in the archive for the tag. In layman's term, it is finding the area under the graph. So you want to consider for your total calculation, would timeweighted total be appropriate, or it is better to use an eventweighted total.
Xi gave a code snippet that will get eventweighted total in PI SDK. But If you are looking for something in PE syntax that will give that, there isn't a PE function that does that directly. You can do something like tagmean('tagname', '*30d', '*') * eventcount('tagname', '*30d', '*') instead
tagmean() function calculates the mean of the tag's value (in another words, the event weighted average), and multiplying it by count of events will give the total.
Another thing that you want to take note for timeweighted total calculation is conversion factor. Without the appropriate conversion factor setting, timeweighted total calculation results from tagtot function may give the wrong result. What this does and why we need to consider a conversion factor is explained in this video on our youtube learning channel.


Re: Running total of tags
ChrisDaycock Oct 18, 2013 1:21 PM (in response to Darren.Metcalfe)Darren,
This is from the help file,
Usage Note
The system chooses a scale factor such that the integral will be correct only if the flow is expressed in units per day. If the flow is expressed in units per hour, or per some other time unit, you must multiply this result by a conversion factor. The conversion factor equals the number of actual flow time units in a day.
For instance, if you totalize a point measured in gallons per minute, you must multiply the result of TagTot by 1440 to get the answer in gallons. This conversion factor is not related to the time period you are totalizing over; it is strictly a function of the point's engineering units.
It sounds to me like a conversion factor. If you are reading KWH then *24. Hope that helps
Chris

Re: Running total of tags
Darren.Metcalfe Oct 22, 2013 1:13 PM (in response to ChrisDaycock)Thanks all for your help. I have used the tagmean function (tagmean('tagname', '*30d', '*') * eventcount('tagname', '*30d', '*') as mentioned by Han and I'm getting the results I require. Once again thanks for your help.
