Search in sources :

Example 1 with StatusBean

use of org.eclipse.scanning.api.event.status.StatusBean 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 2 with StatusBean

use of org.eclipse.scanning.api.event.status.StatusBean 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 3 with StatusBean

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

the class PlanOverview method scanListener.

/**
 * We listen to scan updates in order to display the current status in the appropriate
 * tree node.
 *
 * A special consideration is that a plan can end but a scan started by it is still running.
 * When this final scan ends its trigger node should be updated (if the tree is still in the viewer)
 */
private void scanListener(BeanEvent<StatusBean> event) {
    StatusBean bean = event.getBean();
    final String scanId = bean.getUniqueId();
    final Status scanStatus = bean.getStatus();
    if (// this is a scan that's relevant to the plan
    triggersInCurrentTree.containsKey(scanId) && triggersInCurrentTree.get(scanId).getStatus() != scanStatus) {
        // the status of the scan has changed
        triggersInCurrentTree.get(bean.getUniqueId()).setStatus(bean.getStatus());
        Display.getDefault().asyncExec(() -> viewer.update(triggersInCurrentTree.get(scanId), new String[] { "status" }));
    }
}
Also used : Status(org.eclipse.scanning.api.event.status.Status) StatusBean(org.eclipse.scanning.api.event.status.StatusBean) PlanStatusBean(uk.ac.diamond.daq.experiment.api.plan.event.PlanStatusBean)

Aggregations

StatusBean (org.eclipse.scanning.api.event.status.StatusBean)3 JythonServerFacade (gda.jython.JythonServerFacade)2 EventException (org.eclipse.scanning.api.event.EventException)2 Status (org.eclipse.scanning.api.event.status.Status)1 PlanStatusBean (uk.ac.diamond.daq.experiment.api.plan.event.PlanStatusBean)1