Search in sources :

Example 91 with HousePart

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;
}
Also used : Foundation(org.concord.energy3d.model.Foundation) Mirror(org.concord.energy3d.model.Mirror) HousePart(org.concord.energy3d.model.HousePart)

Example 92 with HousePart

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;
}
Also used : Foundation(org.concord.energy3d.model.Foundation) Mirror(org.concord.energy3d.model.Mirror) HousePart(org.concord.energy3d.model.HousePart)

Example 93 with HousePart

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();
}
Also used : HousePart(org.concord.energy3d.model.HousePart) Sensor(org.concord.energy3d.model.Sensor)

Example 94 with HousePart

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;
}
Also used : HousePart(org.concord.energy3d.model.HousePart) Sensor(org.concord.energy3d.model.Sensor)

Example 95 with HousePart

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;
}
Also used : Human(org.concord.energy3d.model.Human) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart)

Aggregations

HousePart (org.concord.energy3d.model.HousePart)277 Foundation (org.concord.energy3d.model.Foundation)153 Rack (org.concord.energy3d.model.Rack)69 SolarPanel (org.concord.energy3d.model.SolarPanel)60 Roof (org.concord.energy3d.model.Roof)47 Wall (org.concord.energy3d.model.Wall)45 Window (org.concord.energy3d.model.Window)43 ActionEvent (java.awt.event.ActionEvent)42 ActionListener (java.awt.event.ActionListener)42 ArrayList (java.util.ArrayList)41 Mirror (org.concord.energy3d.model.Mirror)38 JMenuItem (javax.swing.JMenuItem)36 JDialog (javax.swing.JDialog)35 FresnelReflector (org.concord.energy3d.model.FresnelReflector)34 ParabolicTrough (org.concord.energy3d.model.ParabolicTrough)32 ParabolicDish (org.concord.energy3d.model.ParabolicDish)28 Tree (org.concord.energy3d.model.Tree)26 Door (org.concord.energy3d.model.Door)25 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)21 JPanel (javax.swing.JPanel)21