Search in sources :

Example 16 with SimulationStatus

use of cbit.vcell.server.SimulationStatus in project vcell by virtualcell.

the class TestingFrameworkWindowManager method updateSimRunningStatus.

/**
 * Insert the method's description here.
 * Creation date: (11/16/2004 7:44:27 AM)
 */
public String updateSimRunningStatus(ClientTaskStatusSupport pp, TestSuiteInfoNew tsin) {
    if (tsin.isLocked()) {
        return null;
    }
    StringBuffer errors = new StringBuffer();
    Vector<TestCriteriaNew> runningTCrits = new Vector<TestCriteriaNew>();
    try {
        TestSuiteInfoNew[] tsinfos = getRequestManager().getDocumentManager().getTestSuiteInfos();
        if (tsinfos != null && tsinfos.length > 0) {
            for (int i = 0; i < tsinfos.length; i += 1) {
                try {
                    if (tsin != null && !tsinfos[i].getTSKey().equals(tsin.getTSKey())) {
                        continue;
                    }
                    pp.setProgress(i * 50 / tsinfos.length);
                    pp.setMessage("Update SimsRunning, Getting Testsuite " + tsinfos[i].getTSID());
                    TestSuiteNew tsn = getRequestManager().getDocumentManager().getTestSuite(tsinfos[i].getTSKey());
                    TestCaseNew[] tcnArr = tsn.getTestCases();
                    if (tcnArr != null) {
                        for (int j = 0; tcnArr != null && j < tcnArr.length; j += 1) {
                            TestCriteriaNew[] tcritArr = tcnArr[j].getTestCriterias();
                            if (tcritArr != null) {
                                for (int k = 0; tcritArr != null && k < tcritArr.length; k += 1) {
                                    if (tcritArr[k].getReportStatus() != null && tcritArr[k].getReportStatus().equals(TestCriteriaNew.TCRIT_STATUS_SIMRUNNING) || tcritArr[k].getReportStatus().equals(TestCriteriaNew.TCRIT_STATUS_SIMNOTRUNFAILDONE)) {
                                        runningTCrits.add(tcritArr[k]);
                                    }
                                }
                            }
                        }
                    }
                } catch (Throwable e) {
                    e.printStackTrace();
                    errors.append(e.getClass().getName() + " " + e.getMessage());
                }
            }
            for (int i = 0; i < runningTCrits.size(); i += 1) {
                try {
                    TestCriteriaNew tcn = (TestCriteriaNew) runningTCrits.elementAt(i);
                    SimulationInfo simInfo = tcn.getSimInfo();
                    pp.setProgress((int) (50 + (i * 50 / runningTCrits.size())));
                    pp.setMessage("Update SimsRunning, Setting Status " + simInfo.getName());
                    // Check if there is some status different from "running"
                    if (simInfo != null) {
                        SimulationStatus simStatus = getRequestManager().getServerSimulationStatus(simInfo);
                        if (simStatus != null) {
                            if (simStatus.isFailed()) {
                                updateTCritStatus(tcn, TestCriteriaNew.TCRIT_STATUS_SIMFAILED, "Sim msg=" + simStatus.getJob0SimulationMessage().getDisplayMessage());
                            } else if (simStatus.isJob0Completed()) {
                                updateTCritStatus(tcn, TestCriteriaNew.TCRIT_STATUS_NEEDSREPORT, null);
                            } else if (!simStatus.isRunning()) {
                                updateTCritStatus(tcn, TestCriteriaNew.TCRIT_STATUS_SIMNOTRUNFAILDONE, "Sim jobstatus " + simStatus.toString() + " " + simStatus.getJob0SimulationMessage().getDisplayMessage());
                            }
                        } else {
                            updateTCritStatus(tcn, TestCriteriaNew.TCRIT_STATUS_SIMNOTRUNFAILDONE, "Can't get sim job status " + (simStatus == null ? "jobStatus is null" : ""));
                        }
                    }
                } catch (Throwable e) {
                    e.printStackTrace();
                    errors.append(e.getClass().getName() + " " + e.getMessage());
                }
            }
        }
    } catch (Throwable e) {
        e.printStackTrace();
        errors.append(e.getClass().getName() + " " + e.getMessage());
    }
    if (errors.length() > 0) {
        errors.insert(0, "Error updating simstatus\n");
        return errors.toString();
    }
    return null;
}
Also used : TestSuiteNew(cbit.vcell.numericstest.TestSuiteNew) TestCaseNew(cbit.vcell.numericstest.TestCaseNew) SimulationStatus(cbit.vcell.server.SimulationStatus) TestCriteriaNew(cbit.vcell.numericstest.TestCriteriaNew) Vector(java.util.Vector) TestSuiteInfoNew(cbit.vcell.numericstest.TestSuiteInfoNew) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 17 with SimulationStatus

