Search in sources :

Example 36 with ScanRequest

use of org.eclipse.scanning.api.event.scan.ScanRequest in project gda-core by openGDA.

the class ProcessingRequestHandlerServiceTest method testUnknownRequest.

@Test
public void testUnknownRequest() {
    ProcessingRequestPair<Double> customPair = new ProcessingRequestPair<Double>() {

        @Override
        public String getKey() {
            return "WeightedProcess";
        }

        @Override
        public List<Double> getValue() {
            List<Double> weights = new ArrayList<>();
            weights.add(1.2);
            weights.add(3.7);
            return weights;
        }
    };
    ScanRequest scanRequest = new ScanRequest();
    scanRequest.setProcessingRequest(new ProcessingRequest());
    scanRequest.getProcessingRequest().setRequest(new HashMap<>());
    service.handle(customPair, scanRequest);
    Assert.assertEquals(0, scanRequest.getProcessingRequest().getRequest().size());
}
Also used : ProcessingRequestPair(uk.ac.gda.api.acquisition.configuration.processing.ProcessingRequestPair) ScanRequest(org.eclipse.scanning.api.event.scan.ScanRequest) ArrayList(java.util.ArrayList) ProcessingRequest(org.eclipse.scanning.api.event.scan.ProcessingRequest) Test(org.junit.Test)

Example 37 with ScanRequest

use of org.eclipse.scanning.api.event.scan.ScanRequest in project gda-core by openGDA.

the class ScanRequestFactory method createScanRequest.

public ScanRequest createScanRequest(IRunnableDeviceService runnableDeviceService) throws ScanningException {
    // Populate the {@link ScanRequest} with the assembled objects
    var scanRequest = new ScanRequest();
    scanRequest.setTemplateFilePaths(new HashSet<>());
    prepareScanRequestAccordingToScanType(scanRequest);
    Optional.ofNullable(getAcquisition().getAcquisitionLocation()).map(URL::getPath).ifPresent(scanRequest::setFilePath);
    try {
        scanRequest.setCompoundModel(createCompoundModel());
    } catch (GDAException e) {
        throw new ScanningException("Cannot create compound model", e);
    }
    parseAcquisitionEngine(scanRequest, runnableDeviceService);
    addPosition(createStartPosition(), scanRequest::setStartPosition);
    addPosition(createEndPosition(), scanRequest::setEnd);
    scanRequest.setMonitorNamesPerPoint(parseMonitorNamesPerPoint());
    scanRequest.setProcessingRequest(new ProcessingRequest());
    scanRequest.getProcessingRequest().setRequest(new HashMap<>());
    for (ProcessingRequestPair<?> request : getAcquisitionConfiguration().getProcessingRequest()) {
        getProcessingRequestHandlerService().handle(request, scanRequest);
    }
    return scanRequest;
}
Also used : ScanRequest(org.eclipse.scanning.api.event.scan.ScanRequest) ScanningException(org.eclipse.scanning.api.scan.ScanningException) GDAException(uk.ac.gda.common.exception.GDAException) ProcessingRequest(org.eclipse.scanning.api.event.scan.ProcessingRequest)

Example 38 with ScanRequest

use of org.eclipse.scanning.api.event.scan.ScanRequest in project gda-core by openGDA.

the class HeterogeneousScanServlet method preprocess.

private void preprocess(ScanBean scanBean) throws ProcessingException {
    // copied from ScanServlet
    ScanRequest req = scanBean.getScanRequest();
    if (req.isIgnorePreprocess()) {
        return;
    }
    for (IPreprocessor processor : Services.getPreprocessors()) {
        req = processor.preprocess(req);
    }
    scanBean.setScanRequest(req);
}
Also used : ScanRequest(org.eclipse.scanning.api.event.scan.ScanRequest) IPreprocessor(org.eclipse.scanning.api.scan.process.IPreprocessor)

Example 39 with ScanRequest

use of org.eclipse.scanning.api.event.scan.ScanRequest in project gda-core by openGDA.

the class AbstractMappingSection method createScanBean.

