v1.0 HF3
This commit is contained in:
parent
d2a14e08b7
commit
675c8e7b92
38
app.py
38
app.py
@ -10,6 +10,8 @@ try:
|
|||||||
except Exception:
|
except Exception:
|
||||||
_APP_CFG = {}
|
_APP_CFG = {}
|
||||||
|
|
||||||
|
OPCcon = opcua_connector(_APP_CFG)
|
||||||
|
|
||||||
# Page configuration
|
# Page configuration
|
||||||
st.set_page_config(
|
st.set_page_config(
|
||||||
page_title="OPC UA Robot Control Dashboard",
|
page_title="OPC UA Robot Control Dashboard",
|
||||||
@ -114,29 +116,10 @@ else:
|
|||||||
if st.session_state.connection_status != "Disconnected":
|
if st.session_state.connection_status != "Disconnected":
|
||||||
st.session_state.connection_status = "Disconnected"
|
st.session_state.connection_status = "Disconnected"
|
||||||
|
|
||||||
def add_log(message):
|
|
||||||
"""No-op logger (logs disabled for minimal UI)."""
|
|
||||||
return None
|
|
||||||
|
|
||||||
def push_button(OPCcon, btn_name):
|
|
||||||
"""Push a button on the OPC UA server"""
|
|
||||||
try:
|
|
||||||
if btn_name == 'INIT':
|
|
||||||
OPCcon.adapt_access_rights()
|
|
||||||
add_log(f"🔧 INIT button pressed - Access rights adapted")
|
|
||||||
else:
|
|
||||||
OPCcon.press_btn(btn_name)
|
|
||||||
add_log(f"🔘 {btn_name} button pressed")
|
|
||||||
return True
|
|
||||||
except Exception as e:
|
|
||||||
add_log(f"❌ Error pressing {btn_name} button: {e}")
|
|
||||||
return False
|
|
||||||
|
|
||||||
def initialize_connection():
|
def initialize_connection():
|
||||||
"""Initialize OPC UA connection"""
|
"""Initialize OPC UA connection"""
|
||||||
try:
|
try:
|
||||||
OPCcon = opcua_connector(_APP_CFG)
|
|
||||||
|
|
||||||
# Connect and check status
|
# Connect and check status
|
||||||
OPCcon.connect()
|
OPCcon.connect()
|
||||||
if OPCcon.check_connection() == 1:
|
if OPCcon.check_connection() == 1:
|
||||||
@ -154,16 +137,13 @@ def initialize_connection():
|
|||||||
|
|
||||||
def execute_button_action(button_name):
|
def execute_button_action(button_name):
|
||||||
"""Execute button action with proper error handling"""
|
"""Execute button action with proper error handling"""
|
||||||
if st.session_state.opcua_connector is None:
|
if button_name == 'INIT':
|
||||||
add_log("❌ No connection available. Please initialize first.")
|
OPCcon.adapt_access_rights()
|
||||||
return
|
add_log(f"🔧 INIT button pressed - Access rights adapted")
|
||||||
|
else:
|
||||||
# Execute directly instead of threading to avoid race conditions
|
OPCcon.press_btn(button_name)
|
||||||
try:
|
add_log(f"🔘 {button_name} button pressed")
|
||||||
push_button(st.session_state.opcua_connector, button_name)
|
return True
|
||||||
except Exception as e:
|
|
||||||
add_log(f"❌ Critical error executing {button_name}: {e}")
|
|
||||||
|
|
||||||
|
|
||||||
# Sidebar
|
# Sidebar
|
||||||
with st.sidebar:
|
with st.sidebar:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user