Skip to content

Commit

Permalink
Fix to allow for single scan runs (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcoreymv authored Nov 20, 2023
1 parent 95e5438 commit 67b22e0
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions lumaviewpro.py
Original file line number Diff line number Diff line change
Expand Up @@ -2907,10 +2907,28 @@ def autofocus_scan_iterate(self, dt):
lumaview.ids['motionsettings_id'].ids['verticalcontrol_id'].autofocus()
return


def _initialize_protocol_data_folder(self):
if os.path.basename(settings['protocol']['filepath']) == "":
protocol_filename = "unsaved_protocol.tsv"
else:
protocol_filename = os.path.basename(settings['protocol']['filepath'])

# Create the folder to save the protocol captures and protocol itself
save_folder = pathlib.Path(settings['live_folder']) / "ProtocolData"
save_folder.mkdir(parents=True, exist_ok=True)
self.protocol_run_dir = self._create_protocol_run_folder(parent_dir=save_folder)
protocol_filepath = self.protocol_run_dir / protocol_filename
self.save_protocol(
filepath=protocol_filepath,
update_protocol_filepath=False
)


# Run one scan of the protocol
def run_scan(self, protocol = False):
logger.info('[LVP Main ] ProtocolSettings.run_scan()')

# If there are no steps, do not continue
if len(self.step_names) < 1:
logger.warning('[LVP Main ] Protocol has no steps.')
Expand All @@ -2922,6 +2940,11 @@ def run_scan(self, protocol = False):
if self.ids['run_scan_btn'].state == 'down' or protocol == True:
self.ids['run_scan_btn'].text = 'Running Scan'

# When only running a single scan (instead of a protocol)
# do similar setup as is done for protocol
if protocol is False:
self._initialize_protocol_data_folder()

# TODO: shut off live updates

# reset the is_complete flag on autofocus
Expand Down Expand Up @@ -3094,21 +3117,7 @@ def run_protocol(self):
self.start_t = time.time() # start of cycle in seconds

if self.ids['run_protocol_btn'].state == 'down':

if os.path.basename(settings['protocol']['filepath']) == "":
protocol_filename = "unsaved_protocol.tsv"
else:
protocol_filename = os.path.basename(settings['protocol']['filepath'])

# Create the folder to save the protocol captures and protocol itself
save_folder = pathlib.Path(settings['live_folder']) / "ProtocolData"
save_folder.mkdir(parents=True, exist_ok=True)
self.protocol_run_dir = self._create_protocol_run_folder(parent_dir=save_folder)
protocol_filepath = self.protocol_run_dir / protocol_filename
self.save_protocol(
filepath=protocol_filepath,
update_protocol_filepath=False
)
self._initialize_protocol_data_folder()

logger.info('[LVP Main ] Clock.unschedule(self.scan_iterate)')
Clock.unschedule(self.scan_iterate) # unschedule all copies of scan iterate
Expand Down

0 comments on commit 67b22e0

Please sign in to comment.