Search in sources :

Example 1 with IPointGeneratorService

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

the class ScanRequestConverterTest method testRoiAxisNamesAreSet.

@Test
public void testRoiAxisNamesAreSet() throws Exception {
    IPointGeneratorService pointGeneratorService = new PointGeneratorService();
    // Act - convert mapping bean to scan request
    final ScanRequest scanRequest = scanRequestConverter.convertToScanRequest(mappingBean);
    final Collection<ScanRegion> regions = scanRequest.getCompoundModel().getRegions();
    // Assert - ensure only one region
    assertThat(regions.size(), is(equalTo(1)));
    for (final ScanRegion scanRegion : regions) {
        final List<String> scannables = scanRegion.getScannables();
        final RectangularROI roi = (RectangularROI) scanRegion.getRoi();
        /* Post DAQ-2739, this ensures if x-y axes of regions are flipped again it will be noticed either here or in the num of point
			 * [n.b. shortly before 2739, Regions were not passed to CompoundModels, then they were but reflected, which broke scanning]
			 */
        assertThat(scannables.get(0), is(equalTo(X_AXIS_NAME)));
        assertThat(scannables.get(1), is(equalTo(Y_AXIS_NAME)));
        assertEquals(X_START, roi.getPoint()[0], DIFF_LIMIT);
        assertEquals(Y_START, roi.getPoint()[1], DIFF_LIMIT);
        assertEquals(X_LENGTH, roi.getLengths()[0], DIFF_LIMIT);
        assertEquals(Y_LENGTH, roi.getLengths()[1], DIFF_LIMIT);
    }
    // Act again - convert scan request back to mapping bean
    scanRequestConverter.mergeIntoMappingBean(scanRequest, newMappingBean);
    assertEquals(mappingBean.getScanDefinition().getMappingScanRegion().getRegion(), newMappingBean.getScanDefinition().getMappingScanRegion().getRegion());
    List<IPosition> allPositions = pointGeneratorService.createCompoundGenerator(scanRequest.getCompoundModel()).createPoints();
    assertEquals(25, allPositions.size());
}
Also used : ScanRequest(org.eclipse.scanning.api.event.scan.ScanRequest) ScanRegion(org.eclipse.scanning.api.points.models.ScanRegion) IMappingScanRegion(uk.ac.diamond.daq.mapping.api.IMappingScanRegion) IPosition(org.eclipse.scanning.api.points.IPosition) IPointGeneratorService(org.eclipse.scanning.api.points.IPointGeneratorService) RectangularROI(org.eclipse.dawnsci.analysis.dataset.roi.RectangularROI) PointGeneratorService(org.eclipse.scanning.points.PointGeneratorService) IPointGeneratorService(org.eclipse.scanning.api.points.IPointGeneratorService) Test(org.junit.Test)

Aggregations

RectangularROI (org.eclipse.dawnsci.analysis.dataset.roi.RectangularROI)1 ScanRequest (org.eclipse.scanning.api.event.scan.ScanRequest)1 IPointGeneratorService (org.eclipse.scanning.api.points.IPointGeneratorService)1 IPosition (org.eclipse.scanning.api.points.IPosition)1 ScanRegion (org.eclipse.scanning.api.points.models.ScanRegion)1 PointGeneratorService (org.eclipse.scanning.points.PointGeneratorService)1 Test (org.junit.Test)1 IMappingScanRegion (uk.ac.diamond.daq.mapping.api.IMappingScanRegion)1