AlistairFrith

Getting tag info from Tag Data Reference attributes.

Discussion created by AlistairFrith on Dec 2, 2011
Latest reply on Dec 5, 2011 by cmanhard

Second time lucky since it ate the text the first time!

 

We have a C# function that returns the tagnames associated with each PIPoint data reference attribute of a given AF element. See below

 
public KeyValuePair[] ReturnElementTagReferences(AFElement e)
{
    List<> kvpl = new List<>();

    if (e != null)
    {
        try
        {
            foreach (AFAttribute at in e.Attributes)
            {
                if (at.DataReference != null)
                {
                    //PISDK.PIPoint p = (PISDK.PIPoint)at.RawPIPoint;
                    kvpl.Add(new KeyValuePair(at.Name, at.DataReference.ToString()));
                    if (p != null)
                        kvpl.Add(new KeyValuePair(at.Name.ToString(), p.Name.ToString()));
                }
            }
        }
        catch (Exception ex)
        {
            LogMessage("Error ReturnElementTagReferences : " + ex.Message + "\nSource: " + ex.Source + "\n" + ex.InnerException);
            kvpl = null;
        }
    }
    if (kvpl.Count > 0)
        return kvpl.ToArray();
    else
        return null;

}

 

 

This works fine when called from C# but when called from a VB.Net application, it returns tag names of the form

 

\\MyPIServer?d015c285-b527-4fbe-820f-a43c445d5e11\sinusoid

 

instead of the tag name that we see in C#. Interestingly, in VB the data reference Description property is "Unable to create the PISDK. PI Data References will not function." when called from VB.Net when it says "PI Tag" when called from C#.

 

Does anyone have any idea what is going on here?

 

--- Alistair.

 

 

 

<edit>

 

We have now created a separate VB.Net application to call this C# function and it works as expected. So it's not a difference between VB and C# but something in the real VB project is screwing this up!

 

</edit>

Outcomes