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;
}
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;
}
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);
}
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;
}
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;
}
}
Aggregations