Search in sources :

Example 6 with ScanBean

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

the class MScanSubmitterTest method createsCorrectProcessorListForCircularStepScanWithAliasedSyntaxAndSubmits.

@Test
public void createsCorrectProcessorListForCircularStepScanWithAliasedSyntaxAndSubmits() throws Exception {
    Object[] arr = { scannable, anotherScannable, RegionShape.CIRCLE, circle.getPointX(), circle.getPointY(), circle.getRadius(), Scanpath.LINE_STEP, steppedGrid.getxAxisStep(), steppedGrid.getyAxisStep(), detectorRunnableDevice };
    when(resolver.resolveScanClauses()).thenReturn(Arrays.asList(Arrays.asList(new ScannableElementProcessor(scannable), new ScannableElementProcessor(anotherScannable), new RegionShapeElementProcessor(RegionShape.CIRCLE), new NumberElementProcessor(circle.getPointX()), new NumberElementProcessor(circle.getPointY()), new NumberElementProcessor(circle.getRadius()), new ScanpathElementProcessor(Scanpath.GRID_STEP), new NumberElementProcessor(steppedGrid.getxAxisStep()), new NumberElementProcessor(steppedGrid.getyAxisStep())), Arrays.asList(new IRunnableDeviceDetectorElementProcessor(detectorRunnableDevice))));
    builder.buildAndSubmitBlockingScanRequest(arr);
    List<IClauseElementProcessor> processors = captor.getValue();
    assertThat(processors.size(), is(10));
    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.CIRCLE));
    assertThat(processors.get(3), instanceOf(NumberElementProcessor.class));
    assertThat(processors.get(3).getElement(), is(circle.getPointX()));
    assertThat(processors.get(4), instanceOf(NumberElementProcessor.class));
    assertThat(processors.get(4).getElement(), is(circle.getPointY()));
    assertThat(processors.get(5), instanceOf(NumberElementProcessor.class));
    assertThat(processors.get(5).getElement(), is(circle.getRadius()));
    assertThat(processors.get(6), instanceOf(ScanpathElementProcessor.class));
    assertThat(processors.get(6).getElement(), is(Scanpath.GRID_STEP));
    assertThat(processors.get(7), instanceOf(NumberElementProcessor.class));
    assertThat(processors.get(7).getElement(), is(steppedGrid.getxAxisStep()));
    assertThat(processors.get(8), instanceOf(NumberElementProcessor.class));
    assertThat(processors.get(8).getElement(), is(steppedGrid.getyAxisStep()));
    assertThat(processors.get(9), instanceOf(IRunnableDeviceDetectorElementProcessor.class));
    assertThat(processors.get(9).getElement(), is(detectorRunnableDevice));
    verify(eventSubscriber).addListener(any(IScanListener.class));
    verify(submitter).blockingSubmit(beanCaptor.capture());
    ScanBean bean = beanCaptor.getValue();
    assertThat(bean.getScanRequest().getCompoundModel(), is(equalTo(getBoundedCompoundModel(steppedGrid, circle))));
    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 7 with ScanBean

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

the class MScanSubmitterTest method createsCorrectProcessorListForAxialStepScanWithFullSyntaxAndSubmits.

@Test
public void createsCorrectProcessorListForAxialStepScanWithFullSyntaxAndSubmits() throws Exception {
    Object[] arr = { scannable, RegionShape.AXIAL, line.getPointX(), line.getIntEndPoint()[0], Scanpath.AXIS_STEP, axStep.getStep(), detectorRunnableDevice };
    when(resolver.resolveScanClauses()).thenReturn(Arrays.asList(Arrays.asList(new ScannableElementProcessor(scannable), new RegionShapeElementProcessor(RegionShape.AXIAL), new NumberElementProcessor(line.getPointX()), new NumberElementProcessor(line.getIntEndPoint()[0]), new ScanpathElementProcessor(Scanpath.AXIS_STEP), new NumberElementProcessor(axStep.getStep())), Arrays.asList(new IRunnableDeviceDetectorElementProcessor(detectorRunnableDevice))));
    builder.buildAndSubmitBlockingScanRequest(arr);
    List<IClauseElementProcessor> processors = captor.getValue();
    assertThat(processors.size(), is(7));
    assertThat(processors.get(0), instanceOf(ScannableElementProcessor.class));
    assertThat(processors.get(0).getElement(), is(scannable));
    assertThat(processors.get(1), instanceOf(RegionShapeElementProcessor.class));
    assertThat(processors.get(1).getElement(), is(RegionShape.AXIAL));
    assertThat(processors.get(2), instanceOf(NumberElementProcessor.class));
    assertThat(processors.get(2).getElement(), is(line.getPointX()));
    assertThat(processors.get(3), instanceOf(NumberElementProcessor.class));
    assertThat(processors.get(3).getElement(), is(line.getIntEndPoint()[0]));
    assertThat(processors.get(4), instanceOf(ScanpathElementProcessor.class));
    assertThat(processors.get(4).getElement(), is(Scanpath.AXIS_STEP));
    assertThat(processors.get(5), instanceOf(NumberElementProcessor.class));
    assertThat(processors.get(5).getElement(), is(axStep.getStep()));
    assertThat(processors.get(6), instanceOf(IRunnableDeviceDetectorElementProcessor.class));
    assertThat(processors.get(6).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(axStep, line))));
    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 8 with ScanBean