use of cbit.vcell.server.SimulationStatus in project vcell by virtualcell.

the class VCellClientDataServiceImpl method getSimsFromOpenModels.

@Override
public List<SimulationDataSetRef> getSimsFromOpenModels() {
    ArrayList<SimulationDataSetRef> simulationDataSetRefs = new ArrayList<SimulationDataSetRef>();
    for (TopLevelWindowManager windowManager : vcellClient.getMdiManager().getWindowManagers()) {
        Simulation[] simulations = null;
        VCDocument modelDocument = null;
        if (windowManager instanceof BioModelWindowManager) {
            BioModelWindowManager selectedBioWindowManager = (BioModelWindowManager) windowManager;
            BioModel bioModel = selectedBioWindowManager.getBioModel();
            simulations = bioModel.getSimulations();
            modelDocument = bioModel;
        // simOwnerCount = bioModel.getNumSimulationContexts();
        } else if (windowManager instanceof MathModelWindowManager) {
            MathModelWindowManager selectedMathWindowManager = (MathModelWindowManager) windowManager;
            MathModel mathModel = selectedMathWindowManager.getMathModel();
            simulations = mathModel.getSimulations();
            modelDocument = mathModel;
        // simOwnerCount = 1;
        }
        if (simulations != null) {
            for (Simulation simulation : simulations) {
                if (!isVtkSupported(simulation)) {
                    continue;
                }
                Origin origin = simulation.getMathDescription().getGeometry().getOrigin();
                Extent extent = simulation.getMathDescription().getGeometry().getExtent();
                SimulationInfo simInfo = simulation.getSimulationInfo();
                SimulationStatus simStatus = vcellClient.getRequestManager().getServerSimulationStatus(simInfo);
                for (int jobIndex = 0; jobIndex < simulation.getScanCount(); jobIndex++) {
                    if (simStatus != null && simStatus.getHasData()) {
                        SimulationDataSetRef simulationDataSetReference = VCellClientDataServiceImpl.createSimulationDataSetRef(simulation, modelDocument, jobIndex, false);
                        simulationDataSetRefs.add(simulationDataSetReference);
                    }
                }
            }
        }
    }
    File localSimDir = ResourceUtil.getLocalSimDir(User.tempUser.getName());
    String[] simtaskFilenames = localSimDir.list((dir, name) -> (name.endsWith(".simtask.xml")));
    for (String simtaskFilename : simtaskFilenames) {
        try {
            SimulationTask simTask = XmlHelper.XMLToSimTask(org.apache.commons.io.FileUtils.readFileToString(new File(localSimDir, simtaskFilename)));
            VCDocument modelDocument = null;
            SimulationDataSetRef simulationDataSetReference = VCellClientDataServiceImpl.createSimulationDataSetRef(simTask.getSimulation(), modelDocument, simTask.getSimulationJob().getJobIndex(), true);
            simulationDataSetRefs.add(simulationDataSetReference);
        } catch (ExpressionException | XmlParseException | IOException e) {
            e.printStackTrace();
        }
    }
    return simulationDataSetRefs;
}
Also used : Origin(org.vcell.util.Origin) MathModel(cbit.vcell.mathmodel.MathModel) SimulationTask(cbit.vcell.messaging.server.SimulationTask) VCDocument(org.vcell.util.document.VCDocument) TopLevelWindowManager(cbit.vcell.client.TopLevelWindowManager) Extent(org.vcell.util.Extent) ArrayList(java.util.ArrayList) XmlParseException(cbit.vcell.xml.XmlParseException) IOException(java.io.IOException) SimulationDataSetRef(cbit.vcell.client.pyvcellproxy.SimulationDataSetRef) MathModelWindowManager(cbit.vcell.client.MathModelWindowManager) ExpressionException(cbit.vcell.parser.ExpressionException) Simulation(cbit.vcell.solver.Simulation) BioModelWindowManager(cbit.vcell.client.BioModelWindowManager) SimulationStatus(cbit.vcell.server.SimulationStatus) BioModel(cbit.vcell.biomodel.BioModel) File(java.io.File) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 18 with SimulationStatus

