st-one-io / node-red-contrib-s7

A Node-RED node to interact with Siemens S7 PLCs
GNU General Public License v3.0
108 stars 55 forks source link

Variables configured on the s7 node and not the endpoint #88

Open OriolFM opened 3 years ago

OriolFM commented 3 years ago

In one of my current applications I have about 30 machines that are almost identical, and I'm reading 30~40 variables on each one.

Since the variables are tied to the endpoint definition and not the S7 node, If I just copy-paste the S7 node and change the IP address to the PLC i want to read from, I am changing the endpoint instead of the node, and then I get the same result from both S7 nodes, the one on the last PLC i edited.

Original procedure:

  1. Copy/paste the S7 node or create a new one
  2. go into the endpoint selection and create a new one, configure IP, slot, etc.
  3. add all 30~40 variables by hand.
  4. If there are any machine-specific variables, add them by hand as well.

Current Workaround:

  1. Copy/paste the S7 node or create a new one
  2. go to endpoint selection, create a new one
  3. add one variable by hand
  4. save and exit the node
  5. select node
  6. go to "export" and copy it into the clipboard
  7. Edit it into Notepad++
  8. select a node from another machine, already configured
  9. go to "export" and copy it into the clipboard
  10. open it into notepad++ as a separate document
  11. copy the humongous variable table from the old one and overwrite the new one (that has only one)
  12. copy the modified text for the new PLC
  13. back in node-red, go into the newest node that was created
  14. delete that node
  15. delete the newest endpoint
  16. import the modified node with the full variable table, place it into the flow.

I don't know if there is a simpler option already done, but as it is, I see two possible solutions:

The first option I see would be to link the variable table to the S7 node instead of the endpoint. That way, we could copy/paste the node, and just create the new endpoint. All the variables that were configured would be kept. A potential problem would come up when a memory address does not exist for a specific variable. Then the node could either return an error or an "undefined", as usual in node-red.

The second option, that may be simpler to implement, would be to add a pair of IMPORT and EXPORT buttons for the variable tables. "Export" would copy the variable table into the clipboard, and "import" could open a text field where the whole variable table could be pasted. Changes like this might be minimal, but would allow for much faster deployment in projects where you have to replicate the same PLC structure for different devices.

I'm sorry for not having enough programming skills to contribute directly, but if I can help with more feedback, let me know.

FT2work commented 2 years ago

Hi @OriolFM, do you know if there's an update related to the PR you created? I mean if a new version has been released to have the chance to dynamically create both the endpoint and variables definition. It would be very useful! Please let me know. Thank you very much

OriolFM commented 2 years ago

There are currently Import/Export buttons that allow to define the variable list as a CSV text file, so that is better.

However, the variables are still defined in the endpoint, not in the S7 node, so you can't define the variables by passing them in the message.