diff --git a/classes/Component.m b/classes/Component.m index 5e0869df4a1cfc602cac5fcb9b185f49a6af4d5f..d99c1c59474ca0cf765e0bcca9428f43c96aa5c4 100644 --- a/classes/Component.m +++ b/classes/Component.m @@ -1,4 +1,4 @@ -classdef Component < Config +classdef Component < Config & matlab.mixin.Copyable % Component: Represents an abstraction layer for all components % Components standardize object construction, config and data loading % @@ -78,6 +78,17 @@ classdef Component < Config end methods(Access = protected) + function cp = copyElement(obj) + fields = obj.getProperties('readable', NonCopyable = 0); + cp = copyElement@matlab.mixin.Copyable(obj); %shallow copy of all elements + + for field = fields + if isa(obj.(field), 'matlab.mixin.Copyable') + cp.(field) = copy(obj.(field)); + end + end + end + function outputVariables = getConfig(obj, mission) fileName = obj.configName; filePath = mission.configPath; diff --git a/classes/Config.m b/classes/Config.m index aff4e5b3251ec130452f47315881e6859c8f9421..cec711a4737ba8e95eb0bc2c54ae6732da94de76 100644 --- a/classes/Config.m +++ b/classes/Config.m @@ -15,9 +15,7 @@ classdef(Abstract) Config < handle fields = obj.getProperties('readable'); for j = 1:size(fields, 2), structOut.(fields{j}) = obj.(fields{j}); end end - end - methods function [propertiesOut, valuesOut] = getProperties(obj, preset, options, attributes) % This function returns properties that match specific attributes % You can specify presets to include combinations of properties: @@ -44,6 +42,7 @@ classdef(Abstract) Config < handle attributes.Transient logical {mustBeMember(attributes.Transient, [0, 1])} = [] attributes.Hidden logical {mustBeMember(attributes.Hidden, [0, 1])} = [] attributes.AbortSet logical {mustBeMember(attributes.AbortSet, [0, 1])} = [] + attributes.NonCopyable logical {mustBeMember(attributes.NonCopyable, [0, 1])} = [] end if ~isempty(preset) diff --git a/classes/Rocket.m b/classes/Rocket.m index 26968d34573d6650cdc179beef7d4dcf31774239..3f3e895253d0cd6b737a808f94809a54708b082e 100644 --- a/classes/Rocket.m +++ b/classes/Rocket.m @@ -22,6 +22,7 @@ classdef Rocket < Component parachutes Para % [-] (nParachutes, nStages) Parachutes onboard length double % [m] Total length + lengthCenter double % [m] Center length - no nose, boat lengthCenterNoMot double % [m] Center length - no nose, no motor diameter double % [m] Diameter mass double % [kg] Total mass @@ -32,18 +33,18 @@ classdef Rocket < Component xCgNoMotor double % [m] xCg without motor stagesMass double % [kg] Mass of stage 2, 3, .. without chutes + + coefficients % [-] Aerodynamic coefficients + coefficientsHighAOA % [-] Aerodynamic coefficients for high angle of attacks end properties(SetAccess = protected) - lengthCenter double % [m] Center length - no nose, boat + crossSection % [m^2] Rocket cross sectional area inertiaDot double % [kg*m^2/s]Total inertia time derivative cutoffInertia double % [kg*m^2] Total inertia at motor cutoff cutoffMass double % [m] Total mass at motor cutoff - coefficients % [-] Aerodynamic coefficients - coefficientsHighAOA % [-] Aerodynamic coefficients for high angle of attacks absolutePositions dictionary ... % [m] Bay start positions - 0 is set at nose base = dictionary() - crossSection % [m^2] Rocket cross sectional area bays dictionary ... % [Bay] All bays = dictionary() end diff --git a/functions/miscellaneous/PoolWaitbar.m b/functions/miscellaneous/PoolWaitbar.m index ce3ed5532988bd35146d55990821c99d6e7ed691..012a62f71107735cf917d10ecb998867d132d4c3 100644 --- a/functions/miscellaneous/PoolWaitbar.m +++ b/functions/miscellaneous/PoolWaitbar.m @@ -1,47 +1,51 @@ -%{ - Example: - n = 20 - pw = PoolWaitbar(n, 'Example'); - parfor ii = 1:20 - increment(pw) - end -Copyright © 2021, Skyward Experimental Rocketry, AFD department -All rights reserved - -SPDX-License-Identifier: GPL-3.0-or-later - -%} classdef PoolWaitbar < handle +% Example: +% n = 20 +% pw = PoolWaitbar(n, 'Example'); +% parfor ii = 1:20 +% increment(pw) +% end +% Copyright © 2021, Skyward Experimental Rocketry, AFD department +% All rights reserved +% +% SPDX-License-Identifier: GPL-3.0-or-later + properties (SetAccess = immutable, GetAccess = private) Queue - N + n end + properties (Access = private, Transient) ClientHandle = [] Count = 0 end + properties (SetAccess = immutable, GetAccess = private, Transient) Listener = [] end + methods (Access = private) function localIncrement(obj) obj.Count = 1 + obj.Count; - waitbar(obj.Count / obj.N, obj.ClientHandle); + waitbar(obj.Count / obj.n, obj.ClientHandle); end end + methods function obj = PoolWaitbar(N, message) if nargin < 2 message = 'PoolWaitbar'; end - obj.N = N; + obj.n = N; obj.ClientHandle = waitbar(0, message); obj.Queue = parallel.pool.DataQueue; obj.Listener = afterEach(obj.Queue, @(~) localIncrement(obj)); end + function increment(obj) send(obj.Queue, true); end + function delete(obj) delete(obj.ClientHandle); delete(obj.Queue);