use of cbit.vcell.server.SimulationStatus in project vcell by virtualcell.

the class SimulationListPanel method refreshButtonsLax.

/**
 * Comment
 */
private void refreshButtonsLax() {
    MathDescription mathDescription = fieldSimulationWorkspace.getSimulationOwner().getMathDescription();
    if (mathDescription != null) {
        // particleViewButton.setVisible(mathDescription.isSpatialStoch());
        // quickPythonRunButton.setVisible(true);
        quickNativeRunButton.setVisible(true);
    }
    int[] selections = getScrollPaneTable().getSelectedRows();
    boolean bCopy = false;
    boolean bEditable = false;
    boolean bDeletable = false;
    boolean bRunnable = false;
    boolean bStoppable = false;
    boolean bHasData = false;
    boolean bStatusDetails = false;
    // boolean bParticleView = false;
    boolean bQuickRun = false;
    Simulation firstSelection = null;
    if (selections != null && selections.length > 0) {
        bCopy = true;
        bStatusDetails = true;
        firstSelection = ivjSimulationListTableModel1.getValueAt(selections[0]);
        if (selections.length == 1) {
            SimulationStatus simStatus = getSimulationWorkspace().getSimulationStatus(firstSelection);
            if (!simStatus.isRunning()) {
                bEditable = true;
            }
            final boolean onlyOne = firstSelection.getScanCount() == 1;
            // bParticleView = onlyOne;
            bQuickRun = onlyOne && canQuickRun(firstSelection.getSolverTaskDescription());
        }
        // we make'em true if at least one sim satisfies criterion (lax policy)
        for (int i = 0; i < selections.length; i++) {
            Simulation sim = ivjSimulationListTableModel1.getValueAt(selections[i]);
            SimulationStatus simStatus = getSimulationWorkspace().getSimulationStatus(sim);
            bDeletable = bDeletable || !simStatus.isRunning();
            bRunnable = bRunnable || simStatus.isRunnable();
            bStoppable = bStoppable || simStatus.isStoppable();
            bHasData = bHasData || simStatus.getHasData();
        }
    }
    copyButton.setEnabled(bCopy);
    getEditButton().setEnabled(bEditable);
    getDeleteButton().setEnabled(bDeletable);
    getRunButton().setEnabled(bRunnable);
    stopButton.setEnabled(bStoppable);
    if (selections != null && selections.length == 1) {
        if (bHasData && firstSelection != null && (firstSelection.getMathDescription().isSpatial3D() || firstSelection.getMathDescription().isSpatial2D())) {
        // getPythonResultsButton().setVisible(true);
        // getPythonResultsButton().setEnabled(true);
        } else {
        // getPythonResultsButton().setVisible(false);
        }
    } else {
    // getPythonResultsButton().setVisible(false);
    }
    getNativeResultsButton().setEnabled(bHasData);
    statusDetailsButton.setEnabled(bStatusDetails);
    // particleViewButton.setEnabled(bParticleView);
    // quickPythonRunButton.setEnabled(bQuickRun);
    quickNativeRunButton.setEnabled(bQuickRun);
}
Also used : Simulation(cbit.vcell.solver.Simulation) MathDescription(cbit.vcell.math.MathDescription) SimulationStatus(cbit.vcell.server.SimulationStatus)

