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());
}
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;
}
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);
}
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;
}
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;
}
Aggregations