With this code you are only getting the server object, you are not connecting. To make the connection you need to call the connect method e.g.:
' gets the PI Server (PI Data Archive) Dim server = PIServer.FindPIServer(servername) If server = Nothing Then Throw New NullReferenceException("The specified PI Server could not be found") End If server.Connect()
Do you have enabled connections by trust or by windows authentication on the client?
(PI SDK Utility, Connections, Options)
Then make sure to add logging to your ACE application, so you understand what is happening.
Let us know if this helps,
Thanks Patrice Thivierge .
We already enabled debugging, and we are connecting via trust, so I think connect method explicitly is not needed.
Code is running fine and we are getting correct output, but we are still unable to understand the weird value of PI Data Archive as well as PI tag.
1 of 1 people found this helpful
If you are not calling the connect explicitely, the AF SDK will have to call it implicitely later on for you, and this is one of the reason that you see this message about side effect on you myPIserver object.
I would recommend to always call connect, even if the connection is already opened, AF SDK will just ignore the connect call it the server is already connected and there is no performance cost there.
What you are seeing is the debugger that is preventing the evaluation because that would lead to a function call and possibly modify your program behavior. The debugger does not know what the program is doing, imagine you move the mouse over a function that writes data and returns some text, each time you put your mouse over the function while debugging you would write data... If you want to see what those variable contains, I'd recommend you add a watch expression instead and force the refresh. For more details, you should loook at this article from Microsoft: Side Effects and Expressions.
Please let me know if this answers your question,
Excellent Patrice. It indeed answered our query.
There is reason we didn't do explicitly connect call. We observed that after adding connect call explicitly to PI Data Archive, more time has been spent in b/w ace code starts and fetching data.
I am glad this helped.
Regarding the connection: it is considered an expensive operation to connect to a server. There are a lot of things going on ( Network calls, Authentication, etc.).
If you look at the documentation, Connecting to a PI Data Archive, here is what is stated:
There are several methods for connecting to a PI Data Archive. The AF SDK will handle caching objects and connections to the server, therefore you should only close a connection when you are through using the server for a long period of time. This is different from typical programming against a database where you open a connect, get the data, and then close the connection.
This means you should keep you server object at a higher level in your application so it lives for the entire duration of the execution of your PI ACE application.
In your case, in VB.NET, you may create a global public MyServer variable in a Module and call the FindPIServer in the moduleDependantInitialization Method. This should be only called once.
Then, in your ACECalculation method, you should call MyServer .Connect() Each time it is called.. The first time it will take a little more time. But after the first connection, as the AF SDK will keep the connection in the cache, that will be very fast and the Connect() will be very fast. If I remember well, the connection stays cached for about 5 minutes (configurable).
Appreciate for taking time to detailing out info.
Can we consider the same in case of recalculation? Means it will connect only once in first evaluation and then onwards it won't connect again in another evaluation.
Our scenario is that we are doing recalculation and evaluations are almost 6,000,000. Will this approach helps in it?
Recalculation is going in the exact same code path, it occurs in the ACECalculations method. So in short yes.
Me.IsRecalculating should tell you when the current calculation is a recalculation.