Example 19 with SimulationStatus

use of cbit.vcell.server.SimulationStatus in project vcell by virtualcell.

the class SimulationListPanel method initConnections.

/**
 * Initializes connections
 * @exception java.lang.Exception The exception description.
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void initConnections() throws java.lang.Exception {
    // user code begin {1}
    // user code end
    getNewButton().addActionListener(ivjEventHandler);
    getEditButton().addActionListener(ivjEventHandler);
    getDeleteButton().addActionListener(ivjEventHandler);
    getRunButton().addActionListener(ivjEventHandler);
    // getPythonResultsButton().addActionListener(ivjEventHandler);
    getNativeResultsButton().addActionListener(ivjEventHandler);
    getMoreActionsButton().addActionListener(ivjEventHandler);
    getScrollPaneTable().addPropertyChangeListener(ivjEventHandler);
    getOutputFunctionsPanel().addPropertyChangeListener(ivjEventHandler);
    getScrollPaneTable().getSelectionModel().addListSelectionListener(ivjEventHandler);
    DefaultScrollTableCellRenderer renderer = new DefaultScrollTableCellRenderer() {

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            if (value instanceof OutputTimeSpec) {
                SimulationWorkspace sw = getSimulationWorkspace();
                SimulationOwner so = sw.getSimulationOwner();
                UnitInfo unitInfo = so.getUnitInfo();
                Objects.requireNonNull(unitInfo);
                OutputTimeSpec ots = (OutputTimeSpec) value;
                String text = ots.describe(unitInfo);
                setText(text);
            } else if (value instanceof Double) {
                setText(value + "");
            }
            boolean bFinitVolumeRerun = false;
            if (value instanceof SolverDescription) {
                SolverDescription solverDescription = (SolverDescription) value;
                try {
                    if (FINITEVOLUME_CUTTOFF != null && solverDescription.equals(SolverDescription.FiniteVolume)) /*Compiled Solver*/
                    {
                        SimulationStatus simStatus = getSimulationWorkspace().getSimulationStatus(getSimulationListTableModel1().getValueAt(row));
                        if (simStatus.getHasData()) {
                            int statusIndex = 0;
                            while (simStatus.getJobStatus(statusIndex) != null) {
                                if (simStatus.getJobStatus(statusIndex).getEndDate().compareTo(FINITEVOLUME_CUTTOFF) > 0) {
                                    bFinitVolumeRerun = true;
                                    break;
                                }
                                statusIndex++;
                            }
                        }
                    }
                } catch (Exception e) {
                    // ignore, let table cell render anyway
                    e.printStackTrace();
                }
                setText(solverDescription.getShortDisplayLabel());
                setToolTipText(solverDescription.getDisplayLabel());
            } else {
                setToolTipText(getText());
            }
            if (bFinitVolumeRerun) {
                setText(getText() + (bFinitVolumeRerun ? "(*)" : ""));
                setToolTipText(getToolTipText() + (bFinitVolumeRerun ? " (data regenerated using FiniteVolumeStandalone)" : ""));
            }
            return this;
        }
    };
    getScrollPaneTable().setDefaultRenderer(OutputTimeSpec.class, renderer);
    getScrollPaneTable().setDefaultRenderer(Double.class, renderer);
    getScrollPaneTable().setDefaultRenderer(String.class, renderer);
    getScrollPaneTable().setDefaultRenderer(SolverDescription.class, renderer);
    getScrollPaneTable().setDefaultEditor(OutputTimeSpec.class, new DefaultCellEditor(new JTextField()));
    getScrollPaneTable().setDefaultRenderer(SimulationStatus.class, new DefaultScrollTableCellRenderer() {

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            Object obj = getSimulationStatusDisplay(row);
            if (obj instanceof JProgressBar) {
                return (JProgressBar) obj;
            }
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            if (value instanceof SimulationStatus) {
                setText(obj.toString());
                String details = ((SimulationStatus) value).getDetails();
                setToolTipText(details);
            }
            return this;
        }
    });
}
Also used : SolverDescription(cbit.vcell.solver.SolverDescription) JProgressBar(javax.swing.JProgressBar) JTextField(javax.swing.JTextField) PropertyVetoException(java.beans.PropertyVetoException) IOException(java.io.IOException) DefaultCellEditor(javax.swing.DefaultCellEditor) SimulationOwner(cbit.vcell.solver.SimulationOwner) UnitInfo(cbit.vcell.solver.SimulationOwner.UnitInfo) OutputTimeSpec(cbit.vcell.solver.OutputTimeSpec) SimulationStatus(cbit.vcell.server.SimulationStatus) JTable(javax.swing.JTable) DefaultScrollTableCellRenderer(org.vcell.util.gui.DefaultScrollTableCellRenderer) Component(java.awt.Component)

