Setting point address at startup


I am writing an application for installation on a number of individual tensile testing stations. All will be running an individually licensed copy of the application. Although overall operation of each station is essentially identical, detail of the connected analog inputs will differ due to a variety of legacy hardware etc.

For example, although I expect all will have a Modbus/TCP input as the primary load signal, the address of the signal will likely vary.

I have found that the PrimaryStation field for a Node can be set within the Startup script … which is great for data driving the Node configuration. However, setting of the associated tag DevicePoint field does not appear to be supported at startup. This doesn’t greatly surprise me … although I had hoped it might be possible.

In this situation is there any general advice on how/whether this can be managed to avoid having to adjust the application before installation at each individual station?

Any advice appreciated.

Greg Shearer

Although setting the PrimaryStation field at startup works well … the setting made at that time is not reflected in the point DevicePoint field. This is what is shown in my running application:


The application is running correctly … but the DevicePoint should now read:


That is, the IP address, port and Unit ID are showing the default values.

Hi Greg,

So basically you have 2 questions when you configure the task here:

1 - How to set some point configurations, for example Address, AccessType, Modifiers… in ClientStartup.
2 - About the DevicePoint property we could reproduce and we are working on it.

Are those informations correct?

Best Regards,
Tatsoft Team.

Mainly the first point.
I don’t need to reference the DevicePoint field other than to possibly set the point address.
I had simply noticed it wasn’t displaying the correct Node details … so thought I’d let you know.

In terms of my application, setting the Node detail works fine.


If there is already a way to set the point address at startup, please let me know.
Reviewing the point characteristics, only the DevicePoint field looked promising to me.
However, if I try to set it in the Startup script, I get the error below:

Hi Greg,

We have an example to show you how to manage the Points in Startup or Runtime. The project is in version fs-9.2.26.

Please let us know if it helps you, all you have to do is run the project and click in the button, the code is in scripts using a trigger, but you could use the same code to put in startup.

Best Regards,
Tatsoft Team.

Thanks so much for sample application, which should resolve my issues. However, I continue to struggle with some coding. I am trying a simplified arrangement just to test that the approach will work for me, before fully detailing the required functions.

My understanding of declaring and using variables in VB .NET is clearly not very good, as I would expect the following progressive statements to work …

Dim rows() as System.Data.DataRow
rows = TK.ProjectDB.NewDataRows(“EditDevicePoints”, 3)
rows(1)(“Label”) = “BLAH”

There are no device points defined in the project.
Although the above compiles OK, at runtime we see this when trying to set the “Label” value …

Does this mean that:

rows = TK.ProjectDB.NewDataRows(“EditDevicePoints”, 3)

is not setting ‘rows’ as an instance of a DataRows array?

Hi Greg,

Could you send us your project in so we can analyze it better please?

Best Regards,
Tatsoft Team.

Hi Eduardo.

Thanks for the offer, but I haven’t sent my application as I doubt it is warranted just yet :slight_smile: As it is, I have overcome nearly all issues by more closely following your example.

I now have only two (hopefully) minor configuration issues to resolve.

  1. Although I have been able to set nearly all of the point configuration elements as required … the DataType field does not appear to be behave in the same way as the others. The elements shown below all appear to work correctly:
    rows(id)(“ID”) = i
    rows(id)(“TagName”) = “load”
    rows(id)(“Node”) = “Node.Load1”
    rows(id)(“Address”) = (400034).ToString()
    rows(id)(“AccessType”) = “AccessType.FastRead”
    rows(id)(“Modifiers”) = “WordSwap.True”

However, if I include either of the following …

rows(0)(“DataType”) = “DataType.Single”
rows(0)(“DataType”) = “Single”

I get a runtime error …

Does this mean that I am unable to configure the point DataType using this method?
Are there numerical values representing the various data types?

  1. Although I mentioned some time ago that I could successfully set the node PrimaryStation field at startup … this method does not appear to be working within my current code. I had originally simply used the assignment:
    Device.Node.Load1.PrimaryStation = “;502;82”
    but this is no longer being effective.

Within the code based on your example I have tried:
nodes.Rows(0)(“PrimaryStation”) = TK.ConvertTo(Of String)(@Tag.teststation(0, “micrometer3”))

and hard-coded:

nodes.Rows(0)(“PrimaryStation”) = “;502;82”

but neither work. I can get the driver working correctly during runtime by using Property Watch to manually enter the correct string.

If you can offer any advice on these two issues it would be appreciated.

Greg Shearer

Hi Greg,

1 - You have 2 ways to do that, the first one is using a number, the number sequence is the same you have in Edit > Devices > Points > Datatype column:

and the second way is using the class eDataType:

[Code in C#]
public enum eDataType

2 - I just did the test and it is working correct here changing through the Property Watch in Devices > Node > modbus > PrimaryStation. What FactoryStudio version are you using? Have you tried to change the IP through the Property Watch? or use the Modbus simulator?


Hi Eduardo.

It turns out that setting the node PrimaryStation does work simply using a tag assignment, as I mentioned earlier and as in the example below.

@Device.Node.Load1.PrimaryStation = @Tag.teststation(0, “micrometer3”)

However, when I then change the Point configuration using the method you have outlined, the node PrimaryStation reverts to the project default value … in my case;502;1

When the project is run, the correct PrimaryStation is active for a few seconds, but appears to be reset to the project default value when the Device Point changes are committed with:

TK.ProjectDB.UpdateDataRows(“EditDevicesPoints”, rows, [Error])

Do you know how this can be avoided? I thought I may need to edit the Node definition in a similar way to the Point definition, but my attempts so far have not been successful.

Any thoughts on this will be appreciated, as the final solution appears to be frustratingly close.

Greg Shearer

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 :slight_smile: This is what the code now looks like:


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
End If

Dim PointsDel As New List(Of System.Data.DataRow)()

Dim pr as System.Data.DataRow
For Each pr In Points.Rows

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”


TK.ProjectDB.UpdateDataRows(“EditDevicesPoints”, PointRows, [Error])


If Nodes.Rows.Count = 0 Then
End If

Dim NodesDel As New List(Of System.Data.DataRow)()

Dim nr as System.Data.DataRow
For Each nr In Nodes.Rows

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”)


TK.ProjectDB.UpdateDataRows(“EditDevicesNodes”, NodeRows, [Error])


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!!

Greg Shearer

Hi Greg,

When you run the line “TK.ProjectDB.ApplyProjectChanges()”, the device stops to apply the changes and retrieve the TManager configurations, because the device was restarted. So we have a solution for you using the following code, when you to change from the right IP > wrong IP > right IP, you will lost connection for an instant, but we think that it will not be a problem for you because you would lost connection anyway when restarting the device.

string previous = @Device.Node.<NodeName>.PrimaryStation;
@Device.Node.<NodeName>.PrimaryStation = previous;

You may have to use a sleep after ApplyProjectChanges because it has to wait devices restart.

But we see the solution you just sent to us and if it is working fine, perfect, seems to be a good solution!!

Let us know if you need something else.

Tatsoft Team.