use of org.eclipse.scanning.api.event.scan.ScanBean in project gda-core by openGDA.
the class MScanSubmitterTest method willAllowStaticScanWithDetectorAndNoScannable.
@Test
public void willAllowStaticScanWithDetectorAndNoScannable() throws Exception {
final int size = 5;
Object[] arr = { Scanpath.STATIC, size, detectorRunnableDevice, EXPOSURE };
when(resolver.resolveScanClauses()).thenReturn(Arrays.asList(Arrays.asList(new ScanpathElementProcessor(Scanpath.STATIC), new NumberElementProcessor(size)), Arrays.asList(new IRunnableDeviceDetectorElementProcessor(detectorRunnableDevice), new NumberElementProcessor(EXPOSURE))));
builder.buildAndSubmitBlockingScanRequest(arr);
verify(submitter).blockingSubmit(beanCaptor.capture());
verify(eventSubscriber).addListener(any(IScanListener.class));
ScanBean bean = beanCaptor.getValue();
assertThat(bean.getScanRequest().getCompoundModel(), is(equalTo(new CompoundModel(new StaticModel(size)))));
assertThat(bean.getScanRequest().getDetectors().values(), contains(detectorRunnableDevice.getModel()));
}
use of org.eclipse.scanning.api.event.scan.ScanBean in project gda-core by openGDA.
the class MScanSubmitterTest method willAllowStaticScanWithDefaultSize.
@Test
public void willAllowStaticScanWithDefaultSize() throws Exception {
// > 1 exposure time to ensure number not stolen by previous clause
Object[] arr = { Scanpath.STATIC, detectorRunnableDevice, 2.7 };
when(resolver.resolveScanClauses()).thenReturn(Arrays.asList(Arrays.asList(new ScanpathElementProcessor(Scanpath.STATIC)), Arrays.asList(new IRunnableDeviceDetectorElementProcessor(detectorRunnableDevice), new NumberElementProcessor(1.7))));
builder.buildAndSubmitBlockingScanRequest(arr);
verify(submitter).blockingSubmit(beanCaptor.capture());
verify(eventSubscriber).addListener(any(IScanListener.class));
ScanBean bean = beanCaptor.getValue();
assertThat(bean.getScanRequest().getCompoundModel(), is(equalTo(new CompoundModel(new StaticModel()))));
assertThat(bean.getScanRequest().getDetectors().values(), contains(detectorRunnableDevice.getModel()));
}
use of org.eclipse.scanning.api.event.scan.ScanBean in project gda-core by openGDA.
the class MScanSubmitterTest method createsCorrectProcessorListForPointScanWithFullSyntaxAndSubmits.
@Test
public void createsCorrectProcessorListForPointScanWithFullSyntaxAndSubmits() throws Exception {
Object[] arr = { scannable, anotherScannable, RegionShape.POINT, point.getX(), point.getY(), RegionShape.POINT, point.getX(), point.getY(), detectorRunnableDevice };
when(resolver.resolveScanClauses()).thenReturn(Arrays.asList(Arrays.asList(new ScannableElementProcessor(scannable), new ScannableElementProcessor(anotherScannable), new RegionShapeElementProcessor(RegionShape.POINT), new NumberElementProcessor(point.getX()), new NumberElementProcessor(point.getY()), new ScanpathElementProcessor(Scanpath.SINGLE_POINT), new NumberElementProcessor(point.getX()), new NumberElementProcessor(point.getY())), Arrays.asList(new IRunnableDeviceDetectorElementProcessor(detectorRunnableDevice))));
builder.buildAndSubmitBlockingScanRequest(arr);
List<IClauseElementProcessor> processors = captor.getValue();
assertThat(processors.size(), is(9));
assertThat(processors.get(0), instanceOf(ScannableElementProcessor.class));
assertThat(processors.get(0).getElement(), is(scannable));
assertThat(processors.get(1), instanceOf(ScannableElementProcessor.class));
assertThat(processors.get(1).getElement(), is(anotherScannable));
assertThat(processors.get(2), instanceOf(RegionShapeElementProcessor.class));
assertThat(processors.get(2).getElement(), is(RegionShape.POINT));
assertThat(processors.get(3), instanceOf(NumberElementProcessor.class));
assertThat(processors.get(3).getElement(), is(point.getX()));
assertThat(processors.get(4), instanceOf(NumberElementProcessor.class));
assertThat(processors.get(4).getElement(), is(point.getY()));
assertThat(processors.get(5), instanceOf(ScanpathElementProcessor.class));
assertThat(processors.get(5).getElement(), is(Scanpath.SINGLE_POINT));
assertThat(processors.get(6), instanceOf(NumberElementProcessor.class));
assertThat(processors.get(6).getElement(), is(point.getX()));
assertThat(processors.get(7), instanceOf(NumberElementProcessor.class));
assertThat(processors.get(7).getElement(), is(point.getY()));
assertThat(processors.get(8), instanceOf(IRunnableDeviceDetectorElementProcessor.class));
assertThat(processors.get(8).getElement(), is(detectorRunnableDevice));
verify(eventSubscriber).addListener(any(IScanListener.class));
verify(submitter).blockingSubmit(beanCaptor.capture());
ScanBean bean = beanCaptor.getValue();
assertThat(bean.getScanRequest().getCompoundModel(), is(equalTo(getCompoundModel(point, pointRoi))));
assertThat(bean.getScanRequest().getDetectors().values(), contains(detectorRunnableDevice.getModel()));
}
use of org.eclipse.scanning.api.event.scan.ScanBean 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.ScanBean 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