Search in sources :

Example 1 with DataSetControllerImpl

use of cbit.vcell.simdata.DataSetControllerImpl in project vcell by virtualcell.

the class SmoldynFileWriter method writeDataProcessor.

private void writeDataProcessor() throws DataAccessException, IOException, MathException, DivideByZeroException, ExpressionException {
    Simulation simulation = simTask.getSimulation();
    DataProcessingInstructions dpi = simulation.getDataProcessingInstructions();
    if (dpi == null) {
        printWriter.println(SmoldynVCellMapper.SmoldynKeyword.cmd + " " + SmoldynVCellMapper.SmoldynKeyword.B + " " + VCellSmoldynKeyword.vcellDataProcess + " begin " + DataProcessingInstructions.ROI_TIME_SERIES);
        printWriter.println(SmoldynVCellMapper.SmoldynKeyword.cmd + " " + SmoldynVCellMapper.SmoldynKeyword.B + " " + VCellSmoldynKeyword.vcellDataProcess + " end");
    } else {
        FieldDataIdentifierSpec fdis = dpi.getSampleImageFieldData(simulation.getVersion().getOwner());
        if (fdis == null) {
            throw new DataAccessException("Can't find sample image in data processing instructions");
        }
        File userDirectory = outputFile.getParentFile();
        String secondarySimDataDir = PropertyLoader.getProperty(PropertyLoader.secondarySimDataDirInternalProperty, null);
        DataSetControllerImpl dsci = new DataSetControllerImpl(null, userDirectory.getParentFile(), secondarySimDataDir == null ? null : new File(secondarySimDataDir));
        CartesianMesh origMesh = dsci.getMesh(fdis.getExternalDataIdentifier());
        SimDataBlock simDataBlock = dsci.getSimDataBlock(null, fdis.getExternalDataIdentifier(), fdis.getFieldFuncArgs().getVariableName(), fdis.getFieldFuncArgs().getTime().evaluateConstant());
        VariableType varType = fdis.getFieldFuncArgs().getVariableType();
        VariableType dataVarType = simDataBlock.getVariableType();
        if (!varType.equals(VariableType.UNKNOWN) && !varType.equals(dataVarType)) {
            throw new IllegalArgumentException("field function variable type (" + varType.getTypeName() + ") doesn't match real variable type (" + dataVarType.getTypeName() + ")");
        }
        double[] origData = simDataBlock.getData();
        String filename = SimulationJob.createSimulationJobID(Simulation.createSimulationID(simulation.getKey()), simTask.getSimulationJob().getJobIndex()) + SimulationData.getDefaultFieldDataFileNameForSimulation(fdis.getFieldFuncArgs());
        File fdatFile = new File(userDirectory, filename);
        DataSet.writeNew(fdatFile, new String[] { fdis.getFieldFuncArgs().getVariableName() }, new VariableType[] { simDataBlock.getVariableType() }, new ISize(origMesh.getSizeX(), origMesh.getSizeY(), origMesh.getSizeZ()), new double[][] { origData });
        printWriter.println(SmoldynVCellMapper.SmoldynKeyword.cmd + " " + SmoldynVCellMapper.SmoldynKeyword.B + " " + VCellSmoldynKeyword.vcellDataProcess + " begin " + dpi.getScriptName());
        StringTokenizer st = new StringTokenizer(dpi.getScriptInput(), "\n\r");
        while (st.hasMoreTokens()) {
            String str = st.nextToken();
            if (str.trim().length() > 0) {
                printWriter.println(SmoldynVCellMapper.SmoldynKeyword.cmd + " " + SmoldynVCellMapper.SmoldynKeyword.B + " " + VCellSmoldynKeyword.vcellDataProcess + " " + str);
            }
        }
        printWriter.println(SmoldynVCellMapper.SmoldynKeyword.cmd + " " + SmoldynVCellMapper.SmoldynKeyword.B + " " + VCellSmoldynKeyword.vcellDataProcess + " SampleImageFile " + fdis.getFieldFuncArgs().getVariableName() + " " + fdis.getFieldFuncArgs().getTime().infix() + " " + fdatFile);
        printWriter.println(SmoldynVCellMapper.SmoldynKeyword.cmd + " " + SmoldynVCellMapper.SmoldynKeyword.B + " " + VCellSmoldynKeyword.vcellDataProcess + " end");
    }
}
Also used : VariableType(cbit.vcell.math.VariableType) ISize(org.vcell.util.ISize) CartesianMesh(cbit.vcell.solvers.CartesianMesh) StringTokenizer(java.util.StringTokenizer) Simulation(cbit.vcell.solver.Simulation) SimDataBlock(cbit.vcell.simdata.SimDataBlock) DataProcessingInstructions(cbit.vcell.solver.DataProcessingInstructions) FieldDataIdentifierSpec(cbit.vcell.field.FieldDataIdentifierSpec) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) File(java.io.File) DataAccessException(org.vcell.util.DataAccessException)

