rdavin

AF.PI LoadAttributes clears cache?

Discussion created by rdavin Employee on Mar 21, 2013
Latest reply on Apr 1, 2013 by rdavin

I’ve been putting together a WinForms app that makes an AFOperations.FindPIPoints call to show the AF Tag Search dialog.  I load the returned List<PIPoint> into a data grid view that includes displaying the Descriptor and EngineeringUnits, which proves those PI point attributes are indeed in my local cache.  If I later click a certain command button, the app takes the List<PIPoint> and uses a little LINQ to filter on just those of PIPointType.Digital.  The filtered enumerated list is used to create a new PIPointList, which I then use to issue a PIPointList.LoadAttributes(PICommonPointAttributes.DigitalSetName) to load the DigitalSetName attribute into my cache so that I can later issue a PIPoint.GetAttribute(PICommonPointAttributes.DigitalSetName). 

 

All of that is working fine and dandy.  That after I load the DigitalSetName attribute into cache that the other attributes previously in cache (Descriptor and EngineeringUnits) are unloaded from cache for the subset of digital tags.  I was hoping that subsequent calls to LoadAttributes would have added to rather than completely replaced that point’s cache.

 

 

 
PIPointList SearchForTags(string piserverName, string tagFilter)
{
    IWin32Window window = this;
    bool bMultiSelect = true;
    bool bReturnEntireQuery = false;
    bool bOkayWithoutSelection = true;
    PIPointCriteria criteria = new PIPointCriteria();
    criteria.NameFilter = tagFilter;
    // The UI Dialog will be called and user may change filter.
    return new PIPointList(AFOperations.FindPIPoints(window, piserverName, bMultiSelect, 
                           bReturnEntireQuery, bOkayWithoutSelection, criteria));
}

void Example1()
{
    object piproperty = null;
    PIPointList points = SearchForTags("RicksServer", "3DTCW*");
    var digiFilter = from point in points where (point.PointType == PIPointType.Digital) select point;
    PIPointList digitals = new PIPointList(digiFilter);
    // This works so Descriptor must be cached.
    piproperty = digitals[0].GetAttribute(PICommonPointAttributes.Descriptor);
    // Load DigitalSetName
    digitals.LoadAttributes(PICommonPointAttributes.DigitalSetName);
    // This works
    piproperty = digitals[0].GetAttribute(PICommonPointAttributes.DigitalSetName);
    // But now this does not.  Descriptor is no longer in the cache.
    piproperty = digitals[0].GetAttribute(PICommonPointAttributes.Descriptor);
}

 

 

 While I’m at it, my overall app requires me to load a few extra attributes.  I naturally want Descriptor, EngineeringUnits, and PointType which are included in the FindPIPoints call.  I also want DigitalSetName, DataSecurity, and PointSecurity to name a few others.  It would be nice if I could have those attributes loaded by FindPIPoints.  I tried using this code, but it did not work.  An exception is thrown the instant I try to access GetAttribute(PICommonPointAttributes.DigitalSetName).  The exception tells me I haven’t loaded the DigitalSetName into cache, so that tells me the next bit of code doesn’t work as intended.

 

 

 
PIPointList SearchForTags2(string piserverName, string tagFilter)
{
    IWin32Window window = this;
    bool bMultiSelect = true;
    bool bReturnEntireQuery = false;
    bool bOkayWithoutSelection = true;
    PIPointCriteria criteria = new PIPointCriteria();
    criteria.NameFilter = tagFilter;
    // This doesn’t load the last 3.
    var propertyNames = new List(); 
    propertyNames.Add(PICommonPointAttributes.PointID);  
    propertyNames.Add(PICommonPointAttributes.PointType);  
    propertyNames.Add(PICommonPointAttributes.Descriptor);  
    propertyNames.Add(PICommonPointAttributes.EngineeringUnits);  
    propertyNames.Add(PICommonPointAttributes.DigitalSetName);  
    propertyNames.Add(PICommonPointAttributes.DataSecurity);  
    propertyNames.Add(PICommonPointAttributes.PointSecurity);  
    criteria.PIPointAttributes = propertyNames; 
    // The UI Dialog will be called and user may change filter.
   return new PIPointList(AFOperations.FindPIPoints(window, piserverName, bMultiSelect, bReturnEntireQuery, bOkayWithoutSelection, criteria));
} 

 

 

 

 

 I guess the questions I have for this thread are:

 

1)      Do others see the same behavior of the cache being cleared out on subsequent LoadAttributes calls?

 

2)      Is clearing the cache the intended behavior or might it be a bug?

 

3)      Am I not allowed to add PIPointAttributes for the PIPointCriteria for that overload?

 

Thanks. 

 

 

Outcomes