Hi Eduardo.
It looks like I now have both Node and Point configuration working correctly within the Client.Startup script.
I am now configuring the device Node(s) using the same method you demonstrated for device Points. This still took some time to get going correctly. For example, I found that Node configuration needed to take place following point configuration, as when the order is reversed Node configuration was not persistent.
I’m hoping that the method I’ve described also sounds correct to you … and isn’t just working due to an undocumented system quirk This is what the code now looks like:
'------------------------------------------------------------------------------------
'POINT CONFIGURATION
'------------------------------------------------------------------------------------
Dim [Error] As String = “”
Dim Nodes As DataTable = TK.ProjectDB.GetDataTable(“EditDevicesNodes”, Nothing)
Dim NodeName As String = TK.ConvertTo(Of String)(nodes.Rows(0)(“Name”))
‘Clean EditDevicePoints table
Dim Points As DataTable = TK.ProjectDB.GetDataTable(“EditDevicesPoints”, “Node='Node.” + nodeName + "’")
If Points.Rows.Count = 0 Then
Return
End If
Dim PointsDel As New List(Of System.Data.DataRow)()
Dim pr as System.Data.DataRow
For Each pr In Points.Rows
pr.Delete()
PointsDel.Add(pr)
Next
TK.ProjectDB.UpdateDataRows(“EditDevicesPoints”, PointsDel.ToArray(), [Error])
Dim PointsTotal As Integer = 1
Dim PointRows As System.Data.DataRow() = TK.ProjectDB.NewDataRows(“EditDevicesPoints”, PointsTotal)
For i As Integer = 0 To PointsTotal - 1
PointRows(i)(“ID”) = i
PointRows(i)(“TagName”) = “load”
PointRows(i)(“Node”) = “Node.Load1”
PointRows(i)(“Address”) = @Tag.load_defn(0, “dccardno”).ToString()
PointRows(i)(“DataType”) = 12
PointRows(i)(“AccessType”) = “AccessType.FastRead”
PointRows(i)(“Modifiers”) = “WordSwap=True”
Next
TK.ProjectDB.UpdateDataRows(“EditDevicesPoints”, PointRows, [Error])
'------------------------------------------------------------------------------------
'NODE CONFIGURATION
'------------------------------------------------------------------------------------
If Nodes.Rows.Count = 0 Then
Return
End If
Dim NodesDel As New List(Of System.Data.DataRow)()
Dim nr as System.Data.DataRow
For Each nr In Nodes.Rows
nr.Delete()
NodesDel.Add(nr)
Next
TK.ProjectDB.UpdateDataRows(“EditDevicesNodes”, NodesDel.ToArray(), [Error])
Dim NodesTotal As Integer = 1
Dim NodeRows As System.Data.DataRow() = TK.ProjectDB.NewDataRows(“EditDevicesNodes”, NodesTotal)
For i As Integer = 0 To NodesTotal - 1
NodeRows(i)(“Name”) = “Load1”
NodeRows(i)(“Channel”) = “OPTO22”
NodeRows(i)(“PrimaryStation”) = @Tag.teststation(0, “micrometer3”)
Next
TK.ProjectDB.UpdateDataRows(“EditDevicesNodes”, NodeRows, [Error])
TK.ProjectDB.ApplyProjectChanges()
The code will be further refined as, for example, there are currently unnecessary/incorrect For loops within the code. These may be refined or removed depending on our final needs. At the moment … I am just happy that it is working!!
Regards,
Greg Shearer