YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

PIAnnotations C#, need help Options · View
mrmot
#1 Posted : Thursday, March 11, 2010 2:10:32 PM
Rank: Newbie
Groups: Member

Joined: 6/5/2009
Posts: 3
Location: Serbia
Hi there,

I'm trying to add an Annotation into PIValue using PI SDK in C#. I've run some existing examples in VB and they are working. Now trying to do same in C# (I have to use C#).
Here is a code sample I'm trying with.
I'm having exception error on line 14 saying "Unable to add to a PIValues collection. Failed to clone ValueAttribute"
If I comment line 13 everything works fine, but there is no annotations in PIValue.
Line 13 doesn't compile if it's like "myVal.ValueAttributes.Add("annotations", ref myAnns);"

1. Server myServer;
2. PIPoint testTag;
3. PIAnnotationsClass myAnns = new PIAnnotationsClass();
4. PIValue myVal = new PIValue();
5. PITime valTim = new PITime();

6. myServer = oSDK.Servers["MYPIServer"];
7. testTag = myServer.PIPoints["SINUSOID"];
8. myAnns.Add("IntegerAnn", "Integer annotation", 1, false, "Integer");
9. valTim.SetToCurrent();

10. myVal.Value = valTim.UTCSeconds;
11. myVal.TimeStamp = valTim;
12. object objValue = myAnns;
13. myVal.ValueAttributes.Add("annotations", ref objValue);
14. testTag.Data.UpdateValue(myVal, valTim, DataMergeConstants.dmReplaceDuplicates, null);

Suggestions?

Thanks

Djuro
Sponsor  
 
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.