Search in sources :

Example 6 with ScanRequest

use of org.eclipse.scanning.api.event.scan.ScanRequest in project gda-core by openGDA.

the class ScanRequestConverterTest method testScanPathIsIncluded.

@Test
public void testScanPathIsIncluded() throws Exception {
    // Act - convert mapping bean to scan request (with the default set-up)
    final ScanRequest scanRequest = scanRequestConverter.convertToScanRequest(mappingBean);
    // Assert
    assertEquals(scanRequest.getCompoundModel().getModels().get(0), scanPath);
    // Act again - convert scan request back to mapping bean
    scanRequestConverter.mergeIntoMappingBean(scanRequest, newMappingBean);
    // Assert again
    assertEquals(newMappingBean.getScanDefinition().getMappingScanRegion().getScanPath(), scanPath);
}
Also used : ScanRequest(org.eclipse.scanning.api.event.scan.ScanRequest) Test(org.junit.Test)

Example 7 with ScanRequest

use of org.eclipse.scanning.api.event.scan.ScanRequest in project gda-core by openGDA.

the class ScanRequestConverterTest method testBeamSizeScannableIncluded.

@Test
public void testBeamSizeScannableIncluded() throws Exception {
    ScanRequest scanRequest = scanRequestConverter.convertToScanRequest(mappingBean);
    assertTrue(scanRequest.getMonitorNamesPerScan().contains(BEAM_SIZE_NAME));
    mappingStageInfo.setBeamSize(null);
    scanRequest = scanRequestConverter.convertToScanRequest(mappingBean);
    assertFalse(scanRequest.getMonitorNamesPerScan().contains(BEAM_SIZE_NAME));
}
Also used : ScanRequest(org.eclipse.scanning.api.event.scan.ScanRequest) Test(org.junit.Test)

Example 8 with ScanRequest

use of org.eclipse.scanning.api.event.scan.ScanRequest in project gda-core by openGDA.

the class ScanRequestConverterTest method testBeamlineConfigurationIncludedCorrectly.

@Test
public void testBeamlineConfigurationIncludedCorrectly() throws Exception {
    // Arrange
    final Map<String, Object> beamlineConfiguration = new HashMap<>();
    beamlineConfiguration.put("energy", 12345.67);
    beamlineConfiguration.put("attenuator_pos", "Gap");
    beamlineConfiguration.put("kb_mirror_pos", 7.0);
    mappingBean.setBeamlineConfiguration(beamlineConfiguration);
    // Act - convert mapping bean to scan request
    final ScanRequest scanRequest = scanRequestConverter.convertToScanRequest(mappingBean);
    // Assert
    final IPosition startPos = scanRequest.getStartPosition();
    assertThat(startPos.getNames().size(), is(equalTo(beamlineConfiguration.size())));
    for (String scannableName : beamlineConfiguration.keySet()) {
        assertThat(startPos.get(scannableName), is(equalTo(beamlineConfiguration.get(scannableName))));
    }
    // Act again - convert scan request back to a mapping bean
    scanRequestConverter.mergeIntoMappingBean(scanRequest, newMappingBean);
    // Assert - the new beamline configuration should be equal to the original one
    final Map<String, Object> newBeamlineConfiguration = newMappingBean.getBeamlineConfiguration();
    assertThat(newBeamlineConfiguration, is(notNullValue()));
    assertThat(newBeamlineConfiguration, is(equalTo(beamlineConfiguration)));
}
Also used : ScanRequest(org.eclipse.scanning.api.event.scan.ScanRequest) IPosition(org.eclipse.scanning.api.points.IPosition) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 9 with ScanRequest

use of org.eclipse.scanning.api.event.scan.ScanRequest in project gda-core by openGDA.

the class ScanRequestConverterTest method testOuterScannableAddedToMappingBeanIfNotThereAlready.

