Search in sources :

Example 6 with MandelbrotModel

use of org.eclipse.scanning.example.detector.MandelbrotModel in project gda-core by openGDA.

the class FocusScanConverterTest method setUp.

@Before
public void setUp() throws Exception {
    mappingStageInfo = new MappingStageInfo();
    mappingStageInfo.setPlotXAxisName("testing_x_axis");
    mappingStageInfo.setPlotYAxisName("testing_y_axis");
    mappingStageInfo.setAssociatedAxis("zone_plate_axis");
    focusScanConverter = new FocusScanConverter();
    focusScanConverter.setMappingStageInfo(mappingStageInfo);
    focusScanBean = new FocusScanBean();
    focusScanBean.setFocusScannableName("zonePlateZ");
    focusScanBean.setFocusCentre(150.0);
    focusScanBean.setFocusRange(17.5);
    focusScanBean.setNumberOfFocusSteps(25);
    focusScanBean.setNumberOfLinePoints(120);
    focusScanBean.setDetector(new MandelbrotModel());
    final LineMappingRegion lineRegion = new LineMappingRegion();
    lineRegion.setxStart(1.23);
    lineRegion.setxStop(6.78);
    lineRegion.setyStart(0.321);
    lineRegion.setyStop(0.289);
    focusScanBean.setLineRegion(lineRegion);
}
Also used : FocusScanConverter(uk.ac.diamond.daq.mapping.ui.experiment.focus.FocusScanConverter) MappingStageInfo(uk.ac.diamond.daq.mapping.impl.MappingStageInfo) LineMappingRegion(uk.ac.diamond.daq.mapping.region.LineMappingRegion) MandelbrotModel(org.eclipse.scanning.example.detector.MandelbrotModel) FocusScanBean(uk.ac.diamond.daq.mapping.api.FocusScanBean) Before(org.junit.Before)

Example 7 with MandelbrotModel

use of org.eclipse.scanning.example.detector.MandelbrotModel in project gda-core by openGDA.

the class ScanRequestConverterTest method testDetectorIsExcludedCorrectly.

@Test
public void testDetectorIsExcludedCorrectly() throws Exception {
    // Arrange
    final String displayName = "Mandelbrot Detector";
    final IDetectorModel detModel = new MandelbrotModel();
    mappingBean.setDetectorParameters(Arrays.asList(new DetectorModelWrapper(displayName, detModel, false)));
    // Act - convert mapping bean to scan request
    final ScanRequest scanRequest = scanRequestConverter.convertToScanRequest(mappingBean);
    // Assert
    assertThat(scanRequest.getDetectors().entrySet(), is(empty()));
    // Act again - merge the scan request back into the same mapping bean
    scanRequestConverter.mergeIntoMappingBean(scanRequest, mappingBean);
    // Assert again - check the mapping bean is the same as the original
    List<IScanModelWrapper<IDetectorModel>> newDetectorParams = mappingBean.getDetectorParameters();
    assertThat(newDetectorParams.size(), is(1));
    IScanModelWrapper<IDetectorModel> wrapper = newDetectorParams.get(0);
    assertThat(wrapper.getName(), is(equalTo(displayName)));
    // names must be same, i.e. mandlebrot
    assertThat(wrapper.getModel(), is(equalTo(detModel)));
    assertThat(wrapper.isIncludeInScan(), is(false));
}
Also used : ScanRequest(org.eclipse.scanning.api.event.scan.ScanRequest) IDetectorModel(org.eclipse.scanning.api.device.models.IDetectorModel) IScanModelWrapper(uk.ac.diamond.daq.mapping.api.IScanModelWrapper) DetectorModelWrapper(uk.ac.diamond.daq.mapping.impl.DetectorModelWrapper) MandelbrotModel(org.eclipse.scanning.example.detector.MandelbrotModel) Test(org.junit.Test)

Example 8 with MandelbrotModel

use of org.eclipse.scanning.example.detector.MandelbrotModel in project gda-core by openGDA.

the class ScanRequestConverterTest method testDetectorIsIncludedCorrectly.

