Search in sources :

Example 1 with EventException

use of org.eclipse.scanning.api.event.EventException in project gda-core by openGDA.

the class QueuePreventingScanSubmitter method getSubmitter.

private ISubmitter<ScanBean> getSubmitter() throws EventException {
    if (submitter == null) {
        Objects.requireNonNull(eventService, "Event service is not set - check OSGi settings");
        try {
            URI queueServerURI = new URI(LocalProperties.getActiveMQBrokerURI());
            submitter = eventService.createSubmitter(queueServerURI, EventConstants.SUBMISSION_QUEUE);
        } catch (URISyntaxException e) {
            throw new EventException("URI syntax problem", e);
        }
    }
    return submitter;
}
Also used : EventException(org.eclipse.scanning.api.event.EventException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 2 with EventException

use of org.eclipse.scanning.api.event.EventException in project gda-core by openGDA.

the class NexusExperimentController method closeNode.

private NodeFileCreationRequest closeNode(ExperimentNode node) throws ExperimentControllerException {
    NodeFileCreationRequest job = null;
    // no need to create a node file if the node is childless
    if (!node.hasChildren())
        return job;
    job = createNodeFileCreationRequestJob(node);
    try {
        job = nodeFileRequesterService.getNodeFileCreationRequestResponse(job);
        if (job.getStatus() == Status.FAILED) {
            throw new ExperimentControllerException(job.getMessage());
        }
    } catch (EventException | InterruptedException e) {
        // NOSONAR please, since we are rethrowing
        throw new ExperimentControllerException(e);
    }
    return job;
}
Also used : ExperimentControllerException(uk.ac.diamond.daq.experiment.api.structure.ExperimentControllerException) EventException(org.eclipse.scanning.api.event.EventException) NodeFileCreationRequest(uk.ac.diamond.daq.experiment.api.structure.NodeFileCreationRequest)

Example 3 with EventException

use of org.eclipse.scanning.api.event.EventException 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);
    }
}
Also used : ScanRequestFactory(uk.ac.diamond.daq.mapping.api.document.ScanRequestFactory) ScanBean(org.eclipse.scanning.api.event.scan.ScanBean) ScanningAcquisitionServiceException(uk.ac.diamond.daq.mapping.api.document.exception.ScanningAcquisitionServiceException) ScanningAcquisitionServiceException(uk.ac.diamond.daq.mapping.api.document.exception.ScanningAcquisitionServiceException) URISyntaxException(java.net.URISyntaxException) EventException(org.eclipse.scanning.api.event.EventException)

Example 4 with EventException

use of org.eclipse.scanning.api.event.EventException 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;
}
Also used : TriggerableMap(uk.ac.diamond.daq.experiment.scans.mapping.TriggerableMap) ExperimentControllerException(uk.ac.diamond.daq.experiment.api.structure.ExperimentControllerException) ScanBean(org.eclipse.scanning.api.event.scan.ScanBean) EventException(org.eclipse.scanning.api.event.EventException) ScanningException(org.eclipse.scanning.api.scan.ScanningException) ExperimentController(uk.ac.diamond.daq.experiment.api.structure.ExperimentController) URL(java.net.URL)

Example 5 with EventException

use of org.eclipse.scanning.api.event.EventException 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.");
    }
}
Also used : ScanRequest(org.eclipse.scanning.api.event.scan.ScanRequest) FocusScanBean(uk.ac.diamond.daq.mapping.api.FocusScanBean) ScanBean(org.eclipse.scanning.api.event.scan.ScanBean) EventException(org.eclipse.scanning.api.event.EventException)

Aggregations

EventException (org.eclipse.scanning.api.event.EventException)15 URISyntaxException (java.net.URISyntaxException)7 URI (java.net.URI)5 IEventService (org.eclipse.scanning.api.event.IEventService)5 ScanBean (org.eclipse.scanning.api.event.scan.ScanBean)4 ScanningException (org.eclipse.scanning.api.scan.ScanningException)3 JythonServerFacade (gda.jython.JythonServerFacade)2 StatusBean (org.eclipse.scanning.api.event.status.StatusBean)2 ExperimentControllerException (uk.ac.diamond.daq.experiment.api.structure.ExperimentControllerException)2 Command (gda.commandqueue.Command)1 CommandBean (gda.commandqueue.CommandBean)1 ExperimentCommandBean (gda.commandqueue.ExperimentCommandBean)1 IObserver (gda.observable.IObserver)1 URL (java.net.URL)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 PrepareScan (org.eclipse.scanning.api.annotation.scan.PrepareScan)1 IBeanListener (org.eclipse.scanning.api.event.bean.IBeanListener)1 QueueCommandBean (org.eclipse.scanning.api.event.queue.QueueCommandBean)1 ScanRequest (org.eclipse.scanning.api.event.scan.ScanRequest)1 StatusLineContributionItem (org.eclipse.ui.texteditor.StatusLineContributionItem)1