Example 20 with SimulationStatus

use of cbit.vcell.server.SimulationStatus in project vcell by virtualcell.

the class SimulationListPanel method getSimulationStatusDisplay.

private Object getSimulationStatusDisplay(int row) {
    Simulation simulation = getSimulationListTableModel1().getValueAt(row);
    SimulationStatus simStatus = getSimulationWorkspace().getSimulationStatus(simulation);
    boolean displayProgress = (simStatus.isRunning() || (simStatus.isFailed() && simStatus.numberOfJobsDone() < simulation.getScanCount())) && simStatus.getProgress() != null && simStatus.getProgress().doubleValue() >= 0;
    if (displayProgress) {
        double progress = simStatus.getProgress().doubleValue() / simulation.getScanCount();
        JProgressBar progressBar = new JProgressBar();
        progressBar.setStringPainted(true);
        progressBar.setValue((int) (progress * 100));
        if (simStatus.isFailed()) {
            progressBar.setString("one or more jobs failed");
        } else {
            progressBar.setString(NumberUtils.formatNumber(progress * 100, 4) + "%");
        }
        return progressBar;
    } else if (simStatus.isFailed()) {
        return simStatus.getFailedMessage();
    } else {
        return simStatus.getDetails();
    }
}
Also used : Simulation(cbit.vcell.solver.Simulation) SimulationStatus(cbit.vcell.server.SimulationStatus) JProgressBar(javax.swing.JProgressBar)

Aggregations

SimulationStatus (cbit.vcell.server.SimulationStatus)27 Simulation (cbit.vcell.solver.Simulation)13 SimulationInfo (cbit.vcell.solver.SimulationInfo)8 ArrayList (java.util.ArrayList)7 Hashtable (java.util.Hashtable)5 Vector (java.util.Vector)5 KeyValue (org.vcell.util.document.KeyValue)5 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)4 SimulationJobStatus (cbit.vcell.server.SimulationJobStatus)4 BioModel (cbit.vcell.biomodel.BioModel)3 MathDescription (cbit.vcell.math.MathDescription)2 MathModel (cbit.vcell.mathmodel.MathModel)2 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)2 TestCaseNew (cbit.vcell.numericstest.TestCaseNew)2 ExpressionException (cbit.vcell.parser.ExpressionException)2 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 JLabel (javax.swing.JLabel)2 JProgressBar (javax.swing.JProgressBar)2