Daniel Takara

accessing PIProperties of PIModule of context where ACE calculation is running

Discussion created by Daniel Takara on Jul 26, 2009
Latest reply on Jun 26, 2014 by Dan Fishman

Hi,

I need to get the values of PIProperties of the PIModule of the context where an ACE 2.x calculation is running. I've been doing this using the non-documented PIACENetInternalFunctions.PIACEMDBFunctions.GetContextName function:

Dim contextPIModuleFullName As String
Dim contextPIModule As PIModule
Dim limiteCorrente As Double
Dim limiteTensao As Double
'(...)
contextPIModuleFullName = PIACENetInternalFunctions.PIACEMDBFunctions.GetContextName(Name)
contextPIModule = myServer.PIModuleDB.PIModules(ParseModuleName(contextPIModuleFullName))
limiteTensao = contextPIModule.PIProperties("LimiteTensaoOperacao").Value
limiteCorrente = contextPIModule.PIProperties("LimiteCorrenteOperacao").Value


However, the PIACENetInternalFunctions.PIACEMDBFunctions.GetContextName function returns a string that is the full path of the context (containing the server name, as in  \\SERVERNAME\RootPIModule\PIModuleLevel1\PIModuleLevel2) and, therefore, I need to remove the server name from it (using the auxiliary function below), so that I get a string (such as \RootPIModule\PIModuleLevel1\PIModuleLevel2) that I can pass as index to the myServer.PIModuleDB.PIModules collection, in order to get a handle of the corresponding PI-SDK PIModule object:

Function ParseModuleName(ByVal MyModuleName As String) As String
   Dim SearchChar As String
   Dim MyPos As Integer
   SearchChar = "\"
   MyPos = InStr(3, MyModuleName, SearchChar, vbTextCompare)
   ParseModuleName = Right$(MyModuleName, Len(MyModuleName) - MyPos + 1)
End Function


Is anyone aware of any ACE function that returns straight a handle of the PIModule of the context where the ACE calculation is running?

Outcomes