def override_commands(input1, n1_clicks, n2_clicks, n3_clicks, n4_clicks, n5_clicks, n6_clicks, n7_clicks, n8_clicks, n9_clicks, n10_clicks, n11_clicks): changed_id = [p['prop_id'] for p in dash.callback_context.triggered][0] if 'actuatorpropopen' in changed_id: actuator_solenoid.open() actuator_prop.open() call = 'Actuator Prop Opened' return call elif 'actuatorproppercentopen' in changed_id: actuator_solenoid.open() actuator_prop_partial = Valve('Actuator Propellant Valve', 'P8_4', 'P8_4', 'Prop', 4, input1) actuator_prop_partial.partial_open() call = u'Actuator Prop Opened {} percent'.format(input1) return call elif 'actuatorsolopen' in changed_id: actuator_solenoid.open() call = 'Actuator Solenoid Opened' return call elif 'pressurantvalveopen' in changed_id: fill_valve.open() call = 'Pressurant Valve Opened' return call elif 'ventvalveopen' in changed_id: vent_valve.open() call = 'Vent Valve Opened' return call elif 'actuatorpropclose' in changed_id: actuator_prop.close() actuator_solenoid.close() call = 'Actuator Prop Closed' return call elif 'actuatorsolclose' in changed_id: actuator_solenoid.close() call = 'Actuator Solenoid Closed' return call elif 'pressurantvalvclose' in changed_id: fill_valve.close() call = 'Pressurant Valve Closed' return call elif 'ventvalveclose' in changed_id: vent_valve.close() call = 'Vent Valve Closed' return call elif 'allvalveclose' in changed_id: vent_valve.close() fill_valve.close() actuator_solenoid.close() actuator_prop.close() call = 'All Valves Closed' return call elif 'allvalveopen' in changed_id: vent_valve.open() fill_valve.open() actuator_solenoid.open() actuator_prop.open() call = 'All Valves Opened' return call else: raise PreventUpdate
def read_sensors(n, time_start, wait_time): # Valve Definition and Classes vent_valve = Valve('Vent Valve', 'P8_12', 0, 'Solenoid', 0, 0) # Pressure Sensor Definition and Classes pressure_cold_flow = Sensor('pressure_cold_flow', 'pressure', 'P9_12', 'P9_14', 'P9_16', '000', '000', '000') pressure_list = [] pressure_time_list = [] for i in range(100): pressure, time_pres = pressure_cold_flow.read_sensor() pressure_list.append(pressure) pressure_time_list.append(time_pres + wait_time * n) current_time = 'Time Update: {} seconds'.format(time.time() - time_start) print(current_time) saved_data_combined = [pressure_list, pressure_time_list] export_data = zip_longest(*saved_data_combined, fillvalue='') with open('leak_data.csv', 'a', encoding="ISO-8859-1", newline='') as myfile: wr = csv.writer(myfile) wr.writerows(export_data) myfile.close()
def upload_event(self, name, size): """Monitor data that went through a given upload valve by name. Arguments: name {str} -- name of valve. size {int} -- amount of traffic that went through named valve. """ if name not in self.limitations: return if name not in self.upload_history: self.upload_history[name] = \ Valve(self.limitations[name][1], self.lifetime) self.upload_history[name].add(size)
def wash_main(): heater = Heater() motor = Motor() sensor = Sensor() stain_removal = StainRemoval() wash_button = WashButton() wash_machine = WashMachine() valve = Valve() def wash_cycle(mediator): wash_machine.set_mediator(mediator) wash_button.set_mediator(mediator) heater.set_mediator(mediator) valve.set_mediator(mediator) wash_button.press() mediator = ColorsMediator( heater, wash_machine, motor, stain_removal, sensor, valve, ) wash_cycle(mediator) print("\n") mediator = WhitesMediator( heater, wash_machine, motor, stain_removal, sensor, valve, ) wash_cycle(mediator)
def main(): window = Tk() window.title('Powerhead Control Program') window.geometry('1000x720') lbl0 = Label(window, text='Chamber Pressure: ') lbl0.grid(column=0, row=7) p0lbl = Label(window, text='Unknown') p0lbl.grid(column=1, row=7) lbl1 = Label(window, text='Methane Pressure: ') lbl1.grid(column=0, row=8) p1lbl = Label(window, text='Unknown') p1lbl.grid(column=1, row=8) lbl2 = Label(window, text='LOX Pressure: ') lbl2.grid(column=0, row=9) p2lbl = Label(window, text='Unknown') p2lbl.grid(column=1, row=9) lbl3 = Label(window, text='Methane Base Temp: ') lbl3.grid(column=0, row=2) t0lbl = Label(window, text='Unknown') t0lbl.grid(column=1, row=2) lbl4 = Label(window, text='Methane Fill Line Temp: ') lbl4.grid(column=0, row=3) t1lbl = Label(window, text='Unknown') t1lbl.grid(column=1, row=3) lbl5 = Label(window, text='LOX Base Temp: ') lbl5.grid(column=0, row=4) t2lbl = Label(window, text='Unknown') t2lbl.grid(column=1, row=4) lbl6 = Label(window, text='LOX Fill Line Temp: ') lbl6.grid(column=0, row=5) t3lbl = Label(window, text='Unknown') t3lbl.grid(column=1, row=5) lox_main = Valve('LOX Propellant Valve', 'P8_13', 'Prop') met_main = Valve('Methane Propellant Valve', 'P8_19', 'Prop') lox_vent = Valve('LOX Vent Valve', 'P8_12', 'Solenoid') met_vent = Valve('Methane Vent Valve', 'P8_14', 'Solenoid') p_valve = Valve('Pressurant Valve', 'P8_16', 'Solenoid') def set_close(): # sets all valves to the close position and also verifies the # connection to the valves lox_main.close() met_main.close() lox_vent.close() met_vent.close() p_valve.close() lox_main.get_state() # this needs to be fixed def bit(): # built in test function, designed to check if every electrical # connection is available for communications if safety_check(): print("Sensors Reading Correctly") else: print("Can't Read Sensors") shut_down() set_close() def safety_check(): # TODO Greg data = [ sensors.get_pressure(0), sensors.get_pressure(1), sensors.get_pressure(2) ] if data[0] > 500: # TODO determine actual engine pressure red-lines p0lbl.configure(text=data[0]) shut_down() return False elif data[1] > 570: p1lbl.configure(text=data[1]) shut_down() return False elif data[2] > 670: p2lbl.configure(text=data[2]) shut_down() return False else: return True def fill(valve): # TODO Wills if valve == 0: v.met_vent(1) x = sensors.get_temperature(1) while x > 150: t1lbl.configure(text=x) t0lbl.configure(text=sensors.get_temperature(1)) x = sensors.get_temperature(1) v.met_vent(0) else: v.lox_vent(1) x = sensors.get_temperature(3) while x > 150: t3lbl.configure(text=x) t2lbl.configure(text=sensors.get_temperature(1)) x = sensors.get_temperature(3) v.lox_vent(0) def start_up(): v.p_valve(1) # TODO determine time to pressurization time.sleep(3) v.lox_valve(0.1) v.met_valve(0.1) while True: if sensors.get_pressure(0) > 50: break v.lox_valve(1) v.met_valve(1) def shut_down(): v.p_valve(0) v.lox_valve(0) v.met_valve(0) v.lox_vent(1) v.met_vent(1) sensors.save_data() v.save_data() def launch(): start_up() for i in range(1000): safety_check() Btn1 = Button(window, text='Launch BIT', command=lambda: bit(), bg='blue') Btn1.grid(column=0, row=0) Btn2 = Button(window, text='Methane Fill', command=lambda: fill(0), bg='yellow') Btn2.grid(column=0, row=1) Btn3 = Button(window, text='LOX Fill', command=lambda: fill(1), bg='yellow') Btn3.grid(column=1, row=1) Btn4 = Button(window, text='Engine Start-Up', command=lambda: launch(), bg='green') Btn4.grid(column=0, row=6) Btn5 = Button(window, text='Engine Shut-Down', command=lambda: shut_down(), bg='red') Btn5.grid(column=1, row=6) window.mainloop()
from sensors import Sensor from valve import Valve import front_end percentage = 100 # Valve Definition and Classes lox_main = Valve('LOX Propellant Valve', 'P8_13', 'P8_13', 'Prop', 4, percentage) lox_vent = Valve('LOX Vent Valve', 'P8_12', 0, 'Solenoid', 0, 0) met_vent = Valve('Methane Vent Valve', 'P8_12', 0, 'Solenoid', 0, 0) p_valve = Valve('Pressurant Valve', 'P8_12', 0, 'Solenoid', 0, 0) # Pressure Sensor Definition and Classes pressure_cold_flow = Sensor('pressure_cold_flow', 'pressure', 'P9_12', 'P9_14', 'P9_16', '000', '000', '000') # Temperature Sensor Definition and Classes temperature_fill_line = Sensor('temperature_fill_line', 'temperature', 'P9_12', 'P9_14', 'P9_16', '000', '000', '000') temperature_empty_line = Sensor('temperature_empty_line', 'temperature', 'P9_12', 'P9_14', 'P9_16', '000', '000', '000') print( "Before Test Start: Verify Electronic Connections and Follow Safety Procedures\n" ) print("------------------------------------------") print("\nProject Daedalus: Powerhead Hardware/Software Test\n") print("""\ ._ o o
from tank import Tank from pump import Pump from valve import Valve from stirrer import Stirrer from heater import Heater import time tanks = [Tank(500, False, False, Valve(10, 2)), # coffee Tank(1000, False, Heater(300), False), # water Tank(1000, Stirrer(10), False, Valve(50, 4)), # main tank Tank(1000, False, False, False), # milk Tank(500, False, False, False)] # cup pumps = [Pump(30, [1, 2]), # water -> main tank Pump(20, [3, 2])] # milk -> main tank flag = 0 dTime = time.time() dTimeWater = time.time() while True: # main loop if time.time() - dTime > 0.1: # 10Hz if flag == 0: # Question about amount of coffee try: amount = int(input("Write how much coffee do you want(ml)")) except ValueError: print("Not an number!") continue else: if amount > 500: print("This is too much, choose amount up to 500ml")
def insulation_test(): # Data Frames for Saving pressure_list = ["Pressure"] pressure_time_list = ["time"] # Valve Definition and Classes actuator_prop = Valve('Actuator Propellant Valve', 'P8_13', 'P8_13', 'Prop', 4, 10) actuator_solenoid = Valve('Actuator Solenoid Valve', 'P8_12', 0, 'Solenoid', 0, 0) fill_valve = Valve('Fill Valve', 'P8_12', 0, 'Solenoid', 0, 0) vent_valve = Valve('Vent Valve', 'P8_12', 0, 'Solenoid', 0, 0) # Pressure Sensor Definition and Classes pressure_cold_flow = Sensor('pressure_cold_flow', 'pressure', 'P9_12', 'P9_14', 'P9_16', '000', '000', '000') # Temperature Sensor Definition and Classes temperature_fill_line = Sensor('temperature_fill_line', 'temperature', 'P9_12', 'P9_14', 'P9_16', '000', '000', '000') temperature_empty_line = Sensor('temperature_empty_line', 'temperature', 'P9_12', 'P9_14', 'P9_16', '000', '000', '000') saved_data_combined = [pressure_list, pressure_time_list] export_data = zip_longest(*saved_data_combined, fillvalue='') with open('insulation_data.csv', 'w', encoding="ISO-8859-1", newline='') as myfile: wr = csv.writer(myfile) wr.writerows(export_data) myfile.close() print('Welcome to the Team Daedalus: Insulation Test') input('Please Press Enter to Confirm Start') print('Starting System Check') print() print("\nVerifying Sensor and Valve Connections\n") while not pressure_cold_flow.verify_connection() and temperature_fill_line.verify_connection() \ and temperature_empty_line.verify_connection(): input("\nPress Enter to Start Verification Again:") print("\nAll Sensors are Functional\n") while not actuator_prop.verify_connection_valve and actuator_solenoid.verify_connection_valve and \ fill_valve.verify_connection_valve and vent_valve.verify_connection_valve: input("\nPress Enter to Start Verification Again:") print("\nAll Valves are Functional\n") input("\nVerification Complete, Press Enter to Continue:\n") print() print('Closing All Valves') actuator_prop.close() actuator_solenoid.close() fill_valve.close() vent_valve.close() print(actuator_prop.get_state()) print(actuator_solenoid.get_state()) print(fill_valve.get_state()) print(vent_valve.get_state()) input('Press Enter to Open filling valve') print('Opening Fill Valve: Begin Filling Procedure') input('Press Enter to begin filling and Enter again to end filling') vent_valve.open() print(vent_valve.get_state()) print('Press Enter When Desired Tank Ullage is Met') time.sleep(3) i = threading.Thread(target=get_input) i.start() while input_flag == 1: temp_fill = temperature_fill_line.read_sensor() temp_empty = temperature_empty_line.read_sensor() pressure = pressure_cold_flow.read_sensor() print(temp_fill[0], temp_empty[0], pressure[0]) time.sleep(.1) vent_valve.close() print(vent_valve.get_state()) final_pressure = pressure_cold_flow.read_sensor() print("Filling Completed: Current Pressure is...") print(final_pressure[0]) input("Press Enter to Begin Leak Test") print('Beginning Leak Test') time_start = time.time() wait_time = 1 n = 0 k = threading.Thread(target=test_end_input) k.start() while test_flag == 1: read_sensors(n, time_start, wait_time) time.sleep(wait_time) n = n + 1 print('done') print(time.time() - time_start) input('Press Enter to Open Valves and Depressurize Tank') actuator_prop.open() actuator_solenoid.open() fill_valve.open() vent_valve.open() actuator_prop.get_state() actuator_solenoid.get_state() fill_valve.get_state() vent_valve.get_state()
def read_sensors(n, time_start, wait_time): # Valve Definition and Classes vent_valve = Valve('Vent Valve', 'P8_12', 0, 'Solenoid', 0, 0) actuator_prop = Valve('Actuator Propellant Valve', 'P8_4', 'P8_4', 'prop', 4, 10) actuator_solenoid = Valve('Actuator Solenoid Valve', 'P8_4', 0, 'solenoid', 0, 0) # Pressure Sensor Definition and Classes pressure_cold_flow = Sensor('pressure_cold_flow', 'pressure', 'P9_16', 'P9_16', 'P9_16', '000', '001', '010') pressure0 = Sensor('pressure_cold_flow', 'pressure', 'P9_16', 'P9_16', 'P9_16', '000', '000', '000') pressure2 = Sensor('pressure_cold_flow', 'pressure', 'P9_16', 'P9_16', 'P9_16', '010', '010', '010') pressure4 = Sensor('pressure_cold_flow', 'pressure', 'P9_16', 'P9_16', 'P9_16', '100', '100', '100') maximum_pressure = 640 nominal_pressure = 500 pressure_list = [] pressure_time_list = [] pressure0_list = [] pressure2_list = [] pressure4_list = [] for i in range(1000): global counter pressure, time_pres = pressure_cold_flow.read_sensor() pres0, time_pres0 = pressure0.read_sensor() pres2, time_pres2 = pressure2.read_sensor() pres4, time_pres4 = pressure4.read_sensor() pressure_list.append(pressure) pressure_time_list.append(time_pres + wait_time * n) pressure0_list.append(pres0) pressure2_list.append(pres2) pressure4_list.append(pres4) if pressure >= maximum_pressure: counter = counter + 1 else: counter = 0 if counter >= 3: time_relief = time.process_time() actuator_solenoid.open() actuator_prop.partial_open() print('Pressure Exceeded Maximum: Opening Relief Valve') print(time_relief) while True: pres_relief = pressure_cold_flow.read_sensor() if pres_relief[0] < nominal_pressure: time_relief_end = time.process_time() print('Closing Relief Valve') actuator_solenoid.close() actuator_prop.close() print(time_relief_end) break current_time = 'Time Update: {} seconds'.format(time.time() - time_start) print(current_time) saved_data_combined = [pressure_list, pressure_time_list] export_data = zip_longest(*saved_data_combined, fillvalue='') with open('leak_data.csv', 'a', encoding="ISO-8859-1", newline='') as myfile: wr = csv.writer(myfile) wr.writerows(export_data) myfile.close() for z in range(21): pres_temp = pressure_cold_flow.read_sensor() print(pres_temp[0])
def leak_test(): global input_flag, counter time_duration = 36000 # Data Frames for Saving pressure_list = ["Pressure"] pressure_time_list = ["time"] pressure0_list = ["Pressure0"] pressure2_list = ["Pressure2"] pressure4_list = ["Pressure4"] # Valve Definition and Classes actuator_prop = Valve('Actuator Propellant Valve', 'P8_4', 'P8_4', 'prop', 4, 20) actuator_solenoid = Valve('Actuator Solenoid Valve', 'P8_4', 0, 'solenoid', 0, 0) fill_valve = Valve('Fill Valve', 'P8_8', 0, 'solenoid', 0, 0) vent_valve = Valve('Vent Valve', 'P8_45', 0, 'solenoid', 0, 0) actuator_solenoid.open() actuator_prop.open() fill_valve.open() # Pressure Sensor Definition and Classes pressure_cold_flow = Sensor('pressure_cold_flow', 'pressure', 'P9_16', 'P9_16', 'P9_16', '000', '010', '100') pressure0 = Sensor('pressure_cold_flow', 'pressure', 'P9_16', 'P9_16', 'P9_16', '000', '000', '000') pressure2 = Sensor('pressure_cold_flow', 'pressure', 'P9_16', 'P9_16', 'P9_16', '010', '010', '010') pressure4 = Sensor('pressure_cold_flow', 'pressure', 'P9_16', 'P9_16', 'P9_16', '100', '100', '100') saved_data_combined = [ pressure_list, pressure_time_list, pressure0_list, pressure2_list, pressure4_list ] export_data = zip_longest(*saved_data_combined, fillvalue='') with open('leak_data.csv', 'w', encoding="ISO-8859-1", newline='') as myfile: wr = csv.writer(myfile) wr.writerows(export_data) myfile.close() print('Welcome to the Team Daedalus: Leak Test') input('Please Press Enter to Confirm Start') print('Starting System Check') print() print("\nVerifying Sensor and Valve Connections\n") while not pressure_cold_flow.verify_connection(): input("\nPress Enter to Start Verification Again:") print("\nAll Sensors are Functional\n") while not actuator_prop.verify_connection_valve and actuator_solenoid.verify_connection_valve and \ fill_valve.verify_connection_valve and vent_valve.verify_connection_valve: input("\nPress Enter to Start Verification Again:") print("\nAll Valves are Functional\n") input("\nVerification Complete, Press Enter to Continue:\n") print() print('Closing All Valves') actuator_solenoid.close() actuator_prop.close() fill_valve.close() vent_valve.close() print(actuator_prop.get_state()) print(actuator_solenoid.get_state()) print(fill_valve.get_state()) print(vent_valve.get_state()) input('Press Enter to Open filling valve') print('Opening Fill Valve: Begin Filling Procedure') input('Press Enter to begin filling and Enter again to end filling') fill_valve.open() print(fill_valve.get_state()) print(vent_valve.get_state()) print('Press Enter When Desired Pressure is Met') time.sleep(3) i = threading.Thread(target=get_input) i.start() maximum_pressure = 640 nominal_pressure = 500 while input_flag == 1: a = pressure0.read_sensor() b = pressure2.read_sensor() c = pressure4.read_sensor() e = pressure_cold_flow.read_sensor() d = [e[0], a[0], b[0], c[0]] if e[0] >= maximum_pressure: counter = counter + 1 else: counter = 0 if counter >= 3: time_relief = time.process_time() actuator_prop_relief = Valve('Actuator Propellant Valve', 'P8_4', 'P8_4', 'prop', 4, 10) actuator_solenoid.open() actuator_prop_relief.partial_open() print('Pressure Exceeded Maximum: Opening Relief Valve') print(time_relief) while True: pres_relief = pressure_cold_flow.read_sensor() if pres_relief[0] < nominal_pressure: time_relief_end = time.process_time() print('Closing Relief Valve') actuator_solenoid.close() actuator_prop_relief.close() print(time_relief_end) break print(d) time.sleep(.2) fill_valve.close() vent_valve.close() print(fill_valve.get_state()) print(vent_valve.get_state()) final_pressure = pressure_cold_flow.read_sensor() print("Filling Completed: Current Pressure is...") print(final_pressure[0]) input("Press Enter to Begin Leak Test") print('Beginning Leak Test') input_flag = 1 time_start = time.time() wait_time = 300 n = 0 while time.time() - time_start < time_duration: read_sensors(n, time_start, wait_time) time.sleep(wait_time) n = n + 1 print('done') print(time.time() - time_start) input('Press Enter to Open Actuator at 20%') actuator_solenoid.open() actuator_prop.partial_open() input('Press Enter to Open All Valves') fill_valve.open() actuator_solenoid.open() actuator_prop.open() actuator_prop.get_state() actuator_solenoid.get_state() fill_valve.get_state() vent_valve.get_state()
def __init__(self): # using GPIO.BOARD for name,bcm in valve_list.items(): self.list [name] = Valve (name,bcm)
import paho.mqtt.client as mqtt import os import time import json from valve import Valve from pressure_sensor import PressureSensor # The callback for when the client receives a CONNACK response from the server. valve = Valve() pressureSensor = PressureSensor() def on_connect(client, userdata, flags, rc): print("Connected with result code " + str(rc)) # Subscribing in on_connect() means that if we lose the connection and # reconnect then subscriptions will be renewed. client.subscribe("valve-req") client.subscribe("pressure-req") # The callback for when a PUBLISH message is received from the server. def on_message(client, userdata, msg): print("Topic: {} / Message: {}".format(msg.topic, str(msg.payload.decode("UTF-8")))) if msg.topic == "valve-req": valve.set_value(int(msg.payload))
def leak_test(): global input_flag global counter # Valve Definition and Classes actuator_prop = Valve('Actuator Propellant Valve', 'P8_4', 'P8_4', 'prop', 4, 20) actuator_solenoid = Valve('Actuator Solenoid Valve', 'P8_4', 0, 'solenoid', 0, 0) fill_valve = Valve('Fill Valve', 'P8_8', 0, 'solenoid', 0, 0) vent_valve = Valve('Vent Valve', 'P8_45', 0, 'solenoid', 0, 0) actuator_solenoid.open() actuator_prop.partial_open() time.sleep(2) # Pressure Sensor Definition and Classes pressureall = Sensor('pressure_cold_flow', 'pressure', 'P9_16', 'P9_16', 'P9_16', '000', '010', '100') pressure0 = Sensor('pressure_cold_flow', 'pressure', 'P9_16', 'P9_16', 'P9_16', '000', '000', '000') pressure2 = Sensor('pressure_cold_flow', 'pressure', 'P9_16', 'P9_16', 'P9_16', '010', '010', '010') pressure4 = Sensor('pressure_cold_flow', 'pressure', 'P9_16', 'P9_16', 'P9_16', '100', '100', '100') print('Welcome to the Team Daedalus: Leak Test') input('Please Press Enter to Confirm Start') print('Starting System Check') print() input("\nVerification Complete, Press Enter to Continue:\n") print() print('Closing All Valves') actuator_solenoid.close() actuator_prop.close() fill_valve.close() vent_valve.close() print(actuator_prop.get_state()) print(actuator_solenoid.get_state()) print(fill_valve.get_state()) print(vent_valve.get_state()) input('Press Enter to Open filling valve') print('Opening Fill Valve: Begin Filling Procedure') input('Press Enter to begin filling and Enter again to end filling') fill_valve.open() print(fill_valve.get_state()) print(vent_valve.get_state()) print('Press Enter When Desired Pressure is Met') time.sleep(3) i = threading.Thread(target=get_input) i.start() maximum_pressure = 10000 nominal_pressure = 500 while input_flag == 1: a = pressure0.read_sensor() b = pressure2.read_sensor() c = pressure4.read_sensor() e = pressureall.read_sensor() d = [e[0], a[0], b[0], c[0]] if e[0] >= maximum_pressure: counter = counter + 1 else: counter = 0 if counter >= 3: time_relief = time.process_time() vent_valve.open() print('Pressure Exceeded Maximum: Opening Relief Valve') print(time_relief) while True: pres_relief = pressureall.read_sensor() if pres_relief[0] < nominal_pressure: time_relief_end = time.process_time() print('Closing Relief Valve') vent_valve.close() print(time_relief_end) break print(d) time.sleep(.2) fill_valve.close() vent_valve.close() print(fill_valve.get_state()) print(vent_valve.get_state()) input('Press Enter to Open Actuator at 10%') actuator_solenoid.open() actuator_prop.partial_open() input('Press Enter to Open Vent Valve') vent_valve.open() input('Enter all Other Valves') vent_valve.close() time.sleep(1) fill_valve.open() actuator_solenoid.open() actuator_prop.open() actuator_prop.get_state() actuator_solenoid.get_state() fill_valve.get_state() vent_valve.get_state() input('Press Enter to End and Close all valves') vent_valve.close() fill_valve.close() actuator_solenoid.close() actuator_prop.close()
with I2C(SCL, SDA, frequency=100000) as i2c, UART(TX, RX, baudrate=115200) as uart: try: # Initialise random random.seed(time.monotonic_ns()) # Setup the rotary encoders enc_left = Encoder(i2c, 0x78) enc_right = Encoder(i2c, 0x70) # Set the encoder LEDs to amber whilst we set-up enc_left.led_color(Encoder.LED_AMBER) enc_right.led_color(Encoder.LED_AMBER) # Setup the valves valve_left = Valve(D2) valve_right = Valve(D3) # Setup the gauges gauge_left = Gauge(uart, "p0", "vol0", "flow0", "tmp0") gauge_right = Gauge(uart, "p1", "vol1", "flow1", "tmp1") # Setup the sensors sensor_left = Sensor(i2c, Sensor.CH_1, Sensor.CH_2) sensor_right = Sensor(i2c, Sensor.CH_3, Sensor.CH_4) # Tick the sensors to fill the buffers sensor_left.tick(time.monotonic_ns()) sensor_right.tick(time.monotonic_ns()) # sensor_left = MockSensor(10, 1, valve_left)
import dash_html_components as html from dash.dependencies import Input, Output from dash.exceptions import PreventUpdate import Adafruit_BBIO.GPIO as GPIO # Data Frames for Saving pressure_list = ["Pressure"] pressure_time_list = ["time"] temperature_fill_list = ["Temperature Fill"] temperature_fill_time_list = ["time"] temperature_empty_list = ["Temperature Empty"] temperature_empty_time_list = ["time"] official_time_list = ["Official Time"] # # Valve Definition and Classes actuator_prop = Valve('Actuator Propellant Valve', 'P8_4', 'P8_4', 'prop', 4, 20) actuator_solenoid = Valve('Actuator Solenoid Valve', 'P8_4', 0, 'solenoid', 0, 0) fill_valve = Valve('Fill Valve', 'P8_8', 0, 'solenoid', 0, 0) vent_valve = Valve('Vent Valve', 'P8_45', 0, 'solenoid', 0, 0) # Pressure Sensor Definition and Classes pressure_cold_flow = Sensor('pressure_cold_flow', 'pressure', 'P9_16', 'P9_16', 'P9_16', '000', '010', '100') # Temperature Sensor Definition and Classes temperature_fill_line = Sensor('temperature_fill_line', 'temperature', 'P9_12', 'P9_12', 'P9_12', '000', '000', '000') temperature_empty_line = Sensor('temperature_empty_line', 'temperature', 'P9_14', 'P9_14', 'P9_16', '000', '000', '000') # Relief Valve Counter: Will always start at zero
from sensors import Sensor from valve import Valve import Adafruit_BBIO.GPIO as GPIO # Valve Definition and Classes actuator_prop = Valve('Actuator Propellant Valve', 'P8_4', 'P8_4', 'prop', 4, 20) actuator_solenoid = Valve('Actuator Solenoid Valve', 'P8_4', 0, 'solenoid', 0, 0) fill_valve = Valve('Fill Valve', 'P8_8', 0, 'solenoid', 0, 0) vent_valve = Valve('Vent Valve', 'P8_45', 0, 'solenoid', 0, 0) actuator_prop.close() actuator_solenoid.close() fill_valve.close() vent_valve.close() input('Press Enter to Begin Purging') fill_valve.open() actuator_prop.partial_open() actuator_solenoid.open() input('Press Enter to End Purge') actuator_prop.open() fill_valve.close() input('Press Enter when Pressurant line has been closed') fill_valve.open()