2 Replies Latest reply on Sep 2, 2015 6:05 PM by SvenBatalla

    What is the PI performance equation syntax equivalent to this Analytics expression?

    SvenBatalla

      I have built an Analytics expression that works great for my needs in AF but does not work when used in the FilteredSummaries call.  I get an error citing an invalid PI performance equation.  The expression is below (in C#):

       

      @"(BadVal('Is Masked') OR 'Is Masked' = false) AND Not(BadVal('Source Tag')) AND Compare(Concat(""*|"", 'Source Tag', ""|*""), Concat(""|"", 'Abnormal States', ""|""), false)"
      

       

      As you may be able to guess from the contents of the expression, I have an element with 3 relevant attributes that are all PI tags:

       

      Element

      |- Abnormal States

      |- Is Masked

      |- Source Tag

      :

       

      The "Abnormal States" attribute is a string tag that contains a pipe-delimited list of possible digital states.  For example, "Phase1|Phase3".

      The "Is Masked" attribute is a Boolean tag (well, int) that will only ever be true, false, or bad.

      The "Source Tag" attribute is a digital tag.

       

      The expression (which again works in AF) first checks if the "Is Masked" tag is bad or false.  This indicates that the calculation is NOT masked and can resume.  Next, the calculation makes sure the value in the "Source Tag" attribute is good.  If all is well to this point, that's where the action happens...  First, the value of the "Source Tag" attribute is wrapped with pipes.  So if the value is "Phase1", the string "|Phase1|" is constructed.  Next, the value of the "Abnormal States" tag is read and wrapped with pipes as well.  So if we use that example from before, the string "|Phase1|Phase3|" would be constructed.  Finally, the source string is compared to the state string (case insensitive).  So the expression breaks down like this:

       

      // Assume:
      //  - Is Masked: false
      //  - Source Tag: Phase1
      //  - Abnormal States: Phase1|Phase3
      //
      // Then:
      //
      // (BadVal('Is Masked') OR 'Is Masked' = false) AND Not(BadVal('Source Tag')) AND Compare(Concat("*|", 'Source Tag', "|*"), Concat("|", 'Abnormal States', "|"), false)
      // (BadVal(false) OR false = false) AND Not(BadVal("Phase1")) AND Compare(Concat("*|", "Phase1", "|*"), Concat("|", "Phase1|Phase3", "|"), false)
      // (BadVal(false) OR false = false) AND Not(BadVal("Phase1")) AND Compare(Concat("*|Phase1|*"), Concat("|Phase1|Phase3|"), false)
      // (false OR true) AND Not(false) AND Compare(Concat("*|Phase1|*"), Concat("|Phase1|Phase3|"), false)
      // (true) AND true AND Compare(Concat("*|Phase1|*"), Concat("|Phase1|Phase3|"), false)
      // true AND true AND true
      // true
      

       

      If the expression evaluates to a positive result, the FilteredSummaries call I've implemented will count the value from the "Source Tag" attribute.  My goal is to count all the values in a given time range that meet the expectations of this expression.

        • Re: What is the PI performance equation syntax equivalent to this Analytics expression?
          stang

          Hi Sven,

           

          After some testing I've confirmed that the problem comes from the part of the expression that tests against a boolean. If you replace = false with = 0, it will evaluate. However, the tricky thing is that 0 does not appear to equate to false. I tried using an expression that evaluates to false, like (1=0), but that doesn't seem to work either with AF SDK, although it does work in the analysis. Unfortunately I have run out of time here, but if you haven't fixed this by tomorrow I will see what I can come up with.

          1 of 1 people found this helpful
            • Re: What is the PI performance equation syntax equivalent to this Analytics expression?
              SvenBatalla

              Thanks for looking into this.  I can tell you that I changed my expression to this:

               

              (BadVal('Is Masked') OR 'Is Masked' = 0) AND Not(BadVal('Source Tag')) AND Compare(Concat("*|", 'Source Tag', "|*"), Concat("|", 'Abnormal States', "|"), false)
                                                    ^
              

               

              And it didn't work.  But...  When I changed it to this:

               

              (BadVal('Is Masked') OR 'Is Masked' = 0) AND Not(BadVal('Source Tag')) AND Compare(Concat("*|", 'Source Tag', "|*"), Concat("|", 'Abnormal States', "|"), 0)
                                                                                                                                                                        ^
              

               

              It worked!  So it looks like any instance of the word "false" confuses the engine.  Just doing some final testing.  If all goes well, your answer will be marked as the correct one.  Thanks!

              1 of 1 people found this helpful