Search in sources :

Example 11 with EventException

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

the class StandardsScanView method stopScan.

private void stopScan() {
    logger.info("Stopping standards scan 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 12 with EventException

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

the class QueueAndRunExperimentNewQueueCommandHandler method startQueue.

/**
 * Starts the new GDA9 queue by sending a {@link PauseBean} with
 * <code>pause</code> set to <code>false</code>.
 */
private void startQueue() {
    IEventService eventService = EventServiceHolder.getEventService();
    if (eventService == null) {
        throw new IllegalStateException("Event service not set - should be set by OSGi DS");
    }
    try (IPublisher<QueueCommandBean> publisher = eventService.createPublisher(new URI(LocalProperties.getActiveMQBrokerURI()), EventConstants.CMD_TOPIC)) {
        QueueCommandBean bean = new QueueCommandBean(EventConstants.SUBMISSION_QUEUE, Command.RESUME_QUEUE);
        publisher.broadcast(bean);
    } catch (EventException | URISyntaxException e) {
        logger.error("Cannot pause scan queue", e);
    }
}
Also used : QueueCommandBean(org.eclipse.scanning.api.event.queue.QueueCommandBean) EventException(org.eclipse.scanning.api.event.EventException) IEventService(org.eclipse.scanning.api.event.IEventService) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 13 with EventException

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

the class FrameCollectingScannable method configureAndCollect.

/**
 * This is invoked shortly before the main scan is configured
 */
@PrepareScan
public void configureAndCollect(ScanModel scanModel) throws ScanningException {
    configureCollection(scanModel);
    try {
        configureBeamline();
        frameFilePath = collectFrame();
        nexusNodePath = generateNodePath();
        restoreBeamline();
    } catch (EventException e) {
        throw new ScanningException("Problem taking snapshot", e);
    }
}
Also used : EventException(org.eclipse.scanning.api.event.EventException) ScanningException(org.eclipse.scanning.api.scan.ScanningException) PrepareScan(org.eclipse.scanning.api.annotation.scan.PrepareScan)

Example 14 with EventException

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

the class CommandProcess method execute.

@Override
public void execute() throws EventException, InterruptedException {
    // an IObserver to listen for progress, i.e. percentComplete
    final IObserver progressObserver = new IObserver() {

        @Override
        public void update(Object source, Object arg) {
            if (arg instanceof CommandProgress) {
                updateProgress((CommandProgress) arg);
            }
        }
    };
    try {
        command.addIObserver(progressObserver);
        // broadcast the bean for the start of the scan
        setBeanStatus(Status.RUNNING);
        bean.setPercentComplete(0);
        broadcast(bean);
        // run the command - this is the method that performs the scan
        command.run();
        // broadcast the bean for the end of the scan
        if (!bean.getStatus().isTerminated()) {
            setBeanStatus(Status.COMPLETE);
            bean.setPercentComplete(100);
            broadcast(bean);
        }
    } catch (Exception e) {
        logger.error("Cannot execute command {}", command, e);
        // broadcast the bean for a failed scan
        setBeanStatus(Status.FAILED);
        bean.setPercentComplete(100);
        bean.setMessage(e.getMessage());
        broadcast(bean);
        throw new EventException(e);
    } finally {
        command.deleteIObserver(progressObserver);
    }
}
Also used : EventException(org.eclipse.scanning.api.event.EventException) IObserver(gda.observable.IObserver) EventException(org.eclipse.scanning.api.event.EventException)

Example 15 with EventException

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

the class TimeSeriesScanView method getRunnableDeviceService.

private IRunnableDeviceService getRunnableDeviceService() throws ScanningException {
    if (runnableDeviceService == null) {
        try {
            final IEventService eventService = eclipseContext.get(IEventService.class);
            final URI jmsURI = new URI(LocalProperties.getActiveMQBrokerURI());
            return eventService.createRemoteService(jmsURI, IRunnableDeviceService.class);
        } catch (EventException | URISyntaxException e) {
            throw new ScanningException(e);
        }
    }
    return runnableDeviceService;
}
Also used : EventException(org.eclipse.scanning.api.event.EventException) ScanningException(org.eclipse.scanning.api.scan.ScanningException) 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