Search in sources :

Example 1 with PointGeneratorService

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

Example 2 with PointGeneratorService

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());
}
Also used : ValidatorService(org.eclipse.scanning.points.validation.ValidatorService) ServiceHolder(org.eclipse.scanning.points.ServiceHolder) PointGeneratorService(org.eclipse.scanning.points.PointGeneratorService) IPointGeneratorService(org.eclipse.scanning.api.points.IPointGeneratorService) BeforeClass(org.junit.BeforeClass)

Example 3 with 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());
}
Also used : RunnableDeviceServiceImpl(org.eclipse.scanning.sequencer.RunnableDeviceServiceImpl) ServiceHolder(gda.data.ServiceHolder) IPointGeneratorService(org.eclipse.scanning.api.points.IPointGeneratorService) PointGeneratorService(org.eclipse.scanning.points.PointGeneratorService) NexusFileFactoryHDF5(org.eclipse.dawnsci.hdf5.nexus.NexusFileFactoryHDF5) MockOperationService(org.eclipse.scanning.test.utilities.scan.mock.MockOperationService) ValidatorService(org.eclipse.scanning.points.validation.ValidatorService) JythonServer(gda.jython.JythonServer) NexusDeviceService(org.eclipse.dawnsci.nexus.device.impl.NexusDeviceService) INexusDeviceService(org.eclipse.dawnsci.nexus.device.INexusDeviceService) INexusDeviceService(org.eclipse.dawnsci.nexus.device.INexusDeviceService) EventServiceImpl(org.eclipse.scanning.event.EventServiceImpl) IEventService(org.eclipse.scanning.api.event.IEventService) ActivemqConnectorService(org.eclipse.scanning.connector.activemq.ActivemqConnectorService) MockFilePathService(org.eclipse.scanning.example.file.MockFilePathService) MarshallerService(org.eclipse.dawnsci.json.MarshallerService) PointsModelMarshaller(org.eclipse.scanning.points.serialization.PointsModelMarshaller) NexusScanFileServiceImpl(org.eclipse.dawnsci.nexus.scan.impl.NexusScanFileServiceImpl) DefaultNexusBuilderFactory(org.eclipse.dawnsci.nexus.builder.impl.DefaultNexusBuilderFactory) Services(org.eclipse.scanning.server.servlet.Services) BeforeClass(org.junit.BeforeClass)

Aggregations

IPointGeneratorService (org.eclipse.scanning.api.points.IPointGeneratorService)3 PointGeneratorService (org.eclipse.scanning.points.PointGeneratorService)3 ValidatorService (org.eclipse.scanning.points.validation.ValidatorService)2 BeforeClass (org.junit.BeforeClass)2 ServiceHolder (gda.data.ServiceHolder)1 JythonServer (gda.jython.JythonServer)1 RectangularROI (org.eclipse.dawnsci.analysis.dataset.roi.RectangularROI)1 NexusFileFactoryHDF5 (org.eclipse.dawnsci.hdf5.nexus.NexusFileFactoryHDF5)1 MarshallerService (org.eclipse.dawnsci.json.MarshallerService)1 DefaultNexusBuilderFactory (org.eclipse.dawnsci.nexus.builder.impl.DefaultNexusBuilderFactory)1 INexusDeviceService (org.eclipse.dawnsci.nexus.device.INexusDeviceService)1 NexusDeviceService (org.eclipse.dawnsci.nexus.device.impl.NexusDeviceService)1 NexusScanFileServiceImpl (org.eclipse.dawnsci.nexus.scan.impl.NexusScanFileServiceImpl)1 IEventService (org.eclipse.scanning.api.event.IEventService)1 ScanRequest (org.eclipse.scanning.api.event.scan.ScanRequest)1 IPosition (org.eclipse.scanning.api.points.IPosition)1 ScanRegion (org.eclipse.scanning.api.points.models.ScanRegion)1 ActivemqConnectorService (org.eclipse.scanning.connector.activemq.ActivemqConnectorService)1 EventServiceImpl (org.eclipse.scanning.event.EventServiceImpl)1 MockFilePathService (org.eclipse.scanning.example.file.MockFilePathService)1