use of org.concord.energy3d.model.HousePart in project energy3d by concord-consortium.
the class HeliostatAnnualAnalysis method toJson.
@Override
public String toJson() {
String s = "{\"Months\": " + getNumberOfDataPoints();
final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
if (selectedPart != null) {
if (selectedPart instanceof Mirror) {
s += ", \"Heliostat\": \"" + selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1) + "\"";
} else if (selectedPart instanceof Foundation) {
s += ", \"Foundation\": \"" + selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1) + "\"";
} else if (selectedPart.getTopContainer() instanceof Foundation) {
s += ", \"Foundation\": \"" + selectedPart.getTopContainer().toString().substring(0, selectedPart.getTopContainer().toString().indexOf(')') + 1) + "\"";
}
} else {
s += ", \"Heliostat\": \"All\"";
}
final String name = "Solar";
final List<Double> data = graph.getData(name);
s += ", \"" + name + "\": {";
s += "\"Monthly\": [";
for (final Double x : data) {
s += Graph.ENERGY_FORMAT.format(x) + ",";
}
s = s.substring(0, s.length() - 1);
s += "]\n";
s += ", \"Total\": " + Graph.ENERGY_FORMAT.format(getResult(name));
s += "}";
s += "}";
return s;
}
use of org.concord.energy3d.model.HousePart in project energy3d by concord-consortium.
the class HeliostatDailyAnalysis method toJson.
@Override
public String toJson() {
String s = "{";
final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
if (selectedPart != null) {
if (selectedPart instanceof Mirror) {
s += "\"Heliostat\": \"" + selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1) + "\"";
} else if (selectedPart instanceof Foundation) {
s += "\"Foundation\": \"" + selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1) + "\"";
} else if (selectedPart.getTopContainer() instanceof Foundation) {
s += "\"Foundation\": \"" + selectedPart.getTopContainer().toString().substring(0, selectedPart.getTopContainer().toString().indexOf(')') + 1) + "\"";
}
} else {
s += "\"Heliostat\": \"All\"";
}
final String name = "Solar";
final List<Double> data = graph.getData(name);
s += ", \"" + name + "\": {";
s += "\"Hourly\": [";
for (final Double x : data) {
s += Graph.FIVE_DECIMALS.format(x) + ",";
}
s = s.substring(0, s.length() - 1);
s += "]\n";
s += ", \"Total\": " + Graph.ENERGY_FORMAT.format(getResult(name));
s += "}";
s += "}";
return s;
}
use of org.concord.energy3d.model.HousePart in project energy3d by concord-consortium.
the class AnnualSensorData method updateGraph.
@Override
public void updateGraph() {
final List<HousePart> parts = Scene.getInstance().getParts();
for (final HousePart p : parts) {
if (p instanceof Sensor) {
final Sensor sensor = (Sensor) p;
String lid = "Light: #" + sensor.getId();
String hid = "Heat Flux: #" + sensor.getId();
graph.hideData(lid, sensor.isLightOff());
graph.hideData(hid, sensor.isHeatFluxOff());
final double area = sensor.getArea();
final double solar = sensor.getSolarPotentialToday();
graph.addData(lid, solar / area);
final double[] loss = sensor.getHeatLoss();
double sum = 0;
for (final double x : loss) sum += x;
graph.addData(hid, -sum / area);
}
}
graph.repaint();
}
use of org.concord.energy3d.model.HousePart in project energy3d by concord-consortium.
the class AnnualSensorData method toJson.
@Override
public String toJson() {
String s = "{\"Months\": " + getNumberOfDataPoints() + ", \"Data\": [";
final List<HousePart> parts = Scene.getInstance().getParts();
for (final HousePart p : parts) {
if (p instanceof Sensor) {
final Sensor sensor = (Sensor) p;
final long id = sensor.getId();
List<Double> lightData = graph.getData("Light: #" + id);
s += "{\"ID\": " + id;
s += ", \"Light\": [";
for (Double x : lightData) {
s += Graph.FIVE_DECIMALS.format(x) + ",";
}
s = s.substring(0, s.length() - 1);
s += "]\n";
List<Double> heatData = graph.getData("Heat Flux: #" + id);
s += ", \"HeatFlux\": [";
for (Double x : heatData) {
s += Graph.FIVE_DECIMALS.format(x) + ",";
}
s = s.substring(0, s.length() - 1);
s += "]";
s += "},";
}
}
s = s.substring(0, s.length() - 1);
s += "]}";
return s;
}
use of org.concord.energy3d.model.HousePart in project energy3d by concord-consortium.
the class BuildingCost method getCostByFoundation.
@Override
public double getCostByFoundation(final Foundation foundation) {
if (foundation == null || foundation.getProjectType() != Foundation.TYPE_BUILDING) {
return 0;
}
double sum = 0;
int buildingCount = 0;
for (final HousePart p : Scene.getInstance().getParts()) {
if (p instanceof Foundation) {
buildingCount++;
}
}
if (buildingCount == 1) {
for (final HousePart p : Scene.getInstance().getParts()) {
// if there is only one building, trees are included in its cost
if (!p.getLockEdit() && !(p instanceof Human)) {
sum += getPartCost(p);
}
}
} else {
sum = getPartCost(foundation);
for (final HousePart p : Scene.getInstance().getParts()) {
if (p.getTopContainer() == foundation) {
sum += getPartCost(p);
}
}
}
return sum;
}
Aggregations