Skip to content

Commit 1be79ec

Browse files
committed
Merge branch 'dev'
2 parents 2db523a + 7fc43de commit 1be79ec

40 files changed

+1218
-818
lines changed

com/data_logger.py

100644100755
+4-2
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,20 @@ def set_state_machine(self, sm_info):
2121
in self.sm_info['analog_inputs'].items()}
2222
self.analog_files = {ai['ID']: None for ai in self.sm_info['analog_inputs'].values()}
2323

24-
def open_data_file(self, data_dir, experiment_name, subject_ID, datetime_now=None):
24+
def open_data_file(self, data_dir, experiment_name, setup_ID, subject_ID, datetime_now=None):
2525
'''Open data file and write header information.'''
2626
self.data_dir = data_dir
2727
self.experiment_name = experiment_name
2828
self.subject_ID = subject_ID
29+
self.setup_ID = setup_ID
2930
if datetime_now is None: datetime_now = datetime.now()
3031
file_name = os.path.join(self.subject_ID + datetime_now.strftime('-%Y-%m-%d-%H%M%S') + '.txt')
3132
self.file_path = os.path.join(self.data_dir, file_name)
3233
self.data_file = open(self.file_path, 'w', newline = '\n')
3334
self.data_file.write('I Experiment name : {}\n'.format(self.experiment_name))
3435
self.data_file.write('I Task name : {}\n'.format(self.sm_info['name']))
3536
self.data_file.write('I Task file hash : {}\n'.format(self.sm_info['task_hash']))
37+
self.data_file.write('I Setup ID : {}\n'.format(self.setup_ID))
3638
self.data_file.write('I Subject ID : {}\n'.format(self.subject_ID))
3739
self.data_file.write('I Start date : ' + datetime_now.strftime('%Y/%m/%d %H:%M:%S') + '\n\n')
3840
self.data_file.write('S {}\n\n'.format(json.dumps(self.sm_info['states'])))
@@ -45,7 +47,7 @@ def copy_task_file(self, data_dir, tasks_dir, dir_name='task_files'):
4547
if not os.path.exists(exp_tasks_dir):
4648
os.mkdir(exp_tasks_dir)
4749
task_file_path = os.path.join(tasks_dir, self.sm_info['name']+'.py')
48-
task_save_name = self.sm_info['name']+'_{}.py'.format(self.sm_info['task_hash'])
50+
task_save_name = os.path.split(self.sm_info['name'])[1] +'_{}.py'.format(self.sm_info['task_hash'])
4951
if not task_save_name in os.listdir(exp_tasks_dir):
5052
copyfile(task_file_path, os.path.join(exp_tasks_dir, task_save_name))
5153

com/pycboard.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,12 @@ def load_hardware_definition(self, hwd_path=os.path.join(dirs['config'], 'hardwa
278278
else:
279279
self.print('Hardware definition file not found.')
280280

281-
def setup_state_machine(self, sm_name, sm_dir=dirs['tasks'], uploaded=False):
281+
def setup_state_machine(self, sm_name, sm_dir=None, uploaded=False):
282282
'''Transfer state machine descriptor file sm_name.py from folder sm_dir
283283
to board. Instantiate state machine object as state_machine on pyboard.'''
284284
self.reset()
285+
if sm_dir is None:
286+
sm_dir = dirs['tasks']
285287
sm_path = os.path.join(sm_dir, sm_name + '.py')
286288
if uploaded:
287289
self.print('\nResetting task. ', end='')
@@ -350,7 +352,10 @@ def process_data(self):
350352
new_byte = self.serial.read(1)
351353
if new_byte == b'A': # Analog data, 13 byte header + variable size content.
352354
data_header = self.serial.read(13)
353-
typecode = data_header[0:1].decode()
355+
typecode = data_header[0:1].decode()
356+
if typecode not in ('b','B','h','H','l','L'):
357+
new_data.append(('!','bad typecode A'))
358+
continue
354359
ID = int.from_bytes(data_header[1:3], 'little')
355360
sampling_rate = int.from_bytes(data_header[3:5], 'little')
356361
data_len = int.from_bytes(data_header[5:7], 'little')

data/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# Ignore all contents of data folder except .gitignore needed to ensure folder is version controlled.
1+
# Ignore all contents of folder except .gitignore needed to ensure folder is version controlled.
22
*
33
!.gitignore

experiments/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore all contents of folder except .gitignore needed to ensure folder is version controlled.
2+
*
3+
!.gitignore

experiments/.hgempty

Whitespace-only changes.

gui/GUI_main.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,22 @@ def __init__(self):
9696
# Go to readthedocs
9797
documentation_action= QtGui.QAction("&Documentation", self)
9898
documentation_action.triggered.connect(self.view_docs)
99+
documentation_action.setIcon(QtGui.QIcon("gui/icons/book.svg"))
99100
help_menu.addAction(documentation_action)
100101
# Go to Google forum
101102
forum_action= QtGui.QAction("&Forum", self)
102103
forum_action.triggered.connect(self.view_forum)
104+
forum_action.setIcon(QtGui.QIcon("gui/icons/google-groups.svg")) #https://iconscout.com/icon/google-groups-1
103105
help_menu.addAction(forum_action)
104106
# Go to GitHub Repository
105107
github_action= QtGui.QAction("&GitHub Repository", self)
106108
github_action.triggered.connect(self.view_github)
109+
github_action.setIcon(QtGui.QIcon("gui/icons/github.svg")) #https://simpleicons.org/?q=github
107110
help_menu.addAction(github_action)
108111
# Keyboard shortcuts dialog.
109112
shortcuts_action = QtGui.QAction("&Keyboard shortcuts", self)
110113
shortcuts_action.triggered.connect(self.shortcuts_dialog.show)
114+
shortcuts_action.setIcon(QtGui.QIcon("gui/icons/keyboard.svg"))
111115
help_menu.addAction(shortcuts_action)
112116

113117
self.show()
@@ -127,10 +131,19 @@ def view_forum(self):
127131
def view_github(self):
128132
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://github.com/pyControl/pyControl"))
129133

134+
def get_task_file_list(self):
135+
'''Return list of .py files in tasks folder and subfolders in format:
136+
subdir_1/subdir_2/task_file_name.py'''
137+
task_files = []
138+
for (dirpath, dirnames, filenames) in os.walk(dirs['tasks']):
139+
task_files += [os.path.join(dirpath, file).split(dirs['tasks'])[1][1:-3]
140+
for file in filenames if file.endswith('.py')]
141+
return task_files
142+
130143
def refresh(self):
131144
'''Called regularly when framework not running.'''
132145
# Scan task folder.
133-
tasks = [t.split('.')[0] for t in os.listdir(dirs['tasks']) if t[-3:] == '.py']
146+
tasks = self.get_task_file_list()
134147
self.available_tasks_changed = tasks != self.available_tasks
135148
if self.available_tasks_changed:
136149
self.available_tasks = tasks

0 commit comments

Comments
 (0)