File size: 3,107 Bytes
32b5cd7 6cca129 32b5cd7 6cca129 32b5cd7 6d0df63 32b5cd7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
def show():
# note to self you can check for empty with if statement st.image(image,
# caption='PIL Image', use_column_width=True)
from os import environ
import streamlit as st
from microscope_demo_client import MicroscopeDemo
# from my_secrets import HIVEMQ_BROKER
HIVEMQ_BROKER = environ["HIVEMQ_BROKER"]
port = 8883
microscopes = [
"microscope",
"microscope2",
"deltastagetransmission",
"deltastagereflection",
]
st.title("GUI control")
microscopeselection = st.selectbox(
"Choose a microscope:", microscopes, index=microscopes.index("microscope2")
)
access_key = st.text_input(label="Enter your access key here:", max_chars=1000)
def get_pos_button():
microscope = MicroscopeDemo(
HIVEMQ_BROKER,
port,
microscopeselection + "clientuser",
access_key,
microscopeselection,
)
# "acmicroscopedemo" is a placeholder until access keys are implemented
pos = microscope.get_pos()
st.write("x: " + str(pos["x"]))
st.write("y: " + str(pos["y"]))
st.write("z: " + str(pos["z"]))
microscope.end_connection()
def take_image_button():
microscope = MicroscopeDemo(
HIVEMQ_BROKER,
port,
microscopeselection + "clientuser",
access_key,
microscopeselection,
)
# "acmicroscopedemo" is a placeholder until access keys are implemented
st.image(
microscope.take_image(),
caption="Taken from the microscope camera",
use_column_width=True,
)
microscope.end_connection()
def focus_button():
microscope = MicroscopeDemo(
HIVEMQ_BROKER,
port,
microscopeselection + "clientuser",
access_key,
microscopeselection,
)
# "acmicroscopedemo" is a placeholder until access keys are implemented
microscope.focus(focusamount)
st.write("Autofocus complete")
microscope.end_connection()
def move_button():
microscope = MicroscopeDemo(
HIVEMQ_BROKER,
port,
microscopeselection + "clientuser",
access_key,
microscopeselection,
)
# "acmicroscopedemo" is a placeholder until access keys are implemented
microscope.move(xmove, ymove)
st.write("Move complete")
microscope.end_connection()
st.button("Get position", on_click=get_pos_button)
st.write("")
st.button("Take image", on_click=take_image_button)
st.write("")
focusamount = st.number_input(
"Autofocus amount 1-5000", min_value=1, max_value=5000, step=100, value=1000
)
st.button("Focus", on_click=focus_button)
st.write("")
xmove = st.number_input("X", min_value=-20000, max_value=20000, step=250, value=0)
ymove = st.number_input("Y", min_value=-20000, max_value=20000, step=250, value=0)
st.button("Move", on_click=move_button)
|