use of org.eclipse.scanning.api.event.scan.ScanBean in project gda-core by openGDA.
the class ScanningAcquisitionService method run.
/**
* Submits the acquisition request to an {@link IScanBeanSubmitter}
*
* @param message
* the scanning acquisition message
* @throws ScanningAcquisitionServiceException
* if not {@link IRunnableDeviceService} is available or if {@link ISubmitter#submit(Object)} raises an
* {@link EventException}
*/
public void run(AcquisitionBase<? extends AcquisitionConfigurationBase<? extends AcquisitionParametersBase>> acquisition) throws ScanningAcquisitionServiceException {
try {
// default path name
var pathName = "ScanningAcquisition";
var scanBean = new ScanBean();
scanBean.setName(String.format("%s - %s Scan", acquisition.getName(), pathName));
scanBean.setFilePath(acquisition.getAcquisitionLocation().toExternalForm());
scanBean.setBeamline(System.getProperty("BEAMLINE", "dummy"));
var tsr = new ScanRequestFactory(acquisition);
scanBean.setScanRequest(tsr.createScanRequest(getRunnableDeviceService()));
getScanBeanSubmitter().submit(scanBean);
} catch (Exception e) {
throw new ScanningAcquisitionServiceException("Cannot submit acquisition", e);
}
}
use of org.eclipse.scanning.api.event.scan.ScanBean in project gda-core by openGDA.
the class MappingTriggerProcessor method process.
@Override
public IdBean process(Triggerable triggerable) {
TriggerableMap map = (TriggerableMap) triggerable;
ScanBean scanBean = map.trigger();
try {
URL url = SpringApplicationContextFacade.getBean(ExperimentController.class).prepareAcquisition(map.getName());
scanBean.getScanRequest().setFilePath(url.getFile());
} catch (ExperimentControllerException e) {
logger.error("Error getting URL for triggered scan - data will not reflect experiment structure", e);
}
try {
if (map.isImportant()) {
scanSubmitter.submitImportantScan(scanBean);
} else {
scanSubmitter.submitScan(scanBean);
}
} catch (ScanningException | EventException e) {
logger.error("Could not submit scan", e);
}
return scanBean;
}
use of org.eclipse.scanning.api.event.scan.ScanBean in project gda-core by openGDA.
the class FocusScanResultPage method startFocusScan.
private void startFocusScan() {
// set the page as incomplete, disables Finish button while scan is running
setPageComplete(false);
plotTraceRunnable.set(null);
initialMapFile = null;
// add a listener for map file events
if (mapFileEventListener == null) {
mapFileEventListener = this::handleMapEvent;
mapFileController.addListener(mapFileEventListener);
}
// create the ScanBean from the focus scan bean
final ScanBean scanBean = new ScanBean();
scanBean.setName(String.format("%s - Focus Scan", getSampleName()));
scanBean.setBeamline(System.getProperty("BEAMLINE"));
ScanRequest scanRequest = converter.convertToScanRequest(focusScanBean);
scanBean.setScanRequest(scanRequest);
// submit the ScanBean
try {
statusBean = scanBean;
submitter.submitScan(scanBean);
messageLabel.setText("Waiting for scan to start");
startScanButton.setEnabled(false);
stopScanButton.setEnabled(true);
} catch (EventException e) {
logger.error("Scan submission failed", e);
MessageDialog.openError(getShell(), "Error Submitting Scan", "The scan could not be submitted. See the error log for more details.");
}
}
use of org.eclipse.scanning.api.event.scan.ScanBean in project gda-core by openGDA.
the class ScanManagementController method submitScan.
/**
* Submits the scan described by the current mapping bean to the submission service. An error dialog is displayed if
* the scan could not be successfully submitted.
*
* @param filePath
* The filepath of the output NeXus file. If {@code null} it is generated through default properties.
*/
public void submitScan(Optional<String> filePath, ScanningAcquisition acquisitionParameters) {
final IScanBeanSubmitter submitter = getService(IScanBeanSubmitter.class);
try {
final ScanBean scanBean = createScanBean(filePath, acquisitionParameters);
if (LocalProperties.isPersistenceServiceAvailable()) {
// Save current status of mapping view and cross-reference in ScanBean
getMappingBean().setDisplayName("");
// Force the persistence service to allocate a new ID to the saved version
// of the mapping bean
final long scanId = saveScanAs(IMappingExperimentBean.INVALID_ID);
scanBean.setMappingBeanId(scanId);
}
submitter.submitScan(scanBean);
} catch (Exception e) {
logger.error("Scan submission failed", e);
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error Submitting Scan", "The scan could not be submitted. See the error log for more details.");
}
}
use of org.eclipse.scanning.api.event.scan.ScanBean in project gda-core by openGDA.
the class ApplicationActionBarAdvisor method buildScanStatus.
private StatusLineContributionItem buildScanStatus() {
StatusLineContributionItem scanStatus = new StatusLineContributionItem("GDA-ScanStatus", true, 55);
IEventService service = ServiceHolder.getEventService();
try {
ISubscriber<IBeanListener<StatusBean>> statusTopicSubscriber = service.createSubscriber(getActiveMqUri(), EventConstants.STATUS_TOPIC);
statusTopicSubscriber.addListener(event -> {
if (event.getBean() instanceof ScanBean) {
updateScanDetails(scanStatus, (ScanBean) event.getBean());
}
});
ApplicationWorkbenchAdvisor.addCleanupWork(() -> {
try {
statusTopicSubscriber.removeAllListeners();
statusTopicSubscriber.close();
} catch (EventException e1) {
logger.error("Error removing listener from STATUS_TOPIC", e1);
}
});
} catch (NullPointerException e) {
// Handling for non-StatusQueueView/Mapping beamlines, prevent stack trace being printed to console
if (service == null) {
logger.warn("EventService null when adding listener to STATUS_TOPIC, ScanBean status bar progress disabled. If this beamline uses the Queue, this will cause errors elsewhere");
} else {
throw e;
}
} catch (Exception e2) {
logger.error("Error adding listener to STATUS_TOPIC", e2);
}
return scanStatus;
}
Aggregations