Search in sources :

Example 1 with TwoAxisGridPointsModel

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

the class ScanRequestConverterTest method testStageNamesChanged.

@Test
public void testStageNamesChanged() throws Exception {
    // Initially the scan path doesn't have the correct axis names
    assertThat(scanPath.getxAxisName(), is(not(equalTo(X_AXIS_NAME))));
    assertThat(scanPath.getyAxisName(), is(not(equalTo(Y_AXIS_NAME))));
    // Act - they're set according to the MappingStageInfo when the mapping bean is
    // converted to a scan request
    ScanRequest scanRequest = scanRequestConverter.convertToScanRequest(mappingBean);
    // Assert - the axis names are now set to the names of the stage
    assertThat(scanPath.getxAxisName(), is(equalTo(X_AXIS_NAME)));
    assertThat(scanPath.getyAxisName(), is(equalTo(Y_AXIS_NAME)));
    // change the mapping stage axis names
    mappingStageInfo.setPlotXAxisName("new_x_axis");
    mappingStageInfo.setPlotYAxisName("new_y_axis");
    // the new mapping bean hasn't been set up with a scan path at this stage
    IMappingScanRegion newRegion = newMappingBean.getScanDefinition().getMappingScanRegion();
    assertThat(newRegion.getScanPath(), is(nullValue()));
    // merging the scan request back into a mapping bean
    scanRequestConverter.mergeIntoMappingBean(scanRequest, newMappingBean);
    // check that the new mapping bean has the correct stage names
    assertThat(newRegion.getScanPath(), is(instanceOf(TwoAxisGridPointsModel.class)));
    TwoAxisGridPointsModel newScanPath = (TwoAxisGridPointsModel) newRegion.getScanPath();
    assertThat(newScanPath.getxAxisName(), is(equalTo(X_AXIS_NAME)));
    assertThat(newScanPath.getyAxisName(), is(equalTo(Y_AXIS_NAME)));
    // check that the mapping stage info has been updated with the stage names from the scan request
    assertThat(mappingStageInfo.getPlotXAxisName(), is(equalTo(X_AXIS_NAME)));
    assertThat(mappingStageInfo.getPlotYAxisName(), is(equalTo(Y_AXIS_NAME)));
}
Also used : IMappingScanRegion(uk.ac.diamond.daq.mapping.api.IMappingScanRegion) TwoAxisGridPointsModel(org.eclipse.scanning.api.points.models.TwoAxisGridPointsModel) ScanRequest(org.eclipse.scanning.api.event.scan.ScanRequest) Test(org.junit.Test)

Example 2 with TwoAxisGridPointsModel

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

the class ScanRequestConverterTest method setUp.

@Before
public void setUp() throws Exception {
    // We wire things together without OSGi here
    // DO NOT COPY THIS IN NON-TEST CODE!
    mappingStageInfo = new MappingStageInfo();
    mappingStageInfo.setPlotXAxisName(X_AXIS_NAME);
    mappingStageInfo.setPlotYAxisName(Y_AXIS_NAME);
    mappingStageInfo.setBeamSize(BEAM_SIZE_NAME);
    // Prepare the Finder
    Factory testFactory = mock(Factory.class);
    ScannableMotionUnits xAxis = mock(ScannableMotionUnits.class);
    when(xAxis.getHardwareUnitString()).thenReturn(X_AXIS_UNITS);
    ScannableMotionUnits yAxis = mock(ScannableMotionUnits.class);
    when(yAxis.getHardwareUnitString()).thenReturn(Y_AXIS_UNITS);
    when(testFactory.getFindable(X_AXIS_NAME)).thenReturn(xAxis);
    when(testFactory.getFindable(Y_AXIS_NAME)).thenReturn(yAxis);
    Finder.addFactory(testFactory);
    scanRequestConverter = new ScanRequestConverter();
    scanRequestConverter.setMappingStageInfo(mappingStageInfo);
    // Set up the experiment bean with some sensible defaults
    mappingBean = new MappingExperimentBean();
    scanPath = new TwoAxisGridPointsModel();
    scanPath.setContinuous(true);
    mappingBean.getScanDefinition().getMappingScanRegion().setScanPath(scanPath);
    final RectangularMappingRegion scanRegion = new RectangularMappingRegion();
    scanRegion.setxStart(X_START);
    scanRegion.setxStop(X_START + X_LENGTH);
    scanRegion.setyStart(Y_START);
    scanRegion.setyStop(Y_START + Y_LENGTH);
    mappingBean.getScanDefinition().getMappingScanRegion().setRegion(scanRegion);
    mappingBean.setDetectorParameters(Collections.emptyList());
    mappingBean.setPerScanMonitorNames(new HashSet<>(Arrays.asList("perScan1", "perScan2")));
    mappingBean.setPerPointMonitorNames(new HashSet<>(Arrays.asList("perPoint1", "perPoint2", "perPoint3")));
    newMappingBean = new MappingExperimentBean();
}
Also used : ScannableMotionUnits(gda.device.ScannableMotionUnits) TwoAxisGridPointsModel(org.eclipse.scanning.api.points.models.TwoAxisGridPointsModel) MappingExperimentBean(uk.ac.diamond.daq.mapping.impl.MappingExperimentBean) MappingStageInfo(uk.ac.diamond.daq.mapping.impl.MappingStageInfo) Factory(gda.factory.Factory) RectangularMappingRegion(uk.ac.diamond.daq.mapping.region.RectangularMappingRegion) ScanRequestConverter(uk.ac.diamond.daq.mapping.ui.experiment.ScanRequestConverter) Before(org.junit.Before)

