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)));
}
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();
}
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);
}
}
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<>()));
}
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));
}
Aggregations