Overview
The PAC Control nodes can read or write variables, tables, and I/O points in a controller.
In the first example, we saw how to read the Device Details for a controller. Now let’s do some more interesting things, like read and write variables and I/O points.
Read All Int32 Variables
Using the same basic flow of an Inject node connected to a PAC Control Read node connected to a Debug node, we can explore some more of the Read nodes capabilities.
- Make sure your controller has a strategy loaded.
- Double-click on an existing PAC Control Read node to open the “Edit pac read node”.
- For the Device field, confirm that a configured controller is selected.
- For the Data Type field, select Int32 Variable.
- Click Done.
- Click Deploy.
- Make sure the Debug tab is open in the right-hand sidebar.
- Click the Inject node’s button.
You should see an entry in the Debug tab like this:
This is an array of names and values for all of the Int32 Variables in the strategy. It’s printed as JSON without any line breaks, but it will make a bit more sense if we reformat it:
[ { "name": "n1", "value": 6 },
{ "name": "n2", "value": 0 },
{ "name": "n3", "value": 25 },
{ "name": "n4", "value": 1178100 },
{ "name": "n5", "value": 1178100 },
{ "name": "n6", "value": 0 },
{ "name": "n7", "value": 0 }
]
Now you can easily see all the variable names and their current value.
Read One Int32 Variable
Reading one variable is also very simple. Continuing from the previous section:
- Double-click on an existing PAC Control Read node to open the “Edit pac read node”.
- For the Tag Name field, enter the name of an Int32 variable in the loaded strategy.
- Click Done.
- Click Deploy.
- Click the Inject node’s button.
You should see an entry in the Debug tab like this:
In this case, just a number is returned, which is the variable’s current value.
Other Data Types
Go ahead and select other data types and tag names. Play around with the Read node and see what it can do.
Notice how the returned object in the message will vary depending upon the type of tag being read. For instance, a digital input point will return a boolean value, while a string variable will return a string value. It’s important to be mindful of these details as you connect to other nodes.
Next Step
Continue on to using the PAC Control Write node.