8 Replies Latest reply on Jun 5, 2017 8:04 AM by VijayaBhaskar Branched to a new discussion.

    A circular reference was detected in attribute

    VijayaBhaskar

      Hi All,

      We have a issue with my AF analytic calculation hope will find answer here,

      We are trying to implement a logic in AF Analytics where the analytic calculation should not hit the PI server if the certain condition meets and it should retain the last value but I am receiving error "Unused: A circular reference was detected in attribute 'TotalLoss'.".

      The TotalLoss is not a tag and we are planning to configure a tag for that because this value will be used on the run and no need to be archived.

       

      Please let me know how to resolve this issue and is there anyway we can implement better ?

       

        • Re: A circular reference was detected in attribute
          Rick Davin

          Hi Vijaya,

           

          The problem is in the expressions to define Loss your final else clause uses TotalLoss.  That's the circular reference.  You don't need the expression for Unused at all.  You should just map the output attribute for Loss to TotalLoss, and change the else 'TotalLoss' to be  else NoOutput().

          1 of 1 people found this helpful
            • Re: A circular reference was detected in attribute
              VijayaBhaskar

              Hi Rick,

              Thanks for your response but I think we cannot use the NoOutput() as it is not supported if we do not map to a Tag. I am receiving the below error when I tried your approach:

               

              Functions such as NoOutput are not supported unless all mapped outputs are configured to save output history.

               

              The TotalLoss is not a tag and we are not planning to implement for it.

               

              Note : typo by mistake in the first post I mentioned that we are planning to implement tag for TotalLoss attribute.

               

                • Re: A circular reference was detected in attribute
                  Rick Davin

                  You could introduce another expression before your Loss.

                   

                  Name: CurrentTotalLoss

                  Expression: 'TotalLoss'

                   

                  and then use CurrentTotalLoss in the expression for Loss.  If it still gives you a circular reference, try the making the expression for CurrentTotalLoss to be 'TotalLoss' + 0.

                    • Re: A circular reference was detected in attribute
                      VijayaBhaskar

                      Hi Rick,

                      It looks like circular reference issue is resolved with that work around ('TotalLoss' + 0) but getting another error , i think this has to do with some parsing , any clues?

                       

                      CurrentTotalLoss: Invalid operation: [Error] + [number]

                       

                       

                        • Re: A circular reference was detected in attribute
                          messingerj

                          You've still got some initial referencing issues here, by calling the value of 'TotalLoss' in your CurrentTotalLoss variable before you've written an output value to TotalLoss. I understand that your logic is to create an incrementing value here. What is the current value of 'TotalLoss'? At this stage I'm guessing it will be an error state ("No Data" or similar I expect), and thus the Invalid Operation error you are seeing.You could deal with this by using logic in CurrentTotalLoss such as:

                           

                          If Not BadVal('TotalLoss') Then 'TotalLoss' + 0 Else 0

                           

                          Or simply set an initial numeric value for 'TotalLoss'.

                          2 of 2 people found this helpful
                            • Re: A circular reference was detected in attribute
                              VijayaBhaskar

                              Hi John,

                              Thanks for your inputs , Yes I implemented the calculation as per the suggestion.

                              Here my requirement is not to create a increment value but to assign a new value (PI Read) when certain condition is met and do not assign any value when another condition is met.

                               

                              Regards

                              Vijay

                                • Re: A circular reference was detected in attribute
                                  Rick Davin

                                  Hi Vijaya,

                                   

                                  The problem is you have one attribute 'TotalLoss' that you want for both input and output.  Hence the circular reference.  Since that attribute is not a PIPoint, you can't use NoOutput() to not assign any value.  Therefore, you MUST assign something.  It's working for good numeric input but fails when its a digital state.  You can try to see if you can echo the same digital state:

                                   

                                  // Else clause probably going to create a circular reference later

                                  If Not BadVal('TotalLoss') Then 'TotalLoss' + 0 Else 'TotalLoss'

                                   

                                  You could get around this by issuing a standard digital state of your own:

                                   

                                  If Not BadVal('TotalLoss') Then 'TotalLoss' + 0 Else DigState("Calc Failed")

                                  2 of 2 people found this helpful