2 Replies Latest reply on Mar 24, 2009 4:14 PM by dhollebeek

    Progammatically changing Search criteria in PIBatch


      Im attempting to progammatically update the PIBatch Search criteria on an event.  Initially when there is nothing configured in the PIUnitBatch search the code below works.  Once the event happens once and there is a unit and product associated with the PIBatch it the code no longer updates the search criteria. 


      Any suggestions?


      Here is the code below:

      Private Sub UpdateBatchSearch()

        Dim theUnit As String

        theUnit = theClass.getUnitPath(LocationBox.Value)

        Dim y As New PIBatchSearch.SearchCriteria

        Set y = BatchGroup1.SearchCriteria

        y.BatchItemCriteria.AttributeType(0) = pibvUAttrBatchID
        y.BatchItemCriteria.AttributeMasksStr(0) = theUnit

        y.BatchItemCriteria.AttributeType(1) = pibvUAttrBatchID
        y.BatchItemCriteria.AttributeMasksStr(1) = ProductBox.Value

        BatchGroup1.SetSearchCriteria y, True

      End Sub
        • Re: Progammatically changing Search criteria in PIBatch

          @Chris.Wiseman: I think the problem lies in how you set your criteria's AttributeType property. Both are set to "pibvUAttrBatchID", which suggests you want to filter on the UnitBatch IDs (twice). If - as the rest of your code suggests - you want to filter on the UnitBatch's Unit and Product, then you should set y.BatchItemCriteria.AttributeType(0) = pibvUAttrUnitName and y.BatchItemCriteria.AttributeType(1) = pibvUAttrProduct. Make sure your UnitBatch ID filter is set to *, in Design mode.


          Let us know how it works!


          As a side note, you may have noticed PI BatchView is not provided as part of the vCampus Kit of PI Products; this is a voluntary omission, not a mistake. If you're wondering why, well it's simply because PI Batch is in the process of being replaced with Event Frames - and so are the PI Batch clients. With its focus on best practices, vCampus tries to make sure people don't develop applications that will become obsolete in a foreseeable future (or at least prevent them from doing so without the knowledge ).  vCampus (and the set of products available on vCampus) reflects OSIsoft's long-term vision in terms of how people should use and access PI technologies.

            • Re: Progammatically changing Search criteria in PIBatch

              I am by no means a Batch guru, but I ran into something that you might want to try.  Batch seems to work better if you do SetSearchCriteria(crit, FALSE) and then explicitly call ExecuteSearch().  I'm not sure exactly why this is, one of the Batch developers explained it to me at one point, but most of it went over my head.  Something to do with the fact that if the Search criteria changes is gets marked as non-active or something...