Example 3 with TwoAxisGridPointsModel

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

the class MScanSubmitterTest method setUp.

@Before
public void setUp() throws Exception {
    try (final MockedStatic<JythonServerFacade> facade = mockStatic(JythonServerFacade.class)) {
        facade.when(JythonServerFacade::getInstance).thenReturn(theFacadeInstance);
        builder = new MScanSubmitter(eventService, runnableDeviceService, resolverFactory);
        when(eventService.getEventConnectorService()).thenReturn(connectorService);
        when(connectorService.marshal(any())).thenReturn("");
        when(eventService.createSubmitter(any(), any())).thenReturn(submitter);
        when(eventService.createSubscriber(any(), anyString())).thenReturn(eventSubscriber);
        when(resolverFactory.getResolver(captor.capture())).thenReturn(resolver);
        when(detector.getName()).thenReturn(DETECTOR_NAME);
        when(runnableDeviceService.getRunnableDevice(DETECTOR_NAME)).thenReturn(runnableDevice);
        when(runnableDevice.getModel()).thenReturn(detectorModel);
        when(detectorRunnableDevice.getModel()).thenReturn(detectorModel);
        when(monitor.getName()).thenReturn("monitor");
        when(scannable.getName()).thenReturn("stage_x");
        when(scannable.getUserUnits()).thenReturn("mm");
        when(anotherScannable.getName()).thenReturn("stage_y");
        when(anotherScannable.getUserUnits()).thenReturn("mm");
        point = new TwoAxisPointSingleModel();
        point.setX(2.0);
        point.setY(3.0);
        pointRoi = new PointROI(point.getX(), point.getY());
        axPoints = new AxialPointsModel(scannable.getName(), 2, 3, 20);
        axPoints.setContinuous(false);
        axStep = new AxialStepModel(scannable.getName(), 2, 3, 0.2);
        axStep.setContinuous(false);
        axArray = new AxialArrayModel(scannable.getName(), positions);
        axArray.setContinuous(false);
        liPoints = new TwoAxisLinePointsModel();
        liPoints.setPoints(20);
        liStep = new TwoAxisLineStepModel();
        liStep.setStep(0.2);
        line = new LinearROI(new double[] { 2, 2 }, new double[] { 3, 3 });
        grid = new TwoAxisGridPointsModel(scannable.getName(), anotherScannable.getName(), 20, 10);
        grid.setContinuous(false);
        steppedGrid = new TwoAxisGridStepModel();
        steppedGrid.setxAxisStep(0.1);
        steppedGrid.setyAxisStep(0.2);
        steppedGrid.setContinuous(false);
        rectangle = new RectangularROI(2, 3, 4, 5, 0);
        rectangleX2 = rectangle.getPointX() + rectangle.getLength(X);
        rectangleY2 = rectangle.getPointY() + rectangle.getLength(Y);
        circle = new CircularROI(5.5, 2, 3);
    }
}
Also used : TwoAxisLinePointsModel(org.eclipse.scanning.api.points.models.TwoAxisLinePointsModel) JythonServerFacade(gda.jython.JythonServerFacade) AxialArrayModel(org.eclipse.scanning.api.points.models.AxialArrayModel) TwoAxisGridPointsModel(org.eclipse.scanning.api.points.models.TwoAxisGridPointsModel) TwoAxisLineStepModel(org.eclipse.scanning.api.points.models.TwoAxisLineStepModel) CircularROI(org.eclipse.dawnsci.analysis.dataset.roi.CircularROI) TwoAxisPointSingleModel(org.eclipse.scanning.api.points.models.TwoAxisPointSingleModel) TwoAxisGridStepModel(org.eclipse.scanning.api.points.models.TwoAxisGridStepModel) LinearROI(org.eclipse.dawnsci.analysis.dataset.roi.LinearROI) AxialStepModel(org.eclipse.scanning.api.points.models.AxialStepModel) IRectangularROI(org.eclipse.dawnsci.analysis.api.roi.IRectangularROI) RectangularROI(org.eclipse.dawnsci.analysis.dataset.roi.RectangularROI) AxialPointsModel(org.eclipse.scanning.api.points.models.AxialPointsModel) PointROI(org.eclipse.dawnsci.analysis.dataset.roi.PointROI) Before(org.junit.Before)

Example 4 with TwoAxisGridPointsModel

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

the class ClausesContextTest method addPathDefinitionToCompoundModelSucceedsForCompliantContext.

