1 Reply Latest reply on Jan 15, 2010 4:50 PM by spilon

    PIModuleDB and EventPipe


      Hello All!


      I've just tried to implement EventPipe OnNewValue handler. My task wask to catch all changes in MDB during COMTRADE file importing (with help of SISCO Comtrade Utility). I've sucessfully catched all events, but have found that I can't utilize this information -- all what I've catched, is Module that was changed. I've absolutely know that Module itself isn't changed during this process, but new PI Propertries are added to Module. I've hoped that I can figure out, which Properties has beed added to module, but I can't extract this information from PIEventObject object. My handler looks lite that (see below).


      I've receivied ten or more identical events, each says that the same PIModule has been changed, but I can't figure it out, which Property (or maybe Alias) was changed. Maybe it's another way to retrieve this information? Thank you!

      Private Sub ModuleDBUpdateHandler()
          Dim IPGR As PISDK.IPIGlobalRestorer
          Dim restorer As PISDKCommon.PIGlobalRestorer
          Dim e As PISDK.PIEventObject
          Dim m As PISDK.PIModule

          MessageLog(String.Format("AceComtradeClass.ModuleDBUpdateHandler: {0} events in queue", mdbEvents.Count))

          ' Create a restorer
          IPGR = sdk
          restorer = IPGR.Restorer

          ' while queue isn't empty
          While mdbEvents.Count > 0
              ' Retrieve next event
              e = mdbEvents.Take
              ' Restore module
              m = restorer.RestoreObject(e.PassivationString)

              MessageLog(String.Format("AceComtradeClass.ModuleDBUpdateHandler: {0} '{1}'", e.Action.ToString, m.Name))

              ' Process NamedValue
              For Each nv As PISDKCommon.NamedValue In e.EventData
                  MessageLog(String.Format("AceComtradeClass.ModuleDBUpdateHandler: {0} := {1}", nv.Name, nv.Value.ToString))
          End While
      End Sub

        • Re: PIModuleDB and EventPipe

          Unfortunately, the PIEventObject will not give you that information (i.e. which exact Property or Alias was added/renamed/deleted, etc.). As per the PI SDK Programming reference, the EventData property will return a NamedValues object containing the following, in the case of a PIModuleDB type of Event Pipe:

          • The unique ID (UID) of the PI Module;
          • Its effective date (EffectiveDate);
          • Its previous effective date, if applicable (OldEffectiveDate).

          The only way for you to determine what really happened on that PI Module, is to "restore" it using the PIEventObject's PassivationString and the PIGlobalRestorer (as you already do), and compare it with what you know was its previous configuration - you probably want to implement your own cache for that purpose (i.e. a collection of the "last known configuration" on the PI Modules you get notified for).


          That said, I suggest you contact our regular technical support and file this in as an enhancement request: adding information to the NamedValues collection that's passed to the PIEventObject.EventData, for a PIModuleDB type of Event Pipe.


          Hope this helps!