I am looking for suggestions to monitor batch events. In particular starts and stops of sub batches.
You could declare a PISDK.EventPipe object and set it to the EventPipe property of
Then all you need to do is consume the Events contained in the event pipe, using its Take or TakeAll methods. These methods return a PIEventObject and a SAFEARRAY of pointers to PIEventObject objects, respectively.
The PIEventObject then contains various properties such as EventData and PassivationString, which allow you to get more information on the related object and even re-create it.
The EventData seems to be quite complex - so finally I decided to use the PassivationString and the PIGlobalRestorer :
mBatch = (PISDK.PIBatch)mRestorer.RestoreObject(mEvent.PassivationString, null);
Using the PassivationString and the PIGlobalRestorer is a great way to recover the "changed" PIBatch or PIUnitBatch object. But depending on what your application is doing, you might only need the UniqueID for that object and using the EventData property would be a little faster/simpler.
The EventData property translates into a PISDKCommon.NamedValues object, a collection of PISDKCommon.NamedValue objects. The NamedValue object is pretty simple: it holds, well, a named value and has 2 main properties, Name and Value.
Here's a simple example of using the EventData to retrieve the object's UniqueID:
Dim myEvent As PISDK.PIEventObject Dim myEventData As PISDKCommon.NamedValues ' Build the EventPipe myEvent = myEventPipe.Take() nvsEventData = myEvent.EventData MessageBox.Show(nvsEventData("UID").Value.ToString())Note that the nature of the object contained in your PIEventObject object determines which named values you'll get in the EventData property. For instance, a PIBatch object would return UID and StartTime, whereas the PIUnitBatch object would return UID, PIUnit and StartTime.
Retrieving data ...