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);
}
}
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);
}
}
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);
}
}
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);
}
}
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;
}
Aggregations