14 Replies Latest reply on Oct 6, 2015 8:17 PM by Rhys Kirk

    Start/Stop PSE Analysis using Processbook VBA

    Argel

      Hello everyone,

       

      Is there a way or a VBA code where you can start/stop an analysis in PI System Explorer from Processbook?

       

      Thanks!

        • Re: Start/Stop PSE Analysis using Processbook VBA
          Roger Palmen

          In short: No, not directly.

          A workaround i can think of is that you write to a triggering PI Point from ProcessBook, and have that trigger your analysis.

           

          There are some experimental efforts (and successes) to control the Analytics engine from code, but as long as that's not supported by OSIsoft in any way i would not recommend you go down that route.

            • Re: Start/Stop PSE Analysis using Processbook VBA
              Argel

              Thanks. How can I do the workaround? Do you have a sample code?

                • Re: Start/Stop PSE Analysis using Processbook VBA
                  Eugene Lee

                  Hi Argel,

                   

                  You can use PI SDK in Processbook to send a value to the PI Data Archive. Here is an example.

                   

                  Tag = "cdt158"
                  Servers.DefaultServer.PIPoints(Tag).Data.UpdateValue 999, "*"
                  

                   

                  In this example, my triggering tag is 'cdt158' and i am sending the value 999 at a timestamp of current time.

                    • Re: Start/Stop PSE Analysis using Processbook VBA
                      Argel

                      Thank you, I think I could use that as well but here is what I'm trying to do.

                       

                      I have a Read/Write tag in OPC (by using the address K0000-K9999) in the OPC Server.


                      I created an attribute in PSE which uses that tag.

                       

                      I write values on that tag based on the results on my analysis>expression in PSE.

                       

                      What I'm trying to do is a decrementing value based on whatever number I write on the WT0001.R. (eg. if I write 10, every 10s, it decrements to 9..8...)

                       

                       

                      analysis expression.jpg

                       

                      The problem is when I want to write value on that tag while the analysis is running (e.g. I write 100, instead of decrementing to 99, it will continue to 7..6...5..)

                       

                      So I need to first stop the analysis, write the value, then start again.


                      I am using that attribute on my Processbook display.

                       

                      I want to be able to stop the analysis, write the value, then start again the analysis in processbook.

                       

                      Is that possible?

                        • Re: Start/Stop PSE Analysis using Processbook VBA
                          Rhys Kirk

                          Argel Tolentino:

                           

                          Thank you, I think I could use that as well but here is what I'm trying to do.

                           

                          I have a Read/Write tag in OPC (by using the address K0000-K9999) in the OPC Server.


                          I created an attribute in PSE which uses that tag.

                           

                          I write values on that tag based on the results on my analysis>expression in PSE.

                           

                          What I'm trying to do is a decrementing value based on whatever number I write on the WT0001.R. (eg. if I write 10, every 10s, it decrements to 9..8...)

                           

                           

                          analysis expression.jpg

                           

                          The problem is when I want to write value on that tag while the analysis is running (e.g. I write 100, instead of decrementing to 99, it will continue to 7..6...5..)

                           

                          So I need to first stop the analysis, write the value, then start again.


                          I am using that attribute on my Processbook display.

                           

                          I want to be able to stop the analysis, write the value, then start again the analysis in processbook.

                           

                          Is that possible?

                          Use an AF Attribute which is a Boolean as to whether the Analysis should decrement or not, very simple.

                          Your analysis could then be as simple as:

                           

                          if 'RunDecrement' = 1 then 'WT0001.R' - 1 else NoOutput()
                          

                           

                          Then you simply update your counter starting value and the RunDecrement attribute to 1 when you want to run the analysis. You can use the AF Wrapper to write directly to an AF Attribute, or have a PI Point behind the RunDecrement attribute.

                           

                          Edit: And I should mention that you could then even pre-determine a future decrement countdown using future PI Points (it works ).

                          2 of 2 people found this helpful
                      • Re: Start/Stop PSE Analysis using Processbook VBA
                        Kenji Hashimoto

                        I believe PI Asset Analyses could not start/stop by PI tag value. If you want to change the results of Analyses by PI Point value, you can use if then else syntax in Analyses > Expression.

                        PI Asset Analyses status information is in Microsoft SQL (PIPC database).Though OSISoft does not recommend to change the value from SQL directly.

                        KB01254 - Direct reading or manipulation of the PI AF SQL Database (PIFD) is not supported

                        Basically Analyses should always run. (Like PE tags)

                        What is your use case for stop/start analyses by PI ProcessBook?

                          • Re: Start/Stop PSE Analysis using Processbook VBA
                            Roger Palmen

                            Yes, you're right that PI Asset Analysis in itself cannot be started or stopped, but the workaround is to trigger the execution of a natural scheduled Analysis through a PI Point.

                             

                            I agee that some idea of the use case would be helpful! We might be able to find different approaches.

                            • Re: Start/Stop PSE Analysis using Processbook VBA
                              Argel

                              Thank you for your response, I think i need to be clear on what I'm trying to do.

                               

                              I have a Read/Write tag in OPC (by using the address K0000-K9999) in the OPC Server.


                              I created an attribute in PSE which uses that tag.

                               

                              I write values on that tag based on the results on my analysis>expression in PSE.

                               

                              What I'm trying to do is a decrementing value based on whatever number I write on the WT0001.R. (eg. if I write 10, every 10s, it decrements to 9..8...)

                               

                               

                              analysis expression.jpg

                               

                              The problem is when I want to write value on that tag while the analysis is running (e.g. I write 100, instead of decrementing to 99, it will continue to 7..6...5..)

                               

                              So I need to first stop the analysis, write the value, then start again.


                              I am using that attribute on my Processbook display.

                               

                              I want to be able to stop the analysis, write the value, then start again the analysis in processbook.

                               

                              Is that possible?

                                • Re: Start/Stop PSE Analysis using Processbook VBA
                                  Roger Palmen

                                  Assumingh this is an analysis with a periodic trigger (every 10s), it's still tricky to write to the output itself. Without diving into the timing, you coudl try and solve this by looking at the previous value of the PI Point, but that won't create easy to understand expression logic.

                                   

                                  I'd recommed to use a second AF attribute (does not need to be a PI Point) to set the new value. Next use some logic in the expression to take the new value from the AF attribute and write that into the PI Point 'WT0001.R', and reset the new value in the AF attribute to 0 or another fixed value indicating it was not set by the user. That way you at least get way from the difficulties of using the output of the PI Point as the input and writing directly to it.

                                  • Re: Start/Stop PSE Analysis using Processbook VBA
                                    gregor

                                    Hello Argel,

                                     

                                    The problem is when I want to write value on that tag while the analysis is running (e.g. I write 100, instead of decrementing to 99, it will continue to 7..6...5..)

                                     

                                    Have you verified if your attempt updating the point with a value of 100 fails e.g. because the point is locked against updates because updates from Asset Based Analytics are buffered through PI Buffer Subsystem?

                                    It's always kind of tricky writing to a single point from different sources.