use of org.eclipse.scanning.api.event.scan.ScanBean 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 9 with ScanBean

use of org.eclipse.scanning.api.event.scan.ScanBean 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 10 with ScanBean

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

the class MScanSubmitterTest method createsCorrectProcessorListForRectangularPointsScanWithAliasedSyntaxAndSubmits.

@Test
public void createsCorrectProcessorListForRectangularPointsScanWithAliasedSyntaxAndSubmits() throws Exception {
    Object[] arr = { scannable, anotherScannable, RegionShape.RECTANGLE, rectangle.getPointX(), rectangle.getPointY(), rectangleX2, rectangleY2, Scanpath.LINE_POINTS, grid.getxAxisPoints(), grid.getyAxisPoints(), detectorRunnableDevice };
    when(resolver.resolveScanClauses()).thenReturn(Arrays.asList(Arrays.asList(new ScannableElementProcessor(scannable), new ScannableElementProcessor(anotherScannable), new RegionShapeElementProcessor(RegionShape.RECTANGLE), new NumberElementProcessor(rectangle.getPointX()), new NumberElementProcessor(rectangle.getPointY()), new NumberElementProcessor(rectangleX2), new NumberElementProcessor(rectangleY2), new ScanpathElementProcessor(Scanpath.GRID_POINTS), new NumberElementProcessor(grid.getxAxisPoints()), new NumberElementProcessor(grid.getyAxisPoints())), Arrays.asList(new IRunnableDeviceDetectorElementProcessor(detectorRunnableDevice))));
    builder.buildAndSubmitBlockingScanRequest(arr);
    List<IClauseElementProcessor> processors = captor.getValue();
    assertThat(processors.size(), is(11));
    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.RECTANGLE));
    assertThat(processors.get(3), instanceOf(NumberElementProcessor.class));
    assertThat(processors.get(3).getElement(), is(rectangle.getPointX()));
    assertThat(processors.get(4), instanceOf(NumberElementProcessor.class));
    assertThat(processors.get(4).getElement(), is(rectangle.getPointY()));
    assertThat(processors.get(5), instanceOf(NumberElementProcessor.class));
    assertThat(processors.get(5).getElement(), is(rectangleX2));
    assertThat(processors.get(6), instanceOf(NumberElementProcessor.class));
    assertThat(processors.get(6).getElement(), is(rectangleY2));
    assertThat(processors.get(7), instanceOf(ScanpathElementProcessor.class));
    assertThat(processors.get(7).getElement(), is(Scanpath.GRID_POINTS));
    assertThat(processors.get(8), instanceOf(NumberElementProcessor.class));
    assertThat(processors.get(8).getElement(), is(grid.getxAxisPoints()));
    assertThat(processors.get(9), instanceOf(NumberElementProcessor.class));
    assertThat(processors.get(9).getElement(), is(grid.getyAxisPoints()));
    assertThat(processors.get(10), instanceOf(IRunnableDeviceDetectorElementProcessor.class));
    assertThat(processors.get(10).getElement(), is(detectorRunnableDevice));
    verify(eventSubscriber).addListener(any(IScanListener.class));
    verify(submitter).blockingSubmit(beanCaptor.capture());
    ScanBean bean = beanCaptor.getValue();
    assertThat(bean.getScanRequest().getCompoundModel(), is(equalTo(getBoundedCompoundModel(grid, rectangle))));
    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)

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