Example 2 with DataSetControllerImpl

use of cbit.vcell.simdata.DataSetControllerImpl in project vcell by virtualcell.

the class SimulationServiceImpl method getTimePoints.

public List<Double> getTimePoints(SimulationInfo simInfo) throws ThriftDataAccessException, TException {
    SimulationServiceContext simServiceContext = sims.get(simInfo.id);
    if (simServiceContext == null) {
        throw new ThriftDataAccessException("simulation results not found");
    }
    try {
        DataSetControllerImpl datasetController = getDataSetController(simServiceContext);
        ArrayList<Double> times = new ArrayList<Double>();
        double[] timeArray;
        timeArray = datasetController.getDataSetTimes(simServiceContext.vcDataIdentifier);
        for (double t : timeArray) {
            times.add(t);
        }
        return times;
    } catch (Exception e) {
        e.printStackTrace();
        throw new ThriftDataAccessException("failed to retrieve times for simulation: " + e.getMessage());
    }
}
Also used : ArrayList(java.util.ArrayList) ThriftDataAccessException(org.vcell.vcellij.api.ThriftDataAccessException) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) XMLStreamException(javax.xml.stream.XMLStreamException) ThriftDataAccessException(org.vcell.vcellij.api.ThriftDataAccessException) SbmlException(org.vcell.sbml.SbmlException) SBMLException(org.sbml.jsbml.SBMLException) XmlParseException(cbit.vcell.xml.XmlParseException) SolverException(cbit.vcell.solver.SolverException) TException(org.apache.thrift.TException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException)

Example 3 with DataSetControllerImpl

use of cbit.vcell.simdata.DataSetControllerImpl in project vcell by virtualcell.

the class LocalWorkspace method getDataSetControllerImpl.

/**
 * Method getDataSetControllerImpl.
 * @return DataSetControllerImpl
 * @throws FileNotFoundException
 */
public DataSetControllerImpl getDataSetControllerImpl() throws FileNotFoundException {
    if (dataSetControllerImpl == null) {
        File rootDir = new File(getDefaultWorkspaceDirectory());
        dataSetControllerImpl = new DataSetControllerImpl(new Cachetable(10000), rootDir, rootDir);
    }
    return dataSetControllerImpl;
}
Also used : Cachetable(cbit.vcell.simdata.Cachetable) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) File(java.io.File)

Example 4 with DataSetControllerImpl

use of cbit.vcell.simdata.DataSetControllerImpl in project vcell by virtualcell.

the class FrapDataUtils method importFRAPDataFromVCellSimulationData.

