Search in sources :

Example 6 with AxialStepModel

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

the class MScanSubmitterTest method trimIfStepAwkwardFitForRegionOccursOnGenerator.

@Test
public // Behaviour combined with {@link StepTest#testImperfectSequence} shows expected behaviour
void trimIfStepAwkwardFitForRegionOccursOnGenerator() throws Exception {
    final AxialStepModel expectedModel = new AxialStepModel(scannable.getName(), -1, 1, 0.3);
    expectedModel.setContinuous(false);
    Object[] arr = { scannable, RegionShape.AXIAL, -1, 1, Scanpath.AXIS_STEP, 0.3, detectorRunnableDevice };
    when(resolver.resolveScanClauses()).thenReturn(Arrays.asList(Arrays.asList(new ScannableElementProcessor(scannable), new RegionShapeElementProcessor(RegionShape.AXIAL), new NumberElementProcessor(-1), new NumberElementProcessor(1), new ScanpathElementProcessor(Scanpath.AXIS_STEP), new NumberElementProcessor(0.3)), Arrays.asList(new IRunnableDeviceDetectorElementProcessor(detectorRunnableDevice))));
    builder.buildAndSubmitBlockingScanRequest(arr);
    verify(submitter).blockingSubmit(beanCaptor.capture());
    verify(eventSubscriber).addListener(any(IScanListener.class));
    CompoundModel model = beanCaptor.getValue().getScanRequest().getCompoundModel();
    assertThat(model.getModels().get(0), is(equalTo(expectedModel)));
}
Also used : IScanListener(org.eclipse.scanning.api.event.scan.IScanListener) NumberElementProcessor(gda.mscan.processor.NumberElementProcessor) ScanpathElementProcessor(gda.mscan.processor.ScanpathElementProcessor) CompoundModel(org.eclipse.scanning.api.points.models.CompoundModel) ScannableElementProcessor(gda.mscan.processor.ScannableElementProcessor) IRunnableDeviceDetectorElementProcessor(gda.mscan.processor.IRunnableDeviceDetectorElementProcessor) AxialStepModel(org.eclipse.scanning.api.points.models.AxialStepModel) RegionShapeElementProcessor(gda.mscan.processor.RegionShapeElementProcessor) Test(org.junit.Test)

Example 7 with AxialStepModel

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

the class ScanpathTest method createModelCreatesCorrectModelForOneDStep.

@Test
public void createModelCreatesCorrectModelForOneDStep() throws Exception {
    pathParams = Arrays.asList(2, 3, 0.5);
    IScanPathModel model = AXIS_STEP.createModel(axialScannables, pathParams, blineParams, mutators);
    assertThat(model, is(instanceOf(AxialStepModel.class)));
    AxialStepModel sModel = (AxialStepModel) model;
    assertThat(sModel.getScannableNames(), contains("name1"));
    assertThat(sModel.getStart(), is(2.0));
    assertThat(sModel.getStop(), is(3.0));
    assertThat(sModel.getStep(), is(0.5));
    assertThat(sModel.getUnits(), is(equalTo(List.of("Deg"))));
}
Also used : AxialStepModel(org.eclipse.scanning.api.points.models.AxialStepModel) IScanPathModel(org.eclipse.scanning.api.points.models.IScanPathModel) Test(org.junit.Test)

Example 8 with AxialStepModel

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

the class XanesScanningUtils method createModelFromEdgeSelection.

/**
 * Create a step model for each range of energies around the edge
 *
 * @param edgeEnergy
 *            energy of the edge to be scanned
 * @param energyScannableName
 *            name of the scannable to control the energy
 * @return corresponding step model
 */
public static IScanPointGeneratorModel createModelFromEdgeSelection(double edgeEnergy, String energyScannableName) {
    final List<AxialStepModel> stepModels = new ArrayList<>(xanesStepRanges.length);
    // Create a step model for each range of energies around the edge
    for (double[] range : xanesStepRanges) {
        stepModels.add(new AxialStepModel(energyScannableName, roundDouble(edgeEnergy + range[0]), roundDouble(edgeEnergy + range[1]), range[2]));
    }
    // Create a multi-step model containing these step models
    final AxialMultiStepModel model = new AxialMultiStepModel(energyScannableName, stepModels);
    model.setContinuous(false);
    return model;
}
Also used : ArrayList(java.util.ArrayList) AxialStepModel(org.eclipse.scanning.api.points.models.AxialStepModel) AxialMultiStepModel(org.eclipse.scanning.api.points.models.AxialMultiStepModel)

