-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvalve_controller.py
More file actions
46 lines (39 loc) · 1.55 KB
/
valve_controller.py
File metadata and controls
46 lines (39 loc) · 1.55 KB
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
class ValveController:
"""
Controls the steam valve for the Biochar Toilet reaction vessel.
The valve is initially closed. When the pressure reaches the target (e.g., 15 PSI)
and the temperature reaches the target (e.g., 121 C), the valve opens to "flash"
the steam, sterilizing and destroying the sample.
"""
def __init__(self, target_pressure=15.0, target_temperature=121.0):
"""
Initializes the ValveController.
Args:
target_pressure (float): The pressure threshold to trigger opening (default 15.0 PSI).
target_temperature (float): The temperature threshold to trigger opening (default 121.0 C).
"""
self.target_pressure = target_pressure
self.target_temperature = target_temperature
self.valve_open = False
def update(self, pressure, temperature):
"""
Updates the valve state based on current sensor readings.
Args:
pressure (float): Current pressure reading.
temperature (float): Current temperature reading.
"""
if not self.valve_open:
if pressure >= self.target_pressure and temperature >= self.target_temperature:
self.valve_open = True
def is_open(self):
"""
Returns the current state of the valve.
Returns:
bool: True if the valve is open, False otherwise.
"""
return self.valve_open
def reset(self):
"""
Resets the valve to the closed state.
"""
self.valve_open = False