Skip to content

Commit

Permalink
Update the code to make it compatible with the GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
UmSenhorQualquer committed Aug 23, 2017
1 parent 054b7c9 commit 10a5712
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
16 changes: 12 additions & 4 deletions pybpodapi/bpod/bpod_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __init__(self, serial_port=None, sync_channel=None, sync_mode=None):
self.baudrate = settings.BAUDRATE
self.sync_channel = sync_channel if sync_channel is not None else settings.SYNC_CHANNEL
self.sync_mode = sync_mode if sync_mode is not None else settings.SYNC_MODE
self.log_function = settings.PYBPOD_API_PUBLISH_DATA_FUNC

self._hardware = Hardware() # type: Hardware
self._session = Session() # type: Session
Expand Down Expand Up @@ -288,7 +289,8 @@ def _publish_data(self, data):
:param data: data to be published (data type varies)
"""
pass
if self.log_function: self.log_function(data)


def softcode_handler_function(self, data):
"""
Expand All @@ -315,8 +317,11 @@ def __add_event_occurrence(self, sma, event_index):

# TODO: Timestamp implementation on Bpod firmware
# type: EventOccurrence
event_occurrence = sma.raw_data.add_event_occurrence(event_index=event_index, event_name=event_name,
timestamp=None)
event_occurrence = sma.raw_data.add_event_occurrence(
event_index=event_index,
event_name=event_name,
timestamp=None
)

self._publish_data(data=event_occurrence)

Expand All @@ -326,7 +331,10 @@ def __add_softcode_occurrence(self, sma, data):

# TODO: Timestamp implementation on Bpod firmware
# type: SoftCodeOccurrence
softcode_occurrence = sma.raw_data.add_softcode_occurrence(softcode_number=data, timestamp=None)
softcode_occurrence = sma.raw_data.add_softcode_occurrence(
softcode_number=data,
timestamp=None
)

self._publish_data(data=softcode_occurrence)

Expand Down
2 changes: 2 additions & 0 deletions pybpodapi/bpod/bpod_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def _publish_data(self, data):
:param data: data to be published (data type varies)
"""
super(BpodIO, self)._publish_data(data)

if isinstance(data, Trial) and self.csv_exporter:
self.csv_exporter.save_trial(data, len(self.session.trials))

Expand Down
1 change: 1 addition & 0 deletions pybpodapi/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#TARGET_BPOD_FIRMWARE_VERSION = "13" # 0.7.9
TARGET_BPOD_FIRMWARE_VERSION = "15" # 0.8

PYBPOD_API_PUBLISH_DATA_FUNC = None

SERIAL_PORT = None
WORKSPACE_PATH = 'BPOD-WORKSPACE'
Expand Down
9 changes: 6 additions & 3 deletions pybpodapi/trial.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,11 @@ def get_all_timestamps_by_event(self):

def export(self):
return {'Bpod start timestamp': self.bpod_start_timestamp,
'States timestamps': self.get_all_timestamps_by_state(),
'Events timestamps': self.get_all_timestamps_by_event()}
'States timestamps': self.get_all_timestamps_by_state(),
'Events timestamps': self.get_all_timestamps_by_event()}

def __str__(self):
def pformat(self):
return pprint.pformat( self.export(), indent=4)

def __str__(self):
return str( self.export() )

0 comments on commit 10a5712

Please sign in to comment.