Exemplo n.º 1
0
                      output_actions=[('Valve', 2)])
        sma.add_state(state_name='wait2',
                      state_timer=waittime,
                      state_change_conditions={EventName.Tup: 'Open Middle'},
                      output_actions=[])
        sma.add_state(state_name='Open Middle',
                      state_timer=ValveOpenTime_M,
                      state_change_conditions={EventName.Tup: 'wait3'},
                      output_actions=[('Valve', 3)])
        sma.add_state(state_name='wait3',
                      state_timer=waittime,
                      state_change_conditions={EventName.Tup: 'Close Valves'},
                      output_actions=[])
        if i == 0:

            sma.add_state(state_name='Close Valves',
                          state_timer=ValveCloseTime,
                          state_change_conditions={EventName.Tup: 'exit'},
                          output_actions=[(OutputChannel.PWM3, 255)])  #
        else:
            sma.add_state(state_name='Close Valves',
                          state_timer=ValveCloseTime,
                          state_change_conditions={EventName.Tup: 'exit'},
                          output_actions=[])

        my_bpod.send_state_machine(
            sma)  # Send state machine description to Bpod device
        my_bpod.run_state_machine(sma)  # Run state machine

my_bpod.close()
Exemplo n.º 2
0
    # initial state
    sma.add_state(
        state_name="start",
        state_timer=5,
        state_change_conditions={"Tup": "reward"},
        output_actions=[("BNC1", 1)],
    )

    # open valve1 for 20 seconds
    sma.add_state(
        state_name="reward",
        # output action will be performed for whole time state is active
        state_timer=20,
        state_change_conditions={"Tup": "exit"},
        # output action for valve open = 255
        # notation for valve alsways Valve + numer of port connected to
        output_actions=[("Valve1", 255)],
    )

    bpod.send_state_machine(sma)

    # Run state machine
    if not bpod.run_state_machine(
            sma):  # Locks until state machine 'exit' is reached
        break

    print("Current trial info: {0}".format(bpod.session.current_trial))

bpod.close()
Exemplo n.º 3
0
    #     Start state machine definition
    # =============================================================================
    sma = StateMachine(bpod)
    sma.add_state(state_name='init',
                  state_timer=0,
                  state_change_conditions={'Tup': 'reward'},
                  output_actions=[])

    sma.add_state(state_name='reward',
                  state_timer=valve_on_time,
                  state_change_conditions={'Tup': 'iti'},
                  output_actions=[('Valve1', 255)])

    sma.add_state(state_name='iti',
                  state_timer=iti,
                  state_change_conditions={'Tup': 'exit'},
                  output_actions=[])

    # Send state machine description to Bpod device
    bpod.send_state_machine(sma)

    # Run state machine
    bpod.run_state_machine(sma)

    print("Current trial info: {0}".format(bpod.session.current_trial))

bpod.close()

if __name__ == '__main__':
    print('main')