v1.0 HF4
This commit is contained in:
parent
675c8e7b92
commit
283879ae10
18
app.py
18
app.py
@ -125,13 +125,13 @@ def initialize_connection():
|
||||
if OPCcon.check_connection() == 1:
|
||||
st.session_state.opcua_connector = OPCcon
|
||||
st.session_state.connection_status = "Connected"
|
||||
add_log("🎉 Connection initialized successfully")
|
||||
print("🎉 Connection initialized successfully")
|
||||
return True
|
||||
|
||||
st.session_state.connection_status = "Disconnected"
|
||||
return False
|
||||
except Exception as e:
|
||||
add_log(f"❌ Failed to initialize connection: {e}")
|
||||
print(f"❌ Failed to initialize connection: {e}")
|
||||
st.session_state.connection_status = "Disconnected"
|
||||
return False
|
||||
|
||||
@ -139,10 +139,10 @@ def execute_button_action(button_name):
|
||||
"""Execute button action with proper error handling"""
|
||||
if button_name == 'INIT':
|
||||
OPCcon.adapt_access_rights()
|
||||
add_log(f"🔧 INIT button pressed - Access rights adapted")
|
||||
print(f"🔧 INIT button pressed - Access rights adapted")
|
||||
else:
|
||||
OPCcon.press_btn(button_name)
|
||||
add_log(f"🔘 {button_name} button pressed")
|
||||
print(f"🔘 {button_name} button pressed")
|
||||
return True
|
||||
|
||||
# Sidebar
|
||||
@ -159,21 +159,17 @@ with st.sidebar:
|
||||
if st.button("🔌 Disconnect", use_container_width=True):
|
||||
if st.session_state.opcua_connector:
|
||||
try:
|
||||
# Close InfluxDB connection
|
||||
if hasattr(st.session_state.opcua_connector, 'influxclient'):
|
||||
st.session_state.opcua_connector.influxclient.close()
|
||||
add_log("📊 InfluxDB connection closed")
|
||||
|
||||
# Disconnect OPC UA using the new method
|
||||
st.session_state.opcua_connector.disconnect()
|
||||
add_log("🔌 Disconnected from OPC UA server")
|
||||
print("🔌 Disconnected from OPC UA server")
|
||||
|
||||
except Exception as e:
|
||||
add_log(f"⚠️ Warning during disconnect: {e}")
|
||||
print(f"⚠️ Warning during disconnect: {e}")
|
||||
|
||||
st.session_state.opcua_connector = None
|
||||
st.session_state.connection_status = "Disconnected"
|
||||
add_log("🔌 Connection reset")
|
||||
print("🔌 Connection reset")
|
||||
st.rerun()
|
||||
|
||||
st.divider()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user