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