Пример #1
0
def local():
    print("MODE = LOCAL")

    while mode == "LOCAL":

    # Button detection / Debouncing
        GPIO.add_event_detect(SWITCHES.sw_pp_pin, GPIO.RISING, callback=ACTIONS.pp_on(), bouncetime=200)
        GPIO.add_event_detect(SWITCHES.sw_tmp_pin, GPIO.RISING, callback=ACTIONS.tmp_on(), bouncetime=200)
        GPIO.add_event_detect(SWITCHES.sw_vv_pin, GPIO.RISING, callback=ACTIONS.vv_on(), bouncetime=200)    
        GPIO.add_event_detect(SWITCHES.sw_hvgv_pin, GPIO.RISING, callback=ACTIONS.hvgv_on(), bouncetime=200)

        GPIO.add_event_detect(SWITCHES.sw_pp_pin, GPIO.FALLING, callback=ACTIONS.pp_off(), bouncetime=200)
        GPIO.add_event_detect(SWITCHES.sw_tmp_pin, GPIO.FALLING, callback=ACTIONS.tmp_off(), bouncetime=200)
        GPIO.add_event_detect(SWITCHES.sw_vv_pin, GPIO.FALLING, callback=ACTIONS.vv_off(), bouncetime=200)    
        GPIO.add_event_detect(SWITCHES.sw_hvgv_pin, GPIO.FALLING, callback=ACTIONS.hvgv_off(), bouncetime=200)
Пример #2
0
    def state_1(self):
        global command, state, sensors, data, pp, tmp, hvgv, vv
        data = [timestamp_sensors, sensors[1], sensors[2], sensors[3], hvgv, vv, pp, tmp]
        out = "/media/pi/KINGSTON/VACUUM_CONTROLLER/LOG"
        print "STATE 1 : ESTABLISH VACUUM\n"

        LCD_DISPLAY.main("STATE 1")  # Display  LCD : STATE 1

        # Safety Check

        # Update command log
        state = "STATE 1"
        thread_command_write = DATA_ACQUISITION_BACKUP.CommandWrite(data, out)
        thread_command_write.start()
        # Start Data acquisition
        thread_physical_write = DATA_ACQUISITION_BACKUP.PhysicalWrite(data, out, state)
        thread_physical_write.start()

        ACTIONS.pp_on()
        start_time = time.time()

        while sensors[3] < sensors[1]:
            # Error log
            WAIT_ROUTINE.wait_routine(state)
            elapsed_time = time.time() - start_time
            if elapsed_time > (3600*5):  # Check if pp switch ON for more than 5 hours
                # Error log
                STATE_4.state_4()  # Go to STATE 4 : SAFE STATE

        ACTIONS.hvgv_on()
        start_time = time.time()

        while sensors[1] > 10^(-1):
            # Error log
            WAIT_ROUTINE.wait_routine(state)
            elapsed_time = time.time() - start_time
            if elapsed_time > (3600*5):  # Check if pp switch ON for more than 5 hours
                # Error log
                STATE_4.state_4()  # Go to STATE 4 : SAFE STATE

        ACTIONS.tmp_on()
        start_time = time.time()

        while sensors[2] > 10^(-4):
            # Error log
            WAIT_ROUTINE.wait_routine(state)
            elapsed_time = time.time() - start_time
            if elapsed_time > (3600*60):  # Check if pp switch ON for more than 60 hours
                # Error log
                STATE_4.state_4()  # Go to STATE 4 : SAFE STATE

        while sensors[2] > 10^(-5):
            WAIT_ROUTINE.wait_routine(state)

        STATE_2.state_2()  # Go to STATE 2 : Maintain Vacuum