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?
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 126.96.36.199. 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
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
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.
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 'Initiliaze 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. aceMDBFunctions_Helper.SetRefreshPIModuleToTrue() blnResult = aceMDBFunctions_Helper.ChangePIACEEMCStatus(modulePath, enuStatusCode.scOutOfService) 'Restart the context If blnResult Then aceMDBFunctions_Helper.SetACENet = True aceMDBFunctions_Helper.SetRefreshPIModuleToTrue() 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.