AnsweredAssumed Answered

Creating an AFEnumerationSet type PI Point data reference issue

Question asked by jmoretti on Jul 31, 2018
Latest reply on Aug 2, 2018 by Eugene Lee

I am trying to create a PI Point data reference attribute that is a value type Enumeration Set using AFSDK 2017R2.  I set the AFAttribute.Type to typeof(AFEnumerationSet) and I see it working correctly while debugging and examining the attribute using intellisense.  However, when I check the attribute in PSE, it is configured as an Integer type.  In my code below, I have an Enumeration Set configured named "State" with 4 values.  I'm creating the attribute as a child of the rootAttribute.   The first line in cmdCreate_Click produces the erroneous PI Point attribute with an Integer value type.  The odd thing is thing is that the second line creates the Formula data reference with the appropriate Enumeration Set type correctly.  Even if I follow up the first line with explicitly setting the Status attribute's Type and TypeQualifier to what the CreateAttribute method would, intellisense shows it correctly but when i see it in PSE it's an Integer.  Am I doing something wrong?

 

private void cmdCreate_Click(object sender, EventArgs e)
{
...
     CreateAttribute(rootAttribute, "Status", "The tank state output", typeof(OSIsoft.AF.Asset.AFEnumerationValue), "State", "PI Point", "\\\\%Server%\\%@|TagName%.%..|Attribute%.%Attribute%;ReadOnly=False;pointtype=Int32;compressing=0;excdev=0;excdevpercent=0;pointsource=L;step=1");
     CreateAttribute(rootAttribute, "Tank State", "The tank state input", typeof(OSIsoft.AF.Asset.AFEnumerationValue), "State", "Formula", "A=[0];stepped=True");
...
}

private AFAttribute CreateAttribute(AFAttribute parentAttribute, string name, string description, Type type, string enumerationSet = null, string dataReferenceName = null, string configString = null, string uom = null)
        {
            AFAttribute newAttribute = parentAttribute.Attributes.Add(name);
            newAttribute.Description = description;
            if (dataReferenceName != null && configString != null)
            {
                newAttribute.DataReferencePlugIn = parentAttribute.PISystem.DataReferencePlugIns[dataReferenceName];
                newAttribute.ConfigString = configString;
            }
            newAttribute.Type = type;
            if (enumerationSet != null)
            {
                newAttribute.TypeQualifier = parentAttribute.Database.EnumerationSets[enumerationSet];
            }
            else
            {
                if (type != typeof(String) && uom != null && parentAttribute.PISystem.UOMDatabase.UOMs.Contains(uom))
                {
                    newAttribute.DefaultUOM = parentAttribute.PISystem.UOMDatabase.UOMs[uom];
                }
            }
            newAttribute.IsConfigurationItem = true;
            return newAttribute;  //if i use intellisense to examine newAttribute.Type here, it shows AFEnumerationValue correctly
        }

Outcomes