Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions Functions/+BpodLib/+BpodObject/+setup/updatePathAndSettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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
17 changes: 13 additions & 4 deletions Functions/+BpodLib/+calibration/+liquid/+ui/VerifyCOMGUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,30 @@ function VerifyCOMGUI(BpodSystem)
along with this program. If not, see <http://www.gnu.org/licenses/>.
%}

assert(strcmp(BpodLib.calibration.liquid.utils.checkCOM(BpodSystem), 'no'))
LiquidCal = BpodSystem.CalibrationTables.LiquidCal; % the handle is extracted for convenience

if BpodLib.multi.isMultiSetup(BpodSystem)
availableMachines = BpodLib.multi.listMultiSetups(BpodLib.path.getPath('config', BpodSystem, 'setuptype', 'single')); % we need to look in Config/ for multi setups

% 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', ...
Expand All @@ -52,7 +61,7 @@ function VerifyCOMGUI(BpodSystem)
return
end

selectedMachine = options{selectionIdx};
selectedMachine = machineNames{selectionIdx};
if strcmp(selectedMachine, ignoreOption)
return
end
Expand Down