I've been working on this myself, I think I've made some progress, but there is still something wrong with the code I have.
Code: PISDK.Server myServer; // server object from the name in server pick list
PISDK.IPIPoints2 IPIP2;
PISDKCommon.NamedValues nvsAddRemove = new PISDKCommon.NamedValues();
PISDKCommon.NamedValues nvsEdit = new PISDKCommon.NamedValues();
PISDKCommon.NamedValues nvsTagAttr = new PISDKCommon.NamedValues();
PISDKCommon.NamedValues nvsEditAttr1 = new PISDKCommon.NamedValues();
PISDKCommon.NamedValues nvsEditAttr2 = new PISDKCommon.NamedValues();
PISDKCommon.NamedValues nvsEditAttr3 = new PISDKCommon.NamedValues();
PISDKCommon.PIErrors myAddErrors = new PISDKCommon.PIErrors();
PISDK.PointList myPtList = new PISDK.PointList();
PISDKCommon.PIErrors myEditErrors = new PISDKCommon.PIErrors();
PISDKCommon.PIErrors myRemoveErrors = new PISDKCommon.PIErrors();
myServer = g_SDK2.Servers[servPickList2.SelectedServerName.ToString()];
IPIP2 = (PISDK.IPIPoints2)myServer.PIPoints;
object className = "classic";
object pointType = "pttypFloat32";
nvsTagAttr.Add("ptclassName", ref className);
nvsTagAttr.Add("pointtype", ref pointType);
object nvsTagAttr2 = nvsTagAttr;
nvsAddRemove.Add("TagName1", ref nvsTagAttr2);
nvsAddRemove.Add("TagName2", ref nvsTagAttr2);
nvsAddRemove.Add("TagName3", ref nvsTagAttr2);
IPIP2.AddTags(nvsAddRemove, out myAddErrors, out myPtList, null);
The problem I'm running into is there seems to be something wrong with my nvsAddRemove NamedValues Collection. Everytime I try to perform any operation on it I get an error of "Type mismatch" which really doesn't tell me anything. I think its a problem with the second argument in my NamedValues.Add method, in the VB example in the PISDK they had this:
Code:Dim myServer As Server
Dim IPIP2 As IPIPoints2 ' IPIPoints2 interface
Dim nvsAddRemove As New NamedValues ' NamedValues collection for adding and removing tags
Dim nvsEdit As New NamedValues ' NamedValues collection for editing tags
Dim nvsTagAttr As New NamedValues ' Add attributes for all tags
Dim nvsEditAttr1 As New NamedValues ' Edit attributes for tag 1
Dim nvsEditAttr2 As New NamedValues ' Edit attributes for tag 2
Dim nvsEditAttr3 As New NamedValues ' Edit attributes for tag 3
Dim myAddErrors As PIErrors ' errors collection for adding
Dim myPtList As PointList ' Point list returned from adding tags
Dim myEditErrors As PIErrors ' errors collection for editing
Dim myRemoveErrors As PIErrors ' errors collection for removing
'
' Get the server and the IPIPoints2 interface
'
Set myServer = PISDK.Servers.DefaultServer
Set IPIP2 = myServer.PIPoints
'
' Populate the tag attributes collection
'
nvsTagAttr.Add "ptclassName", "classic"
nvsTagAttr.Add "pointtype", pttypFloat32
'
' Add three tags with these attributes
'
nvsAddRemove.Add "AER1", nvsTagAttr
nvsAddRemove.Add "AER2", nvsTagAttr
nvsAddRemove.Add "AER3", nvsTagAttr
IPIP2.AddTags nvsAddRemove, myAddErrors, myPtList
Here they clearly just reference the NamedValues collection itself, whereas I have to assign it to an object and reference that object or else the compiler won't shut up. So I figure its either something wrong with that portion of the code or its something wrong with the way I assign the IPIPoints2 object, in VB they assign it as such:
Code:Set IPIP2 = myServer.PIPoints
whereas I have to cast it as well otherwise the compiler won't compile.
Code:IPIP2 = (PISDK.IPIPoints2)myServer.PIPoints;
Hoping someone can catch my mistake, any help is much appreciated.
Thank you,
Michael