@Test
public void testDetectorIsIncludedCorrectly() throws Exception {
    // Arrange
    final String detName = "mandelbrot";
    final String displayName = "Mandelbrot Detector";
    final IDetectorModel detModel = new MandelbrotModel();
    detModel.setName(detName);
    mappingBean.setDetectorParameters(Arrays.asList(new DetectorModelWrapper(displayName, detModel, true)));
    // Act - convert mapping bean to scan request
    final ScanRequest scanRequest = scanRequestConverter.convertToScanRequest(mappingBean);
    // Assert
    assertEquals(detModel, scanRequest.getDetectors().get(detName));
    // Act again - convert scan request back to mapping bean
    ((DetectorModelWrapper) mappingBean.getDetectorParameters().get(0)).setIncludeInScan(false);
    scanRequestConverter.mergeIntoMappingBean(scanRequest, mappingBean);
    // Assert - check the new mapping bean is the same as the original
    List<IScanModelWrapper<IDetectorModel>> newDetectorParams = mappingBean.getDetectorParameters();
    assertThat(newDetectorParams.size(), is(1));
    IScanModelWrapper<IDetectorModel> wrapper = newDetectorParams.get(0);
    assertThat(wrapper.getName(), is(equalTo(displayName)));
    assertThat(wrapper.getModel(), is(equalTo(detModel)));
    assertThat(wrapper.isIncludeInScan(), is(true));
}
Also used : ScanRequest(org.eclipse.scanning.api.event.scan.ScanRequest) IDetectorModel(org.eclipse.scanning.api.device.models.IDetectorModel) IScanModelWrapper(uk.ac.diamond.daq.mapping.api.IScanModelWrapper) DetectorModelWrapper(uk.ac.diamond.daq.mapping.impl.DetectorModelWrapper) MandelbrotModel(org.eclipse.scanning.example.detector.MandelbrotModel) Test(org.junit.Test)

Aggregations

MandelbrotModel (org.eclipse.scanning.example.detector.MandelbrotModel)8 Test (org.junit.Test)6 DetectorModelWrapper (uk.ac.diamond.daq.mapping.impl.DetectorModelWrapper)5 IDetectorModel (org.eclipse.scanning.api.device.models.IDetectorModel)4 HashMap (java.util.HashMap)2 ScanRequest (org.eclipse.scanning.api.event.scan.ScanRequest)2 IScanModelWrapper (uk.ac.diamond.daq.mapping.api.IScanModelWrapper)2 TestHelpers (gda.TestHelpers)1 ServiceHolder (gda.data.ServiceHolder)1 NexusDataWriterConfiguration (gda.data.scan.datawriter.NexusDataWriterConfiguration)1 ScannableWriter (gda.data.scan.datawriter.scannablewriter.ScannableWriter)1 SingleScannableWriter (gda.data.scan.datawriter.scannablewriter.SingleScannableWriter)1 TransformationWriter (gda.data.scan.datawriter.scannablewriter.TransformationWriter)1 ATTR_NAME_GDA_FIELD_NAME (gda.data.scan.nexus.device.AbstractScannableNexusDevice.ATTR_NAME_GDA_FIELD_NAME)1 ATTR_NAME_GDA_SCANNABLE_NAME (gda.data.scan.nexus.device.AbstractScannableNexusDevice.ATTR_NAME_GDA_SCANNABLE_NAME)1 ATTR_NAME_GDA_SCAN_ROLE (gda.data.scan.nexus.device.AbstractScannableNexusDevice.ATTR_NAME_GDA_SCAN_ROLE)1 ATTR_NAME_LOCAL_NAME (gda.data.scan.nexus.device.AbstractScannableNexusDevice.ATTR_NAME_LOCAL_NAME)1 ATTR_NAME_UNITS (gda.data.scan.nexus.device.AbstractScannableNexusDevice.ATTR_NAME_UNITS)1 COLLECTION_NAME_SCANNABLES (gda.data.scan.nexus.device.AbstractScannableNexusDevice.COLLECTION_NAME_SCANNABLES)1 FIELD_NAME_VALUE_SET (gda.data.scan.nexus.device.AbstractScannableNexusDevice.FIELD_NAME_VALUE_SET)1