diff --git a/Functions/+BpodLib/+BpodObject/+setup/updatePathAndSettings.m b/Functions/+BpodLib/+BpodObject/+setup/updatePathAndSettings.m index f51d533e..18184c3b 100644 --- a/Functions/+BpodLib/+BpodObject/+setup/updatePathAndSettings.m +++ b/Functions/+BpodLib/+BpodObject/+setup/updatePathAndSettings.m @@ -117,11 +117,6 @@ function updatePathAndSettings(BpodSystem, varargin) try BpodSystem.CalibrationTables.LiquidCal = BpodLib.calibration.liquid.io.load('BpodSystem', BpodSystem, 'LocalDir', LocalDir, 'type', 'statemachine'); - if strcmp(BpodLib.calibration.liquid.utils.checkCOM(BpodSystem), 'no') - if p.Results.verbose - BpodLib.calibration.liquid.ui.VerifyCOMGUI(BpodSystem); - end - end catch err if strcmp(err.identifier, 'BpodLib:LiquidCalibrationLoad:FileNotFound') BpodSystem.CalibrationTables.LiquidCal = []; @@ -227,4 +222,13 @@ function updatePathAndSettings(BpodSystem, varargin) % I don't see why this would happen, but if it does it's going to be a problem. end +%% -- Final verifications +% Functions that require BpodSystem to be fully setup can be called here. +if strcmp(BpodLib.calibration.liquid.utils.checkCOM(BpodSystem), 'no') + if p.Results.verbose + BpodLib.calibration.liquid.ui.VerifyCOMGUI(BpodSystem); + end +end + + end \ No newline at end of file diff --git a/Functions/+BpodLib/+calibration/+liquid/+ui/VerifyCOMGUI.m b/Functions/+BpodLib/+calibration/+liquid/+ui/VerifyCOMGUI.m index aba6ab52..d1d0d30e 100644 --- a/Functions/+BpodLib/+calibration/+liquid/+ui/VerifyCOMGUI.m +++ b/Functions/+BpodLib/+calibration/+liquid/+ui/VerifyCOMGUI.m @@ -27,7 +27,6 @@ function VerifyCOMGUI(BpodSystem) along with this program. If not, see . %} -assert(strcmp(BpodLib.calibration.liquid.utils.checkCOM(BpodSystem), 'no')) LiquidCal = BpodSystem.CalibrationTables.LiquidCal; % the handle is extracted for convenience if BpodLib.multi.isMultiSetup(BpodSystem) @@ -35,13 +34,23 @@ function VerifyCOMGUI(BpodSystem) % Multi setup - ask user which machine to import from. prompt = { - sprintf('The Bpod COM port (%s) does not match the', BpodLib.utils.getCurrentCOM(BpodSystem)); + sprintf('The Bpod COM port (%s) does not match', BpodLib.utils.getCurrentCOM(BpodSystem)); sprintf('liquid calibration file''s COM port (%s).', LiquidCal.metadata.COM); 'Please select which COM to copy in the liquid'; 'calibration file from:' }; ignoreOption = 'I will remember to recalibrate. (ignore)'; - options = [{ignoreOption}, availableMachines']; + machineNames = [{ignoreOption}, availableMachines']; + options = machineNames; + + % Replace thisMachineName with '(current machine)' in the list + [~, thisMachineName] = fileparts(BpodLib.path.getPath('config', BpodSystem)) + for i = 1:length(options) + if strcmp(options{i}, thisMachineName) + options{i} = sprintf('%s (use existing file)', thisMachineName); + break + end + end [selectionIdx, ok] = listdlg('PromptString', prompt, ... 'SelectionMode', 'single', ... @@ -52,7 +61,7 @@ function VerifyCOMGUI(BpodSystem) return end - selectedMachine = options{selectionIdx}; + selectedMachine = machineNames{selectionIdx}; if strcmp(selectedMachine, ignoreOption) return end