Skip to content

Commit 4241670

Browse files
authored
Merge pull request #41 from ogeesan/fix/test-errors
Fix getCurrentCOM
2 parents bc33156 + f5a9fa0 commit 4241670

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

Functions/+BpodLib/+calibration/+liquid/+portarray/createValveManager.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
%}
3333

3434
PortArrayCal = BpodLib.calibration.liquid.ValveDataManagerClass();
35-
36-
for moduleNumber = 1:BpodSystem.Modules.nModules
35+
nModules = numel(BpodSystem.Modules.Connected);
36+
for moduleNumber = 1:nModules
3737
for valveIndex = 1:8 % Todo: Only the connected PA's?
3838
PortArrayCal.createValve(sprintf('PA%i_%i', moduleNumber, valveIndex));
3939
end

Functions/+BpodLib/+utils/getCurrentCOM.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
along with this program. If not, see <http://www.gnu.org/licenses/>.
3535
%}
3636

37-
if ~isfield(BpodSystem, 'SerialPort')
37+
if ~isprop(BpodSystem, 'SerialPort') || isempty(BpodSystem.SerialPort)
3838
comport = 'EMU';
3939
else
4040
comport = BpodSystem.SerialPort.PortName;

Tests/BpodLib/calibration/liquid/test_save.m

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,28 @@ function setup(testCase)
1515
valveManager.loadData(fullfile(testDataFolder, 'ExpectedLiquidCalibration.json'))
1616
testCase.TestData.mockValveDataManager = valveManager;
1717

18-
% Create various filesetups
19-
mockBpod = struct();
20-
mockBpod.SerialPort.PortName = 'COM13';
21-
mockBpod.CalibrationTables.LiquidCal = valveManager;
18+
% Create various file setups
2219
% Regular setup
20+
mockBpod_regular = BpodLib.BpodObject.MockBpodObject('COM13');
21+
mockBpod_regular.CalibrationTables.LiquidCal = valveManager;
2322
folderPath = fullfile(rootPath, 'CF Regular');
24-
mockBpod.Path.LocalDir = folderPath;
23+
mockBpod_regular.Path.LocalDir = folderPath;
2524
mkdir(folderPath)
2625
folderPath = fullfile(folderPath, 'Config');
2726
mkdir(folderPath);
28-
testCase.TestData.regularBpod = mockBpod;
27+
testCase.TestData.regularBpod = mockBpod_regular;
2928

3029
% Regular multi
30+
mockBpod_multi = BpodLib.BpodObject.MockBpodObject('COM13');
31+
mockBpod_multi.CalibrationTables.LiquidCal = valveManager;
3132
folderPath = fullfile(rootPath, 'CF Multi');
3233
mkdir(folderPath)
33-
mockBpod.Path.LocalDir = folderPath;
34+
mockBpod_multi.Path.LocalDir = folderPath;
3435
folderPath = fullfile(folderPath, 'Config');
3536
mkdir(folderPath);
3637
mkdir(fullfile(folderPath, 'Machine-COM13'))
3738
mkdir(fullfile(folderPath, 'Machine-COM5'))
38-
testCase.TestData.multiBpod = mockBpod;
39+
testCase.TestData.multiBpod = mockBpod_multi;
3940
end
4041

4142
function teardown(testCase)

Tests/BpodLib/utils/test_utils.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ function setup(testCase)
77
testCase.TestData.rootPath = rootPath;
88
mkdir(testCase.TestData.rootPath)
99

10-
mockBpod = struct();
11-
mockBpod.SerialPort.PortName = 'COM13';
10+
mockBpod = BpodLib.BpodObject.MockBpodObject('COM13');
1211
mockBpod.Path.LocalDir = testCase.TestData.rootPath;
1312
testCase.TestData.mockBpod = mockBpod;
1413
end

0 commit comments

Comments
 (0)