From e8796ac45033dfe90faa24ab8ccaec45e0c88437 Mon Sep 17 00:00:00 2001 From: Mauco03 <marco.gaibotti@skywarder.eu> Date: Wed, 26 Mar 2025 21:52:30 +0100 Subject: [PATCH] [handle-value-conversion][Motor] Added input sanitisation for tank length and chamber pressure --- classes/bays/@Motor/Motor.m | 8 +++----- classes/bays/@Motor/loadData.m | 7 ++++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/classes/bays/@Motor/Motor.m b/classes/bays/@Motor/Motor.m index 0d95681..4ba795b 100644 --- a/classes/bays/@Motor/Motor.m +++ b/classes/bays/@Motor/Motor.m @@ -35,7 +35,7 @@ classdef Motor < Bay chamberPressure (1, :) double % [Pa] Pressure inside combustion chamber pe (1, :) double % [Pa] Eflux pressure time (1, :) double % [s] Engine time vector - cutoffTime (1, 1) double % [s] Shutdown time + cutoffTime double % [s] Shutdown time ignitionTransient (1, 1) double % [s] Ignition transient duration cutoffTransient (1, 1) double % [s] Cutoff transient duration tankLength (1, 1) double % [m] Tank length @@ -73,8 +73,7 @@ classdef Motor < Bay end %% Bay implementation - % Getters - methods + methods % Getters function value = get.name(obj) value = obj.NAME; end @@ -92,8 +91,7 @@ classdef Motor < Bay end end - % Setters - methods + methods % Setters function obj = set.name(obj, name) obj.NAME = name; obj = obj.loadData(); diff --git a/classes/bays/@Motor/loadData.m b/classes/bays/@Motor/loadData.m index 5bceb7f..5365122 100644 --- a/classes/bays/@Motor/loadData.m +++ b/classes/bays/@Motor/loadData.m @@ -27,9 +27,10 @@ end if obj.type == "Hybrid" obj.length = chosenMotor.L; - obj.tankLength = chosenMotor.Ltank; - if isempty(obj.tankLength) + if isempty(chosenMotor.Ltank) obj.tankLength = chosenMotor.LtankPr + chosenMotor.LtankOx; + else + obj.tankLength = chosenMotor.Ltank; end obj.fuelMass = chosenMotor.mFu; obj.oxidizerMass = chosenMotor.mOx; @@ -39,7 +40,7 @@ if obj.type == "Hybrid" obj.pe = chosenMotor.Pe(iUniqueTime); obj.ae = chosenMotor.Ae; obj.fuselageMass = chosenMotor.mFus; - if isfield(chosenMotor, 'Pc') + if ~isempty(chosenMotor.Pc) obj.chamberPressure = chosenMotor.Pc; end obj.MASS = obj.propellantMass + obj.structureMass; -- GitLab