@Test
public void addPathDefinitionToCompoundModelSucceedsForCompliantContext() throws Exception {
    CompoundModel compoundModel = new CompoundModel();
    clausesContext.addScannable(scannable);
    clausesContext.addScannable(scannable);
    clausesContext.setRegionShape(RegionShape.CIRCLE);
    clausesContext.addParam(1);
    clausesContext.addParam(2);
    clausesContext.addParam(3);
    clausesContext.setScanpath(Scanpath.GRID_POINTS);
    clausesContext.addParam(1);
    clausesContext.addParam(2);
    clausesContext.addPathDefinitionToCompoundModel(compoundModel);
    assertThat(clausesContext.isScanPathSeen(), is(true));
    assertThat(clausesContext.isClauseProcessed(), is(true));
    assertThat(compoundModel.getModels().get(0), instanceOf(TwoAxisGridPointsModel.class));
    assertThat(((TwoAxisGridPointsModel) compoundModel.getModels().get(0)).getxAxisPoints(), is(1));
    assertThat(((TwoAxisGridPointsModel) compoundModel.getModels().get(0)).getyAxisPoints(), is(2));
    assertThat(compoundModel.getRegions().iterator().next().getRoi(), instanceOf(CircularROI.class));
    assertThat(((CircularROI) compoundModel.getRegions().iterator().next().getRoi()).getCentre()[0], is(1.0));
    assertThat(((CircularROI) compoundModel.getRegions().iterator().next().getRoi()).getCentre()[1], is(2.0));
    assertThat(((CircularROI) compoundModel.getRegions().iterator().next().getRoi()).getRadius(), is(3.0));
    assertThat(compoundModel.getMutators(), is(new ArrayList<>()));
}
Also used : TwoAxisGridPointsModel(org.eclipse.scanning.api.points.models.TwoAxisGridPointsModel) CompoundModel(org.eclipse.scanning.api.points.models.CompoundModel) CircularROI(org.eclipse.dawnsci.analysis.dataset.roi.CircularROI) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 5 with TwoAxisGridPointsModel

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

the class ScanpathTest method createModelCreatesCorrectModelForGridWithVerticalMutator.

@Test
public void createModelCreatesCorrectModelForGridWithVerticalMutator() throws Exception {
    pathParams = Arrays.asList(5, 6);
    mutators.put(Mutator.VERTICAL, Arrays.asList(blankArray));
    mutators.put(Mutator.ALTERNATING, Arrays.asList(blankArray));
    IScanPathModel model = GRID_POINTS.createModel(scannables, pathParams, bboxParams, mutators);
    assertThat(model, is(instanceOf(TwoAxisGridPointsModel.class)));
    TwoAxisGridPointsModel gModel = (TwoAxisGridPointsModel) model;
    assertThat(gModel.getScannableNames(), contains("name1", "name2"));
    assertThat(gModel.getBoundingBox().getxAxisStart(), is(1.0));
    assertThat(gModel.getBoundingBox().getyAxisStart(), is(2.0));
    assertThat(gModel.getBoundingBox().getxAxisLength(), is(3.0));
    assertThat(gModel.getBoundingBox().getyAxisLength(), is(4.0));
    assertThat(gModel.getxAxisPoints(), is(5));
    assertThat(gModel.getyAxisPoints(), is(6));
    assertThat(gModel.getBoundingBox().getyAxisStart(), is(2.0));
    assertThat(gModel.getOrientation(), is(Orientation.VERTICAL));
    assertThat(gModel.isAlternating(), is(true));
    assertThat(gModel.isContinuous(), is(false));
}
Also used : TwoAxisGridPointsModel(org.eclipse.scanning.api.points.models.TwoAxisGridPointsModel) IScanPathModel(org.eclipse.scanning.api.points.models.IScanPathModel) Test(org.junit.Test)

Aggregations

TwoAxisGridPointsModel (org.eclipse.scanning.api.points.models.TwoAxisGridPointsModel)8 Test (org.junit.Test)4 CircularROI (org.eclipse.dawnsci.analysis.dataset.roi.CircularROI)2 AxialStepModel (org.eclipse.scanning.api.points.models.AxialStepModel)2 BoundingBox (org.eclipse.scanning.api.points.models.BoundingBox)2 CompoundModel (org.eclipse.scanning.api.points.models.CompoundModel)2 IScanPathModel (org.eclipse.scanning.api.points.models.IScanPathModel)2 Before (org.junit.Before)2 IMappingScanRegion (uk.ac.diamond.daq.mapping.api.IMappingScanRegion)2 RectangularMappingRegion (uk.ac.diamond.daq.mapping.region.RectangularMappingRegion)2 ScannableMotionUnits (gda.device.ScannableMotionUnits)1 Factory (gda.factory.Factory)1 JythonServerFacade (gda.jython.JythonServerFacade)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 IRectangularROI (org.eclipse.dawnsci.analysis.api.roi.IRectangularROI)1 TreeFile (org.eclipse.dawnsci.analysis.api.tree.TreeFile)1 LinearROI (org.eclipse.dawnsci.analysis.dataset.roi.LinearROI)1 PointROI (org.eclipse.dawnsci.analysis.dataset.roi.PointROI)1 RectangularROI (org.eclipse.dawnsci.analysis.dataset.roi.RectangularROI)1