Search in sources :

Example 1 with StaticModel

use of org.eclipse.scanning.api.points.models.StaticModel in project gda-core by openGDA.

the class MScanSubmitterTest method willAllowStaticScanWithDefaultSizeAndNoDetectorParams.

@Test
public void willAllowStaticScanWithDefaultSizeAndNoDetectorParams() throws Exception {
    Object[] arr = { Scanpath.STATIC, detectorRunnableDevice };
    when(resolver.resolveScanClauses()).thenReturn(Arrays.asList(Arrays.asList(new ScanpathElementProcessor(Scanpath.STATIC)), Arrays.asList(new IRunnableDeviceDetectorElementProcessor(detectorRunnableDevice))));
    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) 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 2 with StaticModel

use of org.eclipse.scanning.api.points.models.StaticModel in project gda-core by openGDA.

the class MScanSubmitterTest method willAllowStaticScanWithOnlyDetectorAndParams.

@Test
public void willAllowStaticScanWithOnlyDetectorAndParams() throws Exception {
    Object[] arr = { Scanpath.STATIC, detectorRunnableDevice, 2.5 };
    when(resolver.resolveScanClauses()).thenReturn(Arrays.asList(Arrays.asList(new ScanpathElementProcessor(Scanpath.STATIC)), Arrays.asList(new IRunnableDeviceDetectorElementProcessor(detectorRunnableDevice), new NumberElementProcessor(2.5))));
    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 3 with StaticModel

use of org.eclipse.scanning.api.points.models.StaticModel in project gda-core by openGDA.

the class MScanSubmitterTest method willAllowStaticScanWithOnlyDetector.

@Test
public void willAllowStaticScanWithOnlyDetector() throws Exception {
    Object[] arr = { detector };
    when(resolver.resolveScanClauses()).thenReturn(Arrays.asList(Arrays.asList(new ScanpathElementProcessor(Scanpath.STATIC)), Arrays.asList(new ScannableDetectorElementProcessor(detector))));
    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()))));
}
Also used : IScanListener(org.eclipse.scanning.api.event.scan.IScanListener) ScanBean(org.eclipse.scanning.api.event.scan.ScanBean) ScanpathElementProcessor(gda.mscan.processor.ScanpathElementProcessor) CompoundModel(org.eclipse.scanning.api.points.models.CompoundModel) StaticModel(org.eclipse.scanning.api.points.models.StaticModel) ScannableDetectorElementProcessor(gda.mscan.processor.ScannableDetectorElementProcessor) Test(org.junit.Test)

Example 4 with StaticModel

use of org.eclipse.scanning.api.points.models.StaticModel in project gda-core by openGDA.

the class MScanSubmitterTest method willNotAllowStaticScanWithoutDetectors.

@Test
public void willNotAllowStaticScanWithoutDetectors() throws Exception {
    // No Size, so default size=1
    Object[] arr = { Scanpath.STATIC };
    when(resolver.resolveScanClauses()).thenReturn(Arrays.asList(Arrays.asList(new ScanpathElementProcessor(Scanpath.STATIC))));
    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()))));
}
Also used : IScanListener(org.eclipse.scanning.api.event.scan.IScanListener) ScanBean(org.eclipse.scanning.api.event.scan.ScanBean) ScanpathElementProcessor(gda.mscan.processor.ScanpathElementProcessor) CompoundModel(org.eclipse.scanning.api.points.models.CompoundModel) StaticModel(org.eclipse.scanning.api.points.models.StaticModel) Test(org.junit.Test)

Example 5 with StaticModel

use of org.eclipse.scanning.api.points.models.StaticModel in project gda-core by openGDA.

the class TimeSeriesScanView method createScanBean.

private ScanBean createScanBean() {
    final IMalcolmModel malcolmModel = malcolmModelEditor.getModel();
    final String malcolmDeviceName = malcolmModel.getName();
    final ScanRequest scanRequest = new ScanRequest();
    // add the malcolm model to the scan request
    final Map<String, IDetectorModel> detectors = new HashMap<>();
    detectors.put(malcolmDeviceName, malcolmModel);
    scanRequest.setDetectors(detectors);
    // extract the models from the outer scannables
    final List<IScanPointGeneratorModel> pointsModels = outerScannablesBlock.getOuterScannables().stream().filter(IScanModelWrapper<IScanPointGeneratorModel>::isIncludeInScan).map(IScanModelWrapper<IScanPointGeneratorModel>::getModel).collect(toCollection(ArrayList::new));
    final int numSteps = numStepsSpinner.getSelection();
    pointsModels.add(new StaticModel(numSteps));
    scanRequest.setCompoundModel(new CompoundModel(pointsModels));
    final ScanBean scanBean = new ScanBean(scanRequest);
    scanBean.setName(String.format("%s - Time Series", malcolmDeviceName));
    return scanBean;
}
Also used : HashMap(java.util.HashMap) StaticModel(org.eclipse.scanning.api.points.models.StaticModel) ScanRequest(org.eclipse.scanning.api.event.scan.ScanRequest) IDetectorModel(org.eclipse.scanning.api.device.models.IDetectorModel) ScanBean(org.eclipse.scanning.api.event.scan.ScanBean) IScanModelWrapper(uk.ac.diamond.daq.mapping.api.IScanModelWrapper) CompoundModel(org.eclipse.scanning.api.points.models.CompoundModel) IMalcolmModel(org.eclipse.scanning.api.device.models.IMalcolmModel) IScanPointGeneratorModel(org.eclipse.scanning.api.points.models.IScanPointGeneratorModel)

Aggregations

ScanBean (org.eclipse.scanning.api.event.scan.ScanBean)7 CompoundModel (org.eclipse.scanning.api.points.models.CompoundModel)7 StaticModel (org.eclipse.scanning.api.points.models.StaticModel)7 ScanpathElementProcessor (gda.mscan.processor.ScanpathElementProcessor)6 IScanListener (org.eclipse.scanning.api.event.scan.IScanListener)6 Test (org.junit.Test)6 IRunnableDeviceDetectorElementProcessor (gda.mscan.processor.IRunnableDeviceDetectorElementProcessor)4 NumberElementProcessor (gda.mscan.processor.NumberElementProcessor)3 ScannableDetectorElementProcessor (gda.mscan.processor.ScannableDetectorElementProcessor)1 HashMap (java.util.HashMap)1 IDetectorModel (org.eclipse.scanning.api.device.models.IDetectorModel)1 IMalcolmModel (org.eclipse.scanning.api.device.models.IMalcolmModel)1 ScanRequest (org.eclipse.scanning.api.event.scan.ScanRequest)1 IScanPointGeneratorModel (org.eclipse.scanning.api.points.models.IScanPointGeneratorModel)1 IScanModelWrapper (uk.ac.diamond.daq.mapping.api.IScanModelWrapper)1