35.2.Read/Write data from/to PLC
To read or write data from PLC, you should use the R/W tags button.
To read or write tags from PLC, you must create a PLC request table first. To do so, please navigate to the PLC Variables Tables section and create a new table. You can call it whatever you like.
In PLC Variables Table, you define what tags will be read or written from the PLC.
In this example, we will be reading two numerical values and one string from the PLC with alias M.
Once you create your request, you can proceed to the script. Click on the R/W Tags button and you will be presented with the following dialog:
In the dialog, you can see, we have specified our created PLC variable table called temps. You can see all the defined tags in the Tags section. If you wish to read/write only some tags, please, uncheck the others. Once you are done, press OK button. myDESIGNER will automatically create a code for you and insert it into the edited script.
For tags reading:
As you can see, myDESIGNER has prepared a code for you, which will read your tags. For each tag, you will get its value and also a status info if it was read or ended in error (for example if you missed typed the tag address)
For tags write:
As you can see, first we create object options and we put all the values we want to write into the options -> values array. Then we call the function myscada.writeTags. On successful write you will get the callback to your function.