Search in sources :

Example 1 with AnalysisEvent

use of org.concord.energy3d.agents.AnalysisEvent in project energy3d by concord-consortium.

the class Analysis method onCompletion.

void onCompletion() {
    MainApplication.addEvent(new AnalysisEvent(Scene.getURL(), System.currentTimeMillis(), getClass().getSimpleName(), graph.data));
    TimeSeriesLogger.getInstance().logAnalysis(this);
    EnergyPanel.getInstance().progress(0);
    runButton.setEnabled(true);
    EnergyPanel.getInstance().disableDateSpinner(false);
    SceneManager.setExecuteAllTask(true);
}
Also used : AnalysisEvent(org.concord.energy3d.agents.AnalysisEvent)

Example 2 with AnalysisEvent

use of org.concord.energy3d.agents.AnalysisEvent in project energy3d by concord-consortium.

the class EnergyPanel method compute.

public void compute(final UpdateRadiation updateRadiation) {
    if (!computeEnabled) {
        return;
    }
    computingStartMillis = System.currentTimeMillis();
    EventQueue.invokeLater(new // must run this Swing UI update in the event queue to avoid a possible deadlock
    Runnable() {

        @Override
        public void run() {
            // TODO: There got to be a better way to do this.
            updateWeatherData();
            ((Component) SceneManager.getInstance().getCanvas()).setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        }
    });
    final boolean doCompute = updateRadiation == UpdateRadiation.ALWAYS || (SceneManager.getInstance().getSolarHeatMap() && (!alreadyRenderedHeatmap || autoRecomputeEnergy));
    if (!doCompute && computing) {
        cancel();
        return;
    }
    SceneManager.getTaskManager().update(new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            computing = true;
            computeRequest = false;
            cancel = false;
            try {
                if (doCompute) {
                    alreadyRenderedHeatmap = true;
                    computeNow();
                    if (!cancel) {
                        SceneManager.getInstance().getSolarLand().setVisible(Scene.getInstance().getSolarMapForLand());
                        SceneManager.getInstance().refresh();
                    } else if (!autoRecomputeEnergy) {
                        turnOffCompute();
                    }
                } else {
                    turnOffCompute();
                }
            } catch (final Throwable e) {
                e.printStackTrace();
                BugReporter.report(e);
                return null;
            } finally {
                EventQueue.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        ((Component) SceneManager.getInstance().getCanvas()).setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                    }
                });
            }
            EventQueue.invokeLater(new // must run this Swing UI update in the event queue to avoid a possible deadlock
            Runnable() {

                @Override
                public void run() {
                    progress(0);
                    if (SceneManager.getInstance().getSolarHeatMap()) {
                        final HousePart p = SceneManager.getInstance().getSelectedPart();
                        if (p instanceof Foundation) {
                            final Foundation f = (Foundation) p;
                            switch(f.getProjectType()) {
                                case Foundation.TYPE_BUILDING:
                                    Util.setSilently(buildingTabbedPane, buildingDailyEnergyGraph);
                                    buildingDailyEnergyGraph.addGraph(f);
                                    TimeSeriesLogger.getInstance().logAnalysis(buildingDailyEnergyGraph);
                                    MainApplication.addEvent(new AnalysisEvent(Scene.getURL(), System.currentTimeMillis(), buildingDailyEnergyGraph.getClass().getSimpleName(), buildingDailyEnergyGraph.getData()));
                                    break;
                                case Foundation.TYPE_PV_PROJECT:
                                    Util.setSilently(pvProjectTabbedPane, pvProjectDailyEnergyGraph);
                                    pvProjectDailyEnergyGraph.addGraph(f);
                                    TimeSeriesLogger.getInstance().logAnalysis(pvProjectDailyEnergyGraph);
                                    MainApplication.addEvent(new AnalysisEvent(Scene.getURL(), System.currentTimeMillis(), pvProjectDailyEnergyGraph.getClass().getSimpleName(), pvProjectDailyEnergyGraph.getData()));
                                    break;
                                case Foundation.TYPE_CSP_PROJECT:
                                    Util.setSilently(cspProjectTabbedPane, cspProjectDailyEnergyGraph);
                                    cspProjectDailyEnergyGraph.addGraph(f);
                                    TimeSeriesLogger.getInstance().logAnalysis(cspProjectDailyEnergyGraph);
                                    MainApplication.addEvent(new AnalysisEvent(Scene.getURL(), System.currentTimeMillis(), cspProjectDailyEnergyGraph.getClass().getSimpleName(), cspProjectDailyEnergyGraph.getData()));
                                    break;
                            }
                        }
                    }
                    computing = false;
                }
            });
            return null;
        }
    });
}
Also used : AnalysisEvent(org.concord.energy3d.agents.AnalysisEvent) Foundation(org.concord.energy3d.model.Foundation) Component(java.awt.Component) CancellationException(java.util.concurrent.CancellationException) HousePart(org.concord.energy3d.model.HousePart)

Aggregations

AnalysisEvent (org.concord.energy3d.agents.AnalysisEvent)2 Component (java.awt.Component)1 CancellationException (java.util.concurrent.CancellationException)1 Foundation (org.concord.energy3d.model.Foundation)1 HousePart (org.concord.energy3d.model.HousePart)1