Skip to content

Commit

Permalink
Enable and Disable ports update
Browse files Browse the repository at this point in the history
  • Loading branch information
UmSenhorQualquer committed Sep 14, 2017
1 parent eaa36dc commit a1980b1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
10 changes: 3 additions & 7 deletions pybpodapi/bpod/bpod_com_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,13 @@ def _bpodcom_enable_ports(self, hardware):
hardware.inputs_enabled = [0] * len(hardware.inputs)
ports_found = False

bnc_inputports = [i for i, input_type in enumerate( hardware.inputs ) if input_type=='B']
wired_inputports = [i for i, input_type in enumerate( hardware.inputs ) if input_type=='W']
behavior_inputports = [i for i, input_type in enumerate( hardware.inputs ) if input_type=='P']

for j, i in enumerate(bnc_inputports):
for j, i in enumerate(hardware.bnc_inputports_indexes):
hardware.inputs_enabled[i] = settings.BPOD_BNC_PORTS_ENABLED[j]

for j, i in enumerate(wired_inputports):
for j, i in enumerate(hardware.wired_inputports_indexes):
hardware.inputs_enabled[i] = settings.BPOD_WIRED_PORTS_ENABLED[j]

for j, i in enumerate(behavior_inputports):
for j, i in enumerate(hardware.behavior_inputports_indexes):
hardware.inputs_enabled[i] = settings.BPOD_BEHAVIOR_PORTS_ENABLED[j]
#############################################################################################

Expand Down
22 changes: 21 additions & 1 deletion pybpodapi/bpod/hardware/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,24 @@ def __str__(self):


@property
def cycle_frequency(self): return int(self.DEFAULT_FREQUENCY_DIVIDER / self.cycle_period )
def cycle_frequency(self): return int(self.DEFAULT_FREQUENCY_DIVIDER / self.cycle_period )

@property
def bnc_inputports_indexes(self): return [i for i, input_type in enumerate( self.inputs ) if input_type=='B']

@property
def wired_inputports_indexes(self): return [i for i, input_type in enumerate( self.inputs ) if input_type=='W']

@property
def behavior_inputports_indexes(self): return [i for i, input_type in enumerate( self.inputs ) if input_type=='P']


@property
def bnc_inputports_names(self): return ['BNC{0}'.format(i) for i, input_type in enumerate( self.inputs ) if input_type=='B']

@property
def wired_inputports_names(self): return ['Wire{0}'.format(i) for i, input_type in enumerate( self.inputs ) if input_type=='W']

@property
def behavior_inputports_names(self): return ['Port{0}'.format(i) for i, input_type in enumerate( self.inputs ) if input_type=='P']

0 comments on commit a1980b1

Please sign in to comment.