Search in sources :

Example 1 with AxialArrayModel

use of org.eclipse.scanning.api.points.models.AxialArrayModel 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 2 with AxialArrayModel

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

the class ScanpathTest method createModelCreatesCorrectModelForAxialArray.

@Test
public void createModelCreatesCorrectModelForAxialArray() throws Exception {
    pathParams = Arrays.asList(0.5, 1, 0.7, -0.135);
    mutators.put(Mutator.CONTINUOUS, Arrays.asList(blankArray));
    IScanPathModel model = AXIS_ARRAY.createModel(axialScannables, pathParams, Arrays.asList(blankArray), mutators);
    assertThat(model, is(instanceOf(AxialArrayModel.class)));
    AxialArrayModel sModel = (AxialArrayModel) model;
    assertThat(sModel.getScannableNames(), contains("name1"));
    assertThat(sModel.getPositions()[0], is(0.5));
    assertThat(sModel.getPositions()[1], is(1.0));
    assertThat(sModel.getPositions()[2], is(0.7));
    assertThat(sModel.getPositions()[3], is(-0.135));
    assertThat(sModel.isContinuous(), is(true));
    assertThat(sModel.isAlternating(), is(false));
    assertThat(sModel.getUnits(), is(equalTo(List.of("Deg"))));
}
Also used : IScanPathModel(org.eclipse.scanning.api.points.models.IScanPathModel) AxialArrayModel(org.eclipse.scanning.api.points.models.AxialArrayModel) Test(org.junit.Test)

Example 3 with AxialArrayModel

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

the class ScanPathEditor method convertTextToModel.

/**
 * Convert text representing a scan path to a {@link AxialMultiStepModel}
 *
 * @param text
 *            The text to convert (can be empty)
 * @param scannableName
 *            The name of the scannable to which the scan path refers
 * @return The corresponding multi-step model
 */
private AxialMultiStepModel convertTextToModel(String text, String scannableName) {
    AxialMultiStepModel multiAxialStepModel = new AxialMultiStepModel();
    if (!text.isEmpty()) {
        final Object oldModel = (new StringToScanPathConverter(scannableName)).convert(text);
        if (oldModel instanceof AxialMultiStepModel) {
            multiAxialStepModel = (AxialMultiStepModel) oldModel;
        } else if (oldModel instanceof AxialStepModel) {
            multiAxialStepModel.getModels().add((AxialStepModel) oldModel);
        } else if (oldModel instanceof AxialArrayModel) {
            final double[] positions = ((AxialArrayModel) oldModel).getPositions();
            for (int i = 0; i < positions.length - 1; i++) {
                final AxialStepModel stepModel = new AxialStepModel(scannableName, positions[i], positions[i + 1], positions[i + 1] - positions[i]);
                multiAxialStepModel.getModels().add(stepModel);
            }
        }
    }
    multiAxialStepModel.setName(scannableName);
    return multiAxialStepModel;
}
Also used : AxialStepModel(org.eclipse.scanning.api.points.models.AxialStepModel) AxialMultiStepModel(org.eclipse.scanning.api.points.models.AxialMultiStepModel) AxialArrayModel(org.eclipse.scanning.api.points.models.AxialArrayModel)

Aggregations

AxialArrayModel (org.eclipse.scanning.api.points.models.AxialArrayModel)3 AxialStepModel (org.eclipse.scanning.api.points.models.AxialStepModel)2 JythonServerFacade (gda.jython.JythonServerFacade)1 IRectangularROI (org.eclipse.dawnsci.analysis.api.roi.IRectangularROI)1 CircularROI (org.eclipse.dawnsci.analysis.dataset.roi.CircularROI)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 AxialMultiStepModel (org.eclipse.scanning.api.points.models.AxialMultiStepModel)1 AxialPointsModel (org.eclipse.scanning.api.points.models.AxialPointsModel)1 IScanPathModel (org.eclipse.scanning.api.points.models.IScanPathModel)1 TwoAxisGridPointsModel (org.eclipse.scanning.api.points.models.TwoAxisGridPointsModel)1 TwoAxisGridStepModel (org.eclipse.scanning.api.points.models.TwoAxisGridStepModel)1 TwoAxisLinePointsModel (org.eclipse.scanning.api.points.models.TwoAxisLinePointsModel)1 TwoAxisLineStepModel (org.eclipse.scanning.api.points.models.TwoAxisLineStepModel)1 TwoAxisPointSingleModel (org.eclipse.scanning.api.points.models.TwoAxisPointSingleModel)1 Before (org.junit.Before)1 Test (org.junit.Test)1