@@ -30,16 +30,16 @@ class BpodCOMProtocol(BpodBase):
3030
3131 """
3232
33- def __init__ (self , serial_port = None , sync_channel = None , sync_mode = None ):
34- super (BpodCOMProtocol , self ).__init__ (serial_port , sync_channel , sync_mode )
33+ def __init__ (self , serial_port = None , sync_channel = None , sync_mode = None , emulator_mode = False ):
34+ super (BpodCOMProtocol , self ).__init__ (serial_port , sync_channel , sync_mode , emulator_mode = emulator_mode )
3535
3636 self ._arcom = None # type: ArCOM
3737 self .bpod_com_ready = False
3838
3939 # used to keep the list of msg ids sent using the load_serial_message function
4040 self .msg_id_list = [False for i in range (255 )]
4141
42- if self .serial_port :
42+ if self .serial_port and not emulator_mode :
4343 self .open ()
4444
4545 def open (self ):
@@ -52,39 +52,6 @@ def close(self):
5252 self ._arcom .close ()
5353 self .bpod_com_ready = False
5454
55- def manual_override (self , channel_type , channel_name , channel_number , value ):
56- """
57- Manually override a Bpod channel
58-
59- :param ChannelType channel_type: channel type input or output
60- :param ChannelName channel_name: channel name like PWM, Valve, etc.
61- :param channel_number:
62- :param int value: value to write on channel
63- """
64- if channel_type == ChannelType .INPUT :
65- input_channel_name = channel_name + str (channel_number )
66- channel_number = self .hardware .channels .input_channel_names .index (input_channel_name )
67- try :
68- self ._bpodcom_override_input_state (channel_number , value )
69- except :
70- raise BpodErrorException (
71- 'Error using manual_override: {name} is not a valid channel name.' .format (name = channel_name ))
72-
73- elif channel_type == ChannelType .OUTPUT :
74- if channel_name == 'Serial' :
75- self ._bpodcom_send_byte_to_hardware_serial (channel_number , value )
76-
77- else :
78- try :
79- output_channel_name = channel_name + str (channel_number )
80- channel_number = self .hardware .channels .output_channel_names .index (output_channel_name )
81- self ._bpodcom_override_digital_hardware_state (channel_number , value )
82- except :
83- raise BpodErrorException ('Error using manual_override: {name} is not a valid channel name.' .format (
84- name = output_channel_name ))
85- else :
86- raise BpodErrorException ('Error using manualOverride: first argument must be "Input" or "Output".' )
87-
8855 def _bpodcom_connect (self , serial_port , baudrate = 115200 , timeout = 1 ):
8956 """
9057 Connect to Bpod using serial connection
@@ -250,18 +217,7 @@ def _bpodcom_enable_ports(self, hardware):
250217 :rtype: bool
251218 """
252219
253- ###### set inputs enabled or disabled #######################################################
254- hardware .inputs_enabled = [0 ] * len (hardware .inputs )
255-
256- for j , i in enumerate (hardware .bnc_inputports_indexes ):
257- hardware .inputs_enabled [i ] = settings .BPOD_BNC_PORTS_ENABLED [j ]
258-
259- for j , i in enumerate (hardware .wired_inputports_indexes ):
260- hardware .inputs_enabled [i ] = settings .BPOD_WIRED_PORTS_ENABLED [j ]
261-
262- for j , i in enumerate (hardware .behavior_inputports_indexes ):
263- hardware .inputs_enabled [i ] = settings .BPOD_BEHAVIOR_PORTS_ENABLED [j ]
264- #############################################################################################
220+ hardware .configure_inputs ()
265221
266222 logger .debug ("Requesting ports enabling (%s)" , SendMessageHeader .ENABLE_PORTS )
267223 logger .debug ("Inputs enabled (%s): %s" , len (hardware .inputs_enabled ), hardware .inputs_enabled )
0 commit comments