Skip to content

Commit 84c2da8

Browse files
authored
Merge pull request #45 from ogeesan/fix/liquidcal-comcheck-description
Improve LiquidCalibration.json COM mismatch UI
2 parents 61f8070 + c7481e6 commit 84c2da8

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

Functions/+BpodLib/+BpodObject/+setup/updatePathAndSettings.m

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,6 @@ function updatePathAndSettings(BpodSystem, varargin)
118118

119119
try
120120
BpodSystem.CalibrationTables.LiquidCal = BpodLib.calibration.liquid.io.load('BpodSystem', BpodSystem, 'LocalDir', LocalDir, 'type', 'statemachine');
121-
if strcmp(BpodLib.calibration.liquid.utils.checkCOM(BpodSystem), 'no')
122-
if p.Results.verbose
123-
BpodLib.calibration.liquid.ui.VerifyCOMGUI(BpodSystem);
124-
end
125-
end
126121
catch err
127122
if strcmp(err.identifier, 'BpodLib:LiquidCalibrationLoad:FileNotFound')
128123
BpodSystem.CalibrationTables.LiquidCal = [];
@@ -228,4 +223,13 @@ function updatePathAndSettings(BpodSystem, varargin)
228223
% I don't see why this would happen, but if it does it's going to be a problem.
229224
end
230225

226+
%% -- Final verifications
227+
% Functions that require BpodSystem to be fully setup can be called here.
228+
if strcmp(BpodLib.calibration.liquid.utils.checkCOM(BpodSystem), 'no')
229+
if p.Results.verbose
230+
BpodLib.calibration.liquid.ui.VerifyCOMGUI(BpodSystem);
231+
end
232+
end
233+
234+
231235
end

Functions/+BpodLib/+calibration/+liquid/+ui/VerifyCOMGUI.m

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,30 @@ function VerifyCOMGUI(BpodSystem)
2727
along with this program. If not, see <http://www.gnu.org/licenses/>.
2828
%}
2929

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

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

3635
% Multi setup - ask user which machine to import from.
3736
prompt = {
38-
sprintf('The Bpod COM port (%s) does not match the', BpodLib.utils.getCurrentCOM(BpodSystem));
37+
sprintf('The Bpod COM port (%s) does not match', BpodLib.utils.getCurrentCOM(BpodSystem));
3938
sprintf('liquid calibration file''s COM port (%s).', LiquidCal.metadata.COM);
4039
'Please select which COM to copy in the liquid';
4140
'calibration file from:'
4241
};
4342
ignoreOption = 'I will remember to recalibrate. (ignore)';
44-
options = [{ignoreOption}, availableMachines'];
43+
machineNames = [{ignoreOption}, availableMachines'];
44+
options = machineNames;
45+
46+
% Replace thisMachineName with '(current machine)' in the list
47+
[~, thisMachineName] = fileparts(BpodLib.path.getPath('config', BpodSystem))
48+
for i = 1:length(options)
49+
if strcmp(options{i}, thisMachineName)
50+
options{i} = sprintf('%s (use existing file)', thisMachineName);
51+
break
52+
end
53+
end
4554

4655
[selectionIdx, ok] = listdlg('PromptString', prompt, ...
4756
'SelectionMode', 'single', ...
@@ -52,7 +61,7 @@ function VerifyCOMGUI(BpodSystem)
5261
return
5362
end
5463

55-
selectedMachine = options{selectionIdx};
64+
selectedMachine = machineNames{selectionIdx};
5665
if strcmp(selectedMachine, ignoreOption)
5766
return
5867
end

0 commit comments

Comments
 (0)