use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.
the class MathModelWindowManager method checkValidSimulationDataViewerFrames.
/**
* Insert the method's description here.
* Creation date: (7/20/2004 1:13:06 PM)
*/
private void checkValidSimulationDataViewerFrames() {
SimulationWindow[] simWindows = (SimulationWindow[]) BeanUtils.getArray(simulationWindowsHash.elements(), SimulationWindow.class);
Simulation[] sims = getMathModel().getSimulations();
Hashtable<VCSimulationIdentifier, Simulation> hash = new Hashtable<VCSimulationIdentifier, Simulation>();
for (int i = 0; i < sims.length; i++) {
SimulationInfo simInfo = sims[i].getSimulationInfo();
if (simInfo != null) {
VCSimulationIdentifier vcSimulationIdentifier = simInfo.getAuthoritativeVCSimulationIdentifier();
hash.put(vcSimulationIdentifier, sims[i]);
}
}
for (int i = 0; i < simWindows.length; i++) {
if (hash.containsKey(simWindows[i].getVcSimulationIdentifier())) {
simWindows[i].resetSimulation((Simulation) hash.get(simWindows[i].getVcSimulationIdentifier()));
} else {
ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(getJPanel());
ChildWindow childWindow = childWindowManager.getChildWindowFromContext(simWindows[i]);
if (childWindow != null) {
childWindow.close();
}
}
}
}
use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.
the class TopLevelWindowManager method prepareDocumentToLoad.
public void prepareDocumentToLoad(VCDocument doc, boolean bInNewWindow) throws Exception {
if (doc instanceof BioModel) {
Simulation[] simulations = ((BioModel) doc).getSimulations();
ArrayList<VCSimulationIdentifier> simIDs = new ArrayList<VCSimulationIdentifier>();
for (int i = 0; i < simulations.length; i++) {
SimulationInfo simulationInfo = simulations[i].getSimulationInfo();
if (simulationInfo != null) {
simIDs.add(simulationInfo.getAuthoritativeVCSimulationIdentifier());
}
}
RequestManager rm = getRequestManager();
ConnectionStatus stat = rm.getConnectionStatus();
if (stat.getStatus() == ConnectionStatus.CONNECTED) {
rm.getDocumentManager().preloadSimulationStatus(simIDs.toArray(new VCSimulationIdentifier[0]));
}
} else if (doc instanceof MathModel) {
Geometry geometry = ((MathModel) doc).getMathDescription().getGeometry();
geometry.precomputeAll(new GeometryThumbnailImageFactoryAWT());
Simulation[] simulations = ((MathModel) doc).getSimulations();
// VCSimulationIdentifier simIDs[] = new VCSimulationIdentifier[simulations.length];
ArrayList<VCSimulationIdentifier> simIDs = new ArrayList<>();
for (int i = 0; i < simulations.length; i++) {
if (simulations[i].getSimulationInfo() != null) {
simIDs.add(simulations[i].getSimulationInfo().getAuthoritativeVCSimulationIdentifier());
}
}
getRequestManager().getDocumentManager().preloadSimulationStatus(simIDs.toArray(new VCSimulationIdentifier[0]));
} else if (doc instanceof Geometry) {
((Geometry) doc).precomputeAll(new GeometryThumbnailImageFactoryAWT());
}
}
use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.
the class ApplicationComponents method cleanSimWindowsHash.
/**
* Remove server side sim results windows that are no longer in use
*/
public void cleanSimWindowsHash() {
Iterator<Entry<VCSimulationIdentifier, SimulationWindow>> iter = simulationWindowsHash.entrySet().iterator();
while (iter.hasNext()) {
Entry<VCSimulationIdentifier, SimulationWindow> es = iter.next();
SimulationWindow sw = es.getValue();
if (!sw.isShowingLocalSimulation()) {
VCSimulationIdentifier vcsid = es.getKey();
Simulation[] sims = simulationWorkspace.getSimulations();
boolean bFound = false;
for (int i = 0; i < sims.length; i += 1) {
if (sims[i].getSimulationInfo() != null && sims[i].getSimulationInfo().getAuthoritativeVCSimulationIdentifier().equals(vcsid)) {
bFound = true;
break;
}
}
if (!bFound) {
iter.remove();
}
}
}
}
use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.
the class ChomboSimpleDataViewer method retrieveVariablesAndTimes.
private void retrieveVariablesAndTimes() {
AsynchClientTask task0 = new AsynchClientTask("clear", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
DefaultComboBoxModel dcm = new DefaultComboBoxModel();
timeComboBox.setModel(dcm);
DefaultListModel dlm = new DefaultListModel();
varList.setModel(dlm);
solTableModel.clear();
meshMetricsTableModel.clear();
meanTextField.setText(null);
maxErrorTextField.setText(null);
sumVolFracTextField.setText(null);
l2ErrorTextField.setText(null);
}
};
AsynchClientTask task1 = new AsynchClientTask("retrieve data", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
String simId = simIdField.getText().trim();
if (simId == null || simId.length() == 0) {
throw new RuntimeException("Please provide a simulation id.");
}
String username = userNameTextField.getText().trim();
if (username == null || username.length() == 0) {
throw new RuntimeException("Please provide a user name.");
}
VCSimulationDataIdentifier vcDataId = new VCSimulationDataIdentifier(new VCSimulationIdentifier(new KeyValue(simId), new User(username, null)), 0);
SimDataInfoHolder simDataInfoHolder = null;
String datadir = dataDirTextField.getText();
if (datadir == null || datadir.length() == 0) {
simDataInfoHolder = createSimulationDataFromRemote(username, vcDataId);
datadir = simDataInfoHolder.userDir.getParent();
dataDirTextField.setText(datadir);
} else {
simDataInfoHolder = createSimulationDataFromDir(new File(datadir), username, vcDataId);
}
simData = simDataInfoHolder.simData;
simData.readVarAndFunctionDataIdentifiers();
usernames.add(username);
userNameTextField.setAutoCompletionWords(usernames);
datadirs.add(datadir);
dataDirTextField.setAutoCompletionWords(datadirs);
simIds.add(simId);
simIdField.setAutoCompletionWords(simIds);
}
};
AsynchClientTask task2 = new AsynchClientTask("show data", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
double[] times = simData.getDataTimes();
DefaultComboBoxModel dcm = new DefaultComboBoxModel();
for (double t : times) {
dcm.addElement(t);
}
timeComboBox.setModel(dcm);
meshMetricsTableModel.setData(simData.getChomboMesh().getMetricsColumnNames(), simData.getChomboMesh().getMetricsNumbers());
List<DataSetIdentifier> dsiList = simData.getDataSetIdentifiers();
DefaultListModel dlm = new DefaultListModel();
for (DataSetIdentifier dsi : dsiList) {
dlm.addElement(dsi);
}
varList.setModel(dlm);
if (times.length > 0) {
timeComboBox.setSelectedIndex(0);
}
if (dsiList.size() > 0) {
varList.setSelectedIndex(0);
}
meshMetricsTableModel.refreshTable();
}
};
ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task0, task1, task2 }, false);
}
use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.
the class VCellClientDataServiceImpl method getVCSimulationDataIdentifier.
public VCSimulationDataIdentifier getVCSimulationDataIdentifier(SimulationDataSetRef simulationDataSetRef) throws FileNotFoundException {
User user = new User(simulationDataSetRef.getUsername(), new KeyValue(simulationDataSetRef.getUserkey()));
KeyValue simKeyValue = new KeyValue(simulationDataSetRef.getSimId());
VCSimulationIdentifier vcSimulationIdentifier = new VCSimulationIdentifier(simKeyValue, user);
if (simulationDataSetRef.isIsLocal()) {
File primaryDir = ResourceUtil.getLocalRootDir();
DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(null, primaryDir, null);
ExportServiceImpl localExportServiceImpl = new ExportServiceImpl();
LocalDataSetControllerProvider localDSCProvider = new LocalDataSetControllerProvider(user, dataSetControllerImpl, localExportServiceImpl);
VCDataManager vcDataManager = new VCDataManager(localDSCProvider);
File localSimDir = ResourceUtil.getLocalSimDir(User.tempUser.getName());
VCSimulationDataIdentifier simulationDataIdentifier = new LocalVCSimulationDataIdentifier(vcSimulationIdentifier, 0, localSimDir);
return simulationDataIdentifier;
} else {
VCSimulationDataIdentifier vcSimulationDataIdentifier = new VCSimulationDataIdentifier(vcSimulationIdentifier, simulationDataSetRef.getJobIndex());
return vcSimulationDataIdentifier;
}
}
Aggregations