public static FRAPData importFRAPDataFromVCellSimulationData(File vcellSimLogFile, String variableName, String bleachedMaskVarName, Double maxIntensity, boolean bNoise, final ClientTaskStatusSupport progressListener) throws Exception {
    // bleachedMaskVarName = "laserMask_cell";
    VCSimulationIdentifier vcSimulationIdentifier = getVCSimulationIdentifierFromVCellSimulationData(vcellSimLogFile);
    VCSimulationDataIdentifier vcSimulationDataIdentifier = new VCSimulationDataIdentifier(vcSimulationIdentifier, 0);
    DataSetControllerImpl dataSetControllerImpl = getDataSetControllerImplFromVCellSimulationData(vcellSimLogFile);
    final DataJobEvent[] bStatus = new DataJobEvent[] { null };
    DataJobListener dataJobListener = new DataJobListener() {

        public void dataJobMessage(DataJobEvent event) {
            bStatus[0] = event;
            if (progressListener != null) {
                progressListener.setProgress((int) (event.getProgress() / 100.0 * .75));
            }
        }
    };
    dataSetControllerImpl.addDataJobListener(dataJobListener);
    DataIdentifier[] dataIdentifiers = getDataIdentiferListFromVCellSimulationData(vcellSimLogFile, 0);
    DataIdentifier variableNameDataIdentifier = null;
    for (int i = 0; i < dataIdentifiers.length; i++) {
        if (dataIdentifiers[i].getName().equals(variableName)) {
            variableNameDataIdentifier = dataIdentifiers[i];
            break;
        }
    }
    if (variableNameDataIdentifier == null) {
        throw new IllegalArgumentException("Variable " + variableName + " not found.");
    }
    if (!variableNameDataIdentifier.getVariableType().equals(VariableType.VOLUME)) {
        throw new IllegalArgumentException("Variable " + variableName + " is not VOLUME type.");
    }
    double[] times = dataSetControllerImpl.getDataSetTimes(vcSimulationDataIdentifier);
    CartesianMesh cartesianMesh = dataSetControllerImpl.getMesh(vcSimulationDataIdentifier);
    BitSet allBitset = new BitSet(cartesianMesh.getNumVolumeElements());
    allBitset.set(0, cartesianMesh.getNumVolumeElements() - 1);
    TimeSeriesJobSpec timeSeriesJobSpec = new TimeSeriesJobSpec(new String[] { variableName }, new BitSet[] { allBitset }, times[0], 1, times[times.length - 1], true, false, VCDataJobID.createVCDataJobID(getDotUser(), true));
    TSJobResultsSpaceStats tsJobResultsSpaceStats = (TSJobResultsSpaceStats) dataSetControllerImpl.getTimeSeriesValues(null, vcSimulationDataIdentifier, timeSeriesJobSpec);
    // wait for job to finish
    while (bStatus[0] == null || bStatus[0].getEventTypeID() != DataJobEvent.DATA_COMPLETE) {
        Thread.sleep(100);
    }
    double allTimesMin = tsJobResultsSpaceStats.getMinimums()[0][0];
    double allTimesMax = allTimesMin;
    for (int i = 0; i < times.length; i++) {
        allTimesMin = Math.min(allTimesMin, tsJobResultsSpaceStats.getMinimums()[0][i]);
        allTimesMax = Math.max(allTimesMax, tsJobResultsSpaceStats.getMaximums()[0][i]);
    }
    // double SCALE_MAX = maxIntensity.doubleValue();/*Math.pow(2,16)-1;*///Scale to 16 bits
    double linearScaleFactor = 1;
    if (maxIntensity != null) {
        linearScaleFactor = maxIntensity.doubleValue() / allTimesMax;
    }
    System.out.println("alltimesMin=" + allTimesMin + " allTimesMax=" + allTimesMax + " linearScaleFactor=" + linearScaleFactor);
    UShortImage[] scaledDataImages = new UShortImage[times.length];
    Random rnd = new Random();
    int shortMax = 65535;
    // set messge to load variable
    if (progressListener != null) {
        progressListener.setMessage("Loading variable " + variableName + "...");
    }
    for (int i = 0; i < times.length; i++) {
        double[] rawData = dataSetControllerImpl.getSimDataBlock(null, vcSimulationDataIdentifier, variableName, times[i]).getData();
        short[] scaledDataShort = new short[rawData.length];
        for (int j = 0; j < scaledDataShort.length; j++) {
            double scaledRawDataJ = rawData[j] * linearScaleFactor;
            if (bNoise) {
                double ran = rnd.nextGaussian();
                double scaledRawDataJ_withNoise = Math.max(0, (scaledRawDataJ + ran * Math.sqrt(scaledRawDataJ)));
                scaledRawDataJ_withNoise = Math.min(shortMax, scaledRawDataJ_withNoise);
                int scaledValue = (int) (scaledRawDataJ_withNoise);
                scaledDataShort[j] &= 0x0000;
                scaledDataShort[j] |= 0x0000FFFF & scaledValue;
            } else {
                int scaledValue = (int) (scaledRawDataJ);
                scaledDataShort[j] &= 0x0000;
                scaledDataShort[j] |= 0x0000FFFF & scaledValue;
            }
        }
        scaledDataImages[i] = new UShortImage(scaledDataShort, cartesianMesh.getOrigin(), cartesianMesh.getExtent(), cartesianMesh.getSizeX(), cartesianMesh.getSizeY(), cartesianMesh.getSizeZ());
        if (progressListener != null) {
            int progress = (int) (((i + 1) * 1.0 / times.length) * 100);
            progressListener.setProgress(progress);
        }
    }
    ImageDataset imageDataSet = new ImageDataset(scaledDataImages, times, cartesianMesh.getSizeZ());
    FRAPData frapData = new FRAPData(imageDataSet, new String[] { FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED.name(), FRAPData.VFRAP_ROI_ENUM.ROI_CELL.name(), FRAPData.VFRAP_ROI_ENUM.ROI_BACKGROUND.name() });
    // get rois from log file
    if (bleachedMaskVarName != null) {
        // set message to load cell ROI variable
        if (progressListener != null) {
            progressListener.setMessage("Loading ROIs...");
        }
        double[] rawROIBleached = dataSetControllerImpl.getSimDataBlock(null, vcSimulationDataIdentifier, bleachedMaskVarName, 0).getData();
        short[] scaledCellDataShort = new short[rawROIBleached.length];
        short[] scaledBleachedDataShort = new short[rawROIBleached.length];
        short[] scaledBackgoundDataShort = new short[rawROIBleached.length];
        for (int j = 0; j < scaledCellDataShort.length; j++) {
            boolean isCell = cartesianMesh.getCompartmentSubdomainNamefromVolIndex(j).equals("subVolume1");
            boolean isBackground = cartesianMesh.getCompartmentSubdomainNamefromVolIndex(j).equals("subVolume0");
            if (isCell) {
                scaledCellDataShort[j] = 1;
            }
            if (isBackground) {
                scaledBackgoundDataShort[j] = 1;
            }
            if (rawROIBleached[j] > 0.2) {
                scaledBleachedDataShort[j] = 1;
            }
        }
        UShortImage cellImage = new UShortImage(scaledCellDataShort, cartesianMesh.getOrigin(), cartesianMesh.getExtent(), cartesianMesh.getSizeX(), cartesianMesh.getSizeY(), cartesianMesh.getSizeZ());
        UShortImage bleachedImage = new UShortImage(scaledBleachedDataShort, cartesianMesh.getOrigin(), cartesianMesh.getExtent(), cartesianMesh.getSizeX(), cartesianMesh.getSizeY(), cartesianMesh.getSizeZ());
        UShortImage backgroundImage = new UShortImage(scaledBackgoundDataShort, cartesianMesh.getOrigin(), cartesianMesh.getExtent(), cartesianMesh.getSizeX(), cartesianMesh.getSizeY(), cartesianMesh.getSizeZ());
        if (progressListener != null) {
            progressListener.setProgress(100);
        }
        frapData.getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_CELL.name()).setROIImages(new UShortImage[] { cellImage });
        frapData.getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED.name()).setROIImages(new UShortImage[] { bleachedImage });
        frapData.getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BACKGROUND.name()).setROIImages(new UShortImage[] { backgroundImage });
    }
    return frapData;
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) DataIdentifier(cbit.vcell.simdata.DataIdentifier) TimeSeriesJobSpec(org.vcell.util.document.TimeSeriesJobSpec) ImageDataset(cbit.vcell.VirtualMicroscopy.ImageDataset) FRAPData(cbit.vcell.microscopy.FRAPData) BitSet(java.util.BitSet) TSJobResultsSpaceStats(org.vcell.util.document.TSJobResultsSpaceStats) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) DataJobEvent(cbit.rmi.event.DataJobEvent) CartesianMesh(cbit.vcell.solvers.CartesianMesh) Random(java.util.Random) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) DataJobListener(cbit.rmi.event.DataJobListener)

