From 6a12dd3d96d763b48d9a95c9931972f3f1f60354 Mon Sep 17 00:00:00 2001 From: George Stuyt <15712782+ogeesan@users.noreply.github.com> Date: Sun, 26 Oct 2025 22:26:22 +1100 Subject: [PATCH 1/2] Fix Bpod mocking and COM checking --- Functions/+BpodLib/+utils/getCurrentCOM.m | 2 +- Tests/BpodLib/calibration/liquid/test_save.m | 17 +++++++++-------- Tests/BpodLib/utils/test_utils.m | 3 +-- 3 files changed, 11 insertions(+), 11 deletions(-) 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 From f5a9fa096df210f015275205661eb5ccc360c2d6 Mon Sep 17 00:00:00 2001 From: George Stuyt <15712782+ogeesan@users.noreply.github.com> Date: Sun, 26 Oct 2025 22:26:31 +1100 Subject: [PATCH 2/2] Fix n-module check --- .../+calibration/+liquid/+portarray/createValveManager.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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