Beispiel #1
0
def run(request):
    if request.method == 'POST':
        c = controller.Controller()
        interface = c.name_to_interface[request.POST.get('choice')]
        if interface:
            print('testing ', request.POST.get('choice'), '.')
            interface.run()
    return HttpResponseRedirect(reverse('testing:index'))
Beispiel #2
0
def read_tube(request):
    if EXHIBIT:
        c = controller.Controller()
        c.tube_led.blink()
        start = time.time()
        timeout = 30
        while not (c.tube.read()):
            time.sleep(0.3)
            if time.time() - start > timeout:
                break
        c.tube_led.on()
    return HttpResponse()
Beispiel #3
0
def read_tube_done(request):
    if EXHIBIT:
        print("IN DONE")
        c = controller.Controller()
        c.tube_led.blink()
        start = time.time()
        timeout = 60
        while c.tube.read():
            time.sleep(0.3)
            if time.time() - start > timeout:
                break
        c.tube_led.on()
    return HttpResponse()
Beispiel #4
0
def index(request):
    topics = Topic.objects
    context = {
        'topics': topics.all(),
    }
    if EXHIBIT:
        c = controller.Controller()
        c.dna_0_led.on()
        c.dna_1_led.on()
        c.tube_led.on()
        return render(request, 'main/interface.html', context)
    else:
        return render(request, 'main/mockup.html', context)
Beispiel #5
0
def produce(request):
    if EXHIBIT:
        c = controller.Controller()
        c.dna_0_led.blink()
        c.dna_1_led.blink()
        c.tube_led.blink()

    time.sleep(10)

    if EXHIBIT:
        c.dna_0_led.off()
        c.dna_1_led.off()
        c.tube_led.on()

    return HttpResponse()
Beispiel #6
0
def demo(request):
    if request.method == 'POST':
        c = controller.Controller()
        petri = c.name_to_interface['petri']
        needle = c.name_to_interface['act0']
        pump = c.name_to_interface['pump0']
        petri.run(200, motor.Motor.DIRECTION.CW)
        petri.run(30, motor.Motor.DIRECTION.CCW)
        needle.run(90, motor.Motor.DIRECTION.CW)
        pump.run()
        needle.run(90, motor.Motor.DIRECTION.CCW)
        petri.run(100, motor.Motor.DIRECTION.CW)
        petri.run(30, motor.Motor.DIRECTION.CCW)
        needle.run(90, motor.Motor.DIRECTION.CW)
        pump.run()
        needle.run(90, motor.Motor.DIRECTION.CCW)
        petri.run(200, motor.Motor.DIRECTION.CCW)
        petri.run(30, motor.Motor.DIRECTION.CW)
        needle.run(90, motor.Motor.DIRECTION.CW)
        pump.run()
        needle.run(90, motor.Motor.DIRECTION.CCW)
        petri.run(100, motor.Motor.DIRECTION.CW)
    return HttpResponseRedirect(reverse('testing:index'))
Beispiel #7
0
def read_samples(request):
    if EXHIBIT:
        timeout = 60
        control = controller.Controller()
        dna_0 = control.dna_0_ms
        dna_1 = control.dna_1_ms
        led_0 = control.dna_0_led
        led_1 = control.dna_1_led

        led_0.blink()
        led_1.blink()
        start = time.time()
        while not (dna_0.read() and dna_1.read()):
            if dna_0.read():
                led_0.on()
            if dna_1.read():
                led_1.on()
            time.sleep(0.3)
            if time.time() - start > timeout:
                print("timeout")
                break
        led_0.on()
        led_1.on()
    return HttpResponse()