Search in sources :

Example 36 with ScanningException

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

the class ProcessingSelectionWizardPage method getDetectorDatasetNameForMalcolm.

/**
 * Get the name of the dataset to use for the malcolm device with the given name. This is the
 * first dataset of type 'primary' in the {@link MalcolmTable} of the {@link MalcolmConstants#ATTRIBUTE_NAME_DATASETS}
 * attribute.
 * @param malcolmModel
 * @return
 */
private Optional<String> getDetectorDatasetNameForMalcolm(IMalcolmModel malcolmModel) {
    if (malcolmDetectorDatasetNames != null && malcolmDetectorDatasetNames.containsKey(malcolmModel.getName())) {
        return Optional.of(malcolmDetectorDatasetNames.get(malcolmModel.getName()));
    }
    Optional<String> datasetName = Optional.empty();
    try {
        final IRunnableDevice<IMalcolmModel> malcolmDevice = getRunnableDeviceService().getRunnableDevice(malcolmModel.getName());
        if (malcolmDevice.getDeviceState() != DeviceState.READY) {
            throw new ScanningException("The malcolm device is not ready. A scan may be running.");
        }
        try {
            // configure the malcolm device, puts it in 'Armed' state
            malcolmDevice.configure(malcolmModel);
            if (malcolmDevice instanceof IMalcolmDevice) {
                final MalcolmTable datasetsTable = ((IMalcolmDevice) malcolmDevice).getDatasets();
                if (datasetsTable != null) {
                    datasetName = getPrimaryDatasetNameForMalcolm(datasetsTable);
                }
            }
            if (datasetName.isPresent()) {
                // if we found the dataset name, cache it
                logger.debug("Got ''{}'' as dataset for processing for malcolm device ''{}''", datasetName.get(), malcolmModel.getName());
                if (malcolmDetectorDatasetNames == null) {
                    malcolmDetectorDatasetNames = new HashMap<>(4);
                }
                malcolmDetectorDatasetNames.put(malcolmModel.getName(), datasetName.get());
            } else {
                logger.error("Could not get primary dataset for malcolm device ''{}''. The dataset for the malcolm device may not be set correctly.", malcolmModel.getName());
            }
        } finally {
            // Reset the malcolm device back to the 'Ready' state
            malcolmDevice.reset();
        }
    } catch (Exception e) {
        logger.error("Could not get primary dataset for malcolm device: " + malcolmModel.getName(), e);
    }
    return datasetName;
}
Also used : MalcolmTable(org.eclipse.scanning.api.malcolm.MalcolmTable) ScanningException(org.eclipse.scanning.api.scan.ScanningException) IMalcolmModel(org.eclipse.scanning.api.device.models.IMalcolmModel) IMalcolmDevice(org.eclipse.scanning.api.malcolm.IMalcolmDevice) URISyntaxException(java.net.URISyntaxException) ScanningException(org.eclipse.scanning.api.scan.ScanningException) EventException(org.eclipse.scanning.api.event.EventException)

Example 37 with ScanningException

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

the class BeamPositionPlotter method getBeamSize.

private double getBeamSize() throws ScanningException {
    if (beamSize < 0 && mappingStageInfo.getBeamSize() != null) {
        try {
            final URI jmsUri = new URI(LocalProperties.getActiveMQBrokerURI());
            final IScannableDeviceService scannableDeviceService = eventService.createRemoteService(jmsUri, IScannableDeviceService.class);
            IScannable<Double> beamScannable = scannableDeviceService.getScannable(mappingStageInfo.getBeamSize());
            if (beamScannable != null)
                beamSize = beamScannable.getPosition();
        } catch (ScanningException e) {
            throw e;
        } catch (Exception e) {
            throw new ScanningException(e);
        }
    }
    return beamSize;
}
Also used : IScannableDeviceService(org.eclipse.scanning.api.device.IScannableDeviceService) ScanningException(org.eclipse.scanning.api.scan.ScanningException) URI(java.net.URI) ScanningException(org.eclipse.scanning.api.scan.ScanningException) DeviceException(gda.device.DeviceException)

Example 38 with ScanningException

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

the class FocusScanResultPage method createControl.

@Override
public void createControl(Composite parent) {
    updateMapExecutor = Executors.newSingleThreadExecutor();
    try {
        focusScannable = scannableService.getScannable(focusScanBean.getFocusScannableName());
        focusScannableOriginalPosition = focusScannable.getPosition();
    } catch (ScanningException e) {
        final String message = "Could not access focus scannable";
        logger.error(message, e);
        displayError(message, "See error log for details", logger);
        return;
    }
    final SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL);
    createFocusScanPlotControl(sashForm);
    final Composite composite = new Composite(sashForm, SWT.NONE);
    GridLayoutFactory.swtDefaults().applyTo(composite);
    createRunScanControls(composite);
    createSelectFocusPositionControls(composite);
    sashForm.setWeights(new int[] { 3, 2 });
    setControl(sashForm);
    setPageComplete(false);
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) Composite(org.eclipse.swt.widgets.Composite) NumberAndUnitsComposite(uk.ac.gda.client.NumberAndUnitsComposite) FocusScanUtils.createNumberAndUnitsLengthComposite(uk.ac.diamond.daq.mapping.ui.experiment.focus.FocusScanUtils.createNumberAndUnitsLengthComposite) ScanningException(org.eclipse.scanning.api.scan.ScanningException)

Example 39 with ScanningException

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

the class TimeSeriesScanView method getRunnableDeviceService.

private IRunnableDeviceService getRunnableDeviceService() throws ScanningException {
    if (runnableDeviceService == null) {
        try {
            final IEventService eventService = eclipseContext.get(IEventService.class);
            final URI jmsURI = new URI(LocalProperties.getActiveMQBrokerURI());
            return eventService.createRemoteService(jmsURI, IRunnableDeviceService.class);
        } catch (EventException | URISyntaxException e) {
            throw new ScanningException(e);
        }
    }
    return runnableDeviceService;
}
Also used : EventException(org.eclipse.scanning.api.event.EventException) ScanningException(org.eclipse.scanning.api.scan.ScanningException) IEventService(org.eclipse.scanning.api.event.IEventService) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 40 with ScanningException

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

the class TimeSeriesScanView method createMalcolmModelEditor.

private MalcolmModelEditor createMalcolmModelEditor(Composite parent, String malcolmDeviceName) {
    try {
        final IRunnableDevice<?> malcolmDevice = getRunnableDeviceService().getRunnableDevice(malcolmDeviceName);
        final IMalcolmModel malcolmModel = (IMalcolmModel) malcolmDevice.getModel();
        final MalcolmModelEditor editor = new MalcolmModelEditor(getRunnableDeviceService(), malcolmModel);
        editor.createEditorPart(parent);
        return editor;
    } catch (ScanningException e) {
        logger.error("Could not get malcolm device: ", malcolmDeviceName, e);
        return null;
    }
}
Also used : ScanningException(org.eclipse.scanning.api.scan.ScanningException) IMalcolmModel(org.eclipse.scanning.api.device.models.IMalcolmModel) MalcolmModelEditor(org.eclipse.scanning.device.ui.device.MalcolmModelEditor)

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