Example 9 with AxialStepModel

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

the class MappingUISerializationTest method createScanDefinition.

private IScanDefinition createScanDefinition() {
    IMappingScanRegion scanRegion = createScanRegion();
    AxialStepModel energy = new AxialStepModel("energy", 10000.0, 10200.0, 10.0);
    ScanPathModelWrapper energyWrapper = new ScanPathModelWrapper("energy", energy, true);
    AxialStepModel z = new AxialStepModel("z", 2.5, 17.5, 0.1);
    ScanPathModelWrapper zWrapper = new ScanPathModelWrapper("z", z, true);
    IScanDefinition scanDefinition = new MappingScanDefinition();
    scanDefinition.setMappingScanRegion(scanRegion);
    scanDefinition.setOuterScannables(Arrays.asList(energyWrapper, zWrapper));
    return scanDefinition;
}
Also used : IMappingScanRegion(uk.ac.diamond.daq.mapping.api.IMappingScanRegion) ScanPathModelWrapper(uk.ac.diamond.daq.mapping.impl.ScanPathModelWrapper) MappingScanDefinition(uk.ac.diamond.daq.mapping.impl.MappingScanDefinition) AxialStepModel(org.eclipse.scanning.api.points.models.AxialStepModel) IScanDefinition(uk.ac.diamond.daq.mapping.api.IScanDefinition)

Example 10 with AxialStepModel

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

the class MappingUISerializationTest method testSerializeScanPathModelWrapper.

@Test
public void testSerializeScanPathModelWrapper() throws Exception {
    AxialStepModel model = new AxialStepModel("energy", 10000.0, 10200.0, 10.0);
    ScanPathModelWrapper wrapper = new ScanPathModelWrapper("energy", model, true);
    String json = service.marshal(wrapper);
    ScanPathModelWrapper newWrapper = service.unmarshal(json, ScanPathModelWrapper.class);
    assertEquals(wrapper, newWrapper);
}
Also used : ScanPathModelWrapper(uk.ac.diamond.daq.mapping.impl.ScanPathModelWrapper) AxialStepModel(org.eclipse.scanning.api.points.models.AxialStepModel) Test(org.junit.Test)

Aggregations

AxialStepModel (org.eclipse.scanning.api.points.models.AxialStepModel)13 Test (org.junit.Test)7 CompoundModel (org.eclipse.scanning.api.points.models.CompoundModel)5 ScanRequest (org.eclipse.scanning.api.event.scan.ScanRequest)4 ScanPathModelWrapper (uk.ac.diamond.daq.mapping.impl.ScanPathModelWrapper)4 IScanPointGeneratorModel (org.eclipse.scanning.api.points.models.IScanPointGeneratorModel)3 IRunnableDeviceDetectorElementProcessor (gda.mscan.processor.IRunnableDeviceDetectorElementProcessor)2 NumberElementProcessor (gda.mscan.processor.NumberElementProcessor)2 RegionShapeElementProcessor (gda.mscan.processor.RegionShapeElementProcessor)2 ScannableElementProcessor (gda.mscan.processor.ScannableElementProcessor)2 ScanpathElementProcessor (gda.mscan.processor.ScanpathElementProcessor)2 LinearROI (org.eclipse.dawnsci.analysis.dataset.roi.LinearROI)2 IDetectorModel (org.eclipse.scanning.api.device.models.IDetectorModel)2 IScanListener (org.eclipse.scanning.api.event.scan.IScanListener)2 AxialArrayModel (org.eclipse.scanning.api.points.models.AxialArrayModel)2 AxialMultiStepModel (org.eclipse.scanning.api.points.models.AxialMultiStepModel)2 ScanRegion (org.eclipse.scanning.api.points.models.ScanRegion)2 TwoAxisGridPointsModel (org.eclipse.scanning.api.points.models.TwoAxisGridPointsModel)2 TwoAxisLinePointsModel (org.eclipse.scanning.api.points.models.TwoAxisLinePointsModel)2 IScanModelWrapper (uk.ac.diamond.daq.mapping.api.IScanModelWrapper)2