Example 5 with DataSetControllerImpl

use of cbit.vcell.simdata.DataSetControllerImpl in project vcell by virtualcell.

the class ClientSimManager method showSimulationResults0.

private AsynchClientTask[] showSimulationResults0(final boolean isLocal, final ViewerType viewerType) {
    // Create the AsynchClientTasks
    ArrayList<AsynchClientTask> taskList = new ArrayList<AsynchClientTask>();
    taskList.add(new AsynchClientTaskFunction(h -> {
        h.put(H_LOCAL_SIM, isLocal);
        h.put(H_VIEWER_TYPE, viewerType);
    }, "setLocal", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING));
    final DocumentWindowManager documentWindowManager = getDocumentWindowManager();
    AsynchClientTask retrieveResultsTask = new AsynchClientTask("Retrieving results", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @SuppressWarnings("unchecked")
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            Simulation[] simsToShow = (Simulation[]) hashTable.get("simsArray");
            for (int i = 0; i < simsToShow.length; i++) {
                final Simulation sim = simsToShow[i];
                final VCSimulationIdentifier vcSimulationIdentifier = sim.getSimulationInfo().getAuthoritativeVCSimulationIdentifier();
                final SimulationWindow simWindow = documentWindowManager.haveSimulationWindow(vcSimulationIdentifier);
                OutputContext outputContext = (OutputContext) hashTable.get("outputContext");
                if (simWindow == null && (viewerType == ViewerType.BothNativeAndPython || viewerType == ViewerType.NativeViewer_only)) {
                    try {
                        // make the manager and wire it up
                        DataViewerController dataViewerController = null;
                        if (!isLocal) {
                            dataViewerController = documentWindowManager.getRequestManager().getDataViewerController(outputContext, sim, 0);
                            // For changes in time or variable
                            documentWindowManager.addDataListener(dataViewerController);
                        } else {
                            // ---- preliminary : construct the localDatasetControllerProvider
                            File primaryDir = ResourceUtil.getLocalRootDir();
                            User usr = sim.getVersion().getOwner();
                            DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(null, primaryDir, null);
                            ExportServiceImpl localExportServiceImpl = new ExportServiceImpl();
                            LocalDataSetControllerProvider localDSCProvider = new LocalDataSetControllerProvider(usr, dataSetControllerImpl, localExportServiceImpl);
                            VCDataManager vcDataManager = new VCDataManager(localDSCProvider);
                            File localSimDir = ResourceUtil.getLocalSimDir(User.tempUser.getName());
                            LocalVCDataIdentifier vcDataId = new LocalVCSimulationDataIdentifier(vcSimulationIdentifier, 0, localSimDir);
                            DataManager dataManager = null;
                            if (sim.isSpatial()) {
                                dataManager = new PDEDataManager(outputContext, vcDataManager, vcDataId);
                            } else {
                                dataManager = new ODEDataManager(outputContext, vcDataManager, vcDataId);
                            }
                            dataViewerController = new SimResultsViewerController(dataManager, sim);
                            dataSetControllerImpl.addDataJobListener(documentWindowManager);
                        }
                        // make the viewer
                        Hashtable<VCSimulationIdentifier, DataViewerController> dataViewerControllers = (Hashtable<VCSimulationIdentifier, DataViewerController>) hashTable.get(H_DATA_VIEWER_CONTROLLERS);
                        if (dataViewerControllers == null) {
                            dataViewerControllers = new Hashtable<VCSimulationIdentifier, DataViewerController>();
                            hashTable.put(H_DATA_VIEWER_CONTROLLERS, dataViewerControllers);
                        }
                        dataViewerControllers.put(vcSimulationIdentifier, dataViewerController);
                    } catch (Throwable exc) {
                        exc.printStackTrace(System.out);
                        saveFailure(hashTable, sim, exc);
                    }
                }
                try {
                    if (viewerType == ViewerType.PythonViewer_only || viewerType == ViewerType.BothNativeAndPython) {
                        VtkManager vtkManager = null;
                        if (!isLocal) {
                            vtkManager = documentWindowManager.getRequestManager().getVtkManager(outputContext, new VCSimulationDataIdentifier(vcSimulationIdentifier, 0));
                        } else {
                            // ---- preliminary : construct the localDatasetControllerProvider
                            File primaryDir = ResourceUtil.getLocalRootDir();
                            User usr = sim.getVersion().getOwner();
                            DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(null, primaryDir, null);
                            ExportServiceImpl localExportServiceImpl = new ExportServiceImpl();
                            LocalDataSetControllerProvider localDSCProvider = new LocalDataSetControllerProvider(usr, dataSetControllerImpl, localExportServiceImpl);
                            VCDataManager vcDataManager = new VCDataManager(localDSCProvider);
                            File localSimDir = ResourceUtil.getLocalSimDir(User.tempUser.getName());
                            VCSimulationDataIdentifier simulationDataIdentifier = new LocalVCSimulationDataIdentifier(vcSimulationIdentifier, 0, localSimDir);
                            vtkManager = new VtkManager(outputContext, vcDataManager, simulationDataIdentifier);
                        }
                        // 
                        // test ability to read data
                        // 
                        VtuVarInfo[] vtuVarInfos = vtkManager.getVtuVarInfos();
                        double[] times = vtkManager.getDataSetTimes();
                        // 
                        // create the SimulationDataSetRef
                        // 
                        VCDocument modelDocument = null;
                        if (documentWindowManager instanceof BioModelWindowManager) {
                            modelDocument = ((BioModelWindowManager) documentWindowManager).getBioModel();
                        } else if (documentWindowManager instanceof MathModelWindowManager) {
                            modelDocument = ((MathModelWindowManager) documentWindowManager).getMathModel();
                        }
                        SimulationDataSetRef simulationDataSetRef = VCellClientDataServiceImpl.createSimulationDataSetRef(sim, modelDocument, 0, isLocal);
                        // Hashtable<VCSimulationIdentifier, SimulationDataSetRef> simDataSetRefs = (Hashtable<VCSimulationIdentifier, SimulationDataSetRef>)hashTable.get(H_SIM_DATASET_REFS);
                        // if (simDataSetRefs == null) {
                        // simDataSetRefs = new Hashtable<VCSimulationIdentifier, SimulationDataSetRef>();
                        // hashTable.put(H_SIM_DATASET_REFS, simDataSetRefs);
                        // }
                        // simDataSetRefs.put(vcSimulationIdentifier, simulationDataSetRef);
                        File visitExe = VCellConfiguration.getFileProperty(PropertyLoader.visitExe);
                        if (visitExe != null) {
                            VisitSupport.launchVisTool(visitExe, simulationDataSetRef);
                        }
                    }
                } catch (Throwable exc) {
                    exc.printStackTrace(System.out);
                    saveFailure(hashTable, sim, exc);
                }
            }
        }
    };
    taskList.add(retrieveResultsTask);
    AsynchClientTask displayResultsTask = new AsynchClientTask("Showing results", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @SuppressWarnings("unchecked")
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            boolean isLocal = fetch(hashTable, H_LOCAL_SIM, Boolean.class, true);
            SimulationWindow.LocalState localState = isLocal ? LocalState.LOCAL : LocalState.SERVER;
            Hashtable<Simulation, Throwable> failures = (Hashtable<Simulation, Throwable>) hashTable.get(H_FAILURES);
            Simulation[] simsToShow = (Simulation[]) hashTable.get("simsArray");
            for (int i = 0; i < simsToShow.length; i++) {
                final Simulation sim = simsToShow[i];
                if (failures != null && failures.containsKey(sim)) {
                    continue;
                }
                final VCSimulationIdentifier vcSimulationIdentifier = simsToShow[i].getSimulationInfo().getAuthoritativeVCSimulationIdentifier();
                final SimulationWindow simWindow = documentWindowManager.haveSimulationWindow(vcSimulationIdentifier);
                if (simWindow != null) {
                    ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(documentWindowManager.getComponent());
                    ChildWindow childWindow = childWindowManager.getChildWindowFromContext(simWindow);
                    if (childWindow == null) {
                        childWindow = childWindowManager.addChildWindow(simWindow.getDataViewer(), simWindow);
                        childWindow.pack();
                        childWindow.setIsCenteredOnParent();
                        childWindow.show();
                    }
                    setFinalWindow(hashTable, childWindow);
                    simWindow.setLocalState(localState);
                } else {
                    // wire it up the viewer
                    Hashtable<VCSimulationIdentifier, DataViewerController> dataViewerControllers = (Hashtable<VCSimulationIdentifier, DataViewerController>) hashTable.get(H_DATA_VIEWER_CONTROLLERS);
                    DataViewerController viewerController = dataViewerControllers.get(vcSimulationIdentifier);
                    Throwable ex = (failures == null ? null : failures.get(sim));
                    if (viewerController != null && ex == null) {
                        // no failure
                        DataViewer viewer = viewerController.createViewer();
                        getSimWorkspace().getSimulationOwner().getOutputFunctionContext().addPropertyChangeListener(viewerController);
                        documentWindowManager.addExportListener(viewer);
                        // For data related activities such as calculating statistics
                        documentWindowManager.addDataJobListener(viewer);
                        viewer.setSimulationModelInfo(new SimulationWorkspaceModelInfo(getSimWorkspace().getSimulationOwner(), sim.getName()));
                        viewer.setDataViewerManager(documentWindowManager);
                        SimulationWindow newWindow = new SimulationWindow(vcSimulationIdentifier, sim, getSimWorkspace().getSimulationOwner(), viewer);
                        BeanUtils.addCloseWindowKeyboardAction(newWindow.getDataViewer());
                        documentWindowManager.addResultsFrame(newWindow);
                        setFinalWindow(hashTable, viewer);
                        newWindow.setLocalState(localState);
                    }
                }
            }
            StringBuffer failMessage = new StringBuffer();
            if (failures != null) {
                if (!failures.isEmpty()) {
                    failMessage.append("Error, " + failures.size() + " of " + simsToShow.length + " sim results failed to display:\n");
                    Enumeration<Simulation> en = failures.keys();
                    while (en.hasMoreElements()) {
                        Simulation sim = en.nextElement();
                        Throwable exc = (Throwable) failures.get(sim);
                        failMessage.append("'" + sim.getName() + "' - " + exc.getMessage());
                    }
                }
            }
            if (failMessage.length() > 0) {
                PopupGenerator.showErrorDialog(ClientSimManager.this.getDocumentWindowManager(), failMessage.toString());
            }
        }
    };
    if (viewerType == ViewerType.BothNativeAndPython || viewerType == ViewerType.NativeViewer_only) {
        taskList.add(displayResultsTask);
    }
    // Dispatch the tasks using the ClientTaskDispatcher.
    AsynchClientTask[] taskArray = new AsynchClientTask[taskList.size()];
    taskList.toArray(taskArray);
    return taskArray;
}
Also used : User(org.vcell.util.document.User) DataViewerController(cbit.vcell.client.data.DataViewerController) SimulationMessage(cbit.vcell.solver.server.SimulationMessage) Enumeration(java.util.Enumeration) LocalVCDataIdentifier(org.vcell.util.document.LocalVCDataIdentifier) SimulationWindow(cbit.vcell.client.desktop.simulation.SimulationWindow) EventObject(java.util.EventObject) VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) Vector(java.util.Vector) DataViewer(cbit.vcell.client.data.DataViewer) FieldDataIdentifierSpec(cbit.vcell.field.FieldDataIdentifierSpec) SmoldynSolver(org.vcell.solver.smoldyn.SmoldynSolver) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) SimulationContext(cbit.vcell.mapping.SimulationContext) PrintWriter(java.io.PrintWriter) VisitSupport(cbit.vcell.resource.VisitSupport) Simulation(cbit.vcell.solver.Simulation) NetworkGenerationRequirements(cbit.vcell.mapping.SimulationContext.NetworkGenerationRequirements) VCDataManager(cbit.vcell.simdata.VCDataManager) BeanUtils(org.vcell.util.BeanUtils) Solver(cbit.vcell.solver.server.Solver) Collection(java.util.Collection) SimulationWorkspace(cbit.vcell.client.desktop.simulation.SimulationWorkspace) SolverListener(cbit.vcell.solver.server.SolverListener) VtkManager(cbit.vcell.simdata.VtkManager) SolverEvent(cbit.vcell.solver.server.SolverEvent) AsynchClientTaskFunction(cbit.vcell.client.task.AsynchClientTaskFunction) Dimension(java.awt.Dimension) SimulationJob(cbit.vcell.solver.SimulationJob) ClientTaskDispatcher(cbit.vcell.client.task.ClientTaskDispatcher) VCellConfiguration(cbit.vcell.resource.VCellConfiguration) ExportServiceImpl(cbit.vcell.export.server.ExportServiceImpl) DataProcessingInstructions(cbit.vcell.solver.DataProcessingInstructions) SimulationOwner(cbit.vcell.solver.SimulationOwner) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow) SimulationWorkspaceModelInfo(cbit.vcell.client.data.SimulationWorkspaceModelInfo) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) VCellClientDataServiceImpl(cbit.vcell.client.data.VCellClientDataServiceImpl) OutputContext(cbit.vcell.simdata.OutputContext) SimulationTask(cbit.vcell.messaging.server.SimulationTask) VCDocument(org.vcell.util.document.VCDocument) VtuVarInfo(org.vcell.vis.io.VtuVarInfo) TempSimulation(cbit.vcell.solver.TempSimulation) ArrayList(java.util.ArrayList) LocalState(cbit.vcell.client.desktop.simulation.SimulationWindow.LocalState) SolverFactory(cbit.vcell.solver.server.SolverFactory) SolverStatus(cbit.vcell.solver.server.SolverStatus) SimDataConstants(cbit.vcell.simdata.SimDataConstants) SolverException(cbit.vcell.solver.SolverException) Hashtable(java.util.Hashtable) SimulationStatusDetailsPanel(cbit.vcell.client.desktop.simulation.SimulationStatusDetailsPanel) SimulationStatus(cbit.vcell.server.SimulationStatus) SimulationDataSetRef(cbit.vcell.client.pyvcellproxy.SimulationDataSetRef) PDEDataManager(cbit.vcell.simdata.PDEDataManager) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) ResourceUtil(cbit.vcell.resource.ResourceUtil) ODEDataManager(cbit.vcell.simdata.ODEDataManager) SmoldynFileWriter(org.vcell.solver.smoldyn.SmoldynFileWriter) IOException(java.io.IOException) PropertyLoader(cbit.vcell.resource.PropertyLoader) InputStreamReader(java.io.InputStreamReader) File(java.io.File) SolverUtilities(cbit.vcell.solver.SolverUtilities) TokenMangler(org.vcell.util.TokenMangler) SolverDescription(cbit.vcell.solver.SolverDescription) DialogUtils(org.vcell.util.gui.DialogUtils) SimulationStatusDetails(cbit.vcell.client.desktop.simulation.SimulationStatusDetails) ProgressDialogListener(org.vcell.util.ProgressDialogListener) DataManager(cbit.vcell.simdata.DataManager) InputStream(java.io.InputStream) UserCancelException(org.vcell.util.UserCancelException) LocalState(cbit.vcell.client.desktop.simulation.SimulationWindow.LocalState) VtuVarInfo(org.vcell.vis.io.VtuVarInfo) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) User(org.vcell.util.document.User) ArrayList(java.util.ArrayList) SimulationDataSetRef(cbit.vcell.client.pyvcellproxy.SimulationDataSetRef) AsynchClientTaskFunction(cbit.vcell.client.task.AsynchClientTaskFunction) DataViewerController(cbit.vcell.client.data.DataViewerController) DataViewer(cbit.vcell.client.data.DataViewer) ExportServiceImpl(cbit.vcell.export.server.ExportServiceImpl) VCDataManager(cbit.vcell.simdata.VCDataManager) SimulationWorkspaceModelInfo(cbit.vcell.client.data.SimulationWorkspaceModelInfo) VCDocument(org.vcell.util.document.VCDocument) Hashtable(java.util.Hashtable) VCDataManager(cbit.vcell.simdata.VCDataManager) PDEDataManager(cbit.vcell.simdata.PDEDataManager) ODEDataManager(cbit.vcell.simdata.ODEDataManager) DataManager(cbit.vcell.simdata.DataManager) LocalVCDataIdentifier(org.vcell.util.document.LocalVCDataIdentifier) VtkManager(cbit.vcell.simdata.VtkManager) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow) OutputContext(cbit.vcell.simdata.OutputContext) Simulation(cbit.vcell.solver.Simulation) TempSimulation(cbit.vcell.solver.TempSimulation) PDEDataManager(cbit.vcell.simdata.PDEDataManager) SimulationWindow(cbit.vcell.client.desktop.simulation.SimulationWindow) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) ODEDataManager(cbit.vcell.simdata.ODEDataManager) File(java.io.File)

Aggregations

DataSetControllerImpl (cbit.vcell.simdata.DataSetControllerImpl)23 File (java.io.File)15 DataAccessException (org.vcell.util.DataAccessException)10 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)9 CartesianMesh (cbit.vcell.solvers.CartesianMesh)8 IOException (java.io.IOException)8 ExportServiceImpl (cbit.vcell.export.server.ExportServiceImpl)7 Cachetable (cbit.vcell.simdata.Cachetable)7 FieldDataIdentifierSpec (cbit.vcell.field.FieldDataIdentifierSpec)6 SolverException (cbit.vcell.solver.SolverException)6 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)6 User (org.vcell.util.document.User)6 SimDataBlock (cbit.vcell.simdata.SimDataBlock)5 VariableType (cbit.vcell.math.VariableType)4 DataServerImpl (cbit.vcell.simdata.DataServerImpl)4 OutputContext (cbit.vcell.simdata.OutputContext)4 Simulation (cbit.vcell.solver.Simulation)4 ArrayList (java.util.ArrayList)4 ThriftDataAccessException (org.vcell.vcellij.api.ThriftDataAccessException)4 UShortImage (cbit.vcell.VirtualMicroscopy.UShortImage)3