@Test
public void testOuterScannableAddedToMappingBeanIfNotThereAlready() {
    // Arrange
    final IScanPointGeneratorModel outerModel = new AxialStepModel(Z_AXIS_NAME, -3, 2, 0.5);
    final List<IScanModelWrapper<IScanPointGeneratorModel>> outerScannables = Arrays.asList(new ScanPathModelWrapper(Z_AXIS_NAME, outerModel, true));
    mappingBean.getScanDefinition().setOuterScannables(outerScannables);
    // Act - convert mapping bean to scan request
    final ScanRequest scanRequest = scanRequestConverter.convertToScanRequest(mappingBean);
    // Creates a new wrapper for the outer scannable in newMappingBean
    scanRequestConverter.mergeIntoMappingBean(scanRequest, newMappingBean);
    assertThat(newMappingBean.getScanDefinition().getOuterScannables(), contains(outerScannables.toArray()));
}
Also used : ScanPathModelWrapper(uk.ac.diamond.daq.mapping.impl.ScanPathModelWrapper) ScanRequest(org.eclipse.scanning.api.event.scan.ScanRequest) IScanModelWrapper(uk.ac.diamond.daq.mapping.api.IScanModelWrapper) AxialStepModel(org.eclipse.scanning.api.points.models.AxialStepModel) IScanPointGeneratorModel(org.eclipse.scanning.api.points.models.IScanPointGeneratorModel) Test(org.junit.Test)

Example 10 with ScanRequest

use of org.eclipse.scanning.api.event.scan.ScanRequest in project gda-core by openGDA.

the class ScanRequestConverterTest method testNullTemplateListInScanRequest.

@Test
public void testNullTemplateListInScanRequest() {
    final String first = "first.yaml";
    final String second = "second.yaml";
    final TemplateFileWrapper firstWrapper = new TemplateFileWrapper(first, true);
    final TemplateFileWrapper secondWrapper = new TemplateFileWrapper(second, true);
    mappingBean.setTemplateFiles(Arrays.asList(firstWrapper, secondWrapper));
    final ScanRequest scanRequest = scanRequestConverter.convertToScanRequest(mappingBean);
    scanRequest.setTemplateFilePaths(null);
    assertNull(scanRequest.getTemplateFilePaths());
    scanRequestConverter.mergeIntoMappingBean(scanRequest, mappingBean);
    // Merging a null list of file paths should deactivate (but not delete) all files in the mapping bean
    final List<TemplateFileWrapper> templateFiles = mappingBean.getTemplateFiles();
    assertEquals(2, templateFiles.size());
    assertContainsWrapper(templateFiles, first, false);
    assertContainsWrapper(templateFiles, second, false);
}
Also used : ScanRequest(org.eclipse.scanning.api.event.scan.ScanRequest) TemplateFileWrapper(uk.ac.diamond.daq.mapping.api.TemplateFileWrapper) Test(org.junit.Test)

Aggregations

ScanRequest (org.eclipse.scanning.api.event.scan.ScanRequest)42 Test (org.junit.Test)25 IDetectorModel (org.eclipse.scanning.api.device.models.IDetectorModel)8 ScanBean (org.eclipse.scanning.api.event.scan.ScanBean)8 CompoundModel (org.eclipse.scanning.api.points.models.CompoundModel)8 IScanPointGeneratorModel (org.eclipse.scanning.api.points.models.IScanPointGeneratorModel)8 ArrayList (java.util.ArrayList)7 ProcessingRequest (org.eclipse.scanning.api.event.scan.ProcessingRequest)7 IScanModelWrapper (uk.ac.diamond.daq.mapping.api.IScanModelWrapper)7 IMarshallerService (org.eclipse.dawnsci.analysis.api.persistence.IMarshallerService)5 ScanRegion (org.eclipse.scanning.api.points.models.ScanRegion)5 IScriptService (org.eclipse.scanning.api.script.IScriptService)5 IMappingExperimentBean (uk.ac.diamond.daq.mapping.api.IMappingExperimentBean)5 HashMap (java.util.HashMap)4 AxialStepModel (org.eclipse.scanning.api.points.models.AxialStepModel)4 IMappingScanRegion (uk.ac.diamond.daq.mapping.api.IMappingScanRegion)4 TemplateFileWrapper (uk.ac.diamond.daq.mapping.api.TemplateFileWrapper)4 DetectorModelWrapper (uk.ac.diamond.daq.mapping.impl.DetectorModelWrapper)4 IMalcolmModel (org.eclipse.scanning.api.device.models.IMalcolmModel)3 IMapPathModel (org.eclipse.scanning.api.points.models.IMapPathModel)3