Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import org.mars_sim.msp.core.structure.building.function.FoodProduction;
import org.mars_sim.msp.core.structure.building.function.Function;
import org.mars_sim.msp.core.structure.building.function.FunctionType;
import org.mars_sim.msp.core.structure.building.function.VehicleGarage;
import org.mars_sim.msp.core.structure.building.function.HeatMode;
import org.mars_sim.msp.core.structure.building.function.Heating;
import org.mars_sim.msp.core.structure.building.function.LifeSupport;
Expand All @@ -78,6 +77,7 @@
import org.mars_sim.msp.core.structure.building.function.Storage;
import org.mars_sim.msp.core.structure.building.function.SystemType;
import org.mars_sim.msp.core.structure.building.function.ThermalGeneration;
import org.mars_sim.msp.core.structure.building.function.VehicleGarage;
import org.mars_sim.msp.core.structure.building.function.VehicleMaintenance;
import org.mars_sim.msp.core.structure.building.function.WasteProcessing;
import org.mars_sim.msp.core.structure.building.function.cooking.Cooking;
Expand Down Expand Up @@ -250,7 +250,8 @@ public Building(int id, int zone, String buildingType, String name, BoundedObjec
length = bounds.getLength();
}

floorArea = length * width;

floorArea = spec.getArea();
if (floorArea < 0) {
throw new IllegalArgumentException("Floor area cannot be -ve w=" + width + ", l=" + length);
}
Expand Down Expand Up @@ -1314,8 +1315,8 @@ public void reinit() {

// TODO this is wrong as names can change. This is just used to identify if there are multiple floors.
public boolean isAHabOrHub() {
return buildingType.contains(" Hab")
|| buildingType.contains(" Hub");
BuildingSpec spec = SimulationConfig.instance().getBuildingConfiguration().getBuildingSpec(buildingType);
return spec != null && "circular".equalsIgnoreCase(spec.getShape());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ private BuildingSpec parseBuilding(String buildingTypeName, Element buildingElem

double width = Double.parseDouble(buildingElement.getAttributeValue(WIDTH));
double length = Double.parseDouble(buildingElement.getAttributeValue(LENGTH));
String shape = buildingElement.getAttributeValue("shape");
double area;
if (shape != null && shape.equalsIgnoreCase("circular")) {
area = Math.PI * (length / 2.0) * (length / 2.0);
} else {
area = width * length;
}
int baseLevel = Integer.parseInt(buildingElement.getAttributeValue(BASE_LEVEL));
double roomTemp = Double.parseDouble(buildingElement.getAttributeValue(ROOM_TEMPERATURE));
int maintenanceTime = Integer.parseInt(buildingElement.getAttributeValue(MAINTENANCE_TIME));
Expand Down Expand Up @@ -182,7 +189,7 @@ private BuildingSpec parseBuilding(String buildingTypeName, Element buildingElem
category = deriveCategory(supportedFunctions.keySet());
}

BuildingSpec newSpec = new BuildingSpec(buildingTypeName, desc, category, width, length, baseLevel,
BuildingSpec newSpec = new BuildingSpec(buildingTypeName, desc, category, width, length,area, baseLevel,
roomTemp, maintenanceTime, wearLifeTime,
basePowerRequirement, basePowerDownPowerRequirement,
supportedFunctions);
Expand All @@ -191,6 +198,9 @@ private BuildingSpec parseBuilding(String buildingTypeName, Element buildingElem
if (construction != null) {
newSpec.setConstruction(ConstructionType.valueOf(ConfigHelper.convertToEnumName(construction)));
}
if (shape != null) {
newSpec.setShape(shape);
}

String baseMass = buildingElement.getAttributeValue(BASE_MASS);
if (baseMass != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public class BuildingSpec {

private double length;
private double width;
private double area;
private String shape;

private double baseMass;

Expand Down Expand Up @@ -65,7 +67,7 @@ public class BuildingSpec {

private BuildingCategory category;

BuildingSpec(String buildingType, String description, BuildingCategory category, double width, double length, int baseLevel,
BuildingSpec(String buildingType, String description, BuildingCategory category, double width, double length, double area,int baseLevel,
double roomTemperature, int maintenanceTime,
int wearLifeTime, double basePowerRequirement, double basePowerDownPowerRequirement,
Map<FunctionType, FunctionSpec> supportedFunctions) {
Expand Down Expand Up @@ -148,6 +150,17 @@ public double getLength() {
public double getWidth() {
return width;
}
public double getArea() {
return area;
}

public String getShape() {
return shape;
}

public void setShape(String shape) {
this.shape = shape;
}

public double getBaseMass() {
return baseMass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public LifeSupport(Building building, FunctionSpec spec) {

length = building.getLength();
width = building.getWidth();
floorArea = length * width;

floorArea = building.getFloorArea();
double t = AirComposition.C_TO_K + building.getCurrentTemperature();
double vol = building.getVolumeInLiter(); // 1 Cubic Meter = 1,000 Liters
air = new AirComposition(t, vol);
Expand Down
13 changes: 7 additions & 6 deletions mars-sim-core/src/main/resources/xml/buildings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<!ATTLIST building category CDATA #IMPLIED>
<!ATTLIST building width CDATA #REQUIRED>
<!ATTLIST building length CDATA #REQUIRED>
<!ATTLIST building shape CDATA #IMPLIED>
<!ATTLIST building construction CDATA #IMPLIED>
<!ATTLIST building base-level CDATA #REQUIRED>
<!ATTLIST building wear-lifetime CDATA #REQUIRED>
Expand Down Expand Up @@ -168,7 +169,7 @@ http://www.uss-hornet.org/groups/pdf/SEMB_MarsHabitat.pdf
<!-- maintenance-time: in millisols (old default : 50 millisols). -->
<!-- room-temperature: in deg Celsius (old default : 22.5D). -->
<!-- base-mass: in kg (old default : 3000). -->
<building type="Lander Hab" width="9.0" length="9.0" base-level="0"
<building type="Lander Hab" width="9.0" length="9.0" shape="circular" base-level="0"
wear-lifetime="3340000" maintenance-time="50" room-temperature="22.5" base-mass="3000">
<description> The Lander Hab is the initial habitat for a crew of four.
It serves as a jack-of-all-trades building that houses many basic but critical functions
Expand Down Expand Up @@ -2083,7 +2084,7 @@ http://www.uss-hornet.org/groups/pdf/SEMB_MarsHabitat.pdf
<!-- end of Astronomy Observatory-->

<!-- A lander hab refitted for storage. -->
<building type="Storage Hab" width="9.0" length="9.0" base-level="0"
<building type="Storage Hab" width="9.0" length="9.0" shape="circular" base-level="0"
wear-lifetime="3340000" maintenance-time="50" room-temperature="22.5" base-mass="2000">
<description> The Storage Hab is a Lander Hab refitted storage
building with ample storage space. It has built-in PV panels
Expand Down Expand Up @@ -2126,7 +2127,7 @@ http://www.uss-hornet.org/groups/pdf/SEMB_MarsHabitat.pdf
</building>
<!-- end of Storage Hab-->

<building type="Research Hab" width="9.0" length="9.0" base-level="0"
<building type="Research Hab" width="9.0" length="9.0" shape="circular" base-level="0"
wear-lifetime="3340000" maintenance-time="50" room-temperature="22.5" base-mass="3000">
<description> The Research Hab is a Lander Hab refitted laboratory
building for scientific research. It can be custom-tailored with COMPUTING
Expand Down Expand Up @@ -2182,7 +2183,7 @@ http://www.uss-hornet.org/groups/pdf/SEMB_MarsHabitat.pdf
</building>
<!-- end of Storage Hab-->

<building type="Residential Hab" width="9.0" length="9.0" base-level="0"
<building type="Residential Hab" width="9.0" length="9.0" shape="circular" base-level="0"
wear-lifetime="3340000" maintenance-time="50" room-temperature="22.5" base-mass="2000">
<description> The Residential Hab is a Lander Hab refitted residential
quarters for living accommodation of up to 8 persons. It uses solar
Expand Down Expand Up @@ -2227,7 +2228,7 @@ http://www.uss-hornet.org/groups/pdf/SEMB_MarsHabitat.pdf
<!-- end of Residential Hab-->

<!-- A lander hab refitted as a medical facility. -->
<building type="Medical Hab" width="9.0" length="9.0" base-level="0"
<building type="Medical Hab" width="9.0" length="9.0" shape="circular" base-level="0"
wear-lifetime="3340000" maintenance-time="50" room-temperature="22.5" base-mass="2500">
<description> The Medical Hab is a Lander Hab refitted medical facility
for providing medical basic care. It also has medical research workbench and
Expand Down Expand Up @@ -2293,7 +2294,7 @@ http://www.uss-hornet.org/groups/pdf/SEMB_MarsHabitat.pdf
</building>
<!-- end of Medical Hab-->

<building type="Machinery Hab" width="9.0" length="9.0" base-level="0"
<building type="Machinery Hab" width="9.0" length="9.0" shape="circular" base-level="0"
wear-lifetime="3340000" maintenance-time="50" room-temperature="22.5" base-mass="3000">
<description> The Machinery Hab is a Lander Hab refitted manufacturing workshop
for making items and synthesizing resource. It provides storage space for
Expand Down