I've created some PI AF analysis and attributes to work out various performance percentages. For instance we look at the time per shift a parameter is within spec while the plant is online. I've created this filter expression as an attribute, and then use this within an analysis to return the timeeq to that attribute being true, and store this in a PI tag. However when I back check the results using Datalink I get different numbers. I've done a manual check (looking at a PI trend) and the manual check confirms what the Datalink result is giving me.
The calculation period is over 7 days, and I'm thinking that as I have only just created the attribute then the analysis can only look back as far as its creation date, but that doesn't seem to be the case when I put in some test tags. When I can create breakdowns of the calcs and I don't get results that I expect for 7days of data. I have a feeling its the way AF is handling the value types in the formula. The digital is down as "double" for the value type so when I create the attribute formula maybe AF doesn't handle things correctly. Here's what I've got;
PI tag 1 = power - value type double
PI tag2 = shift name - value type string
PI tag 3 = drive status (digital on/off) - value type is double
I convert PI tag 2 (shift name) to a number (Int16) as the formula can't handle a string input (or at least doesn't seem to) using a table and its stored as an Int16 value type.
I then assign them variable names A, B , C, (power, shift number, and drive status respectively)
the formula is...
if A >= 90 and B == 1 and C == 1 then 1 else 0. (If all the conditions are true then return 1, else 0)
This is then used by the analysis using timeeq('attribute filter', '*-7d','*',1) and is written to a PI tag to record the data. I've omitted the dividing function which gives the percentage value as I don't seem to even be able to get the first equation to give me the correct values.
I've tried parenthesis around the individual checks, and I've tried changing the value types. Am I missing something really stupid or does AF struggle with converting between digital on/off states to integers, or am I mixing value types that aren't compatible.
All help greatly appreciated!!