Search in sources :

Example 21 with ScanBean

use of org.eclipse.scanning.api.event.scan.ScanBean 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 22 with ScanBean

use of org.eclipse.scanning.api.event.scan.ScanBean 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 23 with ScanBean

use of org.eclipse.scanning.api.event.scan.ScanBean 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)

Example 24 with ScanBean

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

the class ScanManagementController method submitScan.

/**
 * Submits the scan described by the current mapping bean to the submission service. An error dialog is displayed if
 * the scan could not be successfully submitted.
 *
 * @param filePath
 *            The filepath of the output NeXus file. If {@code null} it is generated through default properties.
 */
public void submitScan(Optional<String> filePath, ScanningAcquisition acquisitionParameters) {
    final IScanBeanSubmitter submitter = getService(IScanBeanSubmitter.class);
    try {
        final ScanBean scanBean = createScanBean(filePath, acquisitionParameters);
        if (LocalProperties.isPersistenceServiceAvailable()) {
            // Save current status of mapping view and cross-reference in ScanBean
            getMappingBean().setDisplayName("");
            // Force the persistence service to allocate a new ID to the saved version
            // of the mapping bean
            final long scanId = saveScanAs(IMappingExperimentBean.INVALID_ID);
            scanBean.setMappingBeanId(scanId);
        }
        submitter.submitScan(scanBean);
    } catch (Exception e) {
        logger.error("Scan submission failed", e);
        MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error Submitting Scan", "The scan could not be submitted. See the error log for more details.");
    }
}
Also used : IScanBeanSubmitter(uk.ac.diamond.daq.mapping.api.IScanBeanSubmitter) ScanBean(org.eclipse.scanning.api.event.scan.ScanBean) PersistenceException(uk.ac.diamond.daq.application.persistence.service.PersistenceException) IOException(java.io.IOException)

Example 25 with ScanBean

use of org.eclipse.scanning.api.event.scan.ScanBean 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)

Aggregations

ScanBean (org.eclipse.scanning.api.event.scan.ScanBean)35 Test (org.junit.Test)23 IScanListener (org.eclipse.scanning.api.event.scan.IScanListener)20 ScanpathElementProcessor (gda.mscan.processor.ScanpathElementProcessor)18 IRunnableDeviceDetectorElementProcessor (gda.mscan.processor.IRunnableDeviceDetectorElementProcessor)16 NumberElementProcessor (gda.mscan.processor.NumberElementProcessor)15 IClauseElementProcessor (gda.mscan.processor.IClauseElementProcessor)13 RegionShapeElementProcessor (gda.mscan.processor.RegionShapeElementProcessor)12 ScannableElementProcessor (gda.mscan.processor.ScannableElementProcessor)12 CompoundModel (org.eclipse.scanning.api.points.models.CompoundModel)8 ScanRequest (org.eclipse.scanning.api.event.scan.ScanRequest)7 StaticModel (org.eclipse.scanning.api.points.models.StaticModel)7 EventException (org.eclipse.scanning.api.event.EventException)4 IMappingExperimentBean (uk.ac.diamond.daq.mapping.api.IMappingExperimentBean)3 ScannableDetectorElementProcessor (gda.mscan.processor.ScannableDetectorElementProcessor)2 URISyntaxException (java.net.URISyntaxException)2 IScanPointGeneratorModel (org.eclipse.scanning.api.points.models.IScanPointGeneratorModel)2 ReRunFromFileElementProcessor (gda.mscan.processor.ReRunFromFileElementProcessor)1 ScanDataConsumerElementProcessor (gda.mscan.processor.ScanDataConsumerElementProcessor)1 ScannableMonitorElementProcessor (gda.mscan.processor.ScannableMonitorElementProcessor)1