2 Replies Latest reply on Nov 4, 2011 1:11 PM by eouseph

    Getting PIPoint attributes




      I am trying to get all the point attributes from a PI point. but all i get is the following four attributes only - descriptor, pointid, pointtype and tag. Could you point me in the right direction please? I am interested in the 'engunits' attribute. Thanks.


      ///Code snippet - start


       _PointListPtr piPointsList; 
       piPointsList = m_pServer->GetPoints(_com_util::ConvertStringToBSTR(filter.c_str()), NULL); 


       int count = piPointsList->Count;
       for (int i = 1; i <= count; ++i)
         _variant_t v = i;


         PIPointPtr point = piPointsList->Item[&v];
         _NamedValuesPtr nvsp(point->PointAttributes->GetAttributes());


         for (int j = 1; j <= nvsp->Count; ++j)
            _variant_t var = j;
            NamedValuePtr navp = nvsp->Item[&var];
            _bstr_t name = navp->Name;
            _variant_t value = navp->Value;


      ///Code snippet - end

        • Re: Getting PIPoint attributes

          Seems to be quite some interest in samples in other languages then C# and VB.NET


          I got a little C# snippet translated for you. To get the other point attributes you might want to take a look into the IGetPoints2 interface.


          Here is a code snippet using this, to extend it, just add more attributes to the named value collection:

               // Get the secondary interfaces
               IGetPoints2Ptr spIGP2;
               spIGP2 = spServer;
               // The collection of additional attributes
               _NamedValuesPtr spNVRetrieveAttr;
               _variant_t vb = true;
               _PointListPtr spPointsList;  
               spPointsList =     spIGP2->GetPoints2("tag='cdt*'", spNVretrieveAttr,useGetPoints,NULL,NULL,NULL);
               for (int iPoints=1; iPoints <= spPointsList->Count; iPoints++)
                    _variant_t vPoints = iPoints;
                    PIPointPtr point = spPointsList->GetItem(&vPoints);
                    _NamedValuesPtr spNVAttributes(point->PointAttributes->GetAttributes());
                    for (int iAttrs = 1; iAttrs <= spNVAttributes->Count; ++iAttrs)
                         _variant_t var = iAttrs;
                         NamedValuePtr navp = spNVAttributes->GetItem(&var);
                         _bstr_t name = navp->Name;
                         _variant_t value = navp->Value;