diff --git a/classes/Bay.m b/classes/Bay.m new file mode 100644 index 0000000000000000000000000000000000000000..055847e981d03cf77a46f309ef8a7ab1619e0a3f --- /dev/null +++ b/classes/Bay.m @@ -0,0 +1,38 @@ +classdef (Abstract) Bay < Config + % An abstraction class that enables a standardized management of data + % Properties and methods implemented in the Component class will + % impact every physical component of the rocket (e.g. motor, elc ...) + + properties(Abstract) + length + diameter + mass + inertia + end + + properties(Abstract, Access = protected) + % Insert dependencies here + mission Mission + end + + methods(Abstract) + loadData(obj) + end + + methods(Access = protected) + function loadConfig(obj) + fileName = obj.configName; + filePath = obj.mission.configPath; + if ~isfile(fullfile(filePath, fileName)) + error(strcat("File not found inside the config folder: ", filePath)); + end + + varName = strtok(fileName,'C'); + run(fileName); + configObj = eval(varName); + fields = obj.getAvailableProperties(); + for j = 1:size(fields, 2), obj.(fields{j}) = configObj.(fields{j}); end + end + end +end + diff --git a/classes/Component.asv b/classes/Component.asv new file mode 100644 index 0000000000000000000000000000000000000000..1a2e1422ea4be7a75f128c4acb17a32e34da9fff --- /dev/null +++ b/classes/Component.asv @@ -0,0 +1,25 @@ +classdef (Abstract) Component < Config + % An abstraction class that enables a standardized management of data + % Properties and methods implemented in the Component class will impact + % every data class in the framework (e.g. Component and its subclasses) + + + properties + Property1 + end + + methods + function obj = Component(inputArg1,inputArg2) + %COMPONENT Construct an instance of this class + % Detailed explanation goes here + obj.Property1 = inputArg1 + inputArg2; + end + + function outputArg = method1(obj,inputArg) + %METHOD1 Summary of this method goes here + % Detailed explanation goes here + outputArg = obj.Property1 + inputArg; + end + end +end + diff --git a/missions/classes/Config.m b/classes/Config.m similarity index 58% rename from missions/classes/Config.m rename to classes/Config.m index 0ae56e2f49a65a174c8047b9c316188770de4384..e77bddc1d34002b2d2b7c9d93db09b1df5ae6a76 100644 --- a/missions/classes/Config.m +++ b/classes/Config.m @@ -1,54 +1,13 @@ classdef(Abstract) Config < handle % An abstraction class that enables a standardized management of data - % Grants the ability to load respective config + % Properties and methods implemented in the Config class will impact + % every data class in the framework (e.g. Component and its subclasses) properties(Abstract, Access = protected) - mission Mission - end - - properties(Access = protected, Abstract) configName {mustBeTextScalar} end - properties(Access = public) - a = 0; - end - methods(Access = protected) - function loadConfig(obj) - fileName = obj.configName; - filePath = obj.mission.configPath; - if ~isfile(fullfile(filePath, fileName)) - error(strcat("File not found inside the config folder: ", filePath)); - end - - varName = strtok(fileName,'C'); - run(fileName); - configObj = eval(varName); - fields = getAvailableProperties(obj); - for j = 1:length(fields), obj.(fields{j}) = configObj.(fields{j}); end - end - - function varargout = getConfig(varargin) - varargout = cell(1, nargin-1); - missionTemp = varargin{1}.mission; - - %% LOAD desired configs - for i = 2:nargin - fileName = char(varargin{i}); - if ~isfile(fullfile(varargin{1}.mission.configPath, fileName)) - error(strcat("File not found inside the config folder: ", varargin{i})); - end - - varName = strtok(fileName,'C'); - run(fileName); - configObj = eval(varName); - - varargout{i-1} = configObj; - varargout{i-1}.mission = missionTemp; - end - end - function propertiesOut = getAvailableProperties(obj) % This function returns "available" properties % Available means: not Dependent, not Hidden, public diff --git a/classes/Mission.m b/classes/Mission.m new file mode 100644 index 0000000000000000000000000000000000000000..d9edb83ef43bdaed7632955e68f184ff728d723d --- /dev/null +++ b/classes/Mission.m @@ -0,0 +1,44 @@ +classdef Mission < Config + % Class containing names and paths to access mission files + % This should be the first class to be created, + % when running a tool. + % + % To get an empty Mission, run "Mission()", or "Mission(false)" + % To get an initialized Mission, run "Mission(true)" + % Where the argument specifies whether to read config files or not + + properties + name % Mission name, used to access <mission> folder + currentPath + end + + properties(Dependent) + configPath + dataPath + end + + properties(Access = protected) + configName = 'missionConfig.m' + end + + methods + function obj = Mission(loadConfig) + arguments + loadConfig {islogical} = false + end + if loadConfig, obj.loadConfig; end + end + + function path = get.configPath(obj) + if (obj.name), path = fullfile(obj.currentPath, obj.name, 'config'); + else, path = ''; + end + end + + function path = get.dataPath(obj) + if (obj.name), path = fullfile(obj.currentPath, obj.name, 'data'); + else, path = ''; + end + end + end +end \ No newline at end of file diff --git a/missions/classes/components/Boat.m b/classes/bays/Boat.m similarity index 100% rename from missions/classes/components/Boat.m rename to classes/bays/Boat.m diff --git a/missions/classes/components/Center.m b/classes/bays/Center.m similarity index 100% rename from missions/classes/components/Center.m rename to classes/bays/Center.m diff --git a/missions/classes/components/Fins.m b/classes/bays/Fins.m similarity index 100% rename from missions/classes/components/Fins.m rename to classes/bays/Fins.m diff --git a/missions/classes/Motor.m b/classes/bays/Motor.m similarity index 90% rename from missions/classes/Motor.m rename to classes/bays/Motor.m index 7c3b769ec2f5ef83e7132bed323175d144a8b69e..adf8ce8d02ca762d8ae00b1a70f827d2c24d4606 100644 --- a/missions/classes/Motor.m +++ b/classes/bays/Motor.m @@ -1,10 +1,10 @@ -classdef Motor < Config +classdef Motor < Bay %MOTOR Summary of this class goes here % Detailed explanation goes here properties name {mustBeTextScalar} = '' % [-] Motor name - motorLength double % [m] Motor length + motorLength double % [kg] Motor length tankLength double % [m] Tank length ignitionTime double % [s] Ignition transient duration cutoffTime double % [s] Cutoff transient duration @@ -22,13 +22,14 @@ classdef Motor < Config properties(Dependent) totalMass double % [kg] Total motor mass + length double % [m] Total length (motor + tank) totalLength double % [m] Motor + Tank lenght fuselageXCg double % [m] xcg of the engine fuselage only from tank tip end properties(Access = protected) configName = 'motorConfig.m' - mission Mission + mission {mustBeA(mission, 'Config')} end methods @@ -53,12 +54,12 @@ classdef Motor < Config end function fuselageXCg = get.fuselageXCg(obj) - fuselageXCg = (obj.motorLength - ... + fuselageXCg = (obj.length - ... obj.tankLength)/2 + obj.tankLength; end function totalLength = get.totalLength(obj) - totalLength = obj.motorLength + obj.tankLength; + totalLength = obj.length + obj.tankLength; end end @@ -69,7 +70,7 @@ classdef Motor < Config chosenMotor = motors(strcmp({motors.MotorName}, obj.name)); if isempty(chosenMotor), error(strcat('Unable to find engine: ', obj.name)); end - obj.motorLength = chosenMotor.L; + obj.length = chosenMotor.L; obj.tankLength = chosenMotor.Ltank; obj.time = chosenMotor.t; obj.thrust = chosenMotor.T; diff --git a/missions/classes/components/Nose.m b/classes/bays/Nose.m similarity index 100% rename from missions/classes/components/Nose.m rename to classes/bays/Nose.m diff --git a/missions/classes/components/Pitot.m b/classes/bays/Pitot.m similarity index 100% rename from missions/classes/components/Pitot.m rename to classes/bays/Pitot.m diff --git a/missions/classes/components/Protuberances.m b/classes/bays/Protuberances.m similarity index 100% rename from missions/classes/components/Protuberances.m rename to classes/bays/Protuberances.m diff --git a/missions/classes/Control.m b/classes/old/Control.m similarity index 100% rename from missions/classes/Control.m rename to classes/old/Control.m diff --git a/missions/classes/Environment.asv b/classes/old/Environment.asv similarity index 100% rename from missions/classes/Environment.asv rename to classes/old/Environment.asv diff --git a/missions/classes/Environment.m b/classes/old/Environment.m similarity index 100% rename from missions/classes/Environment.m rename to classes/old/Environment.m diff --git a/missions/classes/Geometries.m b/classes/old/Geometries.m similarity index 100% rename from missions/classes/Geometries.m rename to classes/old/Geometries.m diff --git a/missions/classes/Masses.m b/classes/old/Masses.m similarity index 100% rename from missions/classes/Masses.m rename to classes/old/Masses.m diff --git a/missions/classes/Mission.m b/missions/classes/Mission.m deleted file mode 100644 index d0d6a5742a63c400cfc9471f16dd99aeec512804..0000000000000000000000000000000000000000 --- a/missions/classes/Mission.m +++ /dev/null @@ -1,80 +0,0 @@ -classdef Mission < handle - % Class containing names and paths to access mission files - % This should be the first class to be created, - % when running a tool. - % - % To get an empty Mission, run "Mission()", or "Mission(false)" - % To get an initialized Mission, run "Mission(true)" - % Where the argument specifies whether to read config files or not - - properties - name % Mission name, used to access <mission> folder - currentPath - end - - properties(Dependent) - configPath - dataPath - end - - properties(Access = protected) - configName = 'missionConfig.m' - end - - methods - function obj = Mission(loadConfig) - arguments - loadConfig {islogical} = false - end - if loadConfig, obj.loadConfig; end - end - - function path = get.configPath(obj) - if (obj.name), path = fullfile(obj.currentPath, obj.name, 'config'); - else, path = ''; - end - end - - function path = get.dataPath(obj) - if (obj.name), path = fullfile(obj.currentPath, obj.name, 'data'); - else, path = ''; - end - end - end - - methods(Access = private) - function loadConfig(obj) - fileName = obj.configName; - filePath = fullfile(fileparts(mfilename("fullpath")), '..'); - if ~isfile(fullfile(filePath, fileName)) - error(strcat("File not found inside the mission folder: ", filePath)); - end - - varName = strtok(fileName,'C'); - run(fileName); - configObj = eval(varName); - fields = getAvailableProperties(configObj); - for j = 1:length(fields), obj.(fields{j}) = configObj.(fields{j}); end - obj.currentPath = filePath; - end - - function propertiesOut = getAvailableProperties(obj) - % This function returns "available" properties - % Available means: not Dependent, not Hidden, public - mc = metaclass(obj); - ii = 0; - nProperties = length(mc.PropertyList); - properties = cell(1,nProperties); - for c = 1:nProperties - mp = mc.PropertyList(c); - if ~(mp.Dependent || mp.Hidden) && ... - strcmp(mp.GetAccess, 'public') && ... - strcmp(mp.SetAccess, 'public') - ii = ii + 1; - properties(ii) = {mp.Name}; - end - end - propertiesOut = properties(1:ii); - end - end -end \ No newline at end of file