use of org.eclipse.scanning.points.PointGeneratorService 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());
}
use of org.eclipse.scanning.points.PointGeneratorService in project gda-core by openGDA.
the class ScanRequestConverterTest method setUpClass.
@BeforeClass
public static void setUpClass() {
final ServiceHolder serviceHolder = new ServiceHolder();
serviceHolder.setValidatorService(new ValidatorService());
serviceHolder.setPointGeneratorService(new PointGeneratorService());
}
use of org.eclipse.scanning.points.PointGeneratorService in project gda-core by openGDA.
the class ScannableNexusWrapperScanTest method setServices.
@BeforeClass
public static void setServices() throws Exception {
jythonServer = mock(JythonServer.class);
scannableDeviceService = new ScannableDeviceConnectorService();
// Not testing OSGi so using hard coded service.
scanService = new RunnableDeviceServiceImpl(scannableDeviceService);
pointGenService = new PointGeneratorService();
nexusFileFactory = new NexusFileFactoryHDF5();
final ActivemqConnectorService activemqConnectorService = new ActivemqConnectorService();
activemqConnectorService.setJsonMarshaller(new MarshallerService(new PointsModelMarshaller()));
final IEventService eservice = new EventServiceImpl(activemqConnectorService);
final Services services = new Services();
services.setEventService(eservice);
services.setRunnableDeviceService(scanService);
services.setGeneratorService(pointGenService);
services.setConnector(scannableDeviceService);
final INexusDeviceService nexusDeviceService = new NexusDeviceService();
new org.eclipse.dawnsci.nexus.ServiceHolder().setNexusFileFactory(nexusFileFactory);
final org.eclipse.scanning.sequencer.ServiceHolder serviceHolder = new org.eclipse.scanning.sequencer.ServiceHolder();
serviceHolder.setNexusDeviceService(nexusDeviceService);
serviceHolder.setNexusScanFileService(new NexusScanFileServiceImpl());
serviceHolder.setOperationService(new MockOperationService());
serviceHolder.setFilePathService(new MockFilePathService());
final org.eclipse.dawnsci.nexus.scan.ServiceHolder scanServiceHolder = new org.eclipse.dawnsci.nexus.scan.ServiceHolder();
scanServiceHolder.setNexusDeviceService(nexusDeviceService);
scanServiceHolder.setNexusBuilderFactory(new DefaultNexusBuilderFactory());
final org.eclipse.scanning.points.ServiceHolder pointsServiceHolder = new org.eclipse.scanning.points.ServiceHolder();
pointsServiceHolder.setValidatorService(new ValidatorService());
pointsServiceHolder.setPointGeneratorService(new PointGeneratorService());
}
Aggregations