protected ScanBean createScanBean() {
    final IMappingExperimentBean mappingBean = getMappingBean();
    addMonitors(mappingBean);
    final ScanBean scanBean = new ScanBean();
    String sampleName = mappingBean.getSampleMetadata().getSampleName();
    if (sampleName == null || sampleName.length() == 0) {
        sampleName = "unknown sample";
    }
    final String pathName = mappingBean.getScanDefinition().getMappingScanRegion().getScanPath().getName();
    scanBean.setName(String.format("%s - %s Scan", sampleName, pathName));
    scanBean.setBeamline(System.getProperty("BEAMLINE"));
    final ScanRequest scanRequest = getScanRequest(mappingBean);
    scanBean.setScanRequest(scanRequest);
    return scanBean;
}
Also used : ScanRequest(org.eclipse.scanning.api.event.scan.ScanRequest) ScanBean(org.eclipse.scanning.api.event.scan.ScanBean) IMappingExperimentBean(uk.ac.diamond.daq.mapping.api.IMappingExperimentBean)

Example 40 with ScanRequest

use of org.eclipse.scanning.api.event.scan.ScanRequest in project gda-core by openGDA.

the class ScanManagementController method createScanBean.

/**
 * Transforms the current mapping bean into a a {@link ScanBean} which can be submitted. The given filePath is set
 * in the intermediate {@link ScanRequest}.
 *
 * @param filePath
 *            the output path. This will override any path set in the {@link ScanRequest} created from the mapping
 *            bean.
 * @param acquisitionParameters
 *            the acquisition parameters
 * @return a scan bean
 */
public ScanBean createScanBean(Optional<String> filePath, ScanningAcquisition acquisitionParameters) {
    checkInitialised();
    final IMappingExperimentBean mappingBean = getMappingBean();
    // Ensure the detector named in ScanningAcquisition (if any) is activated
    Optional.ofNullable(acquisitionParameters).map(ScanningAcquisition::getName).ifPresent(dName -> ensureDetectorIncludedInScan(dName, mappingBean));
    addMonitors(mappingBean);
    final String sampleName = getSampleName(mappingBean, acquisitionParameters);
    final String pathName = mappingBean.getScanDefinition().getMappingScanRegion().getScanPath().getName();
    final ScanBean scanBean = new ScanBean();
    scanBean.setName(String.format("%s - %s Scan", sampleName, pathName));
    scanBean.setBeamline(System.getProperty("BEAMLINE"));
    final ScanRequestConverter converter = getService(ScanRequestConverter.class);
    final ScanRequest scanRequest = converter.convertToScanRequest(mappingBean);
    if (acquisitionParameters != null) {
        setSampleMetadata(scanRequest, sampleName);
    }
    if (filePath.isPresent()) {
        scanRequest.setFilePath(filePath.get());
    }
    scanBean.setScanRequest(scanRequest);
    return scanBean;
}
Also used : ScanRequest(org.eclipse.scanning.api.event.scan.ScanRequest) ScanBean(org.eclipse.scanning.api.event.scan.ScanBean) IMappingExperimentBean(uk.ac.diamond.daq.mapping.api.IMappingExperimentBean)

Aggregations

ScanRequest (org.eclipse.scanning.api.event.scan.ScanRequest)42 Test (org.junit.Test)25 IDetectorModel (org.eclipse.scanning.api.device.models.IDetectorModel)8 ScanBean (org.eclipse.scanning.api.event.scan.ScanBean)8 CompoundModel (org.eclipse.scanning.api.points.models.CompoundModel)8 IScanPointGeneratorModel (org.eclipse.scanning.api.points.models.IScanPointGeneratorModel)8 ArrayList (java.util.ArrayList)7 ProcessingRequest (org.eclipse.scanning.api.event.scan.ProcessingRequest)7 IScanModelWrapper (uk.ac.diamond.daq.mapping.api.IScanModelWrapper)7 IMarshallerService (org.eclipse.dawnsci.analysis.api.persistence.IMarshallerService)5 ScanRegion (org.eclipse.scanning.api.points.models.ScanRegion)5 IScriptService (org.eclipse.scanning.api.script.IScriptService)5 IMappingExperimentBean (uk.ac.diamond.daq.mapping.api.IMappingExperimentBean)5 HashMap (java.util.HashMap)4 AxialStepModel (org.eclipse.scanning.api.points.models.AxialStepModel)4 IMappingScanRegion (uk.ac.diamond.daq.mapping.api.IMappingScanRegion)4 TemplateFileWrapper (uk.ac.diamond.daq.mapping.api.TemplateFileWrapper)4 DetectorModelWrapper (uk.ac.diamond.daq.mapping.impl.DetectorModelWrapper)4 IMalcolmModel (org.eclipse.scanning.api.device.models.IMalcolmModel)3 IMapPathModel (org.eclipse.scanning.api.points.models.IMapPathModel)3