diff --git a/Functions/+BpodLib/+calibration/+liquid/+portarray/createValveManager.m b/Functions/+BpodLib/+calibration/+liquid/+portarray/createValveManager.m index 2e46420f..50dd8360 100644 --- a/Functions/+BpodLib/+calibration/+liquid/+portarray/createValveManager.m +++ b/Functions/+BpodLib/+calibration/+liquid/+portarray/createValveManager.m @@ -32,8 +32,8 @@ %} PortArrayCal = BpodLib.calibration.liquid.ValveDataManagerClass(); - -for moduleNumber = 1:BpodSystem.Modules.nModules +nModules = numel(BpodSystem.Modules.Connected); +for moduleNumber = 1:nModules for valveIndex = 1:8 % Todo: Only the connected PA's? PortArrayCal.createValve(sprintf('PA%i_%i', moduleNumber, valveIndex)); end diff --git a/Functions/+BpodLib/+utils/getCurrentCOM.m b/Functions/+BpodLib/+utils/getCurrentCOM.m index a1d4aa8a..a546fa30 100644 --- a/Functions/+BpodLib/+utils/getCurrentCOM.m +++ b/Functions/+BpodLib/+utils/getCurrentCOM.m @@ -34,7 +34,7 @@ along with this program. If not, see . %} -if ~isfield(BpodSystem, 'SerialPort') +if ~isprop(BpodSystem, 'SerialPort') || isempty(BpodSystem.SerialPort) comport = 'EMU'; else comport = BpodSystem.SerialPort.PortName; diff --git a/Tests/BpodLib/calibration/liquid/test_save.m b/Tests/BpodLib/calibration/liquid/test_save.m index 6db17415..ae98cba1 100644 --- a/Tests/BpodLib/calibration/liquid/test_save.m +++ b/Tests/BpodLib/calibration/liquid/test_save.m @@ -15,27 +15,28 @@ function setup(testCase) valveManager.loadData(fullfile(testDataFolder, 'ExpectedLiquidCalibration.json')) testCase.TestData.mockValveDataManager = valveManager; - % Create various filesetups - mockBpod = struct(); - mockBpod.SerialPort.PortName = 'COM13'; - mockBpod.CalibrationTables.LiquidCal = valveManager; + % Create various file setups % Regular setup + mockBpod_regular = BpodLib.BpodObject.MockBpodObject('COM13'); + mockBpod_regular.CalibrationTables.LiquidCal = valveManager; folderPath = fullfile(rootPath, 'CF Regular'); - mockBpod.Path.LocalDir = folderPath; + mockBpod_regular.Path.LocalDir = folderPath; mkdir(folderPath) folderPath = fullfile(folderPath, 'Config'); mkdir(folderPath); - testCase.TestData.regularBpod = mockBpod; + testCase.TestData.regularBpod = mockBpod_regular; % Regular multi + mockBpod_multi = BpodLib.BpodObject.MockBpodObject('COM13'); + mockBpod_multi.CalibrationTables.LiquidCal = valveManager; folderPath = fullfile(rootPath, 'CF Multi'); mkdir(folderPath) - mockBpod.Path.LocalDir = folderPath; + mockBpod_multi.Path.LocalDir = folderPath; folderPath = fullfile(folderPath, 'Config'); mkdir(folderPath); mkdir(fullfile(folderPath, 'Machine-COM13')) mkdir(fullfile(folderPath, 'Machine-COM5')) - testCase.TestData.multiBpod = mockBpod; + testCase.TestData.multiBpod = mockBpod_multi; end function teardown(testCase) diff --git a/Tests/BpodLib/utils/test_utils.m b/Tests/BpodLib/utils/test_utils.m index d76de736..cd98fa7e 100644 --- a/Tests/BpodLib/utils/test_utils.m +++ b/Tests/BpodLib/utils/test_utils.m @@ -7,8 +7,7 @@ function setup(testCase) testCase.TestData.rootPath = rootPath; mkdir(testCase.TestData.rootPath) - mockBpod = struct(); - mockBpod.SerialPort.PortName = 'COM13'; + mockBpod = BpodLib.BpodObject.MockBpodObject('COM13'); mockBpod.Path.LocalDir = testCase.TestData.rootPath; testCase.TestData.mockBpod = mockBpod; end