Search in sources :

Example 11 with AxialStepModel

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

the class ScannableNexusWrapperScanTest method createGridScan.

private IRunnableDevice<ScanModel> createGridScan(final IRunnableDevice<? extends IDetectorModel> detector, String outerScannableName, int... size) throws Exception {
    // Create scan points for a grid and make a generator
    final TwoAxisGridPointsModel gridModel = new TwoAxisGridPointsModel();
    gridModel.setxAxisName("salong");
    gridModel.setxAxisPoints(size[size.length - 1]);
    gridModel.setyAxisName("saperp");
    gridModel.setyAxisPoints(size[size.length - 2]);
    gridModel.setBoundingBox(new BoundingBox(0, 0, 3, 3));
    final CompoundModel compoundModel = new CompoundModel();
    // We add the outer scans, if any
    if (outerScannableName != null) {
        for (int dim = 0; dim < size.length - 2; dim++) {
            if (size[dim] > 1) {
                // TODO outer scannable name(s)? could use cryostat temperature as an outer scan
                compoundModel.addModel(new AxialStepModel(outerScannableName, 10000, 20000, 9999.99d / (size[dim] - 1)));
            } else {
                // Will generate one value at 10
                compoundModel.addModel(new AxialStepModel(outerScannableName + (dim + 1), 10, 20, 30));
            }
        }
    }
    compoundModel.addModel(gridModel);
    final IPointGenerator<CompoundModel> pointGen = pointGenService.createCompoundGenerator(compoundModel);
    // Create the model for a scan
    final ScanModel scanModel = new ScanModel();
    scanModel.setPointGenerator(pointGen);
    scanModel.setScanPathModel(compoundModel);
    scanModel.setDetector(detector);
    final IScannable<?> attributeScannable = scannableDeviceService.getScannable("attributes");
    final IScannable<?> beamSizeScannable = scannableDeviceService.getScannable("beam");
    scanModel.setMonitorsPerScan(attributeScannable, beamSizeScannable);
    // Create a file to scan into
    final File output = File.createTempFile("test_legacy_nexus", ".nxs");
    output.deleteOnExit();
    scanModel.setFilePath(output.getAbsolutePath());
    System.out.println("File writing to " + scanModel.getFilePath());
    // Create a scan and run it without publishing events
    final IRunnableDevice<ScanModel> scanner = scanService.createScanDevice(scanModel);
    final IPointGenerator<?> fgen = pointGen;
    ((IRunnableEventDevice<ScanModel>) scanner).addRunListener(new IRunListener() {

        @Override
        public void runWillPerform(RunEvent evt) throws ScanningException {
            System.out.println("Running acquisition scan of size " + fgen.size());
        }
    });
    return scanner;
}
Also used : ScanModel(org.eclipse.scanning.api.scan.models.ScanModel) IRunListener(org.eclipse.scanning.api.scan.event.IRunListener) TwoAxisGridPointsModel(org.eclipse.scanning.api.points.models.TwoAxisGridPointsModel) IRunnableEventDevice(org.eclipse.scanning.api.device.IRunnableEventDevice) CompoundModel(org.eclipse.scanning.api.points.models.CompoundModel) ScanningException(org.eclipse.scanning.api.scan.ScanningException) BoundingBox(org.eclipse.scanning.api.points.models.BoundingBox) AxialStepModel(org.eclipse.scanning.api.points.models.AxialStepModel) NexusFile(org.eclipse.dawnsci.nexus.NexusFile) File(java.io.File) TreeFile(org.eclipse.dawnsci.analysis.api.tree.TreeFile) RunEvent(org.eclipse.scanning.api.scan.event.RunEvent)

Example 12 with AxialStepModel

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

the class ScanPathEditor method convertTextToModel.

/**
 * Convert text representing a scan path to a {@link AxialMultiStepModel}
 *
 * @param text
 *            The text to convert (can be empty)
 * @param scannableName
 *            The name of the scannable to which the scan path refers
 * @return The corresponding multi-step model
 */
private AxialMultiStepModel convertTextToModel(String text, String scannableName) {
    AxialMultiStepModel multiAxialStepModel = new AxialMultiStepModel();
    if (!text.isEmpty()) {
        final Object oldModel = (new StringToScanPathConverter(scannableName)).convert(text);
        if (oldModel instanceof AxialMultiStepModel) {
            multiAxialStepModel = (AxialMultiStepModel) oldModel;
        } else if (oldModel instanceof AxialStepModel) {
            multiAxialStepModel.getModels().add((AxialStepModel) oldModel);
        } else if (oldModel instanceof AxialArrayModel) {
            final double[] positions = ((AxialArrayModel) oldModel).getPositions();
            for (int i = 0; i < positions.length - 1; i++) {
                final AxialStepModel stepModel = new AxialStepModel(scannableName, positions[i], positions[i + 1], positions[i + 1] - positions[i]);
                multiAxialStepModel.getModels().add(stepModel);
            }
        }
    }
    multiAxialStepModel.setName(scannableName);
    return multiAxialStepModel;
}
Also used : AxialStepModel(org.eclipse.scanning.api.points.models.AxialStepModel) AxialMultiStepModel(org.eclipse.scanning.api.points.models.AxialMultiStepModel) AxialArrayModel(org.eclipse.scanning.api.points.models.AxialArrayModel)

Example 13 with AxialStepModel

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

the class FocusScanConverter method convertToScanRequest.

public ScanRequest convertToScanRequest(FocusScanBean focusScanBean) {
    logger.debug("Converting focusScanBean to scan request");
    final ScanRequest scanRequest = new ScanRequest();
    final IMapPathModel lineModel = createLineModel(focusScanBean);
    final ILineMappingRegion lineRegion = focusScanBean.getLineRegion();
    final ScanRegion scanRegion = new ScanRegion(lineRegion.toROI(), lineModel.getxAxisName(), lineModel.getyAxisName());
    final AxialStepModel focusModel = createFocusPathModel(focusScanBean);
    final CompoundModel compoundModel = new CompoundModel(Arrays.asList(focusModel, lineModel));
    compoundModel.setRegions(Arrays.asList(scanRegion));
    scanRequest.setCompoundModel(compoundModel);
    // add detectors
    final IDetectorModel detectorModel = focusScanBean.getDetector();
    final Map<String, IDetectorModel> detectorsMap = new HashMap<>();
    detectorsMap.put(detectorModel.getName(), detectorModel);
    scanRequest.setDetectors(detectorsMap);
    return scanRequest;
}
Also used : ScanRequest(org.eclipse.scanning.api.event.scan.ScanRequest) ScanRegion(org.eclipse.scanning.api.points.models.ScanRegion) IDetectorModel(org.eclipse.scanning.api.device.models.IDetectorModel) IMapPathModel(org.eclipse.scanning.api.points.models.IMapPathModel) CompoundModel(org.eclipse.scanning.api.points.models.CompoundModel) HashMap(java.util.HashMap) ILineMappingRegion(uk.ac.diamond.daq.mapping.api.ILineMappingRegion) AxialStepModel(org.eclipse.scanning.api.points.models.AxialStepModel)

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