Skip to content

Commit

Permalink
Task #207 Code improvement and review.
Browse files Browse the repository at this point in the history
  • Loading branch information
ngat_di authored and ngat_di committed Mar 12, 2024
1 parent dae18de commit ef97dcc
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
*/
public class CreateDLRCEFXStudyCommand {

static final String POWER_NAME = "Power";
static final String STRUCTURE_NAME = "Structure";
static final String AOCS_NAME = "AOCS";
static final String PAYLOAD_NAME = "Payload";
static final String DATAHANDLING_NAME = "DataHandling";

/**
* Private constructor.
*/
Expand Down Expand Up @@ -69,40 +75,40 @@ public static CompoundCommand create(EObject parent, Concept conceptPs, Concept


ProductTreeDomain powerProductTreeDomain = DLRCEFXStudyCommandHelper.createSubSystemAsProductTreeDomain(conceptPs);
powerProductTreeDomain.setName("Power");
powerProductTreeDomain.setName(POWER_NAME);
ProductTreeDomain structureProductTreeDomain = DLRCEFXStudyCommandHelper.createSubSystemAsProductTreeDomain(conceptPs);
structureProductTreeDomain.setName("Structure");
structureProductTreeDomain.setName(STRUCTURE_NAME);
ProductTreeDomain aocsProductTreeDomain = DLRCEFXStudyCommandHelper.createSubSystemAsProductTreeDomain(conceptPs);
aocsProductTreeDomain.setName("AOCS");
aocsProductTreeDomain.setName(AOCS_NAME);
ProductTreeDomain payloadProductTreeDomain = DLRCEFXStudyCommandHelper.createSubSystemAsProductTreeDomain(conceptPs);
payloadProductTreeDomain.setName("Payload");
payloadProductTreeDomain.setName(PAYLOAD_NAME);
ProductTreeDomain dataHandlingProductTreeDomain = DLRCEFXStudyCommandHelper.createSubSystemAsProductTreeDomain(conceptPs);
dataHandlingProductTreeDomain.setName("DataHandling");
dataHandlingProductTreeDomain.setName(DATAHANDLING_NAME);

ElementConfiguration powerSubsystem = DLRCEFXStudyCommandHelper.createSubSystemAsElementConfiguration(conceptPs);
powerSubsystem.setName("Power");
powerSubsystem.setName(POWER_NAME);
ElementConfiguration structureSubsystem = DLRCEFXStudyCommandHelper.createSubSystemAsElementConfiguration(conceptPs);
structureSubsystem.setName("Structure");
structureSubsystem.setName(STRUCTURE_NAME);
ElementConfiguration aocsSubsystem = DLRCEFXStudyCommandHelper.createSubSystemAsElementConfiguration(conceptPs);
aocsSubsystem.setName("AOCS");
aocsSubsystem.setName(AOCS_NAME);
ElementConfiguration payloadSubsystem = DLRCEFXStudyCommandHelper.createSubSystemAsElementConfiguration(conceptPs);
payloadSubsystem.setName("Payload");
payloadSubsystem.setName(PAYLOAD_NAME);
ElementConfiguration dataHandlingSubsystem = DLRCEFXStudyCommandHelper.createSubSystemAsElementConfiguration(conceptPs);
dataHandlingSubsystem.setName("DataHandling");
dataHandlingSubsystem.setName(DATAHANDLING_NAME);

BeanDiscipline powerBeanDiscipline = DLRCEFXStudyCommandHelper.createDiscipline(domain, "Power");
BeanDiscipline powerBeanDiscipline = DLRCEFXStudyCommandHelper.createDiscipline(domain, POWER_NAME);
powerEquipment.setAssignedDiscipline(powerBeanDiscipline);
powerElementDefinition.setAssignedDiscipline(powerBeanDiscipline);
BeanDiscipline strucureBeanDiscipline = DLRCEFXStudyCommandHelper.createDiscipline(domain, "Structure");
BeanDiscipline strucureBeanDiscipline = DLRCEFXStudyCommandHelper.createDiscipline(domain, STRUCTURE_NAME);
structureElementDefinition.setAssignedDiscipline(strucureBeanDiscipline);
structureEquipment.setAssignedDiscipline(strucureBeanDiscipline);
BeanDiscipline aocsBeanDiscipline = DLRCEFXStudyCommandHelper.createDiscipline(domain, "AOCS");
BeanDiscipline aocsBeanDiscipline = DLRCEFXStudyCommandHelper.createDiscipline(domain, AOCS_NAME);
aocsEquipment.setAssignedDiscipline(aocsBeanDiscipline);
aocsElementDefinition.setAssignedDiscipline(aocsBeanDiscipline);
BeanDiscipline payloadBeanDiscipline = DLRCEFXStudyCommandHelper.createDiscipline(domain, "Payload");
BeanDiscipline payloadBeanDiscipline = DLRCEFXStudyCommandHelper.createDiscipline(domain, PAYLOAD_NAME);
payloadEquipment.setAssignedDiscipline(payloadBeanDiscipline);
payloadElementDefinition.setAssignedDiscipline(payloadBeanDiscipline);
BeanDiscipline dataHandlingBeanDiscipline = DLRCEFXStudyCommandHelper.createDiscipline(domain, "DataHandling");
BeanDiscipline dataHandlingBeanDiscipline = DLRCEFXStudyCommandHelper.createDiscipline(domain, DATAHANDLING_NAME);
dataHandlingEquipment.setAssignedDiscipline(dataHandlingBeanDiscipline);
dataHandlingElementDefinition.setAssignedDiscipline(dataHandlingBeanDiscipline);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ public class DLRCEFXStudyCommandHelper {
static final int DEFAULT_TEMPERATURE_OPS_MIN = 15;
static final int DEFAULT_MARGIN_MATURITY = 20;
static final int DEFAULT_EQUIPMENT_MASS_PARAMETERS = 10;

static final String SYSTEM_NAME = "System";
static final String PRODUCT_TREE_NAME = "ProductTree";
static final String PRODUCT_TREE_DOMAIN_NAME = "PTD";
static final String SUB_SYSTEM_NAME = "SubSystem";
static final String EQUIPMENT_NAME = "Equipment";
static final String SYSTEM_PARAMETERS_NAME = "SystemParameters";
static final String MASS_PARAMETERS_NAME = "MassParameters";
static final String POWER_PARAMETERS_NAME = "PowerParameters";
static final String EQUIPMENT_MASS_PARAMETERS_NAME = "EquipmentMassParameters";
static final String TEMPERATURE_PARAMETERS_NAME = "TemperatureParameters";
/**
* private Constructor
*/
Expand Down Expand Up @@ -104,7 +115,7 @@ public static Concept getPsConcept(VirSatTransactionalEditingDomain domain) {
public static ConfigurationTree createSystemAsConfigurationTree(Concept conceptPs) {

ConfigurationTree system = new ConfigurationTree(conceptPs);
system.setName("System");
system.setName(SYSTEM_NAME);
return system;
}

Expand All @@ -116,7 +127,7 @@ public static ConfigurationTree createSystemAsConfigurationTree(Concept conceptP
public static ProductTree createSystemAsProductTree(Concept conceptPs) {

ProductTree system = new ProductTree(conceptPs);
system.setName("ProductTree");
system.setName(PRODUCT_TREE_NAME);
return system;
}

Expand All @@ -127,7 +138,7 @@ public static ProductTree createSystemAsProductTree(Concept conceptPs) {
*/
public static ProductTreeDomain createSubSystemAsProductTreeDomain(Concept conceptPs) {
ProductTreeDomain productTreeDomain = new ProductTreeDomain(conceptPs);
productTreeDomain.setName("PTD");
productTreeDomain.setName(PRODUCT_TREE_DOMAIN_NAME);
return productTreeDomain;
}

Expand All @@ -138,7 +149,7 @@ public static ProductTreeDomain createSubSystemAsProductTreeDomain(Concept conce
*/
public static ElementConfiguration createSubSystemAsElementConfiguration(Concept conceptPs) {
ElementConfiguration subSystem = new ElementConfiguration(conceptPs);
subSystem.setName("subSystem");
subSystem.setName(SUB_SYSTEM_NAME);
return subSystem;
}

Expand All @@ -148,7 +159,7 @@ public static ElementConfiguration createSubSystemAsElementConfiguration(Concept
*/
public static ElementDefinition createEquipmentAsElementDefinition(Concept conceptPs) {
ElementDefinition equipment = new ElementDefinition(conceptPs);
equipment.setName("ReactionWheel");
equipment.setName(EQUIPMENT_NAME);
return equipment;
}

Expand All @@ -158,7 +169,7 @@ public static ElementDefinition createEquipmentAsElementDefinition(Concept conce
*/
public static ElementConfiguration createEquipmentAsElementConfiguration(Concept conceptPs) {
ElementConfiguration equipment = new ElementConfiguration(conceptPs);
equipment.setName("equipment");
equipment.setName(EQUIPMENT_NAME);
return equipment;
}

Expand All @@ -168,19 +179,19 @@ public static ElementConfiguration createEquipmentAsElementConfiguration(Concept
public static void addSystemParameters(Concept conceptCEFX, ConfigurationTree system) {
//default unit in concept is percent
SystemParameters systemParameters = new SystemParameters(conceptCEFX);
systemParameters.setName("systemParameters");
systemParameters.setName(SYSTEM_PARAMETERS_NAME);
systemParameters.setSystemMargin(DEFAULT_SYSTEM_MAGRIN);
system.add(systemParameters);

SystemMassParameters systemMassParameters = new SystemMassParameters(conceptCEFX);
systemMassParameters.setName("massParameters");
systemMassParameters.setName(MASS_PARAMETERS_NAME);
systemMassParameters.getMassAdapter().setDefaultValue(DEFAULT_MASS_ADAPTER);
systemMassParameters.getMassLaunchMax().setDefaultValue(DEFAULT_MASS_LAUNCH_MAX);
systemMassParameters.getMassPropellant().setDefaultValue(DEFAULT_MASS_PROPELLANT);
system.add(systemMassParameters);

SystemPowerParameters systemPowerParameters = new SystemPowerParameters(conceptCEFX);
systemPowerParameters.setName("powerParameters");
systemPowerParameters.setName(POWER_PARAMETERS_NAME);
system.add(systemPowerParameters);
}

Expand All @@ -197,11 +208,11 @@ public static void addProductTreeDomainParameters(Concept conceptCEFX, ProductTr
*/
public static void addSubSystemParameters(Concept conceptCEFX, ElementConfiguration subSystem) {
SubSystemMassParameters subSystemMassParameters = new SubSystemMassParameters(conceptCEFX);
subSystemMassParameters.setName("massParameters");
subSystemMassParameters.setName(MASS_PARAMETERS_NAME);
subSystem.add(subSystemMassParameters);

SubSystemPowerParameters subSystemPowerParameters = new SubSystemPowerParameters(conceptCEFX);
subSystemPowerParameters.setName("powerParameters");
subSystemPowerParameters.setName(POWER_PARAMETERS_NAME);
subSystem.add(subSystemPowerParameters);
}

Expand All @@ -214,16 +225,16 @@ public static void addEquipmentParameters(Concept conceptCEFX, ElementConfigurat
equipment.add(equipmentParams);

EquipmentMassParameters equipmentMassParameters = new EquipmentMassParameters(conceptCEFX);
equipmentMassParameters.setName("EquipmentMassParameters");
equipmentMassParameters.setName(EQUIPMENT_MASS_PARAMETERS_NAME);
equipmentMassParameters.getMass().setDefaultValue(DEFAULT_EQUIPMENT_MASS_PARAMETERS);
equipment.add(equipmentMassParameters);

EquipmentPowerParameters powerParameters = new EquipmentPowerParameters(conceptCEFX);
powerParameters.setName("powerParameters");
powerParameters.setName(POWER_PARAMETERS_NAME);
equipment.add(powerParameters);

EquipmentTemperatureParameters temperatureParameters = new EquipmentTemperatureParameters(conceptCEFX);
temperatureParameters.setName("temperatureParameters");
temperatureParameters.setName(TEMPERATURE_PARAMETERS_NAME);
temperatureParameters.getTemperatureNoOpsMax().setDefaultValue(DEFAULT_TEMPERATURE_NO_OPS_MAX);
temperatureParameters.getTemperatureNoOpsMin().setDefaultValue(DEFAULT_TEMPERATURE_NO_OPS_MIN);
temperatureParameters.getTemperatureOpsMax().setDefaultValue(DEFAULT_TEMPERATURE_OPS_MAX);
Expand All @@ -240,7 +251,7 @@ public static void addElementDefinitionParameters(Concept conceptCEFX, ElementDe
elementDefinition.add(equipmentParams);

EquipmentMassParameters equipmentMassParameters = new EquipmentMassParameters(conceptCEFX);
equipmentMassParameters.setName("EquipmentMassParameters");
equipmentMassParameters.setName(EQUIPMENT_MASS_PARAMETERS_NAME);
equipmentMassParameters.getMass().setDefaultValue(DEFAULT_EQUIPMENT_MASS_PARAMETERS);
elementDefinition.add(equipmentMassParameters);

Expand All @@ -259,7 +270,7 @@ public static BeanDiscipline createDiscipline(VirSatTransactionalEditingDomain d
RoleManagement roleManagement = domain.getResourceSet().getRoleManagement();
newDiscipline = RolesFactory.eINSTANCE.createDiscipline();
newDiscipline.setName(disciplineName);
newDiscipline.getUsers().add(UserRegistry.getInstance().getUserName());
newDiscipline.setUser(UserRegistry.getInstance().getUserName());
Command addCommand = AddCommand.create(domain, roleManagement, RolesPackage.eINSTANCE.getRoleManagement_Disciplines(), newDiscipline);
domain.getCommandStack().execute(addCommand);

Expand Down

0 comments on commit ef97dcc

Please sign in to comment.