Search in sources :

Example 1 with ScanningException

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

the class ScanningAcquisitionController method publishScanRequestSavedEvent.

/**
 * Creates a ScanRequest for sake of the fully automated implementation.
 * @param fileName
 *
 * @deprecated the fully automated can, and should, use an approach consistent with the ScanningAcquisitionController
 * and compose its operations using the saved ScanningAcquisition.
 * While this class is a client side controller, this methods keeps this class dependent from objects,
 * like ScanRequestFactory, that instead live naturally in the server side.
 * This inconsistency is fixed in K11-1313
 */
@Deprecated
private void publishScanRequestSavedEvent(String fileName) {
    try {
        var srf = new ScanRequestFactory(getAcquisition());
        var scanRequest = srf.createScanRequest(remoteServices.getIRunnableDeviceService());
        publishEvent(new ScanRequestSavedEvent(this, fileName, scanRequest));
    } catch (ScanningException e) {
        logger.error("Canot create scanRequest", e);
    }
}
Also used : ScanRequestFactory(uk.ac.diamond.daq.mapping.api.document.ScanRequestFactory) ScanningException(org.eclipse.scanning.api.scan.ScanningException) ScanRequestSavedEvent(uk.ac.diamond.daq.mapping.api.ScanRequestSavedEvent)

Example 2 with ScanningException

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

the class BeamPositionPlotter method replot.

/**
 * Plot the current beam position by drawing a CircularROI at the current stage coordinates
 */
private void replot() {
    if (initialised) {
        // Get the region from the plot. If it already exists we just set the new parameters, otherwise we create
        // a new region and configure it first.
        IRegion markerRegion = mapPlottingSystem.getRegion(POSITION_MARKER_NAME);
        if (markerRegion == null) {
            try {
                markerRegion = mapPlottingSystem.createRegion(POSITION_MARKER_NAME, RegionType.CIRCLE);
                markerRegion.setRegionColor(beamMarkerColour);
                markerRegion.setFill(true);
                markerRegion.setAlpha(128);
                markerRegion.setMobile(false);
                markerRegion.setUserRegion(false);
                markerRegion.setLineWidth(5);
                mapPlottingSystem.addRegion(markerRegion);
            } catch (Exception e) {
                logger.warn("Error creating beam position region; stopping position plotting", e);
                initialised = false;
                return;
            }
        }
        try {
            // Sets this.beamSize to beamsize, or -1 if no scannable/scannableName
            getBeamSize();
            markerRegion.setVisible(showBeamPosition && beamSize > 0);
            if (beamSize < 0)
                return;
            markerRegion.setROI(new CircularROI(beamSize, lastXCoordinate, lastYCoordinate));
        } catch (ScanningException e) {
            logger.error("Error drawing ROI", e);
        }
    }
}
Also used : CircularROI(org.eclipse.dawnsci.analysis.dataset.roi.CircularROI) ScanningException(org.eclipse.scanning.api.scan.ScanningException) IRegion(org.eclipse.dawnsci.plotting.api.region.IRegion) ScanningException(org.eclipse.scanning.api.scan.ScanningException) DeviceException(gda.device.DeviceException)

Example 3 with ScanningException

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

the class BeamlineConfigurationSection method formatScannablePosition.

private String formatScannablePosition(Entry<String, Object> configuredScannable) {
    String name = configuredScannable.getKey();
    Object value = configuredScannable.getValue();
    DecimalFormat fourDecimalPlaces = new DecimalFormat("##########0.0###");
    String position = value instanceof Number ? fourDecimalPlaces.format(value) : value.toString();
    try {
        // get the units
        IScannable<?> scannable = scannableDeviceService.getScannable(name);
        if (Objects.nonNull(scannable.getUnit()) && !scannable.getUnit().isEmpty())
            position += " " + scannable.getUnit();
    } catch (ScanningException e) {
        LOGGER.info("Error getting scannable {} - will not show units.", name, e);
    }
    return name + " = " + position;
}
Also used : ScanningException(org.eclipse.scanning.api.scan.ScanningException) DecimalFormat(java.text.DecimalFormat)

Example 4 with ScanningException

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

the class ClausesContext method addDetector.

/**
 * Adds an {@link IDetectorModel} corresponding to the supplied {@link IRunnableDevice} to the map of detectors,
 * setting the exposure time if specified
 *
 * @param detector				The {@link IRunnableDevice} corresponding to the detector
 * @param exposure				The exposure time of the {@link Detector} to be set if specified
 * @throws ScanningException	If the {@link IDetectorModel} for the {@link IRunnableDevice} is null.
 */
public void addDetector(final IRunnableDevice<?> detector, final double exposure) throws ScanningException {
    nullCheck(detector, IRunnableDevice.class.getSimpleName());
    IDetectorModel model = (IDetectorModel) detector.getModel();
    if (model == null) {
        throw new ScanningException(String.format("Could not get model for detector %s", detector.getName()));
    }
    if (exposure > 0) {
        model.setExposureTime(exposure);
    }
    detectorMap.put(detector.getName(), model);
    detectorClauseSeen = true;
    clauseProcessed = true;
    LOGGER.debug("Detector added for {}", detector.getName());
}
Also used : IDetectorModel(org.eclipse.scanning.api.device.models.IDetectorModel) ScanningException(org.eclipse.scanning.api.scan.ScanningException) IRunnableDevice(org.eclipse.scanning.api.device.IRunnableDevice)

Example 5 with ScanningException

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

the class AreaDetectorRunnableDevice method configureDetectorData.

private void configureDetectorData() throws ScanningException {
    try {
        // Get the data size so we know how big to write in the file and cache it here so we don't
        // need to go to EPICS all the time
        dataDimensions[0] = adDetector.getAdBase().getArraySizeY_RBV();
        dataDimensions[1] = adDetector.getAdBase().getArraySizeX_RBV();
        // Get the dataType to expect
        // image data type setting before 1st frame being collected.
        dataType = adDetector.getNdArray().getDataType();
    } catch (Exception e) {
        setDeviceState(DeviceState.FAULT);
        throw new ScanningException("Configuring detector failed", e);
    }
}
Also used : ScanningException(org.eclipse.scanning.api.scan.ScanningException) DeviceException(gda.device.DeviceException) NexusException(org.eclipse.dawnsci.nexus.NexusException) ScanningException(org.eclipse.scanning.api.scan.ScanningException)

Aggregations

ScanningException (org.eclipse.scanning.api.scan.ScanningException)41 DeviceException (gda.device.DeviceException)13 NexusException (org.eclipse.dawnsci.nexus.NexusException)7 IMalcolmModel (org.eclipse.scanning.api.device.models.IMalcolmModel)4 EventException (org.eclipse.scanning.api.event.EventException)4 Scannable (gda.device.Scannable)3 CAException (gov.aps.jca.CAException)3 TimeoutException (gov.aps.jca.TimeoutException)3 DatasetException (org.eclipse.january.DatasetException)3 Dataset (org.eclipse.january.dataset.Dataset)3 ILazyWriteableDataset (org.eclipse.january.dataset.ILazyWriteableDataset)3 SliceND (org.eclipse.january.dataset.SliceND)3 IScanSlice (org.eclipse.scanning.api.scan.rank.IScanSlice)3 Composite (org.eclipse.swt.widgets.Composite)3 File (java.io.File)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 AbstractScannable (org.eclipse.scanning.api.AbstractScannable)2