File size: 1,530 Bytes
34398d0
d39e161
34398d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d39e161
34398d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# app.py
import streamlit as st

def adjust_ratios(components):
    """Adjusts the ratio of each component."""
    st.write("### Adjust Air Mixture Components")
    adjusted_components = {}
    for component, value in components.items():
        adjusted_value = st.slider(
            label=f"{component} Ratio (%)", min_value=0, max_value=100, value=int(value)
        )
        adjusted_components[component] = adjusted_value
    return adjusted_components

def main():
    st.title("Air Mixture Adjustment App")
    st.write("This app allows you to sense and adjust the ratio of each component in an air mixture.")

    # Simulate sensing air mixture (replace with actual sensing functionality if available)
    st.write("### Sensed Air Components")
    sensed_components = {
        "Nitrogen": 78,
        "Oxygen": 21,
        "Carbon Dioxide": 0.04,
        "Argon": 0.93
    }

    # Display sensed components
    for component, value in sensed_components.items():
        st.write(f"{component}: {value}%")

    # Adjust components
    adjusted_components = adjust_ratios(sensed_components)

    # Ensure the sum of the components is 100%
    total = sum(adjusted_components.values())
    if total != 100:
        st.warning("The total percentage does not equal 100%. Please adjust the values.")

    # Display adjusted components
    st.write("### Final Adjusted Components")
    for component, value in adjusted_components.items():
        st.write(f"{component}: {value}%")

if __name__ == "__main__":
    main()