Search in sources :

Example 6 with IEventService

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

the class StandardsScanView method createView.

@PostConstruct
public void createView(Composite parent) {
    GridDataFactory.swtDefaults().applyTo(parent);
    GridLayoutFactory.swtDefaults().applyTo(parent);
    createScannableEditor(parent);
    createSubmitSection(parent);
    final IEventService eventService = injectionContext.get(IEventService.class);
    try {
        final URI activeMQUri = new URI(LocalProperties.getActiveMQBrokerURI());
        jobQueueProxy = eventService.createJobQueueProxy(activeMQUri, EventConstants.SUBMISSION_QUEUE, EventConstants.CMD_TOPIC, EventConstants.ACK_TOPIC);
    } catch (Exception e) {
        logger.error("Error creating job queue proxy", e);
    }
}
Also used : IEventService(org.eclipse.scanning.api.event.IEventService) URI(java.net.URI) EventException(org.eclipse.scanning.api.event.EventException) PostConstruct(javax.annotation.PostConstruct)

Example 7 with IEventService

use of org.eclipse.scanning.api.event.IEventService 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 8 with IEventService

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

Example 9 with IEventService

use of org.eclipse.scanning.api.event.IEventService 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 10 with IEventService

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

the class ProcessingSelectionWizardPage method getRunnableDeviceService.

private IRunnableDeviceService getRunnableDeviceService() throws EventException, URISyntaxException {
    if (runnableDeviceService == null) {
        IEventService eventService = context.get(IEventService.class);
        URI jmsURI = new URI(LocalProperties.getActiveMQBrokerURI());
        runnableDeviceService = eventService.createRemoteService(jmsURI, IRunnableDeviceService.class);
    }
    return runnableDeviceService;
}
Also used : IRunnableDeviceService(org.eclipse.scanning.api.device.IRunnableDeviceService) IEventService(org.eclipse.scanning.api.event.IEventService) URI(java.net.URI)

Aggregations

IEventService (org.eclipse.scanning.api.event.IEventService)12 URI (java.net.URI)8 EventException (org.eclipse.scanning.api.event.EventException)7 URISyntaxException (java.net.URISyntaxException)5 IRunnableDeviceService (org.eclipse.scanning.api.device.IRunnableDeviceService)2 ServiceHolder (gda.data.ServiceHolder)1 JythonServer (gda.jython.JythonServer)1 ArrayList (java.util.ArrayList)1 PostConstruct (javax.annotation.PostConstruct)1 NexusFileFactoryHDF5 (org.eclipse.dawnsci.hdf5.nexus.NexusFileFactoryHDF5)1 MarshallerService (org.eclipse.dawnsci.json.MarshallerService)1 DefaultNexusBuilderFactory (org.eclipse.dawnsci.nexus.builder.impl.DefaultNexusBuilderFactory)1 INexusDeviceService (org.eclipse.dawnsci.nexus.device.INexusDeviceService)1 NexusDeviceService (org.eclipse.dawnsci.nexus.device.impl.NexusDeviceService)1 NexusScanFileServiceImpl (org.eclipse.dawnsci.nexus.scan.impl.NexusScanFileServiceImpl)1 IBeanListener (org.eclipse.scanning.api.event.bean.IBeanListener)1 QueueCommandBean (org.eclipse.scanning.api.event.queue.QueueCommandBean)1 ScanBean (org.eclipse.scanning.api.event.scan.ScanBean)1 IMalcolmDevice (org.eclipse.scanning.api.malcolm.IMalcolmDevice)1 IPointGeneratorService (org.eclipse.scanning.api.points.IPointGeneratorService)1