Search in sources :

Example 1 with TomographyCalibrationData

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);
    }
}
Also used : IMarshallerService(org.eclipse.dawnsci.analysis.api.persistence.IMarshallerService) TomographyCalibrationData(uk.ac.diamond.daq.mapping.api.TomographyCalibrationData) File(java.io.File) DeviceException(gda.device.DeviceException) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter)

Example 2 with TomographyCalibrationData

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"));
}
Also used : IMarshallerService(org.eclipse.dawnsci.analysis.api.persistence.IMarshallerService) ScanRequest(org.eclipse.scanning.api.event.scan.ScanRequest) TomographyCalibrationData(uk.ac.diamond.daq.mapping.api.TomographyCalibrationData) BufferedReader(java.io.BufferedReader) IScriptService(org.eclipse.scanning.api.script.IScriptService) TomographyParams(uk.ac.diamond.daq.mapping.api.TomographyParams) IMappingExperimentBean(uk.ac.diamond.daq.mapping.api.IMappingExperimentBean)

Example 3 with TomographyCalibrationData

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);
    }
}
Also used : IMarshallerService(org.eclipse.dawnsci.analysis.api.persistence.IMarshallerService) ScanRequest(org.eclipse.scanning.api.event.scan.ScanRequest) TomographyCalibrationData(uk.ac.diamond.daq.mapping.api.TomographyCalibrationData) IScriptService(org.eclipse.scanning.api.script.IScriptService) TomographyParams(uk.ac.diamond.daq.mapping.api.TomographyParams) DeviceException(gda.device.DeviceException) IOException(java.io.IOException) JythonServerFacade(gda.jython.JythonServerFacade)

Aggregations

IMarshallerService (org.eclipse.dawnsci.analysis.api.persistence.IMarshallerService)3 TomographyCalibrationData (uk.ac.diamond.daq.mapping.api.TomographyCalibrationData)3 DeviceException (gda.device.DeviceException)2 IOException (java.io.IOException)2 ScanRequest (org.eclipse.scanning.api.event.scan.ScanRequest)2 IScriptService (org.eclipse.scanning.api.script.IScriptService)2 TomographyParams (uk.ac.diamond.daq.mapping.api.TomographyParams)2 JythonServerFacade (gda.jython.JythonServerFacade)1 BufferedReader (java.io.BufferedReader)1 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 IMappingExperimentBean (uk.ac.diamond.daq.mapping.api.IMappingExperimentBean)1