20250904_141652_
This commit is contained in:
parent
bacb84b736
commit
a05456e8ad
15
EXEC_INIT.bat
Normal file
15
EXEC_INIT.bat
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal
|
||||||
|
|
||||||
|
:: ---------- USER DEFINE --------------
|
||||||
|
set "venvName=opcua_com"
|
||||||
|
set "scriptPath=RUN_BTN.py"
|
||||||
|
set "arg=-n INIT"
|
||||||
|
:: -------------------------------------
|
||||||
|
|
||||||
|
:: Activate the Conda environment and execute the Python script
|
||||||
|
call conda activate %venvName%
|
||||||
|
python "%scriptPath%" %arg%
|
||||||
|
|
||||||
|
:: Pause at the end of the script
|
||||||
|
#pause
|
||||||
@ -34,7 +34,10 @@ def push_btn(OPCcon, btn_name):
|
|||||||
"""State 2:"""
|
"""State 2:"""
|
||||||
print("---- State 2 ----")
|
print("---- State 2 ----")
|
||||||
try:
|
try:
|
||||||
OPCcon.press_btn(btn_name)
|
if btn_name == 'INIT':
|
||||||
|
OPCcon.adapt_access_rights(OPCcon)
|
||||||
|
else:
|
||||||
|
OPCcon.press_btn(btn_name)
|
||||||
print("Press button done.")
|
print("Press button done.")
|
||||||
return 99
|
return 99
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@ -31,6 +31,14 @@ class opcua_connector:
|
|||||||
df = pd.read_csv(filename, delimiter=DELIMITER, header=None)
|
df = pd.read_csv(filename, delimiter=DELIMITER, header=None)
|
||||||
return dict(zip(df.iloc[:, 0], df.iloc[:, 1]))
|
return dict(zip(df.iloc[:, 0], df.iloc[:, 1]))
|
||||||
|
|
||||||
|
|
||||||
|
def adapt_access_rights(self, access_rights="PlcWrite"):
|
||||||
|
'''
|
||||||
|
adapt the userrights
|
||||||
|
'''
|
||||||
|
method_node = self.opcuaclient.get_node("ns=2;s=/Methods/GiveUserAccess")
|
||||||
|
object_node = self.opcuaclient.get_node("ns=2;s=/Methods")
|
||||||
|
object_node.call_method(method_node, self.config['cred']["robot"]["username"], access_rights)
|
||||||
|
|
||||||
def _get_opcua_data(self, var_list):
|
def _get_opcua_data(self, var_list):
|
||||||
""" Retrieve OPC UA node values based on the list of variable nodes. """
|
""" Retrieve OPC UA node values based on the list of variable nodes. """
|
||||||
@ -42,3 +50,5 @@ def _sent_opcua_data_impuls(self, var):
|
|||||||
node.set_value(1) # Set node to 1
|
node.set_value(1) # Set node to 1
|
||||||
# time.sleep(1) # Wait for 1 second
|
# time.sleep(1) # Wait for 1 second
|
||||||
# node.set_value(0) # Set node back to 0
|
# node.set_value(0) # Set node back to 0
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user