Search in sources :

Example 31 with ScanBean

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()));
}
Also used : IScanListener(org.eclipse.scanning.api.event.scan.IScanListener) ScanBean(org.eclipse.scanning.api.event.scan.ScanBean) NumberElementProcessor(gda.mscan.processor.NumberElementProcessor) ScanpathElementProcessor(gda.mscan.processor.ScanpathElementProcessor) CompoundModel(org.eclipse.scanning.api.points.models.CompoundModel) IRunnableDeviceDetectorElementProcessor(gda.mscan.processor.IRunnableDeviceDetectorElementProcessor) StaticModel(org.eclipse.scanning.api.points.models.StaticModel) Test(org.junit.Test)

Example 32 with ScanBean

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()));
}
Also used : IScanListener(org.eclipse.scanning.api.event.scan.IScanListener) ScanBean(org.eclipse.scanning.api.event.scan.ScanBean) NumberElementProcessor(gda.mscan.processor.NumberElementProcessor) ScanpathElementProcessor(gda.mscan.processor.ScanpathElementProcessor) CompoundModel(org.eclipse.scanning.api.points.models.CompoundModel) IRunnableDeviceDetectorElementProcessor(gda.mscan.processor.IRunnableDeviceDetectorElementProcessor) StaticModel(org.eclipse.scanning.api.points.models.StaticModel) Test(org.junit.Test)

Example 33 with ScanBean

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()));
}
Also used : IScanListener(org.eclipse.scanning.api.event.scan.IScanListener) ScanBean(org.eclipse.scanning.api.event.scan.ScanBean) NumberElementProcessor(gda.mscan.processor.NumberElementProcessor) ScanpathElementProcessor(gda.mscan.processor.ScanpathElementProcessor) IClauseElementProcessor(gda.mscan.processor.IClauseElementProcessor) ScannableElementProcessor(gda.mscan.processor.ScannableElementProcessor) IRunnableDeviceDetectorElementProcessor(gda.mscan.processor.IRunnableDeviceDetectorElementProcessor) RegionShapeElementProcessor(gda.mscan.processor.RegionShapeElementProcessor) Test(org.junit.Test)

Example 34 with ScanBean

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;
}
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 35 with 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;
}
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

ScanBean (org.eclipse.scanning.api.event.scan.ScanBean)35 Test (org.junit.Test)23 IScanListener (org.eclipse.scanning.api.event.scan.IScanListener)20 ScanpathElementProcessor (gda.mscan.processor.ScanpathElementProcessor)18 IRunnableDeviceDetectorElementProcessor (gda.mscan.processor.IRunnableDeviceDetectorElementProcessor)16 NumberElementProcessor (gda.mscan.processor.NumberElementProcessor)15 IClauseElementProcessor (gda.mscan.processor.IClauseElementProcessor)13 RegionShapeElementProcessor (gda.mscan.processor.RegionShapeElementProcessor)12 ScannableElementProcessor (gda.mscan.processor.ScannableElementProcessor)12 CompoundModel (org.eclipse.scanning.api.points.models.CompoundModel)8 ScanRequest (org.eclipse.scanning.api.event.scan.ScanRequest)7 StaticModel (org.eclipse.scanning.api.points.models.StaticModel)7 EventException (org.eclipse.scanning.api.event.EventException)4 IMappingExperimentBean (uk.ac.diamond.daq.mapping.api.IMappingExperimentBean)3 ScannableDetectorElementProcessor (gda.mscan.processor.ScannableDetectorElementProcessor)2 URISyntaxException (java.net.URISyntaxException)2 IScanPointGeneratorModel (org.eclipse.scanning.api.points.models.IScanPointGeneratorModel)2 ReRunFromFileElementProcessor (gda.mscan.processor.ReRunFromFileElementProcessor)1 ScanDataConsumerElementProcessor (gda.mscan.processor.ScanDataConsumerElementProcessor)1 ScannableMonitorElementProcessor (gda.mscan.processor.ScannableMonitorElementProcessor)1