So, I have started writing my Data Reference to pull PI Tag attribute values into AF attributes. To familiarize myself with the AFSDK, first I wrote a little standalone forms program to do this - retrieve an attribute based on entered values for DA server, tag, and attribute name. It worked great.
However, I am writing the Data Reference now, and running into problems at the very end (and here's where my lack of experience with C# and the SDK collide).
So, I am using GetValue to write the result back to the attribute (because that's how it seems it has to be done based on the AF SDK youtube videos and from other things I've seen. However, the GetAttribute() call returns an Object. When I try to write back to the attribute, I get an error like:
Unable to cast object of type 'System.String' to type 'OSIsoft.AF.Asset.AFValue'.
However, that could be System.Single, System.Int, what have you. It depends on what the attribute is, naturally.
I am unsure how to get these to jibe properly.
Here is what I am doing (I cleared out some extraneous stuff that had nothing to do with this part.
The result below is declared as an Object, because if I declare is as an AFValue, the GetAttribute call won't play nice.
result = srchPoint.GetAttribute(srcAttribute);
return new AFValue(result);
Any suggestions would be grand.