Search in sources :

Example 6 with EventException

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

the class FrameCollectingScannable method getRequester.

private IRequester<AcquireRequest> getRequester() throws EventException {
    if (acquireRequester == null) {
        final IEventService eventService = org.eclipse.scanning.sequencer.ServiceHolder.getEventService();
        try {
            final var uri = new URI(LocalProperties.getActiveMQBrokerURI());
            acquireRequester = eventService.createRequestor(uri, EventConstants.ACQUIRE_REQUEST_TOPIC, EventConstants.ACQUIRE_RESPONSE_TOPIC);
            acquireRequester.setTimeout(5, TimeUnit.SECONDS);
        } catch (URISyntaxException e) {
            throw new EventException(e);
        }
    }
    return acquireRequester;
}
Also used : EventException(org.eclipse.scanning.api.event.EventException) IEventService(org.eclipse.scanning.api.event.IEventService) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 7 with EventException

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

the class RunExperimentNewQueueCommandHandler method submitCommandToQueue.

@Override
protected void submitCommandToQueue(ExperimentCommandProvider commandProvider) throws ExecutionException {
    // create the command bean
    final Command command = commandProvider.getCommand();
    CommandBean bean = createCommandBean(command);
    // submit the bean
    try {
        getSubmitter().submitScan(bean);
    } catch (EventException e) {
        logger.error("Exception adding ExperimentCommandProvider to queue", e);
        throw new ExecutionException("Exception adding ExperimentCommandProvider to queue.", e);
    }
}
Also used : CommandBean(gda.commandqueue.CommandBean) ExperimentCommandBean(gda.commandqueue.ExperimentCommandBean) Command(gda.commandqueue.Command) EventException(org.eclipse.scanning.api.event.EventException) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 8 with EventException

use of org.eclipse.scanning.api.event.EventException 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;
}
Also used : StatusLineContributionItem(org.eclipse.ui.texteditor.StatusLineContributionItem) ScanBean(org.eclipse.scanning.api.event.scan.ScanBean) EventException(org.eclipse.scanning.api.event.EventException) IEventService(org.eclipse.scanning.api.event.IEventService) IBeanListener(org.eclipse.scanning.api.event.bean.IBeanListener) URISyntaxException(java.net.URISyntaxException) EventException(org.eclipse.scanning.api.event.EventException)

Example 9 with EventException

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

the class SubmitScanToScriptSection method stopScan.

private void stopScan() {
    logger.info("Stopping script & job");
    // Stop the script
    final JythonServerFacade jythonServerFacade = JythonServerFacade.getInstance();
    jythonServerFacade.abortCommands();
    try {
        // Stop the currently-running job
        final List<StatusBean> currentJobs = jobQueueProxy.getRunningAndCompleted();
        for (StatusBean job : currentJobs) {
            if (job.getStatus() == Status.RUNNING) {
                jobQueueProxy.terminateJob(job);
            }
        }
    } catch (EventException e) {
        logger.error("Error accessing queue", e);
    }
}
Also used : StatusBean(org.eclipse.scanning.api.event.status.StatusBean) EventException(org.eclipse.scanning.api.event.EventException) JythonServerFacade(gda.jython.JythonServerFacade)

Example 10 with EventException

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

the class NodeFileRequesterService method createNodeFileRequester.

private void createNodeFileRequester() throws EventException {
    try {
        URI activemqURL = new URI(LocalProperties.getActiveMQBrokerURI());
        IEventService eventService = Activator.getService(IEventService.class);
        nodeFileRequester = eventService.createRequestor(activemqURL, requestTopic, responseTopic);
        nodeFileRequester.setTimeout(5, TimeUnit.SECONDS);
    } catch (URISyntaxException e) {
        throw new EventException("Cannot create submitter", e);
    }
}
Also used : EventException(org.eclipse.scanning.api.event.EventException) IEventService(org.eclipse.scanning.api.event.IEventService) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

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