use of org.eclipse.scanning.api.scan.ScanningException in project gda-core by openGDA.
the class AreaDetectorRunnableDevice method run.
@Override
public void run(IPosition position) throws ScanningException, InterruptedException {
setDeviceState(DeviceState.RUNNING);
try {
adDetector.collectData();
adDetector.waitWhileBusy();
} catch (Exception e) {
setDeviceState(DeviceState.FAULT);
throw new ScanningException("Acquiring from detector failed", e);
}
setDeviceState(DeviceState.ARMED);
}
use of org.eclipse.scanning.api.scan.ScanningException in project gda-core by openGDA.
the class AreaDetectorRunnableDevice method write.
@Override
public boolean write(IPosition pos) throws ScanningException {
if (firstPointInScan) {
firstFrame();
firstPointInScan = false;
}
try {
// Get the data from the detector array plugin
final Object image = adDetector.getNdArray().getImageData(imageDimensions[0] * imageDimensions[1]);
// Create a dataset from the data
final Dataset dataset = DatasetFactory.createFromObject(image);
// Write the image data
IScanSlice scanSlice = IScanRankService.getScanRankService().createScanSlice(pos, imageDimensions);
SliceND sliceND = new SliceND(data.getShape(), data.getMaxShape(), scanSlice.getStart(), scanSlice.getStop(), scanSlice.getStep());
data.setSlice(null, dataset, sliceND);
// Write the total data
scanSlice = IScanRankService.getScanRankService().createScanSlice(pos);
sliceND = new SliceND(total.getShape(), total.getMaxShape(), scanSlice.getStart(), scanSlice.getStop(), scanSlice.getStep());
total.setSlice(null, DatasetFactory.createFromObject(dataset.sum()), sliceND);
} catch (Exception e) {
setDeviceState(DeviceState.FAULT);
throw new ScanningException("Getting the data from the detector failed", e);
}
setDeviceState(DeviceState.ARMED);
// saying I failed?
return true;
}
use of org.eclipse.scanning.api.scan.ScanningException in project gda-core by openGDA.
the class AreaDetectorRunnableDevice method scanStart.
/**
* add call to {@link ADDetector#atScanStart()} so decorators in collection strategy work to save detector state.
*/
@Override
@ScanStart
public void scanStart(ScanInformation info) throws ScanningException {
super.scanStart(info);
try {
adDetector.atScanStart();
firstPointInScan = true;
} catch (DeviceException e) {
throw new ScanningException("Error calling atScanStart", e);
}
}
use of org.eclipse.scanning.api.scan.ScanningException in project gda-core by openGDA.
the class AreaDetectorRunnableDeviceWaitForArray method write.
@Override
public boolean write(IPosition pos) throws ScanningException {
try {
final long startTime = System.currentTimeMillis();
int currentCounter = getArrayCounter();
logger.trace("write(): currentCounter = {}, timeout = {}", currentCounter, timeout);
while (currentCounter <= arrayCounter) {
final long elapsedTime = (System.currentTimeMillis() - startTime) / 1000;
if (elapsedTime >= timeout) {
throw new ScanningException(String.format("Wait for array counter timed out after %d s", elapsedTime));
}
logger.debug("Waiting {} ms for array data", writeDelay);
Thread.sleep(writeDelay);
currentCounter = getArrayCounter();
logger.trace("write(): currentCounter = {}", currentCounter);
}
} catch (Exception e) {
final String message = "Exception waiting for array counter to increment";
logger.error(message, e);
throw new ScanningException(message, e);
}
return super.write(pos);
}
use of org.eclipse.scanning.api.scan.ScanningException in project gda-core by openGDA.
the class MScanSubmitterTest method rejectsTypeWithNoMappedProcessor.
@Test
public void rejectsTypeWithNoMappedProcessor() throws Exception {
Object[] arr = { scannable, new ScanningException() };
exception.expect(IllegalArgumentException.class);
exception.expectMessage("Your command contains an invalid argument at position 1");
builder.buildAndSubmitBlockingScanRequest(arr);
verify(eventSubscriber, never()).addListener(any(IScanListener.class));
verify(submitter, never()).blockingSubmit(any(ScanBean.class));
}
Aggregations