4 Replies Latest reply on May 27, 2015 6:27 PM by dng

    ACE Contexts - Programatically created, but can't get calculations to start programatically




      I'm working on some code that creates ACE contexts programatically, directly in the MDB. This has been done for a long time and works fine. The issue is, the calculations only begin if we go into the ACE Manager manually and change the Status from On or Off to Out of Service, then Resume. There is nothing wrong with the calculations, they have functioned for years.


      I've carefully read all the similar posts about this and the warnings that this is not officially supported. I observed that the ACE libraries have been changed as of version 2.1.50, and these are the ones I'm trying to use, but the methods are different than what has been posted in the past.


      The main problem I'm having is specifying the path for the ACE methods. I can't seem to retrieve a module, and until I can do this, I will not be able to use the method that should change the Status correctly.


      In the MDB, I have a path like this:


      %OSI\ACEClassLibraries\BCMS_Rack\Rack_ONEToEightCircuit\Bay IDC1 - 1st Floor_BY1F01C01-AH010


      Using PI SDK, I can access the module just fine (or create them or delete them, etc.) when logged into the PI server. The Name property of the module is: \\by2\BCMS_BY1\Bay IDC1 - 1st Floor\Racks\BY1F01C01-AH010


      In ACE Manager, the same context object has a path like this:

      by2.default\BCMS_Rack\Rack_ONEToEightCircuit\\\by2\BCMS_BY1\Bay IDC1 - 1st Floor\Racks\BY1F01C01-AH010


      I have tried every conceivable combination in the method PIACEMDBFunctions.GetPIACEModule(aceModulePath). If I can't access the module this way, then I'm not going to be able to reference the context using the PIACEMDBFunctions.ChangePIACEEMCStatus(modulePath, newStatus) method, which is my primary goal to see if I can programatically get the calculations to start.


      Any help in determining what the path for the ACE methods needs to look like would be greatly appreciated!





        • Re: ACE Contexts - Programatically created, but can't get calculations to start programatically

          Hi Stephen,


          The modulePath that the ChangePIACEEMCStatus method takes the form of:

          • For version 2.1.12 to 2.1.32: <PI Server>\<Module (exe or dll)>\<class>\<context> where the context parameter is the full path to reach a particular module in the PI Module Database.
          • For version 2.1.50 or later: <Server>\<scheduler>\<Module (exe or dll)>\<class>\<context> where the <scheduler> parameter can be the name of the machine used for scheduling or the keyword default that will tell to use the default scheduling machine configured for PI ACE.


          Can you test the second format to see if it works in your application?

            • Re: ACE Contexts - Programatically created, but can't get calculations to start programatically

              Hi Daphne,


              Thanks for the reply. Sorry, I marked your reply as Correct Answer by accident. But, I hope to be able to do so soon!


              To confirm, the ACE Servers are running version I say serverS (plural) because the scheduler is running on a server called BAYDCSACE01, while the contexts exist on an ACE Server called BY2DCSACE01. In ACE Manager, on either server, upper most item in the tree, I assume the server level, is called by2, which matches the name of the PI collective of two PI servers.


              Just to see if the server, module (exe or dll), class and context items are being interpreted correctly from the modulePath string I'm creating, in a test app, I am calling the methods:






              To test that the modulePath is correct, I am also calling the methods PIACEMDBFunctions.GetPIACEModule(modulePath) and PIACEBIFunctions.GetPIModuleFromPath(modulePath), but neither so far have successfully returned a PIModule object no matter what variation of modulePath I try. I also call ChangePIACEEMCStatus(modulePath, (short) newStatus) but it always returns false and makes no change to the Status. Prior to calling these methods, I call PIACEMDBFunctions.SetRefreshPIModuleToTrue(), which from other posts, seems to be necessary.


              Choosing a path (a more simple path than I first mentioned) that in the ACE Manager looks like this when the Contexts node in the tree is selected:

              by2.default\BCMS\Circuit_OnePole\\\by2\BCMS_BY1\Bay IDC1 - 1st Floor\Circuits\1-3A.03


              I formatted the modulePath string as you suggested like so: by2\BAYDCSACE01\BCMS\Circuit_OnePole\\\by2\BCMS_BY1\Bay IDC1 - 1st Floor\Circuits\1-3A.03


              When I run the test app, the modulePath is exactly the same as typed in: by2\BAYDCSACE01\BCMS\Circuit_OnePole\\\by2\BCMS_BY1\Bay IDC1 - 1st Floor\Circuits\1-3A.03


              The methods return:

              Server Name: by2

              EXE/DLL Name:BAYDCSACE01

              Module Name:BCMS

              Context Name: Circuit_OnePole\\\by2\BCMS_BY1\Bay IDC1 - 1st Floor\Circuits\1-3A.03


              Obviously the EXE/DLL Name and Context Name are wrong. BTW, there is no GetSchedulerName() method in the library.


              If I take out the <scheduler> section, I get:

              Server Name: by2

              EXE/DLL Name:BCMS

              Module Name:Circuit_OnePole

              Context Name: \\by2\BCMS_BY1\Bay IDC1 - 1st Floor\Circuits\1-3A.03


              This looks right, but still, the code does not return a PIModule object and the status setting method still returns false and the Status is not changed.


              Sorry about being so wordy, but I hope the detail helps to resolve the problem. If you could, using the ACE Manager path above, provide the exact format of the modulePath string, perhaps that will help. But I feel there is something else not right.


              Thanks again,



                • Re: ACE Contexts - Programatically created, but can't get calculations to start programatically

                  Hi Stephen,


                  I am currently working on your issue. Can you send me a screenshot from your ACE manager with the context expanded? e.g.

                  2015-05-27 13_04_41-DNG-CODE - Remote Desktop Connection Manager v2.2.png

                  • Re: ACE Contexts - Programatically created, but can't get calculations to start programatically

                    Hi Stephen,


                    I have tested your scenario, and have achieved some success. Things that I changed to make my environment working:

                    • If you are using the default scheduler (see my ACE manager screenshot above), try setting the scheduler as default (instead of the name of your ACE scheduler machine)
                    • Before calling PIACEModuleDBFunctions.ChangePIACEEMCStatus, call PIACEModuleDBFunctions.SetACENet = True and PIACEModuleDBFunctions.SetRefreshPIModuleToTrue() (to make sure everyone is aware of the new PI ACE status).


                    The full code is as follows:

                            Dim blnResult As Boolean
                            Dim strServer As String
                            Dim strScheduler As String
                            Dim strACEExe As String
                            Dim strClass As String
                            Dim strContext As String
                            Dim modulePath As String
                            strServer = "DNG-PI2012"
                            strScheduler = "default"
                            'strScheduler = "DNG-CODE"
                            strACEExe = "ModuleInit"
                            strClass = "Test"
                            strContext = String.Concat("\\", strServer, "\", "Test", "\", "Child1")
                            'Generate the Full Context Path 
                            modulePath = String.Concat(strServer, "\", strScheduler, "\", strACEExe, "\", strClass, "\", strContext)
                            'Stop the context  
                            aceMDBFunctions_Helper.SetACENet = True 'If you need to restart a 1.X module skip that command. 
                            blnResult = aceMDBFunctions_Helper.ChangePIACEEMCStatus(modulePath, enuStatusCode.scOutOfService)
                            'Restart the context 
                            If blnResult Then
                                aceMDBFunctions_Helper.SetACENet = True
                                blnResult = aceMDBFunctions_Helper.ChangePIACEEMCStatus(modulePath, enuStatusCode.scOff)
                            End If


                    Hope it helps. Let me know if you were able to achieve success with the above changes.