use of uk.ac.diamond.daq.mapping.api.TomographyCalibrationData in project gda-core by openGDA.
the class TomographyConfigurationDialog method saveCalibrationToFile.
/**
* Save calibration data to a file, so that the Submit button can read it.
*/
private void saveCalibrationToFile() {
CALIBRATION_DIRECTORY_PATH.toFile().mkdirs();
final File outputFile = CALIBRATION_FILE_PATH.toFile();
try (BufferedWriter outputWriter = Files.newBufferedWriter(CALIBRATION_FILE_PATH, CREATE)) {
final IMarshallerService marshallerService = getService(IMarshallerService.class);
final TomographyCalibrationData tomoCalibration = new TomographyCalibrationData(xCalibration, zCalibration);
outputWriter.write(marshallerService.marshal(tomoCalibration));
logger.debug("Calibration data written to {}", CALIBRATION_FILE_PATH);
unsavedCalibration = false;
setButtonStates();
} catch (Exception e) {
final String message = String.format(getClientMessage(TOMO_CALIBRATE_SAVE_FILE_ERROR), outputFile.getName());
handleException(message, e);
}
}
use of uk.ac.diamond.daq.mapping.api.TomographyCalibrationData in project gda-core by openGDA.
the class TomographySubmitScanSection method submitScan.
@Override
protected void submitScan() {
// Read parameters from file
try (BufferedReader reader = Files.newBufferedReader(CALIBRATION_FILE_PATH)) {
final IScriptService scriptService = getService(IScriptService.class);
final IMarshallerService marshallerService = getService(IMarshallerService.class);
final IMappingExperimentBean mappingBean = getMappingBean();
final TomographyCalibrationData calibrationParams = marshallerService.unmarshal(reader.readLine(), TomographyCalibrationData.class);
final ScanRequest scanRequest = getScanRequest(mappingBean);
final TomographyParams tomoParams = new TomographyParams();
tomoParams.setTomographyCalibration(calibrationParams);
tomoParams.setProcessingFiles(getProcessingFilesAs(mappingBean));
tomoParams.setVisitId(InterfaceProvider.getBatonStateProvider().getBatonHolder().getVisitID());
populateScriptService(scriptService, marshallerService, scanRequest, tomoParams);
} catch (Exception e) {
handleException(getClientMessage(TOMO_CALIBRATE_SUBMIT_ERROR), e);
return;
}
Async.execute(() -> runScript(tomoScanScript, "tomography scanning script"));
}
use of uk.ac.diamond.daq.mapping.api.TomographyCalibrationData in project gda-core by openGDA.
the class TomographyConfigurationDialog method performDryRun.
private void performDryRun() {
try {
// Put calibration data etc. into script context
final IScriptService scriptService = getService(IScriptService.class);
final IMarshallerService marshallerService = getService(IMarshallerService.class);
final ScanRequest scanRequest = getScanRequest(mappingView.getBean());
final TomographyParams tomoParams = new TomographyParams();
tomoParams.setTomographyCalibration(new TomographyCalibrationData(xCalibration, zCalibration));
populateScriptService(scriptService, marshallerService, scanRequest, tomoParams);
// Run script
final JythonServerFacade jythonServerFacade = JythonServerFacade.getInstance();
setDryRunEnabled(false);
logger.info("Running tomography scan");
jythonServerFacade.runScript(tomoScript);
while (jythonServerFacade.getScriptStatus() == RUNNING) {
Thread.sleep(500);
}
logger.info("Finished running tomography scan");
} catch (Exception e) {
logger.error("Error running tomography scan", e);
} finally {
setDryRunEnabled(true);
}
}
Aggregations