DeaD_EyE icon

Access via OPCUA Tags on a sImulated MTP700

DeaD_EyE | PRO | 05/19/25 01:43:08 PM UTC | 0 ⭐ | 1108 👁️ | Never ⏰ | []
Python |

630 B

|

None

|

0 👍

/

0 👎

import typing
 
import opcua
 
 
def get_value(hmi_opcua: opcua.Client, tag: str) -> typing.Any:
    root = hmi_opcua.get_root_node()
 
    for child in root.get_child(["0:Objects", "1:HmiRuntime", "1:HMI_RT_4", "1:Tags"]).get_children():
        name = child.get_browse_name().Name.split("::")[1]
        if name == tag:
            return child.get_value()
 
    raise ValueError(f"Could not find {tag}")
 
 
 
# simulated MTP700 with activated OPCUA
client = opcua.Client("opc.tcp://127.0.0.1:4949")
client.session_timeout = 600000
client.connect()
 
 
print("Tag in position:", get_value(client, "Tag_in_pos"))
client.disconnect()
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