35.6.Reading data from PLC
To read data from your PLC and save it into the local variables, you will use the R/W Tags function. In this example we will read 2 values from the PLC, one integer value, and a string value.
1. Firstly, navigate to the Server Side Scripts section and open the PLC Variables Tables
2. Now click on the “New” button in the main Toolbar
3. In the dialog, provide a name for the table, select connection and hit the “Create” button
4. You will be presented with the table where you should fill all the tags you wish to read from the PLC.
As you can see, we have added 2 tags, one is a Numeric type and other is a String.
5. When you are done, open the main.js script from JS Sources.
6. While in the script, click on the R/W tags button which is located in the scripts window toolbar
7. In the dialog, select the name of the table we have created in step 3
8. When you press the OK button, myDESIGNER will generate the code for you.
9. Once this code runs, you will receive values from the PLC and they will be stored in the local variables
As you can see from the code, you will receive the values from the PLC as well as the info if the mySCADA was able to read from the tag.